use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class GenerationContextTest method getLocalNumberForRegisterReturnsMinusOneIfNotALocal.
@Test
public void getLocalNumberForRegisterReturnsMinusOneIfNotALocal() throws Exception {
GenerationContext gc = createMostlyEmptyContext("emptyInstanceMethodWithoutAnnotations");
Register reg = new Register(currentRegisterNumber--);
reg.setLong();
reg.setLocal();
int localNumber = gc.getLocalNumberFor(reg, TypeReference.Long);
assertThat(localNumber, is(-1));
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class GenerationContextTest method makeNullCheckGuardAlwaysReturnsCopies.
@Test
public void makeNullCheckGuardAlwaysReturnsCopies() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
OptOptions opts = new OptOptions();
GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
int localNumber = 0;
TypeReference localType = nm.getDeclaringClass().getTypeRef();
RegisterOperand regOp = gc.makeLocal(localNumber, localType);
Register reg = regOp.getRegister();
RegisterOperand expectedNullCheckGuard = gc.makeNullCheckGuard(reg);
RegisterOperand copiedGuard = expectedNullCheckGuard.copy().asRegister();
expectedNullCheckGuard.setGuard(new TrueGuardOperand());
RegisterOperand actual = gc.makeNullCheckGuard(reg);
assertTrue(actual.sameRegisterPropertiesAs(copiedGuard));
assertNull(actual.getGuard());
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class ActiveSetTest method freeIntervalHasNoVisibleInfluenceOnFreeIntervalsWhenThereAreStillIntervalsLeftInTheCompoundInterval.
@Test
public void freeIntervalHasNoVisibleInfluenceOnFreeIntervalsWhenThereAreStillIntervalsLeftInTheCompoundInterval() throws Exception {
Register reg = new Register(FIRST_REG_NUMBER);
reg.setInteger();
RegisterAllocatorState state = new RegisterAllocatorState(MAXIMUM_REGISTER_NUMBER);
state.setSpill(reg, SPILL_LOCATION);
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);
ci.spill(spillLocations, state);
assertThat(spillLocations.freeIntervals.size(), is(0));
active.freeInterval(firstMapped);
assertThat(spillLocations.freeIntervals.size(), is(0));
}
use of org.jikesrvm.compilers.opt.ir.Register 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.Register in project JikesRVM by JikesRVM.
the class ActiveSetTest method expireOldIntervalsRemovesIntervalsWhoseEndPrecedesTheNewStart.
@Test
public void expireOldIntervalsRemovesIntervalsWhoseEndPrecedesTheNewStart() throws Exception {
Register reg = new Register(FIRST_REG_NUMBER);
reg.setInteger();
RegisterAllocatorState state = new RegisterAllocatorState(MAXIMUM_REGISTER_NUMBER);
state.setSpill(reg, SPILL_LOCATION);
ActiveSet active = createActiveSetFromRegisterAllocatorState(state);
CompoundInterval ci = new CompoundInterval(reg);
BasicInterval first = new BasicInterval(1, 2);
BasicInterval firstMapped = new MappedBasicInterval(first, ci);
active.add(firstMapped);
ci.add(firstMapped);
BasicInterval second = new BasicInterval(7, 8);
BasicInterval secondMapped = new MappedBasicInterval(second, ci);
active.add(secondMapped);
ci.add(secondMapped);
ci.spill(spillLocations, state);
assertThat(active.size(), is(2));
active.expireOldIntervals(new MappedBasicInterval(new BasicInterval(4, 5), ci));
assertThat(active.size(), is(1));
}
Aggregations