Search in sources :

Example 81 with Register

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

Example 82 with Register

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

Example 83 with Register

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);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) OptOptions(org.jikesrvm.compilers.opt.OptOptions) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) Test(org.junit.Test)

Example 84 with Register

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

Example 85 with Register

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