diff options
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java')
-rw-r--r-- | org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java new file mode 100644 index 00000000..bccf42ec --- /dev/null +++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/LocalProbeArrayStrategy.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2009, 2014 Mountainminds GmbH & Co. KG and Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc R. Hoffmann - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.internal.instr; + +import org.jacoco.core.runtime.IExecutionDataAccessorGenerator; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +/** + * The strategy for interfaces inlines the runtime access directly into the + * methods as this is the only method without keeping reference within this + * class. This is very inefficient as the runtime is contacted for every method + * invocation and therefore only used for static initializers in interfaces. + */ +class LocalProbeArrayStrategy implements IProbeArrayStrategy { + + private final String className; + private final long classId; + private final int probeCount; + private final IExecutionDataAccessorGenerator accessorGenerator; + + LocalProbeArrayStrategy(final String className, final long classId, + final int probeCount, + final IExecutionDataAccessorGenerator accessorGenerator) { + this.className = className; + this.classId = classId; + this.probeCount = probeCount; + this.accessorGenerator = accessorGenerator; + } + + public int storeInstance(final MethodVisitor mv, final int variable) { + final int maxStack = accessorGenerator.generateDataAccessor(classId, + className, probeCount, mv); + mv.visitVarInsn(Opcodes.ASTORE, variable); + return maxStack; + } + + public void addMembers(final ClassVisitor delegate, final int probeCount) { + // nothing to do + } + +}
\ No newline at end of file |