use of org.jikesrvm.classloader.NormalMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method makeNullCheckGuardReturnsSameGuardForSameRegister.
@Test
public void makeNullCheckGuardReturnsSameGuardForSameRegister() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
OptOptions opts = new OptOptions();
GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
int localNumber = 0;
TypeReference localType = nm.getDeclaringClass().getTypeRef();
RegisterOperand regOp = gc.makeLocal(localNumber, localType);
Register reg = regOp.getRegister();
RegisterOperand expectedNullCheckGuard = gc.makeNullCheckGuard(reg);
RegisterOperand actual = gc.makeNullCheckGuard(reg);
assertTrue(actual.sameRegisterPropertiesAs(expectedNullCheckGuard));
}
use of org.jikesrvm.classloader.NormalMethod 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.classloader.NormalMethod 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.classloader.NormalMethod 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.classloader.NormalMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method getOriginalMethodReturnsTheOutermostMethod.
@Test
public void getOriginalMethodReturnsTheOutermostMethod() throws Exception {
GenerationContext outermostContext = createMostlyEmptyContext("emptyStaticMethodWithNoBoundCheckAnnotation");
NormalMethod outermostCaller = getNormalMethodForTest("emptyStaticMethodWithNoBoundCheckAnnotation");
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
NormalMethod callee = getNormalMethodForTest("emptyStaticMethodWithNoCheckStoreAnnotation");
Instruction noCheckStoreInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, outermostCaller);
GenerationContext nextInnerContext = outermostContext.createChildContext(ebag, callee, noCheckStoreInstr);
assertThat(nextInnerContext.getOriginalMethod(), is(outermostCaller));
NormalMethod nextInnerCallee = getNormalMethodForTest("emptyStaticMethodWithNoNullCheckAnnotation");
Instruction noNullCheckInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, nextInnerCallee);
GenerationContext innermostContext = nextInnerContext.createChildContext(ebag, nextInnerCallee, noNullCheckInstr);
assertThat(innermostContext.getOriginalMethod(), is(outermostCaller));
}
Aggregations