use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class ActiveSetTest method freeIntervalWorksForIntervalsAssignedToUnspilledNonPhysicalRegisters.
@Test
public void freeIntervalWorksForIntervalsAssignedToUnspilledNonPhysicalRegisters() throws Exception {
Register reg = new Register(FIRST_REG_NUMBER);
Register mappedReg = new Register(SECOND_REG_NUMBER);
reg.allocateRegister(mappedReg);
mappedReg.setPhysical();
mappedReg.allocateRegister();
RegisterAllocatorState state = new RegisterAllocatorState(MAXIMUM_REGISTER_NUMBER);
ActiveSet active = createActiveSetFromRegisterAllocatorState(state);
CompoundInterval ci = new CompoundInterval(reg);
BasicInterval first = new BasicInterval(1, 2);
MappedBasicInterval firstMapped = new MappedBasicInterval(first, ci);
active.add(firstMapped);
ci.add(firstMapped);
BasicInterval second = new BasicInterval(2, 3);
MappedBasicInterval secondMapped = new MappedBasicInterval(second, ci);
ci.add(secondMapped);
active.freeInterval(firstMapped);
assertThat(mappedReg.isAllocated(), is(false));
assertNull(mappedReg.mapsToRegister);
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class GenerationContextTest method localRegAlwaysReturnsSameRegisterForSameArguments.
@Test
public void localRegAlwaysReturnsSameRegisterForSameArguments() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
OptOptions opts = new OptOptions();
GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
Register regExpected = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
Register regActual = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
assertSame(regActual, regExpected);
}
use of org.jikesrvm.compilers.opt.ir.Register 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.Register in project JikesRVM by JikesRVM.
the class CompoundIntervalTest method assignCausesAssignmentOfTheIntervalsRegisterToTheGivenRegister.
@Test
public void assignCausesAssignmentOfTheIntervalsRegisterToTheGivenRegister() {
Register r = new Register(0);
CompoundInterval ci = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, r);
Register s = new Register(1);
RegisterAllocatorState regAllocState = new RegisterAllocatorState(0);
assertThat(ci.isAssigned(regAllocState), is(false));
assertNull(ci.getAssignment(regAllocState));
ci.assign(s);
assertThat(s.mapsToRegister, is(r));
assertThat(!s.isSpilled() && s.isTouched() && s.isAllocated(), is(true));
assertThat(r.mapsToRegister, is(s));
assertThat(!r.isSpilled() && r.isTouched() && r.isAllocated(), is(true));
assertThat(ci.isAssigned(regAllocState), is(true));
assertThat(ci.getAssignment(regAllocState), is(s));
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class CompoundIntervalTest method registersDoNotMatterForIntersection.
@Test
public void registersDoNotMatterForIntersection() {
CompoundInterval ci = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, new Register(-1));
CompoundInterval otherCi = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, new Register(-2));
assertThat(ci.intersects(otherCi), is(true));
}
Aggregations