Search in sources :

Example 71 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class GenerationContextTest method makeLocalUsesLocalRegToDetermineRegisters.

@Test
public void makeLocalUsesLocalRegToDetermineRegisters() 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();
    Register expectedRegister = gc.localReg(localNumber, localType);
    RegisterOperand regOp = gc.makeLocal(localNumber, localType);
    assertSame(expectedRegister, regOp.getRegister());
}
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) Test(org.junit.Test)

Example 72 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class GenerationContextTest method constructorCreatesOperandsForInstanceMethods.

@Test
public void constructorCreatesOperandsForInstanceMethods() throws Exception {
    Class<?>[] argumentTypes = { Object.class, double.class, int.class, long.class };
    NormalMethod nm = getNormalMethodForTest("emptyInstanceMethodWithParams", 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, 5);
    RegisterOperand thisOperand = getThisOperand(gc);
    assertThatRegOpHoldsClassType(thisOperand);
    assertThatRegOpHasDeclaredType(thisOperand);
    RegisterOperand objectRegOp = gc.getArguments()[1].asRegister();
    assertThatRegOpHoldsClassType(objectRegOp);
    assertThatRegOpHasDeclaredType(objectRegOp);
    RegisterOperand doubleRegOp = gc.getArguments()[2].asRegister();
    assertThat(doubleRegOp.isDouble(), is(true));
    assertThatRegOpHasDeclaredType(doubleRegOp);
    RegisterOperand intRegOp = gc.getArguments()[3].asRegister();
    assertThat(intRegOp.isInt(), is(true));
    assertThatRegOpHasDeclaredType(intRegOp);
    RegisterOperand longRegOp = gc.getArguments()[4].asRegister();
    assertThat(longRegOp.isLong(), is(true));
    assertThatRegOpHasDeclaredType(longRegOp);
    Register thisLocalReg = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
    assertThatRegOpIsLocalRegOfRegister(thisOperand, thisLocalReg);
    Register objectReg = gc.localReg(1, TypeReference.JavaLangObject);
    assertThatRegOpIsLocalRegOfRegister(objectRegOp, objectReg);
    Register doubleReg = gc.localReg(2, TypeReference.Double);
    assertThatRegOpIsLocalRegOfRegister(doubleRegOp, doubleReg);
    Register intReg = gc.localReg(4, TypeReference.Int);
    assertThatRegOpIsLocalRegOfRegister(intRegOp, intReg);
    Register longReg = gc.localReg(5, TypeReference.Long);
    assertThatRegOpIsLocalRegOfRegister(longRegOp, longReg);
    BasicBlock prologue = gc.getPrologue();
    assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
    assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
    Instruction lastPrologueInstruction = prologue.lastRealInstruction();
    assertThatInstructionIsGuardMoveForPrologue(lastPrologueInstruction, thisOperand, gc);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, thisOperand, 0);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, objectRegOp, 1);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, doubleRegOp, 2);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, intRegOp, 3);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, longRegOp, 4);
    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) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) 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 73 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class GenerationContextTest method localRegistersAreSavedInDifferentPools.

@Test
public void localRegistersAreSavedInDifferentPools() throws Exception {
    GenerationContext gc = createMostlyEmptyContext("emptyInstanceMethodWithoutAnnotations");
    Register longReg = gc.localReg(0, TypeReference.Long);
    Register referenceReg = gc.localReg(0, TypeReference.JavaLangObject);
    assertNotSame(longReg, referenceReg);
    Register intReg = gc.localReg(0, TypeReference.Int);
    assertNotSame(longReg, intReg);
    assertNotSame(referenceReg, intReg);
    Register doubleReg = gc.localReg(0, TypeReference.Double);
    assertNotSame(longReg, doubleReg);
    assertNotSame(referenceReg, doubleReg);
    assertNotSame(intReg, doubleReg);
    Register floatReg = gc.localReg(0, TypeReference.Float);
    assertNotSame(longReg, floatReg);
    assertNotSame(referenceReg, floatReg);
    assertNotSame(intReg, floatReg);
    assertNotSame(doubleReg, floatReg);
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) Test(org.junit.Test)

Example 74 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class GenerationContextTest method specializationOfParametersIsSupported.

@Test
public void specializationOfParametersIsSupported() throws Exception {
    Class<?>[] argumentTypes = { Object.class };
    TypeReference typeRef = JikesRVMSupport.getTypeForClass(Uninterruptible.class).getTypeRef();
    TypeReference[] specializedArgumentTypes = { typeRef };
    NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithObjectParam", argumentTypes);
    CompiledMethod cm = new OptCompiledMethod(-1, nm);
    OptOptions opts = new OptOptions();
    InlineOracle io = new DefaultInlineOracle();
    GenerationContext gc = new GenerationContext(nm, specializedArgumentTypes, cm, opts, io);
    InlineSequence inlineSequence = new InlineSequence(nm);
    assertThatInlineSequenceWasSetCorrectly(gc, inlineSequence);
    assertThatNumberOfParametersIs(gc, 1);
    RegisterOperand objectRegOp = getThisOperand(gc);
    assertThatRegOpHoldsClassType(objectRegOp);
    assertThatRegOpHasDeclaredType(objectRegOp);
    Register objectReg = gc.localReg(0, TypeReference.Uninterruptible);
    assertThatRegOpIsLocalRegOfRegister(objectRegOp, objectReg);
    BasicBlock prologue = gc.getPrologue();
    assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
    assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
    assertThatBlockOnlyHasOneRealInstruction(prologue);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, objectRegOp, 0);
    assertThatEpilogueIsForVoidReturnMethod(gc, inlineSequence);
    assertThatExitBlockIsSetCorrectly(gc);
    assertThatDataIsSavedCorrectly(nm, cm, io, gc);
    assertThatReturnValueIsVoid(gc);
    assertThatGCHasNoExceptionHandlers(gc);
    assertThatRegisterPoolExists(gc);
    assertThatChecksWontBeSkipped(gc);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) Uninterruptible(org.vmmagic.pragma.Uninterruptible) 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) TypeReference(org.jikesrvm.classloader.TypeReference) Test(org.junit.Test)

Example 75 with Register

use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.

the class GenerationContextTest method localRegInvalidLocalNumberCausesArrayOutOfBoundsException.

@Test(expected = ArrayIndexOutOfBoundsException.class)
public void localRegInvalidLocalNumberCausesArrayOutOfBoundsException() throws Exception {
    GenerationContext gc = createMostlyEmptyContext("emptyInstanceMethodWithoutAnnotations");
    Register reg = gc.localReg(Integer.MAX_VALUE, TypeReference.Int);
    assertNotNull(reg);
}
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