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