use of org.jikesrvm.compilers.opt.OptOptions 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.OptOptions in project JikesRVM by JikesRVM.
the class GenerationContextTest method localRegReturnsRegistersThatAreFlaggedAsLocals.
@Test
public void localRegReturnsRegistersThatAreFlaggedAsLocals() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
OptOptions opts = new OptOptions();
GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
Register localReg = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
assertNotNull(localReg);
assertTrue(localReg.isLocal());
}
use of org.jikesrvm.compilers.opt.OptOptions 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);
}
use of org.jikesrvm.compilers.opt.OptOptions in project JikesRVM by JikesRVM.
the class GenerationContextTest method getLocalNumberReturnsLocalNumberForRegistersCreateViaMakeLocal.
@Test
public void getLocalNumberReturnsLocalNumberForRegistersCreateViaMakeLocal() 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);
Register thisReg = thisRegOp.getRegister();
assertThat(gc.getLocalNumberFor(thisReg, localType), is(thisLocalNumber));
}
use of org.jikesrvm.compilers.opt.OptOptions in project JikesRVM by JikesRVM.
the class GenerationContextTest method childContextsSaveOSRBarrierInformationInOutermostParent.
@Test
public void childContextsSaveOSRBarrierInformationInOutermostParent() 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));
GenerationContext child2 = child.createChildContext(ebag, callee, callInstr);
Instruction osrBarrier2 = createMockOSRBarrier();
Instruction call2 = createMockCall();
child2.saveOSRBarrierForInst(osrBarrier2, call2);
assertThat(outermost.getOSRBarrierFromInst(call2), is(osrBarrier2));
}
Aggregations