Search in sources :

Example 6 with Unpreemptible

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

use of org.vmmagic.pragma.Unpreemptible 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)

Example 8 with Unpreemptible

use of org.vmmagic.pragma.Unpreemptible 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 cm, Address catchBlockInstructionAddress, Throwable exceptionObject, AbstractRegisters registers) {
    // store exception object for later retrieval by catch block
    OptCompiledMethod compiledMethod = (OptCompiledMethod) cm;
    Offset offset = Offset.fromIntSignExtend(compiledMethod.getUnsignedExceptionOffset());
    if (!offset.isZero()) {
        // 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).
        Address fp = registers.getInnermostFramePointer();
        Magic.setObjectAtOffset(Magic.addressAsObject(fp), offset, exceptionObject);
    }
    // set address at which to resume executing frame
    registers.setIP(catchBlockInstructionAddress);
    // disabled right before Runtime.deliverException was called
    VM.enableGC();
    if (VM.VerifyAssertions)
        VM._assert(registers.getInUse());
    registers.setInUse(false);
    // "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) Offset(org.vmmagic.unboxed.Offset) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

Example 9 with Unpreemptible

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

the class RuntimeEntrypoints method athrow.

// ---------------------------------------------------------------//
// Exception Handling.                        //
// ---------------------------------------------------------------//
/**
 * Deliver a software exception to current java thread.
 * @param exceptionObject exception object to deliver
 * (null --&gt; deliver NullPointerException).
 * does not return
 * (stack is unwound and execution resumes in a catch block)
 *
 * This method is public so that it can be invoked by java.lang.VMClass.
 */
@NoInline
@Entrypoint
@Unpreemptible("Deliver exception possibly from unpreemptible code")
public static void athrow(Throwable exceptionObject) {
    if (traceAthrow) {
        VM.sysWriteln("in athrow.");
        RVMThread.dumpStack();
    }
    RVMThread myThread = RVMThread.getCurrentThread();
    AbstractRegisters exceptionRegisters = myThread.getExceptionRegisters();
    // VM.enableGC() is called when the exception is delivered.
    VM.disableGC();
    Magic.saveThreadState(exceptionRegisters);
    exceptionRegisters.setInUse(true);
    deliverException(exceptionObject, exceptionRegisters);
}
Also used : RVMThread(org.jikesrvm.scheduler.RVMThread) AbstractRegisters(org.jikesrvm.architecture.AbstractRegisters) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Entrypoint(org.vmmagic.pragma.Entrypoint) NoInline(org.vmmagic.pragma.NoInline)

Example 10 with Unpreemptible

use of org.vmmagic.pragma.Unpreemptible 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)

Aggregations

Unpreemptible (org.vmmagic.pragma.Unpreemptible)34 Entrypoint (org.vmmagic.pragma.Entrypoint)23 NoInline (org.vmmagic.pragma.NoInline)14 Address (org.vmmagic.unboxed.Address)12 RVMThread (org.jikesrvm.scheduler.RVMThread)7 Offset (org.vmmagic.unboxed.Offset)6 Word (org.vmmagic.unboxed.Word)6 NoCheckStore (org.vmmagic.pragma.NoCheckStore)5 NoNullCheck (org.vmmagic.pragma.NoNullCheck)5 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)4 Inline (org.vmmagic.pragma.Inline)4 BaselineSaveLSRegisters (org.vmmagic.pragma.BaselineSaveLSRegisters)3 NoOptCompile (org.vmmagic.pragma.NoOptCompile)3 NormalMethod (org.jikesrvm.classloader.NormalMethod)2 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)2 GPR (org.jikesrvm.ia32.RegisterConstants.GPR)2 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)1 RVMArray (org.jikesrvm.classloader.RVMArray)1 RVMMethod (org.jikesrvm.classloader.RVMMethod)1 RVMType (org.jikesrvm.classloader.RVMType)1