Search in sources :

Example 81 with Offset

use of org.vmmagic.unboxed.Offset 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 82 with Offset

use of org.vmmagic.unboxed.Offset 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)

Example 83 with Offset

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

the class AscendingOffsetComparator method compare.

@Override
public int compare(RVMField firstField, RVMField secondField) {
    Offset firstOff = firstField.getOffset();
    Offset secondOff = secondField.getOffset();
    if (firstOff.sGT(secondOff))
        return 1;
    if (firstOff.sLT(secondOff))
        return -1;
    return 0;
}
Also used : Offset(org.vmmagic.unboxed.Offset)

Example 84 with Offset

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

the class GenArch_ia32 method emitArchVirtualMachineDeclarations.

@Override
public void emitArchVirtualMachineDeclarations() {
    Offset offset;
    offset = ArchEntrypoints.registersFPField.getOffset();
    pln("Registers_fp_offset", offset);
    pln("Constants_EAX", EAX.value());
    pln("Constants_ECX", ECX.value());
    pln("Constants_EDX", EDX.value());
    pln("Constants_EBX", EBX.value());
    pln("Constants_ESP", ESP.value());
    pln("Constants_EBP", EBP.value());
    pln("Constants_ESI", ESI.value());
    pln("Constants_EDI", EDI.value());
    if (VM.BuildFor64Addr) {
        pln("Constants_R8", R8.value());
        pln("Constants_R9", R9.value());
        pln("Constants_R10", R10.value());
        pln("Constants_R11", R11.value());
        pln("Constants_R12", R12.value());
        pln("Constants_R13", R13.value());
        pln("Constants_R14", R14.value());
        pln("Constants_R15", R15.value());
    }
    pln("Constants_STACKFRAME_BODY_OFFSET", STACKFRAME_BODY_OFFSET);
    pln("Constants_STACKFRAME_RETURN_ADDRESS_OFFSET", STACKFRAME_RETURN_ADDRESS_OFFSET);
    pln("Constants_RVM_TRAP_BASE", RVM_TRAP_BASE);
    pln("Constants_RED_ZONE_SIZE", RED_ZONE_SIZE);
    if (VM.BuildForOptCompiler) {
        pln("Constants_MAX_DIFFERENCE_TO_STACK_LIMIT", StackManager.MAX_DIFFERENCE_TO_STACK_LIMIT);
    } else {
        // The baseline compiler always checks for stack overflow before
        // creating the frame, so it's not necessary to allow any overflow
        // into the guard region of the stack.
        pln("Constants_MAX_DIFFERENCE_TO_STACK_LIMIT", 0);
    }
    offset = ArchEntrypoints.framePointerField.getOffset();
    pln("Thread_framePointer_offset", offset);
    offset = ArchEntrypoints.arrayIndexTrapParamField.getOffset();
    pln("Thread_arrayIndexTrapParam_offset", offset);
    pln("ArchConstants_SSE2", (SSE2_BASE ? 1 : 0));
}
Also used : Offset(org.vmmagic.unboxed.Offset)

Example 85 with Offset

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

the class GenerateInterfaceDeclarations method emitVirtualMachineDeclarations.

// Emit virtual machine class interface information.
// 
static void emitVirtualMachineDeclarations(long bootImageDataAddress, long bootImageCodeAddress, long bootImageRMapAddress) {
    // load address for the boot image
    // 
    pln("bootImageDataAddress", Address.fromLong(bootImageDataAddress));
    pln("bootImageCodeAddress", Address.fromLong(bootImageCodeAddress));
    pln("bootImageRMapAddress", Address.fromLong(bootImageRMapAddress));
    // values in Constants, from Configuration
    // 
    pln("Constants_STACK_SIZE_GUARD", StackFrameLayout.getStackSizeGuard());
    pln("Constants_INVISIBLE_METHOD_ID", StackFrameLayout.getInvisibleMethodID());
    pln("Constants_STACKFRAME_HEADER_SIZE", StackFrameLayout.getStackFrameHeaderSize());
    pln("Constants_STACKFRAME_METHOD_ID_OFFSET", StackFrameLayout.getStackFrameMethodIDOffset());
    pln("Constants_STACKFRAME_FRAME_POINTER_OFFSET", StackFrameLayout.getStackFramePointerOffset());
    pln("Constants_STACKFRAME_SENTINEL_FP", StackFrameLayout.getStackFrameSentinelFP());
    pln("ThinLockConstants_TL_THREAD_ID_SHIFT", TL_THREAD_ID_SHIFT);
    // values in RuntimeEntrypoints
    // 
    pln("Runtime_TRAP_UNKNOWN", RuntimeEntrypoints.TRAP_UNKNOWN);
    pln("Runtime_TRAP_NULL_POINTER", RuntimeEntrypoints.TRAP_NULL_POINTER);
    pln("Runtime_TRAP_ARRAY_BOUNDS", RuntimeEntrypoints.TRAP_ARRAY_BOUNDS);
    pln("Runtime_TRAP_DIVIDE_BY_ZERO", RuntimeEntrypoints.TRAP_DIVIDE_BY_ZERO);
    pln("Runtime_TRAP_STACK_OVERFLOW", RuntimeEntrypoints.TRAP_STACK_OVERFLOW);
    pln("Runtime_TRAP_CHECKCAST", RuntimeEntrypoints.TRAP_CHECKCAST);
    pln("Runtime_TRAP_REGENERATE", RuntimeEntrypoints.TRAP_REGENERATE);
    pln("Runtime_TRAP_JNI_STACK", RuntimeEntrypoints.TRAP_JNI_STACK);
    pln("Runtime_TRAP_MUST_IMPLEMENT", RuntimeEntrypoints.TRAP_MUST_IMPLEMENT);
    pln("Runtime_TRAP_STORE_CHECK", RuntimeEntrypoints.TRAP_STORE_CHECK);
    pln("Runtime_TRAP_UNREACHABLE_BYTECODE", RuntimeEntrypoints.TRAP_UNREACHABLE_BYTECODE);
    pln();
    // fields in RVMThread
    // 
    Offset offset = Entrypoints.threadStackField.getOffset();
    pln("RVMThread_stack_offset", offset);
    offset = Entrypoints.stackLimitField.getOffset();
    pln("RVMThread_stackLimit_offset", offset);
    offset = Entrypoints.threadExceptionRegistersField.getOffset();
    pln("RVMThread_exceptionRegisters_offset", offset);
    offset = Entrypoints.jniEnvField.getOffset();
    pln("RVMThread_jniEnv_offset", offset);
    offset = Entrypoints.execStatusField.getOffset();
    pln("RVMThread_execStatus_offset", offset);
    // constants in RVMThread
    pln("RVMThread_TERMINATED", RVMThread.TERMINATED);
    // fields in Registers
    // 
    offset = ArchEntrypoints.registersGPRsField.getOffset();
    pln("Registers_gprs_offset", offset);
    offset = ArchEntrypoints.registersFPRsField.getOffset();
    pln("Registers_fprs_offset", offset);
    offset = ArchEntrypoints.registersIPField.getOffset();
    pln("Registers_ip_offset", offset);
    offset = ArchEntrypoints.registersInUseField.getOffset();
    pln("Registers_inuse_offset", offset);
    // fields in JNIEnvironment
    offset = Entrypoints.JNIExternalFunctionsField.getOffset();
    pln("JNIEnvironment_JNIExternalFunctions_offset", offset);
    arch.emitArchVirtualMachineDeclarations();
}
Also used : Offset(org.vmmagic.unboxed.Offset)

Aggregations

Offset (org.vmmagic.unboxed.Offset)215 Address (org.vmmagic.unboxed.Address)48 Inline (org.vmmagic.pragma.Inline)38 Entrypoint (org.vmmagic.pragma.Entrypoint)32 ObjectReference (org.vmmagic.unboxed.ObjectReference)21 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)20 TypeReference (org.jikesrvm.classloader.TypeReference)17 RVMField (org.jikesrvm.classloader.RVMField)14 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)13 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)13 NoInline (org.vmmagic.pragma.NoInline)13 RVMMethod (org.jikesrvm.classloader.RVMMethod)11 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)10 Word (org.vmmagic.unboxed.Word)10 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)9 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)9 RVMType (org.jikesrvm.classloader.RVMType)8 Register (org.jikesrvm.compilers.opt.ir.Register)8 RVMClass (org.jikesrvm.classloader.RVMClass)7 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)7