This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
AJP/DiSLProject2022/src-profiler/ex6/Instrumentation.java

33 lines
1.3 KiB
Java
Raw Normal View History

2023-01-02 09:46:59 +00:00
package ex6;
2023-01-09 07:01:15 +00:00
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;
2023-01-02 09:46:59 +00:00
public class Instrumentation {
2023-01-09 07:01:15 +00:00
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);
}
2023-01-02 09:46:59 +00:00
}