use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class GenerationContextTest method assertThatStateIsCorrectForUnsynchronizedEmptyStaticMethod.
private void assertThatStateIsCorrectForUnsynchronizedEmptyStaticMethod(NormalMethod nm, CompiledMethod cm, InlineOracle io, GenerationContext gc) {
InlineSequence inlineSequence = new InlineSequence(nm);
assertThatInlineSequenceWasSetCorrectly(gc, inlineSequence);
assertThatNumberOfParametersIs(gc, 0);
BasicBlock prologue = gc.getPrologue();
assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
assertThatBlockOnlyHasOneRealInstruction(prologue);
assertThatEpilogueIsForVoidReturnMethod(gc, inlineSequence);
assertThatExitBlockIsSetCorrectly(gc);
assertThatRegisterPoolExists(gc);
assertThatDataIsSavedCorrectly(nm, cm, io, gc);
assertThatReturnValueIsVoid(gc);
assertThatGCHasNoExceptionHandlers(gc);
assertThatChecksWontBeSkipped(gc);
assertThatNoRethrowBlockExists(gc);
}
use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class GenerationContextTest method constructorCreatesOperandsForStaticMethodWithParameters.
@Test
public void constructorCreatesOperandsForStaticMethodWithParameters() throws Exception {
Class<?>[] argumentTypes = { long.class, int.class, Object.class, double.class };
NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithParams", argumentTypes);
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, 4);
RegisterOperand longRegOp = getThisOperand(gc);
assertThat(longRegOp.isLong(), is(true));
assertThatRegOpHasDeclaredType(longRegOp);
RegisterOperand intRegOp = gc.getArguments()[1].asRegister();
assertThat(intRegOp.isInt(), is(true));
assertThatRegOpHasDeclaredType(intRegOp);
RegisterOperand objectRegOp = gc.getArguments()[2].asRegister();
assertThatRegOpHoldsClassType(objectRegOp);
assertThatRegOpHasDeclaredType(objectRegOp);
RegisterOperand doubleRegOp = gc.getArguments()[3].asRegister();
assertThat(doubleRegOp.isDouble(), is(true));
assertThatRegOpHasDeclaredType(doubleRegOp);
Register longReg = gc.localReg(0, TypeReference.Long);
assertThatRegOpIsLocalRegOfRegister(longRegOp, longReg);
Register intReg = gc.localReg(2, TypeReference.Int);
assertThatRegOpIsLocalRegOfRegister(intRegOp, intReg);
Register objectReg = gc.localReg(3, TypeReference.JavaLangObject);
assertThatRegOpIsLocalRegOfRegister(objectRegOp, objectReg);
Register doubleReg = gc.localReg(4, TypeReference.Double);
assertThatRegOpIsLocalRegOfRegister(doubleRegOp, doubleReg);
BasicBlock prologue = gc.getPrologue();
assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
assertThatBlockOnlyHasOneRealInstruction(prologue);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, longRegOp, 0);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, intRegOp, 1);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, objectRegOp, 2);
assertThatPrologueOperandIsRegOpFromLocalNr(prologue, doubleRegOp, 3);
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.BasicBlock in project JikesRVM by JikesRVM.
the class GenerationContextTest method assertThatEpilogueIsForVoidReturnMethod.
private void assertThatEpilogueIsForVoidReturnMethod(GenerationContext gc, InlineSequence inlineSequence) {
BasicBlock epilogue = gc.getEpilogue();
assertThatEpilogueBlockIsSetupCorrectly(gc, inlineSequence, epilogue);
assertThatLastInstructionInEpilogueIsReturn(gc, epilogue);
assertThatReturnInstructionReturnsVoid(epilogue);
assertThatBlockOnlyHasOneRealInstruction(epilogue);
}
use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class CompoundIntervalTest method addRangeChangesEndOfLastIntervalWhenRangesDirectlyFollowEachOther_DefUseSameInstruction.
@Test
public void addRangeChangesEndOfLastIntervalWhenRangesDirectlyFollowEachOther_DefUseSameInstruction() {
Register reg = new Register(3);
CompoundInterval ci = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, reg);
assertThat(ci.last().getEnd(), is(DEFAULT_END));
RegisterAllocatorState regAllocState = new RegisterAllocatorState(1);
Instruction empty = Empty.create(WRITE_FLOOR);
Instruction defUse = Empty.create(WRITE_FLOOR);
Instruction lastUse = Empty.create(WRITE_FLOOR);
LiveIntervalElement live = new LiveIntervalElement(reg, defUse, lastUse);
ControlFlowGraph emptyCfg = new ControlFlowGraph(0);
BasicBlock bb = new BasicBlock(1, null, emptyCfg);
bb.appendInstruction(empty);
bb.appendInstruction(defUse);
bb.appendInstruction(lastUse);
regAllocState.initializeDepthFirstNumbering(10);
regAllocState.setDFN(empty, DEFAULT_BEGIN);
regAllocState.setDFN(defUse, DEFAULT_END);
regAllocState.setDFN(lastUse, DEFAULT_END + 1);
BasicInterval bi = ci.addRange(regAllocState, live, bb);
assertNull(bi);
assertThat(ci.last().getEnd(), is(DEFAULT_END + 1));
}
use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class CompoundIntervalTest method addRangeChangesEndOfLastIntervalWhenRangesDirectlyFollowEachOther_DefUse.
@Test
public void addRangeChangesEndOfLastIntervalWhenRangesDirectlyFollowEachOther_DefUse() {
Register reg = new Register(3);
CompoundInterval ci = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, reg);
assertThat(ci.last().getEnd(), is(DEFAULT_END));
RegisterAllocatorState regAllocState = new RegisterAllocatorState(1);
Instruction def = Empty.create(WRITE_FLOOR);
Instruction lastUse = Empty.create(WRITE_FLOOR);
LiveIntervalElement live = new LiveIntervalElement(reg, def, lastUse);
ControlFlowGraph emptyCfg = new ControlFlowGraph(0);
BasicBlock bb = new BasicBlock(1, null, emptyCfg);
bb.appendInstruction(def);
bb.appendInstruction(lastUse);
regAllocState.initializeDepthFirstNumbering(10);
regAllocState.setDFN(def, DEFAULT_END);
regAllocState.setDFN(lastUse, DEFAULT_END + 1);
BasicInterval bi = ci.addRange(regAllocState, live, bb);
assertNull(bi);
assertThat(ci.last().getEnd(), is(DEFAULT_END + 1));
}
Aggregations