use of org.graalvm.compiler.bytecode.BytecodeStream in project graal by oracle.
the class GraalOSRTestBase method getBackedgeBCI.
/**
* Returns the target BCI of the first bytecode backedge. This is where HotSpot triggers
* on-stack-replacement in case the backedge counter overflows.
*/
private static int getBackedgeBCI(DebugContext debug, ResolvedJavaMethod method) {
Bytecode code = new ResolvedJavaMethodBytecode(method);
BytecodeStream stream = new BytecodeStream(code.getCode());
OptionValues options = debug.getOptions();
BciBlockMapping bciBlockMapping = BciBlockMapping.create(stream, code, options, debug);
for (BciBlock block : bciBlockMapping.getBlocks()) {
if (block.startBci != -1) {
int bci = block.startBci;
for (BciBlock succ : block.getSuccessors()) {
if (succ.startBci != -1) {
int succBci = succ.startBci;
if (succBci < bci) {
// back edge
return succBci;
}
}
}
}
}
TTY.println("Cannot find loop back edge with bytecode loops at:%s", Arrays.toString(bciBlockMapping.getLoopHeaders()));
TTY.println(new BytecodeDisassembler().disassemble(code));
return -1;
}
Aggregations