Search in sources :

Example 51 with OptOptions

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());
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) ExceptionHandlerBasicBlockBag(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag) Test(org.junit.Test)

Example 52 with OptOptions

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());
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) NormalMethod(org.jikesrvm.classloader.NormalMethod) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Test(org.junit.Test)

Example 53 with OptOptions

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);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) ExceptionHandlerBasicBlockBag(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) Test(org.junit.Test)

Example 54 with OptOptions

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));
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) OptOptions(org.jikesrvm.compilers.opt.OptOptions) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) TypeReference(org.jikesrvm.classloader.TypeReference) Test(org.junit.Test)

Example 55 with OptOptions

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));
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) ExceptionHandlerBasicBlockBag(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) Test(org.junit.Test)

Aggregations

OptOptions (org.jikesrvm.compilers.opt.OptOptions)70 Test (org.junit.Test)48 NormalMethod (org.jikesrvm.classloader.NormalMethod)45 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)32 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)29 DefaultInlineOracle (org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle)28 InlineOracle (org.jikesrvm.compilers.opt.inlining.InlineOracle)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)27 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)19 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)17 ExceptionHandlerBasicBlockBag (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)14 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)13 TypeReference (org.jikesrvm.classloader.TypeReference)12 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)12 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)12 Register (org.jikesrvm.compilers.opt.ir.Register)12 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)8 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)8 ClassConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand)7 ObjectConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand)7