use of org.jikesrvm.compilers.opt.inlining.InlineOracle in project JikesRVM by JikesRVM.
the class GenerationContextTest method prologueAndEpilogueForSynchronizedInstanceMethodHaveMonitorEnterAndExit.
@Test
public void prologueAndEpilogueForSynchronizedInstanceMethodHaveMonitorEnterAndExit() throws Exception {
NormalMethod nm = getNormalMethodForTest("emptySynchronizedInstanceMethod");
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);
assertThatLocalsForInstanceMethodWithoutParametersAreCorrect(nm, gc);
RegisterOperand thisOperand = getThisOperand(gc);
BasicBlock prologue = gc.getPrologue();
assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
Enumeration<Instruction> prologueInstructions = prologue.forwardRealInstrEnumerator();
prologueInstructions.nextElement();
Instruction secondInstruction = prologueInstructions.nextElement();
assertThatInstructionIsGuardMoveForPrologue(secondInstruction, thisOperand, gc);
Instruction lastInstruction = prologueInstructions.nextElement();
assertInstructionIsMonitorEnterInPrologue(lastInstruction, inlineSequence);
assertThatGuardIsCorrectForMonitorEnter(lastInstruction);
Operand lockObject = MonitorOp.getRef(lastInstruction);
Operand expectedLockObject = buildLockObjectForInstanceMethod(nm, thisOperand, gc);
assertTrue(expectedLockObject.similar(lockObject));
assertThatNumberOfRealInstructionsMatches(prologue, 3);
BasicBlock epilogue = gc.getEpilogue();
assertThatEpilogueBlockIsSetupCorrectly(gc, inlineSequence, epilogue);
assertThatFirstInstructionEpilogueIsMonitorExit(inlineSequence, epilogue);
assertThatLastInstructionInEpilogueIsReturn(gc, epilogue);
assertThatReturnInstructionReturnsVoid(epilogue);
assertThatNumberOfRealInstructionsMatches(epilogue, 2);
assertThatExitBlockIsSetCorrectly(gc);
assertThatRegisterPoolExists(gc);
assertThatDataIsSavedCorrectly(nm, cm, io, gc);
assertThatReturnValueIsVoid(gc);
assertThatExceptionHandlersWereGenerated(gc);
assertThatUnlockAndRethrowBlockIsCorrect(gc, inlineSequence, prologue, expectedLockObject, epilogue);
assertThatChecksWontBeSkipped(gc);
}
use of org.jikesrvm.compilers.opt.inlining.InlineOracle in project JikesRVM by JikesRVM.
the class GenerationContextTest method isLocalReturnsTrueForRegistersCreatedViaMakeLocal.
@Test
public void isLocalReturnsTrueForRegistersCreatedViaMakeLocal() 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);
int thisLocalNumber = 0;
TypeReference localType = nm.getDeclaringClass().getTypeRef();
RegisterOperand thisRegOp = gc.makeLocal(thisLocalNumber, localType);
assertTrue(gc.isLocal(thisRegOp, thisLocalNumber, localType));
}
use of org.jikesrvm.compilers.opt.inlining.InlineOracle in project JikesRVM by JikesRVM.
the class GenerationContextTest method osrSpecializedMethodsDoNotHaveMonitorEnterButHaveMonitorExit.
@Test
public void osrSpecializedMethodsDoNotHaveMonitorEnterButHaveMonitorExit() throws Exception {
NormalMethod nm = getNormalMethodForTest("emptySynchronizedStaticMethodForOSR");
byte[] osrPrologue = {};
nm.setForOsrSpecialization(osrPrologue, (short) 0);
assertTrue(nm.isForOsrSpecialization());
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);
assertThatNumberOfRealInstructionsMatches(prologue, 1);
BasicBlock epilogue = gc.getEpilogue();
assertThatEpilogueBlockIsSetupCorrectly(gc, inlineSequence, epilogue);
assertThatFirstInstructionEpilogueIsMonitorExit(inlineSequence, epilogue);
assertThatLastInstructionInEpilogueIsReturn(gc, epilogue);
assertThatReturnInstructionReturnsVoid(epilogue);
assertThatNumberOfRealInstructionsMatches(epilogue, 2);
assertThatExitBlockIsSetCorrectly(gc);
assertThatRegisterPoolExists(gc);
assertThatDataIsSavedCorrectly(nm, cm, io, gc);
assertThatReturnValueIsVoid(gc);
assertThatExceptionHandlersWereGenerated(gc);
Operand expectedLockObject = buildLockObjectForStaticMethod(nm);
assertThatUnlockAndRethrowBlockIsCorrect(gc, inlineSequence, prologue, expectedLockObject, epilogue);
assertThatChecksWontBeSkipped(gc);
}
use of org.jikesrvm.compilers.opt.inlining.InlineOracle in project JikesRVM by JikesRVM.
the class GenerationContextTest method annotationsAreTreatedCorrectlyForInlinedMethods.
@Test
public void annotationsAreTreatedCorrectlyForInlinedMethods() 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);
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
NormalMethod callee = getNormalMethodForTest("emptyStaticMethodWithNoBoundCheckAnnotation");
Instruction noBoundsInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, nm);
GenerationContext noBoundsContext = gc.createChildContext(ebag, callee, noBoundsInstr);
assertTrue(noBoundsContext.noBoundsChecks());
assertFalse(noBoundsContext.noNullChecks());
assertFalse(noBoundsContext.noCheckStoreChecks());
callee = getNormalMethodForTest("emptyStaticMethodWithNoCheckStoreAnnotation");
Instruction noCheckStoreInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, nm);
GenerationContext noCheckStoreContext = gc.createChildContext(ebag, callee, noCheckStoreInstr);
assertFalse(noCheckStoreContext.noBoundsChecks());
assertFalse(noCheckStoreContext.noNullChecks());
assertTrue(noCheckStoreContext.noCheckStoreChecks());
callee = getNormalMethodForTest("emptyStaticMethodWithNoNullCheckAnnotation");
Instruction noNullChecks = buildCallInstructionForStaticMethodWithoutReturn(callee, nm);
GenerationContext noNullCheckContext = gc.createChildContext(ebag, callee, noNullChecks);
assertFalse(noNullCheckContext.noBoundsChecks());
assertTrue(noNullCheckContext.noNullChecks());
assertFalse(noNullCheckContext.noCheckStoreChecks());
}
use of org.jikesrvm.compilers.opt.inlining.InlineOracle in project JikesRVM by JikesRVM.
the class GenerationContextTest method basicChildContextsWorkCorrectly.
@Test
public void basicChildContextsWorkCorrectly() 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);
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();
int nodeNumber = 12345;
gc.getCfg().setNumberOfNodes(nodeNumber);
GenerationContext child = gc.createChildContext(ebag, callee, callInstr);
RegisterOperand expectedLocalForObjectParam = child.makeLocal(0, objectParam);
assertThatStateIsCopiedFromParentToChild(gc, callee, child, ebag);
InlineSequence expectedInlineSequence = new InlineSequence(callee, callInstr.position(), callInstr);
assertEquals(expectedInlineSequence, child.getInlineSequence());
RegisterOperand firstArg = child.getArguments()[0].asRegister();
assertTrue(firstArg.sameRegisterPropertiesAs(expectedLocalForObjectParam));
assertSame(result.getRegister(), child.getResultReg());
assertTrue(child.getResultReg().spansBasicBlock());
assertThatPrologueAndEpilogueAreWiredCorrectlyForChildContext(ebag, nodeNumber, child);
Enumeration<Instruction> prologueRealInstr = child.getPrologue().forwardRealInstrEnumerator();
Instruction move = prologueRealInstr.nextElement();
RegisterOperand objectParamInChild = objectParam.copy().asRegister();
assertMoveOperationIsCorrect(callInstr, REF_MOVE, expectedLocalForObjectParam, objectParamInChild, move);
assertThatNoMoreInstructionsExist(prologueRealInstr);
Enumeration<Instruction> epilogueRealInstr = child.getEpilogue().forwardRealInstrEnumerator();
assertThatNoMoreInstructionsExist(epilogueRealInstr);
assertThatNoRethrowBlockExists(child);
assertThatChecksWontBeSkipped(gc);
}
Aggregations