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));
}
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);
}
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));
}
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);
}
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));
}
Aggregations