use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod in project JikesRVM by JikesRVM.
the class OptExceptionDeliverer method unwindStackFrame.
/**
* Unwind a stackframe.
*/
@Override
@Unpreemptible("Deliver exception possibly from unpreemptible code")
public void unwindStackFrame(CompiledMethod cm, AbstractRegisters registers) {
Address fp = registers.getInnermostFramePointer();
OptCompiledMethod compiledMethod = (OptCompiledMethod) cm;
// restore non-volatile registers
Offset frameOffset = Offset.fromIntSignExtend(compiledMethod.getUnsignedNonVolatileOffset());
int firstInteger = compiledMethod.getFirstNonVolatileGPR();
if (firstInteger >= 0) {
if (VM.BuildFor64Addr) {
frameOffset = frameOffset.plus(7).toWord().and(Word.fromIntSignExtend(~7)).toOffset();
}
for (int i = firstInteger; i < 32; i++) {
registers.getGPRs().set(i, fp.loadWord(frameOffset));
frameOffset = frameOffset.plus(BYTES_IN_ADDRESS);
}
}
int firstFloat = compiledMethod.getFirstNonVolatileFPR();
if (firstFloat >= 0) {
frameOffset = frameOffset.plus(7).toWord().and(Word.fromIntSignExtend(~7)).toOffset();
for (int i = firstFloat; i < 32; i++) {
long temp = Magic.getLongAtOffset(Magic.addressAsObject(fp), frameOffset);
registers.getFPRs()[i] = Magic.longBitsAsDouble(temp);
frameOffset = frameOffset.plus(BYTES_IN_DOUBLE);
}
}
registers.unwindStackFrame();
}
use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod in project JikesRVM by JikesRVM.
the class CompiledMethods method createCompiledMethod.
public static synchronized CompiledMethod createCompiledMethod(RVMMethod m, int compilerType) {
int id = currentCompiledMethodId + 1;
ensureCapacity(id);
currentCompiledMethodId++;
CompiledMethod cm = null;
if (compilerType == CompiledMethod.BASELINE) {
if (VM.BuildForIA32) {
cm = new org.jikesrvm.compilers.baseline.ia32.ArchBaselineCompiledMethod(id, m);
} else {
if (VM.VerifyAssertions)
VM._assert(VM.BuildForPowerPC);
cm = new org.jikesrvm.compilers.baseline.ppc.ArchBaselineCompiledMethod(id, m);
}
} else if (VM.BuildForOptCompiler && compilerType == CompiledMethod.OPT) {
cm = new OptCompiledMethod(id, m);
} else if (compilerType == CompiledMethod.JNI) {
cm = new JNICompiledMethod(id, m);
} else {
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED, "Unexpected compiler type!");
}
setCompiledMethod(id, cm);
return cm;
}
use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method prologueAndEpilogueForSynchronizedStaticMethodHaveMonitorEnterAndExit.
@Test
public void prologueAndEpilogueForSynchronizedStaticMethodHaveMonitorEnterAndExit() throws Exception {
NormalMethod nm = getNormalMethodForTest("emptySynchronizedStaticMethod");
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, 0);
BasicBlock prologue = gc.getPrologue();
assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
Enumeration<Instruction> prologueInstructions = prologue.forwardRealInstrEnumerator();
prologueInstructions.nextElement();
Instruction secondInstruction = prologueInstructions.nextElement();
assertInstructionIsMonitorEnterInPrologue(secondInstruction, inlineSequence);
assertThatGuardIsCorrectForMonitorEnter(secondInstruction);
Operand lockObject = MonitorOp.getRef(secondInstruction);
Operand expectedLockObject = buildLockObjectForStaticMethod(nm);
assertTrue(expectedLockObject.similar(lockObject));
assertThatNumberOfRealInstructionsMatches(prologue, 2);
BasicBlock epilogue = gc.getEpilogue();
assertThatEpilogueBlockIsSetupCorrectly(gc, inlineSequence, epilogue);
assertThatFirstInstructionEpilogueIsMonitorExit(inlineSequence, epilogue);
assertThatLastInstructionInEpilogueIsReturn(gc, epilogue);
assertThatReturnInstructionReturnsVoid(epilogue);
assertThatNumberOfRealInstructionsMatches(epilogue, 2);
assertThatExitBlockIsSetCorrectly(gc);
assertThatRegisterPoolExists(gc);
assertThatDataIsSavedCorrectly(nm, cm, io, gc);
assertThatReturnValueIsVoid(gc);
assertThatExceptionHandlersWereGenerated(gc);
assertThatUnlockAndRethrowBlockIsCorrect(gc, inlineSequence, prologue, expectedLockObject, epilogue);
assertThatChecksWontBeSkipped(gc);
}
use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method constructorIsCorrectForTheSimplestMethods.
@Test
public void constructorIsCorrectForTheSimplestMethods() throws Exception {
NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithoutAnnotations");
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
assertThatStateIsCorrectForUnsynchronizedEmptyStaticMethod(nm, cm, io, gc);
}
use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method unintBeginAndUnintEndAreAddedWhenNecessary.
@Test
public void unintBeginAndUnintEndAreAddedWhenNecessary() throws Exception {
NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithoutAnnotations");
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
assertThatStateIsCorrectForUnsynchronizedEmptyStaticMethod(nm, cm, io, gc);
NormalMethod callee = getNormalMethodForTest("emptyStaticUninterruptibleMethod");
Instruction callInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, nm);
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
int nodeNumber = 23456;
gc.getCfg().setNumberOfNodes(nodeNumber);
GenerationContext child = gc.createChildContext(ebag, callee, callInstr);
assertThatStateIsCopiedFromParentToChild(gc, callee, child, ebag);
InlineSequence expectedInlineSequence = new InlineSequence(callee, callInstr.position(), callInstr);
assertEquals(expectedInlineSequence, child.getInlineSequence());
assertThatPrologueAndEpilogueAreWiredCorrectlyForChildContext(ebag, nodeNumber, child);
Enumeration<Instruction> prologueRealInstr = child.getPrologue().forwardRealInstrEnumerator();
Instruction unintBegin = prologueRealInstr.nextElement();
assertThatInstructionIsUnintMarker(unintBegin, UNINT_BEGIN);
assertThatNoMoreInstructionsExist(prologueRealInstr);
Enumeration<Instruction> epilogueRealInstr = child.getEpilogue().forwardRealInstrEnumerator();
Instruction unintEnd = epilogueRealInstr.nextElement();
assertThatInstructionIsUnintMarker(unintEnd, UNINT_END);
assertThatNoMoreInstructionsExist(epilogueRealInstr);
}
Aggregations