Search in sources :

Example 76 with Register

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));
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) Test(org.junit.Test)

Example 77 with Register

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());
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) NormalMethod(org.jikesrvm.classloader.NormalMethod) OptOptions(org.jikesrvm.compilers.opt.OptOptions) TypeReference(org.jikesrvm.classloader.TypeReference) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Test(org.junit.Test)

Example 78 with Register

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));
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) Test(org.junit.Test)

Example 79 with Register

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));
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) Test(org.junit.Test)

Example 80 with Register

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));
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) Test(org.junit.Test)

Aggregations

Register (org.jikesrvm.compilers.opt.ir.Register)279 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)144 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)106 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)82 Test (org.junit.Test)52 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)50 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)45 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)43 GenericPhysicalRegisterSet (org.jikesrvm.compilers.opt.ir.GenericPhysicalRegisterSet)40 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)39 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)32 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)30 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)29 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)27 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)26 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)25 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)24 IA32ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand)23 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)22 StackLocationOperand (org.jikesrvm.compilers.opt.ir.operand.StackLocationOperand)22