32 lines
1.3 KiB
Java
32 lines
1.3 KiB
Java
package ex6;
|
|
|
|
import ch.usi.dag.disl.annotation.Before;
|
|
import ch.usi.dag.disl.marker.BytecodeMarker;
|
|
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
|
|
import org.objectweb.asm.Opcodes;
|
|
import org.objectweb.asm.util.Printer;
|
|
|
|
public class Instrumentation {
|
|
|
|
final static String[] BRANCH_OP_NAMES = new String[]{
|
|
Printer.OPCODES[Opcodes.GOTO],
|
|
Printer.OPCODES[Opcodes.IF_ACMPEQ],
|
|
Printer.OPCODES[Opcodes.IF_ACMPNE],
|
|
Printer.OPCODES[Opcodes.IF_ICMPEQ],
|
|
Printer.OPCODES[Opcodes.IF_ICMPGE],
|
|
Printer.OPCODES[Opcodes.IF_ICMPLE],
|
|
Printer.OPCODES[Opcodes.IF_ICMPGT],
|
|
Printer.OPCODES[Opcodes.IF_ICMPLT],
|
|
Printer.OPCODES[Opcodes.IF_ICMPNE]
|
|
};
|
|
// static final String BRANCH_OP_NAMES_STRING = String.join(",", BRANCH_OP_NAMES);
|
|
static final String BRANCH_OP_NAMES_STRING = "GOTO,IF_ACMPEQ,IF_ACMPNE,IF_ICMPEQ,IF_ICMPGE,IF_ICMPLE,IF_ICMPGT,IF_ICMPLT,IF_ICMPNE";
|
|
|
|
|
|
@Before(marker = BytecodeMarker.class, args = BRANCH_OP_NAMES_STRING, scope = "ex6.MainThread.*", guard = IsLoopInstructionGuard.class)
|
|
static void handleLoopInstruction(MethodStaticContext mc) {
|
|
final String methodName = mc.thisMethodFullName();
|
|
Profiler.countLoop(methodName);
|
|
|
|
}
|
|
}
|