Search in sources :

Example 46 with Address

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

the class OptSaveVolatile method resolve.

/**
 * Wrapper to save/restore volatile registers when a class needs to be
 * dynamically loaded/resolved/etc.
 */
@Entrypoint
@Interruptible
public static void resolve() throws NoClassDefFoundError {
    VM.disableGC();
    // (1) Get the compiled method & compilerInfo for the (opt)
    // compiled method that called resolve
    Address fp = Magic.getCallerFramePointer(Magic.getFramePointer());
    int cmid = Magic.getCompiledMethodID(fp);
    OptCompiledMethod cm = (OptCompiledMethod) CompiledMethods.getCompiledMethod(cmid);
    // (2) Get the return address
    Address ip = Magic.getReturnAddressUnchecked(Magic.getFramePointer());
    Offset offset = cm.getInstructionOffset(ip);
    VM.enableGC();
    // (3) Call the routine in OptLinker that does all the real work.
    OptLinker.resolveDynamicLink(cm, offset);
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint) Offset(org.vmmagic.unboxed.Offset) Interruptible(org.vmmagic.pragma.Interruptible) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 47 with Address

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

the class OptSaveVolatile method yieldpointFromEpilogue.

/**
 * Handle timer interrupt taken in method epilogue.
 * This method is identical to the yieldpointFromEpilogue()
 * method used by the baseline compiler, except in the OPT compiler world,
 * we also save the volatile registers.
 */
@Entrypoint
public static void yieldpointFromEpilogue() {
    Address fp = Magic.getFramePointer();
    RVMThread.yieldpoint(RVMThread.EPILOGUE, fp);
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 48 with Address

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

the class OptSaveVolatile method yieldpointFromPrologue.

/**
 * Handle timer interrupt taken in method prologue.
 * This method is identical to the yieldpointFromPrologue()
 * method used by the baseline compiler, except in the OPT compiler world,
 * we also save the volatile registers.
 */
@Entrypoint
public static void yieldpointFromPrologue() {
    Address fp = Magic.getFramePointer();
    RVMThread.yieldpoint(RVMThread.PROLOGUE, fp);
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 49 with Address

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

the class OptExceptionDeliverer method deliverException.

/**
 * Pass control to a catch block.
 */
@Override
@Unpreemptible("Deliver exception possibly from unpreemptible code")
public void deliverException(CompiledMethod compiledMethod, Address catchBlockInstructionAddress, Throwable exceptionObject, AbstractRegisters registers) {
    OptCompiledMethod optMethod = (OptCompiledMethod) compiledMethod;
    Address fp = registers.getInnermostFramePointer();
    RVMThread myThread = RVMThread.getCurrentThread();
    if (TRACE) {
        VM.sysWrite("Frame size of ");
        VM.sysWrite(optMethod.getMethod());
        VM.sysWrite(" is ");
        VM.sysWrite(optMethod.getFrameFixedSize());
        VM.sysWriteln();
    }
    // reset sp to "empty params" state (ie same as it was after prologue)
    Address sp = fp.minus(optMethod.getFrameFixedSize());
    registers.getGPRs().set(STACK_POINTER.value(), sp.toWord());
    // store exception object for later retrieval by catch block
    int offset = optMethod.getUnsignedExceptionOffset();
    if (offset != 0) {
        // only put the exception object in the stackframe if the catch block is expecting it.
        // (if the method hasn't allocated a stack slot for caught exceptions, then we can safely
        // drop the exceptionObject on the floor).
        Magic.setObjectAtOffset(Magic.addressAsObject(fp), Offset.fromIntSignExtend(-offset), exceptionObject);
        if (TRACE) {
            VM.sysWrite("Storing exception object ");
            VM.sysWrite(Magic.objectAsAddress(exceptionObject));
            VM.sysWrite(" at offset ");
            VM.sysWrite(offset);
            VM.sysWrite(" from framepoint ");
            VM.sysWrite(fp);
            VM.sysWriteln();
        }
    }
    if (TRACE) {
        VM.sysWrite("Registers before delivering exception in ");
        VM.sysWrite(optMethod.getMethod());
        VM.sysWriteln();
        for (GPR reg : GPR.values()) {
            VM.sysWrite(reg.toString());
            VM.sysWrite(" = ");
            VM.sysWrite(registers.getGPRs().get(reg.value()));
            VM.sysWriteln();
        }
    }
    // set address at which to resume executing frame
    registers.setIP(catchBlockInstructionAddress);
    if (TRACE) {
        VM.sysWrite("Set ip to ");
        VM.sysWrite(registers.getIP());
        VM.sysWriteln();
    }
    // disabled right before RuntimeEntrypoints.deliverException was called
    VM.enableGC();
    if (VM.VerifyAssertions)
        VM._assert(registers.getInUse());
    registers.setInUse(false);
    // 'give back' the portion of the stack we borrowed to run
    // exception delivery code when invoked for a hardware trap.
    // If this was a straight software trap (athrow) then setting
    // the stacklimit should be harmless, since the stacklimit should already have exactly
    // the value we are setting it too.
    myThread.stackLimit = Magic.objectAsAddress(myThread.getStack()).plus(STACK_SIZE_GUARD);
    // "branches" to catchBlockInstructionAddress
    Magic.restoreHardwareExceptionState(registers);
    if (VM.VerifyAssertions)
        VM._assert(NOT_REACHED);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) Address(org.vmmagic.unboxed.Address) RVMThread(org.jikesrvm.scheduler.RVMThread) GPR(org.jikesrvm.ia32.RegisterConstants.GPR) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

Example 50 with Address

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

the class OptExceptionDeliverer method unwindStackFrame.

/**
 * Unwind a stackframe.
 */
@Override
@Unpreemptible("Unwind stack possibly from unpreemptible code")
public void unwindStackFrame(CompiledMethod compiledMethod, AbstractRegisters registers) {
    Address fp = registers.getInnermostFramePointer();
    OptCompiledMethod optMethod = (OptCompiledMethod) compiledMethod;
    if (TRACE) {
        VM.sysWrite("Registers before unwinding frame for ");
        VM.sysWrite(optMethod.getMethod());
        VM.sysWriteln();
        for (GPR reg : GPR.values()) {
            VM.sysWrite(reg.toString());
            VM.sysWrite(" = ");
            VM.sysWrite(registers.getGPRs().get(reg.value()));
            VM.sysWriteln();
        }
    }
    // restore non-volatile registers
    int frameOffset = optMethod.getUnsignedNonVolatileOffset();
    for (int i = optMethod.getFirstNonVolatileGPR(); i < NUM_NONVOLATILE_GPRS; i++, frameOffset += BYTES_IN_ADDRESS) {
        registers.getGPRs().set(NONVOLATILE_GPRS[i].value(), fp.minus(frameOffset).loadWord());
    }
    if (VM.VerifyAssertions)
        VM._assert(NUM_NONVOLATILE_FPRS == 0);
    registers.unwindStackFrame();
    if (TRACE) {
        VM.sysWrite("Registers after unwinding frame for ");
        VM.sysWrite(optMethod.getMethod());
        VM.sysWriteln();
        for (GPR reg : GPR.values()) {
            VM.sysWrite(reg.toString());
            VM.sysWrite(" = ");
            VM.sysWrite(registers.getGPRs().get(reg.value()));
            VM.sysWriteln();
        }
    }
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) Address(org.vmmagic.unboxed.Address) GPR(org.jikesrvm.ia32.RegisterConstants.GPR) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

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