Search in sources :

Example 71 with CompiledMethod

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;
}
Also used : Address(org.vmmagic.unboxed.Address) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Example 72 with CompiledMethod

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;
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) RVMMethod(org.jikesrvm.classloader.RVMMethod) OptMachineCodeMap(org.jikesrvm.compilers.opt.runtimesupport.OptMachineCodeMap) NormalMethod(org.jikesrvm.classloader.NormalMethod) BaselineCompiledMethod(org.jikesrvm.compilers.baseline.BaselineCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) Offset(org.vmmagic.unboxed.Offset)

Example 73 with CompiledMethod

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);
    }
}
Also used : Address(org.vmmagic.unboxed.Address) AbstractRegisters(org.jikesrvm.architecture.AbstractRegisters) BaselineCompiledMethod(org.jikesrvm.compilers.baseline.BaselineCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) Uninterruptible(org.vmmagic.pragma.Uninterruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 74 with CompiledMethod

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;
}
Also used : BaselineCompiledMethod(org.jikesrvm.compilers.baseline.BaselineCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 75 with CompiledMethod

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();
}
Also used : Address(org.vmmagic.unboxed.Address) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Aggregations

CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)97 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)56 NormalMethod (org.jikesrvm.classloader.NormalMethod)41 Test (org.junit.Test)33 OptOptions (org.jikesrvm.compilers.opt.OptOptions)32 Address (org.vmmagic.unboxed.Address)30 DefaultInlineOracle (org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle)28 InlineOracle (org.jikesrvm.compilers.opt.inlining.InlineOracle)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)20 Offset (org.vmmagic.unboxed.Offset)20 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)19 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)17 RVMMethod (org.jikesrvm.classloader.RVMMethod)14 ExceptionHandlerBasicBlockBag (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)14 TypeReference (org.jikesrvm.classloader.TypeReference)13 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)13 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)13 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)13 BaselineCompiledMethod (org.jikesrvm.compilers.baseline.BaselineCompiledMethod)10 RVMClass (org.jikesrvm.classloader.RVMClass)7