use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class StackBrowser method upOneFrameInternal.
/**
* Browse up one frame
* @param set should the state of the stack browser be effected?
* @return do more frames exist?
*/
private boolean upOneFrameInternal(boolean set) {
Address fp;
if (currentMethod != null && currentMethod.getDeclaringClass().hasBridgeFromNativeAnnotation()) {
// Elide native frames
fp = RuntimeEntrypoints.unwindNativeStackFrame(currentFramePointer);
} else {
fp = currentFramePointer;
}
Address prevFP = fp;
Address newFP = Magic.getCallerFramePointer(fp);
if (newFP.EQ(StackFrameLayout.getStackFrameSentinelFP())) {
return false;
}
// getReturnAddress has to be put here, consider the case
// on ppc, when fp is the frame above SENTINEL FP
Address newIP = Magic.getReturnAddress(prevFP);
int cmid = Magic.getCompiledMethodID(newFP);
while (cmid == StackFrameLayout.getInvisibleMethodID()) {
prevFP = newFP;
newFP = Magic.getCallerFramePointer(newFP);
if (newFP.EQ(StackFrameLayout.getStackFrameSentinelFP())) {
return false;
}
newIP = Magic.getReturnAddress(prevFP);
cmid = Magic.getCompiledMethodID(newFP);
}
if (set) {
CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
currentFramePointer = newFP;
currentInstructionPointer = cm.getInstructionOffset(newIP);
cm.set(this, currentInstructionPointer);
}
return true;
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class StackTrace method buildStackTrace.
private Element[] buildStackTrace(int first, int last) {
Element[] elements = new Element[countFrames(first, last)];
if (!VM.BuildForOptCompiler) {
int element = 0;
for (int i = first; i <= last; i++) {
elements[element] = createStandardStackTraceElement(getCompiledMethod(i), instructionOffsets[i]);
element++;
}
} else {
int element = 0;
for (int i = first; i <= last; i++) {
CompiledMethod compiledMethod = getCompiledMethod(i);
if ((compiledMethod == null) || (compiledMethod.getCompilerType() != CompiledMethod.OPT)) {
// Invisible or non-opt compiled method
elements[element] = createStandardStackTraceElement(compiledMethod, instructionOffsets[i]);
element++;
} else {
Offset instructionOffset = Offset.fromIntSignExtend(instructionOffsets[i]);
OptCompiledMethod optInfo = (OptCompiledMethod) compiledMethod;
OptMachineCodeMap map = optInfo.getMCMap();
int iei = map.getInlineEncodingForMCOffset(instructionOffset);
if (iei < 0) {
elements[element] = createStandardStackTraceElement(compiledMethod, instructionOffsets[i]);
element++;
} else {
int[] inlineEncoding = map.inlineEncoding;
int bci = map.getBytecodeIndexForMCOffset(instructionOffset);
for (; iei >= 0; iei = OptEncodedCallSiteTree.getParent(iei, inlineEncoding)) {
int mid = OptEncodedCallSiteTree.getMethodID(iei, inlineEncoding);
RVMMethod method = MemberReference.getMethodRef(mid).getResolvedMember();
int lineNumber = ((NormalMethod) method).getLineNumberForBCIndex(bci);
elements[element] = createOptStackTraceElement(method, lineNumber, instructionOffset, bci);
element++;
if (iei > 0) {
bci = OptEncodedCallSiteTree.getByteCodeOffset(iei, inlineEncoding);
}
}
}
}
}
}
return elements;
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class StackTrace method recordFramesUninterruptible.
/**
* Walk the stack recording the stack frames encountered
* The stack being walked is our stack, so code is Uninterrupible to stop the
* stack moving.
*
* @param stackTraceThread the thread whose stack is walked
*/
@Uninterruptible
@NoInline
private void recordFramesUninterruptible(RVMThread stackTraceThread) {
int stackFrameCount = 0;
Address fp;
Address ip;
/* Stack trace for the thread */
if (stackTraceThread == RVMThread.getCurrentThread()) {
fp = Magic.getFramePointer();
} else {
AbstractRegisters contextRegisters = stackTraceThread.getContextRegisters();
fp = contextRegisters.getInnermostFramePointer();
}
ip = Magic.getReturnAddress(fp);
fp = Magic.getCallerFramePointer(fp);
while (Magic.getCallerFramePointer(fp).NE(StackFrameLayout.getStackFrameSentinelFP())) {
// VM.sysWriteln("at stackFrameCount = ",stackFrameCount);
int compiledMethodId = Magic.getCompiledMethodID(fp);
compiledMethods[stackFrameCount] = compiledMethodId;
if (compiledMethodId != StackFrameLayout.getInvisibleMethodID()) {
CompiledMethod compiledMethod = CompiledMethods.getCompiledMethod(compiledMethodId);
if (compiledMethod.getCompilerType() != CompiledMethod.TRAP) {
instructionOffsets[stackFrameCount] = compiledMethod.getInstructionOffset(ip).toInt();
if (compiledMethod.hasBridgeFromNativeAnnotation()) {
// VM.sysWriteln("native!");
// skip native frames, stopping at last native frame preceeding the
// Java To C transition frame
fp = RuntimeEntrypoints.unwindNativeStackFrame(fp);
}
} else {
// VM.sysWriteln("trap!");
}
} else {
// VM.sysWriteln("invisible method!");
}
stackFrameCount++;
ip = Magic.getReturnAddress(fp, stackTraceThread);
fp = Magic.getCallerFramePointer(fp);
}
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class StackTrace method removeStackTraceFrames.
/**
* Removes all frames from the StackTrace class (i.e. this class) from
* the stack trace by skipping them.
* <p>
* Note: Callers must update all data relating to the element index themselves.
*
* @param element the element index
* @return an updated element index
*/
private int removeStackTraceFrames(int element) {
CompiledMethod compiledMethod = getCompiledMethod(element);
while ((element < compiledMethods.length) && (compiledMethod != null) && compiledMethod.getMethod().getDeclaringClass().getClassForType() == StackTrace.class) {
element++;
compiledMethod = getCompiledMethod(element);
}
return element;
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class OptExecutionStateExtractor method walkOnStack.
/* walk on stack frame, print out methods
*/
private static void walkOnStack(byte[] stack, Offset fpOffset) {
VM.disableGC();
Address fp = Magic.objectAsAddress(stack).plus(fpOffset);
while (Magic.getCallerFramePointer(fp).NE(STACKFRAME_SENTINEL_FP)) {
int cmid = Magic.getCompiledMethodID(fp);
if (cmid == INVISIBLE_METHOD_ID) {
VM.sysWriteln(" invisible method ");
} else {
CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
fpOffset = fp.diff(Magic.objectAsAddress(stack));
VM.enableGC();
VM.sysWriteln(cm.getMethod().toString());
VM.disableGC();
fp = Magic.objectAsAddress(stack).plus(fpOffset);
if (cm.getMethod().getDeclaringClass().hasBridgeFromNativeAnnotation()) {
fp = RuntimeEntrypoints.unwindNativeStackFrame(fp);
}
}
fp = Magic.getCallerFramePointer(fp);
}
VM.enableGC();
}
Aggregations