use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class EdgeListener method update.
/**
* This method is called when a call stack edge needs to be
* sampled. Expect the sfp argument to point to the stack frame that
* contains the target of the edge to be sampled.
* <p>
* NOTE: This method is uninterruptible, therefore we don't need to disable
* thread switching during stackframe inspection.
*
* @param sfp a pointer to the stack frame that corresponds to the callee of
* the call graph edge that is to be sampled.
* @param whereFrom Was this a yieldpoint in a PROLOGUE, BACKEDGE, or
* EPILOGUE?
*/
@Override
public final void update(Address sfp, int whereFrom) {
if (DEBUG) {
VM.sysWrite("EdgeListener.update(", sfp, ",", whereFrom);
VM.sysWriteln("): enter ", samplesTaken);
}
Synchronization.fetchAndAdd(this, AosEntrypoints.edgeListenerUpdateCalledField.getOffset(), 1);
// don't take a sample for back edge yield points
if (whereFrom == RVMThread.BACKEDGE)
return;
int calleeCMID = 0;
int callerCMID = 0;
Address returnAddress = Address.zero();
if (sfp.loadAddress().EQ(StackFrameLayout.getStackFrameSentinelFP())) {
if (DEBUG)
VM.sysWriteln(" Walking off end of stack!");
return;
}
calleeCMID = Magic.getCompiledMethodID(sfp);
if (calleeCMID == StackFrameLayout.getInvisibleMethodID()) {
if (DEBUG) {
VM.sysWrite(" INVISIBLE_METHOD_ID (assembler code) ");
VM.sysWrite(calleeCMID);
VM.sysWriteln();
}
return;
}
// return address in caller
returnAddress = Magic.getReturnAddress(sfp);
// caller's frame pointer
sfp = Magic.getCallerFramePointer(sfp);
if (sfp.loadAddress().EQ(StackFrameLayout.getStackFrameSentinelFP())) {
if (DEBUG)
VM.sysWriteln(" Walking off end of stack");
return;
}
callerCMID = Magic.getCompiledMethodID(sfp);
if (callerCMID == StackFrameLayout.getInvisibleMethodID()) {
if (DEBUG) {
VM.sysWrite(" INVISIBLE_METHOD_ID (assembler code) ");
VM.sysWrite(callerCMID);
VM.sysWriteln();
}
return;
}
// store the offset of the return address from the beginning of the
// instruction
CompiledMethod callerCM = CompiledMethods.getCompiledMethod(callerCMID);
if (callerCM.getCompilerType() == CompiledMethod.TRAP) {
if (DEBUG) {
VM.sysWriteln(" HARDWARE TRAP FRAME ");
}
return;
}
Offset callSite = callerCM.getInstructionOffset(returnAddress);
if (DEBUG) {
VM.sysWrite(" <");
VM.sysWrite(calleeCMID);
VM.sysWrite(",");
VM.sysWrite(callerCMID);
VM.sysWrite(",");
VM.sysWrite(returnAddress);
VM.sysWriteln(">");
}
// Find out what sample we are.
int sampleNumber = Synchronization.fetchAndAdd(this, AosEntrypoints.edgeListenerSamplesTakenField.getOffset(), 1);
int idx = 3 * sampleNumber;
// is in the process of activating our organizer and processing the buffer).
if (idx < buffer.length) {
buffer[idx + 1] = callerCMID;
buffer[idx + 2] = callSite.toInt();
Magic.fence();
buffer[idx + 0] = calleeCMID;
// If we are the last sample, we need to activate the organizer.
if (sampleNumber + 1 == desiredSamples) {
activateOrganizer();
}
}
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class SpecializedMethodPool method registerCompiledMethod.
static void registerCompiledMethod(SpecializedMethod m) {
int smid = m.getSpecializedMethodIndex();
CompiledMethod cm = m.getCompiledMethod();
storeSpecializedMethod(cm, smid);
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class BaselineGCMapIteratorTest method getNextReferenceAddressReturnsCorrectReferenceIfReferencesArePresent.
@Test
public void getNextReferenceAddressReturnsCorrectReferenceIfReferencesArePresent() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyStaticMethodWithObjectParam", Object.class);
CompiledMethod cm = nm.getCurrentCompiledMethod();
// Fake a stack frame
int stackWords = 5;
WordArray wa = createNonMovableWordArray(stackWords);
for (int i = 0; i < wa.length(); i++) {
wa.set(i, Word.fromIntSignExtend(5 * i));
}
int targetSlot = wa.length() - 1;
Address fp = Magic.objectAsAddress(wa).plus(targetSlot * BYTES_IN_WORD);
// local 0 is reference.
// +/- 0 words: FP
// - 1 words: CMID
// - 2 words: saved GPRs (EDI)
// - 3 words: saved GPRs (EBX)
// - 4 words: local0 == reference
Address targetAddress = fp.minus(4 * BYTES_IN_STACKSLOT);
Word targetContents = targetAddress.loadWord();
gcMapIter.setupIterator(cm, Offset.fromIntZeroExtend(cm.getEntryCodeArray().length()), fp);
Address referenceAddr = gcMapIter.getNextReferenceAddress();
assertEquals(targetAddress, referenceAddr);
assertEquals(targetContents, referenceAddr.loadWord());
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class BaselineGCMapIteratorTest method getNextReferenceAddressReturnsZeroIfNoReferencesArePresent.
@Test
public void getNextReferenceAddressReturnsZeroIfNoReferencesArePresent() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyStaticMethodWithoutAnnotations");
CompiledMethod cm = nm.getCurrentCompiledMethod();
gcMapIter.setupIterator(cm, NO_OFFSET, NO_FP);
Address referenceAddr = gcMapIter.getNextReferenceAddress();
assertZero(referenceAddr);
}
use of org.jikesrvm.compilers.common.CompiledMethod 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);
}
Aggregations