use of org.jikesrvm.compilers.opt.inlining.InlineSequence in project JikesRVM by JikesRVM.
the class CFGVisualization method enumerateAndFormatInstructions.
protected String enumerateAndFormatInstructions(BasicBlock succBB) {
StringBuilder next = new StringBuilder();
for (Enumeration<Instruction> e = succBB.forwardInstrEnumerator(); e.hasMoreElements(); ) {
Instruction inst = e.nextElement();
int lineNumber = 0;
String s = formatInstruction(inst);
s = s.replaceAll("\n", " ");
s = s.replaceAll("\"", "\\\\\"");
InlineSequence position = inst.position();
int bytecodeIndex = inst.getBytecodeIndex();
if (position != null) {
lineNumber = position.getMethod().getLineNumberForBCIndex(bytecodeIndex);
}
next.append(s);
next.append(" ");
next.append(bytecodeIndex);
next.append(",");
next.append(lineNumber);
next.append(LEFT_JUSTIFIED);
next.append("\n");
}
return next.toString();
}
use of org.jikesrvm.compilers.opt.inlining.InlineSequence in project JikesRVM by JikesRVM.
the class GenerationContextTest method childContextsQueryOSRBarrierInformationViaOutermostParent.
@Test
public void childContextsQueryOSRBarrierInformationViaOutermostParent() throws Exception {
NormalMethod nm = getNormalMethodForTest("methodForInliningTests");
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext outermost = new GenerationContext(nm, null, cm, opts, io);
Class<?>[] classArgs = { Object.class };
NormalMethod callee = getNormalMethodForTest("emptyStaticMethodWithObjectParamAndReturnValue", classArgs);
MethodOperand methOp = MethodOperand.STATIC(callee);
RegisterOperand result = createMockRegisterOperand(TypeReference.JavaLangObject);
Instruction callInstr = Call.create(CALL, result, null, methOp, 1);
RegisterOperand objectParam = createMockRegisterOperand(TypeReference.JavaLangObject);
Call.setParam(callInstr, 0, objectParam);
callInstr.setPosition(new InlineSequence(nm));
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
GenerationContext child = outermost.createChildContext(ebag, callee, callInstr);
Instruction osrBarrier = createMockOSRBarrier();
Instruction call = createMockCall();
child.saveOSRBarrierForInst(osrBarrier, call);
assertThat(outermost.getOSRBarrierFromInst(call), is(osrBarrier));
assertThat(child.getOSRBarrierFromInst(call), is(osrBarrier));
GenerationContext child2 = outermost.createChildContext(ebag, callee, callInstr);
assertThat(child2.getOSRBarrierFromInst(call), is(osrBarrier));
}
use of org.jikesrvm.compilers.opt.inlining.InlineSequence in project JikesRVM by JikesRVM.
the class GenerationContextTest method methodsWithReturnValueHaveReturnInstructionInEpilogue.
@Test
public void methodsWithReturnValueHaveReturnInstructionInEpilogue() throws Exception {
NormalMethod nm = getNormalMethodForTest("staticMethodReturningLongMaxValue");
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
InlineSequence inlineSequence = new InlineSequence(nm);
assertThatInlineSequenceWasSetCorrectly(gc, inlineSequence);
assertThatNumberOfParametersIs(gc, 0);
BasicBlock prologue = gc.getPrologue();
assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
assertThatBlockOnlyHasOneRealInstruction(prologue);
BasicBlock epilogue = gc.getEpilogue();
assertThatEpilogueBlockIsSetupCorrectly(gc, inlineSequence, epilogue);
assertThatLastInstructionInEpilogueIsReturn(gc, epilogue);
RegisterOperand returnValue = Return.getVal(epilogue.lastRealInstruction()).asRegister();
assertThat(returnValue.getType(), is(TypeReference.Long));
assertThatExitBlockIsSetCorrectly(gc);
assertThatDataIsSavedCorrectly(nm, cm, io, gc);
assertThat(gc.getResultReg().isLong(), is(true));
assertThatGCHasNoExceptionHandlers(gc);
assertThatRegisterPoolExists(gc);
assertThatChecksWontBeSkipped(gc);
}
use of org.jikesrvm.compilers.opt.inlining.InlineSequence in project JikesRVM by JikesRVM.
the class GenerationContextTest method constructorCreatesOperandsForInstanceMethods.
@Test
public void constructorCreatesOperandsForInstanceMethods() throws Exception {
Class<?>[] argumentTypes = { Object.class, double.class, int.class, long.class };
NormalMethod nm = getNormalMethodForTest("emptyInstanceMethodWithParams", argumentTypes);
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
InlineSequence inlineSequence = new InlineSequence(nm);
assertThatInlineSequenceWasSetCorrectly(gc, inlineSequence);
assertThatNumberOfParametersIs(gc, 5);
RegisterOperand thisOperand = getThisOperand(gc);
assertThatRegOpHoldsClassType(thisOperand);
assertThatRegOpHasDeclaredType(thisOperand);
RegisterOperand objectRegOp = gc.getArguments()[1].asRegister();
assertThatRegOpHoldsClassType(objectRegOp);
assertThatRegOpHasDeclaredType(objectRegOp);
RegisterOperand doubleRegOp = gc.getArguments()[2].asRegister();
assertThat(doubleRegOp.isDouble(), is(true));
assertThatRegOpHasDeclaredType(doubleRegOp);
RegisterOperand intRegOp = gc.getArguments()[3].asRegister();
assertThat(intRegOp.isInt(), is(true));
assertThatRegOpHasDeclaredType(intRegOp);
RegisterOperand longRegOp = gc.getArguments()[4].asRegister();
assertThat(longRegOp.isLong(), is(true));
assertThatRegOpHasDeclaredType(longRegOp);
Register thisLocalReg = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
assertThatRegOpIsLocalRegOfRegister(thisOperand, thisLocalReg);
Register objectReg = gc.localReg(1, TypeReference.JavaLangObject);
assertThatRegOpIsLocalRegOfRegister(objectRegOp, objectReg);
Register doubleReg = gc.localReg(2, TypeReference.Double);
assertThatRegOpIsLocalRegOfRegister(doubleRegOp, doubleReg);
Register intReg = gc.localReg(4, TypeReference.Int);
assertThatRegOpIsLocalRegOfRegister(intRegOp, intReg);
Register longReg = gc.localReg(5, TypeReference.Long);
assertThatRegOpIsLocalRegOfRegister(longRegOp, longReg);
BasicBlock prologue = gc.getPrologue();
assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
Instruction lastPrologueInstruction = prologue.lastRealInstruction();
assertThatInstructionIsGuardMoveForPrologue(lastPrologueInstruction, thisOperand, gc);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, thisOperand, 0);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, objectRegOp, 1);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, doubleRegOp, 2);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, intRegOp, 3);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, longRegOp, 4);
assertThatEpilogueIsForVoidReturnMethod(gc, inlineSequence);
assertThatExitBlockIsSetCorrectly(gc);
assertThatDataIsSavedCorrectly(nm, cm, io, gc);
assertThatReturnValueIsVoid(gc);
assertThatGCHasNoExceptionHandlers(gc);
assertThatRegisterPoolExists(gc);
assertThatChecksWontBeSkipped(gc);
assertThatNoRethrowBlockExists(gc);
}
use of org.jikesrvm.compilers.opt.inlining.InlineSequence in project JikesRVM by JikesRVM.
the class GenerationContextTest method invalidReceiverCausesException.
@Test(expected = OptimizingCompilerException.class)
public void invalidReceiverCausesException() throws Exception {
NormalMethod nm = getNormalMethodForTest("methodForInliningTests");
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
NormalMethod callee = getNormalMethodForTest("emptyInstanceMethodWithoutAnnotations");
MethodOperand methOp = MethodOperand.VIRTUAL(callee.getMemberRef().asMethodReference(), callee);
Instruction callInstr = Call.create(CALL, null, null, methOp, 1);
Operand receiver = new InvalidReceiverOperand();
Call.setParam(callInstr, 0, receiver);
callInstr.setPosition(new InlineSequence(nm));
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
gc.createChildContext(ebag, callee, callInstr);
}
Aggregations