Search in sources :

Example 21 with Uninterruptible

use of org.vmmagic.pragma.Uninterruptible in project JikesRVM by JikesRVM.

the class ThinLock method getLockIndex.

/**
 * Return the lock index for a given lock word.  Assert valid index
 * ranges, that the fat lock bit is set, and that the lock entry
 * exists.
 *
 * @param lockWord The lock word whose lock index is being established
 * @return the lock index corresponding to the lock workd.
 */
@Inline
@Uninterruptible
public static int getLockIndex(Word lockWord) {
    int index = lockWord.and(TL_LOCK_ID_MASK).rshl(TL_LOCK_ID_SHIFT).toInt();
    if (VM.VerifyAssertions) {
        if (!(index > 0 && index < Lock.numLocks())) {
            VM.sysWriteln("Lock index out of range! Word: ", lockWord);
            VM.sysWrite(" index: ", index);
            VM.sysWrite(" locks: ", Lock.numLocks());
            VM.sysWriteln();
        }
        // index is in range
        VM._assert(index > 0 && index < Lock.numLocks());
        // fat lock bit is set
        VM._assert(lockWord.and(TL_STAT_MASK).EQ(TL_STAT_FAT));
    }
    return index;
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) Uninterruptible(org.vmmagic.pragma.Uninterruptible) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 22 with Uninterruptible

use of org.vmmagic.pragma.Uninterruptible in project JikesRVM by JikesRVM.

the class RuntimeEntrypoints method unwindNativeStackFrame.

/**
 * Skip over all frames below currfp with saved code pointers outside of heap
 * (C frames), stopping at the native frame immediately preceding the glue
 * frame which contains the method ID of the native method (this is necessary
 * to allow retrieving the return address of the glue frame).
 *
 * @param currfp The current frame is expected to be one of the JNI functions
 *            called from C, below which is one or more native stack frames
 * @return the frame pointer for the appropriate frame
 */
@Uninterruptible
public static Address unwindNativeStackFrame(Address currfp) {
    if (VM.BuildForIA32) {
        return currfp;
    }
    // Remembered address of previous FP
    Address callee_fp;
    // Address of native frame
    Address fp = Magic.getCallerFramePointer(currfp);
    // Instruction pointer for current native frame
    Address ip;
    // in one of our heaps
    do {
        callee_fp = fp;
        ip = Magic.getReturnAddressUnchecked(fp);
        fp = Magic.getCallerFramePointer(fp);
    } while (!MemoryManager.addressInVM(ip) && fp.NE(StackFrameLayout.getStackFrameSentinelFP()));
    if (VM.BuildForPowerPC) {
        // pointed to by callee_fp which is where the saved ip was actually stored.
        return fp;
    } else {
        return callee_fp;
    }
}
Also used : Address(org.vmmagic.unboxed.Address) Uninterruptible(org.vmmagic.pragma.Uninterruptible)

Example 23 with Uninterruptible

use of org.vmmagic.pragma.Uninterruptible 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 24 with Uninterruptible

use of org.vmmagic.pragma.Uninterruptible in project JikesRVM by JikesRVM.

the class Registers method adjustESP.

@Uninterruptible
@Override
public void adjustESP(Offset delta, boolean traceAdjustments) {
    Word old = getGPRs().get(FRAME_POINTER.value());
    getGPRs().set(FRAME_POINTER.value(), old.plus(delta));
    if (traceAdjustments) {
        VM.sysWrite(" esp =");
        VM.sysWrite(getGPRs().get(FRAME_POINTER.value()));
    }
}
Also used : Word(org.vmmagic.unboxed.Word) Uninterruptible(org.vmmagic.pragma.Uninterruptible)

Example 25 with Uninterruptible

use of org.vmmagic.pragma.Uninterruptible in project JikesRVM by JikesRVM.

the class Registers method initializeStack.

/**
 * The following method initializes a thread stack as if
 * "startoff" method had been called by an empty baseline-compiled
 *  "sentinel" frame with one local variable
 *
 * @param ip The instruction pointer for the "startoff" method
 * @param sp The base of the stack
 */
@Override
@Uninterruptible
public void initializeStack(Address ip, Address sp) {
    Address fp;
    // align stack frame
    int INITIAL_FRAME_SIZE = STACKFRAME_HEADER_SIZE;
    fp = Memory.alignDown(sp.minus(INITIAL_FRAME_SIZE), STACKFRAME_ALIGNMENT);
    fp.plus(STACKFRAME_FRAME_POINTER_OFFSET).store(STACKFRAME_SENTINEL_FP);
    // need to fix
    fp.plus(STACKFRAME_RETURN_ADDRESS_OFFSET).store(ip);
    fp.plus(STACKFRAME_METHOD_ID_OFFSET).store(INVISIBLE_METHOD_ID);
    getGPRs().set(FRAME_POINTER.value(), fp.toWord());
    this.ip = ip;
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint) Uninterruptible(org.vmmagic.pragma.Uninterruptible)

Aggregations

Uninterruptible (org.vmmagic.pragma.Uninterruptible)29 Address (org.vmmagic.unboxed.Address)14 Word (org.vmmagic.unboxed.Word)8 Entrypoint (org.vmmagic.pragma.Entrypoint)7 Inline (org.vmmagic.pragma.Inline)6 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)5 NoInline (org.vmmagic.pragma.NoInline)4 Offset (org.vmmagic.unboxed.Offset)4 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)3 ContextListener (org.jikesrvm.adaptive.measurements.listeners.ContextListener)2 MethodListener (org.jikesrvm.adaptive.measurements.listeners.MethodListener)2 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)2 BaselineCompiledMethod (org.jikesrvm.compilers.baseline.BaselineCompiledMethod)2 ObjectReference (org.vmmagic.unboxed.ObjectReference)2 NullListener (org.jikesrvm.adaptive.measurements.listeners.NullListener)1 RVMMethod (org.jikesrvm.classloader.RVMMethod)1 RVMType (org.jikesrvm.classloader.RVMType)1 JNICompiledMethod (org.jikesrvm.jni.JNICompiledMethod)1 TIB (org.jikesrvm.objectmodel.TIB)1 NoNullCheck (org.vmmagic.pragma.NoNullCheck)1