AJP/DiSLProject2022/src-profiler/ex6/LoopContext.java
2023-01-09 08:01:15 +01:00

22 lines
774 B
Java

package ex6;
import ch.usi.dag.disl.staticcontext.AbstractStaticContext;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.JumpInsnNode;
public class LoopContext extends AbstractStaticContext {
// considered loop instruction if loop footer.
public boolean isLoopInstruction() {
final InsnList insList = staticContextData.getMethodNode().instructions;
final AbstractInsnNode ins = staticContextData.getRegionStart();
if (ins instanceof final JumpInsnNode jIns) {
final int nextInsOffset = insList.indexOf(jIns.label);
final int insOffset = insList.indexOf(jIns);
return nextInsOffset < insOffset;
}
return false;
}
}