1/******************************************************************************* 2 * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * Marc R. Hoffmann - initial API and implementation 10 * 11 *******************************************************************************/ 12package org.jacoco.core.internal.instr; 13 14import org.jacoco.core.runtime.IExecutionDataAccessorGenerator; 15import org.objectweb.asm.ClassVisitor; 16import org.objectweb.asm.MethodVisitor; 17import org.objectweb.asm.Opcodes; 18 19/** 20 * The strategy for interfaces inlines the runtime access directly into the 21 * methods as this is the only method without keeping reference within this 22 * class. This is very inefficient as the runtime is contacted for every method 23 * invocation and therefore only used for static initializers in interfaces. 24 */ 25class LocalProbeArrayStrategy implements IProbeArrayStrategy { 26 27 private final String className; 28 private final long classId; 29 private final int probeCount; 30 private final IExecutionDataAccessorGenerator accessorGenerator; 31 32 LocalProbeArrayStrategy(final String className, final long classId, 33 final int probeCount, 34 final IExecutionDataAccessorGenerator accessorGenerator) { 35 this.className = className; 36 this.classId = classId; 37 this.probeCount = probeCount; 38 this.accessorGenerator = accessorGenerator; 39 } 40 41 public int storeInstance(final MethodVisitor mv, final boolean clinit, 42 final int variable) { 43 final int maxStack = accessorGenerator.generateDataAccessor(classId, 44 className, probeCount, mv); 45 mv.visitVarInsn(Opcodes.ASTORE, variable); 46 return maxStack; 47 } 48 49 public void addMembers(final ClassVisitor delegate, final int probeCount) { 50 // nothing to do 51 } 52 53}