Search in sources :

Example 76 with Address

use of org.vmmagic.unboxed.Address 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) {
    int cmid = STACKFRAME_SENTINEL_FP.toInt();
    do {
        cmid = Magic.getIntAtOffset(stack, fpOffset.plus(STACKFRAME_METHOD_ID_OFFSET));
        if (cmid == INVISIBLE_METHOD_ID) {
            VM.sysWriteln(" invisible method ");
        } else {
            CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
            VM.sysWriteln(cm.getMethod().toString());
        }
        VM.disableGC();
        Address callerfp = Magic.objectAsAddress(stack).loadAddress(fpOffset.plus(STACKFRAME_FRAME_POINTER_OFFSET));
        fpOffset = callerfp.diff(Magic.objectAsAddress(stack));
        VM.enableGC();
    } while (cmid != STACKFRAME_SENTINEL_FP.toInt());
}
Also used : Address(org.vmmagic.unboxed.Address) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Example 77 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class PostThreadSwitch method postProcess.

/* This method must be inlined to keep the correctness
   * This method is called at the end of threadSwitch, the caller
   * is threadSwitchFrom<...>
   */
@NoInline
public static void postProcess(RVMThread myThread) {
    /* We need to generate thread specific code and install new code.
    * We have to make sure that no GC happens from here and before
    * the new code get executed.
    */
    // add branch instruction from CTR.
    CodeArray bridge = myThread.bridgeInstructions;
    Address bridgeaddr = Magic.objectAsAddress(bridge);
    Offset offset = myThread.fooFPOffset.plus(STACKFRAME_RETURN_ADDRESS_OFFSET);
    Magic.objectAsAddress(myThread.getStack()).store(bridgeaddr, offset);
    myThread.fooFPOffset = Offset.zero();
    myThread.isWaitingForOsr = false;
    myThread.bridgeInstructions = null;
}
Also used : CodeArray(org.jikesrvm.compilers.common.CodeArray) Address(org.vmmagic.unboxed.Address) Offset(org.vmmagic.unboxed.Offset) NoInline(org.vmmagic.pragma.NoInline)

Example 78 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class RVMThread method transferExecutionToNewStack.

@NoInline
@BaselineNoRegisters
private static // --> non-volatiles not restored!
void transferExecutionToNewStack(byte[] newStack, AbstractRegisters exceptionRegisters) {
    // prevent opt compiler from inlining a method that contains a magic
    // (returnToNewStack) that it does not implement.
    RVMThread myThread = getCurrentThread();
    byte[] myStack = myThread.stack;
    // initialize new stack with live portion of stack we're
    // currently running on
    // 
    // lo-mem hi-mem
    // |<---myDepth----|
    // +----------+---------------+
    // | empty | live |
    // +----------+---------------+
    // ^myStack ^myFP ^myTop
    // 
    // +-------------------+---------------+
    // | empty | live |
    // +-------------------+---------------+
    // ^newStack ^newFP ^newTop
    // 
    Address myTop = Magic.objectAsAddress(myStack).plus(myStack.length);
    Address newTop = Magic.objectAsAddress(newStack).plus(newStack.length);
    Address myFP = Magic.getFramePointer();
    Offset myDepth = myTop.diff(myFP);
    Address newFP = newTop.minus(myDepth);
    // The frame pointer addresses the top of the frame on powerpc and
    // the bottom
    // on intel. if we copy the stack up to the current
    // frame pointer in here, the
    // copy will miss the header of the intel frame. Thus we make another
    // call
    // to force the copy. A more explicit way would be to up to the
    // frame pointer
    // and the header for intel.
    Offset delta = copyStack(newStack);
    // 
    if (exceptionRegisters != null) {
        adjustRegisters(exceptionRegisters, delta);
    }
    adjustStack(newStack, newFP, delta);
    // install new stack
    // 
    myThread.stack = newStack;
    myThread.stackLimit = Magic.objectAsAddress(newStack).plus(StackFrameLayout.getStackSizeGuard());
    // 
    if (VM.BuildForPowerPC) {
        Magic.returnToNewStack(Magic.getCallerFramePointer(newFP));
    } else if (VM.BuildForIA32) {
        Magic.returnToNewStack(newFP);
    }
    if (VM.VerifyAssertions)
        VM._assert(VM.NOT_REACHED);
}
Also used : Address(org.vmmagic.unboxed.Address) Offset(org.vmmagic.unboxed.Offset) BaselineNoRegisters(org.vmmagic.pragma.BaselineNoRegisters) NoInline(org.vmmagic.pragma.NoInline)

Example 79 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class RVMThread method yieldpointFromBackedge.

/**
 * Yieldpoint taken on backedge.
 */
@BaselineSaveLSRegisters
// Save all non-volatile registers in prologue
@NoOptCompile
@NoInline
// TODO fix this -- related to SaveVolatile
@Entrypoint
@Unpreemptible("Becoming another thread interrupts the current thread, avoid preemption in the process")
public static void yieldpointFromBackedge() {
    Address fp = Magic.getFramePointer();
    yieldpoint(BACKEDGE, fp);
}
Also used : Address(org.vmmagic.unboxed.Address) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Entrypoint(org.vmmagic.pragma.Entrypoint) BaselineSaveLSRegisters(org.vmmagic.pragma.BaselineSaveLSRegisters) NoInline(org.vmmagic.pragma.NoInline) NoOptCompile(org.vmmagic.pragma.NoOptCompile)

Example 80 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class RVMThread method copyStack.

/**
 * Initialize a new stack with the live portion of the stack we're currently
 * running on.
 *
 * <pre>
 *  lo-mem                                        hi-mem
 *                           |&lt;---myDepth----|
 *                 +----------+---------------+
 *                 |   empty  |     live      |
 *                 +----------+---------------+
 *                  &circ;myStack   &circ;myFP           &circ;myTop
 *       +-------------------+---------------+
 *       |       empty       |     live      |
 *       +-------------------+---------------+
 *        &circ;newStack           &circ;newFP          &circ;newTop
 * </pre>
 *
 * @param newStack space for the new stack
 * @return offset that needs to be applied to all interior references of
 *  the new stack
 */
private static Offset copyStack(byte[] newStack) {
    RVMThread myThread = getCurrentThread();
    byte[] myStack = myThread.stack;
    Address myTop = Magic.objectAsAddress(myStack).plus(myStack.length);
    Address newTop = Magic.objectAsAddress(newStack).plus(newStack.length);
    Address myFP = Magic.getFramePointer();
    Offset myDepth = myTop.diff(myFP);
    Address newFP = newTop.minus(myDepth);
    // 
    if (VM.VerifyAssertions) {
        VM._assert(newFP.GE(Magic.objectAsAddress(newStack).plus(StackFrameLayout.getStackSizeGuard())));
    }
    Memory.memcopy(newFP, myFP, myDepth.toWord().toExtent());
    return newFP.diff(myFP);
}
Also used : Address(org.vmmagic.unboxed.Address) Offset(org.vmmagic.unboxed.Offset)

Aggregations

Address (org.vmmagic.unboxed.Address)281 Offset (org.vmmagic.unboxed.Offset)48 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)30 NoInline (org.vmmagic.pragma.NoInline)30 Test (org.junit.Test)24 Entrypoint (org.vmmagic.pragma.Entrypoint)22 TypeReference (org.jikesrvm.classloader.TypeReference)21 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)17 RVMType (org.jikesrvm.classloader.RVMType)16 Inline (org.vmmagic.pragma.Inline)15 Uninterruptible (org.vmmagic.pragma.Uninterruptible)14 Word (org.vmmagic.unboxed.Word)14 BaseMMTkTest (org.mmtk.harness.tests.BaseMMTkTest)13 Unpreemptible (org.vmmagic.pragma.Unpreemptible)12 ObjectReference (org.vmmagic.unboxed.ObjectReference)12 Interruptible (org.vmmagic.pragma.Interruptible)11 Extent (org.vmmagic.unboxed.Extent)11 RVMClass (org.jikesrvm.classloader.RVMClass)9 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8