use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class RuntimeMeasurements method takeCBSCallSample.
/**
* Called from Thread.yieldpoint when it is time to take a CBS call sample.
*
* @param whereFrom source of the yieldpoint (e.g. backedge)
* @param yieldpointServiceMethodFP the frame pointer of the service
* method that is responsible for handling the yieldpoint
*/
@Uninterruptible
public static void takeCBSCallSample(int whereFrom, Address yieldpointServiceMethodFP) {
// method that took yieldpoint
Address ypTakenInFP = Magic.getCallerFramePointer(yieldpointServiceMethodFP);
// Get the cmid for the method in which the yieldpoint was taken.
int ypTakenInCMID = Magic.getCompiledMethodID(ypTakenInFP);
// Get the cmid for that method's caller.
Address ypTakenInCallerFP = Magic.getCallerFramePointer(ypTakenInFP);
int ypTakenInCallerCMID = Magic.getCompiledMethodID(ypTakenInCallerFP);
// Determine if ypTakenInCallerCMID corresponds to a real Java stackframe.
// If one of the following conditions is detected, set ypTakenInCallerCMID to -1
// Caller is out-of-line assembly (no RVMMethod object) or top-of-stack psuedo-frame
// Caller is a native method
CompiledMethod ypTakenInCM = CompiledMethods.getCompiledMethod(ypTakenInCMID);
if (ypTakenInCallerCMID == StackFrameLayout.getInvisibleMethodID() || ypTakenInCM.getMethod().getDeclaringClass().hasBridgeFromNativeAnnotation()) {
// drop sample
} else {
// Notify all registered listeners
for (ContextListener listener : cbsContextListeners) {
if (listener.isActive()) {
listener.update(ypTakenInFP, whereFrom);
}
}
}
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method childContextsQueryOSRBarrierInformationViaOutermostParent.
@Test
public void childContextsQueryOSRBarrierInformationViaOutermostParent() throws Exception {
NormalMethod nm = getNormalMethodForTest("methodForInliningTests");
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = new OptOptions();
InlineOracle io = new DefaultInlineOracle();
GenerationContext outermost = new GenerationContext(nm, null, cm, opts, io);
Class<?>[] classArgs = { Object.class };
NormalMethod callee = getNormalMethodForTest("emptyStaticMethodWithObjectParamAndReturnValue", classArgs);
MethodOperand methOp = MethodOperand.STATIC(callee);
RegisterOperand result = createMockRegisterOperand(TypeReference.JavaLangObject);
Instruction callInstr = Call.create(CALL, result, null, methOp, 1);
RegisterOperand objectParam = createMockRegisterOperand(TypeReference.JavaLangObject);
Call.setParam(callInstr, 0, objectParam);
callInstr.setPosition(new InlineSequence(nm));
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
GenerationContext child = outermost.createChildContext(ebag, callee, callInstr);
Instruction osrBarrier = createMockOSRBarrier();
Instruction call = createMockCall();
child.saveOSRBarrierForInst(osrBarrier, call);
assertThat(outermost.getOSRBarrierFromInst(call), is(osrBarrier));
assertThat(child.getOSRBarrierFromInst(call), is(osrBarrier));
GenerationContext child2 = outermost.createChildContext(ebag, callee, callInstr);
assertThat(child2.getOSRBarrierFromInst(call), is(osrBarrier));
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method methodsWithReturnValueHaveReturnInstructionInEpilogue.
@Test
public void methodsWithReturnValueHaveReturnInstructionInEpilogue() throws Exception {
NormalMethod nm = getNormalMethodForTest("staticMethodReturningLongMaxValue");
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);
assertThatBlockOnlyHasOneRealInstruction(prologue);
BasicBlock epilogue = gc.getEpilogue();
assertThatEpilogueBlockIsSetupCorrectly(gc, inlineSequence, epilogue);
assertThatLastInstructionInEpilogueIsReturn(gc, epilogue);
RegisterOperand returnValue = Return.getVal(epilogue.lastRealInstruction()).asRegister();
assertThat(returnValue.getType(), is(TypeReference.Long));
assertThatExitBlockIsSetCorrectly(gc);
assertThatDataIsSavedCorrectly(nm, cm, io, gc);
assertThat(gc.getResultReg().isLong(), is(true));
assertThatGCHasNoExceptionHandlers(gc);
assertThatRegisterPoolExists(gc);
assertThatChecksWontBeSkipped(gc);
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method specializedParametersAreNotSanityChecked.
@Test
public void specializedParametersAreNotSanityChecked() throws Exception {
Class<?>[] argumentTypes = { Object.class };
TypeReference[] specializedArgumentTypes = {};
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);
assertThatNumberOfParametersIs(gc, 0);
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method methodIsSelectedForDebuggingWithMethodToPrintReturnsTrueIfOutermostParentMatches.
@Test
public void methodIsSelectedForDebuggingWithMethodToPrintReturnsTrueIfOutermostParentMatches() throws Exception {
String methodName = "emptyStaticMethodWithoutAnnotations";
NormalMethod nm = getNormalMethodForTest(methodName);
CompiledMethod cm = new OptCompiledMethod(-1, nm);
OptOptions opts = buildOptionsWithMethodToPrintOptionSet(methodName);
InlineOracle io = new DefaultInlineOracle();
GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
ExceptionHandlerBasicBlockBag ebag = getMockEbag();
NormalMethod callee = getNormalMethodForTest("emptyStaticMethodWithNoCheckStoreAnnotation");
Instruction noCheckStoreInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, nm);
GenerationContext nextInnerContext = gc.createChildContext(ebag, callee, noCheckStoreInstr);
NormalMethod nextInnerCallee = getNormalMethodForTest("emptyStaticMethodWithNoNullCheckAnnotation");
Instruction noNullCheckInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, nextInnerCallee);
GenerationContext innermostContext = nextInnerContext.createChildContext(ebag, nextInnerCallee, noNullCheckInstr);
assertThat(innermostContext.methodIsSelectedForDebuggingWithMethodToPrint(), is(true));
}
Aggregations