Search in sources :

Example 91 with Instruction

use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.

the class TailRecursionEliminationTest method callsWithNoTailCallEliminationAnnotationArentSubjectToOptimization.

@Test
public void callsWithNoTailCallEliminationAnnotationArentSubjectToOptimization() throws Exception {
    Class<?>[] types = {};
    RVMMethod m = TestingTools.getNormalMethod(MethodsForTests.class, "emptyStaticMethodWithNoTailCallEliminationAnnotation", types);
    MethodOperand methOp = MethodOperand.STATIC(m);
    Instruction call = Call.create(CALL, null, null, methOp, 0);
    assertFalse(tailRecursionElimination.allowedToOptimize(call));
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) Test(org.junit.Test)

Example 92 with Instruction

use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.

the class SplitBasicBlockTest method branchesAtTheEndOfTheBlockDoNotCountAsIntructions.

@Test
public void branchesAtTheEndOfTheBlockDoNotCountAsIntructions() {
    int maxInstPerBlock = 3;
    IR ir = createIRWithEmptyCFG(maxInstPerBlock);
    int nodeNumberBefore = ir.cfg.numberOfNodes();
    Enumeration<BasicBlock> blocks = ir.getBasicBlocks();
    while (blocks.hasMoreElements()) {
        BasicBlock bb = blocks.nextElement();
        bb.appendInstruction(Empty.create(FENCE));
        bb.appendInstruction(Empty.create(FENCE));
        Instruction i = IfCmp.create(INT_IFCMP, null, null, null, null, null, null);
        bb.appendInstruction(i);
    }
    splitPhase.perform(ir);
    int nodeNumberAfter = ir.cfg.numberOfNodes();
    assertThat(nodeNumberAfter, is(nodeNumberBefore));
    assertThatInstructionCountForEachBlockIsAtMost(ir, maxInstPerBlock);
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) IR(org.jikesrvm.compilers.opt.ir.IR) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) Test(org.junit.Test)

Example 93 with Instruction

use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.

the class ActiveSetTest method getBasicIntervalReturnsCorrectIntervalIfRegisterContainsTheInstruction.

@Test
public void getBasicIntervalReturnsCorrectIntervalIfRegisterContainsTheInstruction() throws Exception {
    Register regZero = new Register(0);
    RegisterAllocatorState state = new RegisterAllocatorState(1);
    CompoundInterval ci = new CompoundInterval(regZero);
    MappedBasicInterval mbi = new MappedBasicInterval(1, 10, ci);
    ci.add(mbi);
    Instruction fence = Empty.create(FENCE);
    state.setInterval(regZero, ci);
    state.initializeDepthFirstNumbering(10);
    state.setDFN(fence, 5);
    ActiveSet active = createActiveSetFromRegisterAllocatorState(state);
    BasicInterval bi = active.getBasicInterval(regZero, fence);
    assertThat(bi.getBegin(), is(1));
    assertThat(bi.getEnd(), is(10));
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) Test(org.junit.Test)

Example 94 with Instruction

use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.

the class GenerationContextTest method instanceMethodsHaveMovesInPrologue.

@Test
public void instanceMethodsHaveMovesInPrologue() throws Exception {
    NormalMethod nm = getNormalMethodForTest("emptyInstanceMethodWithoutAnnotations");
    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);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, thisOperand, 0);
    Instruction lastPrologueInstruction = prologue.lastRealInstruction();
    assertThatInstructionIsGuardMoveForPrologue(lastPrologueInstruction, thisOperand, gc);
    assertThatEpilogueIsForVoidReturnMethod(gc, inlineSequence);
    assertThatExitBlockIsSetCorrectly(gc);
    assertThatDataIsSavedCorrectly(nm, cm, io, gc);
    assertThatReturnValueIsVoid(gc);
    assertThatGCHasNoExceptionHandlers(gc);
    assertThatRegisterPoolExists(gc);
    assertThatChecksWontBeSkipped(gc);
    assertThatNoRethrowBlockExists(gc);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) 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) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) 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) Test(org.junit.Test)

Example 95 with Instruction

use of org.jikesrvm.compilers.opt.ir.Instruction in project JikesRVM by JikesRVM.

the class CompoundIntervalTest method getBasicIntervalRegAllocStateReturnsIntervalWithGreatestStartIfMultipleMatch.

@Test
public void getBasicIntervalRegAllocStateReturnsIntervalWithGreatestStartIfMultipleMatch() {
    CompoundInterval ci = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, null);
    ci.add(new BasicInterval(DEFAULT_BEGIN, DEFAULT_END + 1));
    RegisterAllocatorState regAllocState = new RegisterAllocatorState(1);
    regAllocState.initializeDepthFirstNumbering(20);
    Instruction writeFloor = Empty.create(WRITE_FLOOR);
    regAllocState.setDFN(writeFloor, DEFAULT_END);
    BasicInterval bi = ci.getBasicInterval(regAllocState, writeFloor);
    assertThat(bi.getBegin(), is(DEFAULT_BEGIN));
    assertThat(bi.getEnd(), is(DEFAULT_END + 1));
}
Also used : Instruction(org.jikesrvm.compilers.opt.ir.Instruction) Test(org.junit.Test)

Aggregations

Instruction (org.jikesrvm.compilers.opt.ir.Instruction)356 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)204 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)144 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)117 Register (org.jikesrvm.compilers.opt.ir.Register)106 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)72 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)61 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)61 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)54 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)53 Test (org.junit.Test)49 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)46 TypeReference (org.jikesrvm.classloader.TypeReference)38 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)38 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)35 BasicBlockOperand (org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand)33 HeapOperand (org.jikesrvm.compilers.opt.ir.operand.HeapOperand)33 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)31 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)28 TypeOperand (org.jikesrvm.compilers.opt.ir.operand.TypeOperand)27