Search in sources :

Example 1 with RVMThread

use of org.jikesrvm.scheduler.RVMThread in project JikesRVM by JikesRVM.

the class VM method enableGC.

/**
 * enableGC(): Re-Enable GC if we're popping off the last
 * possibly-recursive {@link #disableGC} request.  This enforces a stack discipline;
 * we need it for the JNI Get*Critical and Release*Critical functions.
 * Should be matched with a preceding call to {@link #disableGC}.
 *
 * @param recursiveOK unused (!)
 */
@Inline
public static void enableGC(boolean recursiveOK) {
    RVMThread myThread = RVMThread.getCurrentThread();
    int gcDepth = myThread.getDisableGCDepth();
    if (VM.VerifyAssertions) {
        VM._assert(gcDepth >= 1);
        VM._assert(myThread.getDisallowAllocationsByThisThread());
    }
    gcDepth--;
    myThread.setDisableGCDepth(gcDepth);
    if (gcDepth > 0) {
        return;
    }
    // Now the actual work of re-enabling GC.
    myThread.clearDisallowAllocationsByThisThread();
    myThread.enableYieldpoints();
}
Also used : RVMThread(org.jikesrvm.scheduler.RVMThread) Entrypoint(org.vmmagic.pragma.Entrypoint) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 2 with RVMThread

use of org.jikesrvm.scheduler.RVMThread in project JikesRVM by JikesRVM.

the class VM method boot.

/**
 * Begin VM execution.<p>
 *
 * Uninterruptible because we are not setup to execute a yieldpoint
 * or stackoverflow check in the prologue this early in booting.<p>
 *
 * The following machine registers are set by "C" bootstrap program
 * before calling this method:
 * <ol>
 *   <li>JTOC_POINTER - required for accessing globals
 *   <li>FRAME_POINTER - required for accessing locals
 *   <li>THREAD_ID_REGISTER - required for method prolog (stack overflow check)
 * </ol>
 */
@UnpreemptibleNoWarn("No point threading until threading is booted")
@Entrypoint
public static void boot() {
    writingBootImage = false;
    runningVM = true;
    verboseBoot = BootRecord.the_boot_record.verboseBoot;
    verboseSignalHandling = BootRecord.the_boot_record.verboseSignalHandling != 0;
    sysWriteLockOffset = Entrypoints.sysWriteLockField.getOffset();
    if (verboseBoot >= 1)
        VM.sysWriteln("Booting");
    // register.
    if (verboseBoot >= 1)
        VM.sysWriteln("Setting up current RVMThread");
    if (VM.BuildForIA32) {
        org.jikesrvm.ia32.ThreadLocalState.boot();
    } else {
        if (VM.VerifyAssertions)
            VM._assert(VM.BuildForPowerPC);
        org.jikesrvm.ppc.ThreadLocalState.boot();
    }
    // 
    if (verboseBoot >= 1)
        VM.sysWriteln("Doing thread initialization");
    RVMThread currentThread = RVMThread.getCurrentThread();
    currentThread.stackLimit = Magic.objectAsAddress(currentThread.getStack()).plus(StackFrameLayout.getStackSizeGuard());
    finishBooting();
}
Also used : RVMThread(org.jikesrvm.scheduler.RVMThread) Entrypoint(org.vmmagic.pragma.Entrypoint) UnpreemptibleNoWarn(org.vmmagic.pragma.UnpreemptibleNoWarn)

Example 3 with RVMThread

use of org.jikesrvm.scheduler.RVMThread in project JikesRVM by JikesRVM.

the class OSROrganizerThread method processOsrRequest.

private void processOsrRequest() {
    // scan RVMThread.threads (scan down so we don't miss anything)
    for (int i = RVMThread.numThreads - 1; i >= 0; i--) {
        Magic.combinedLoadBarrier();
        RVMThread t = RVMThread.threads[i];
        if (t != null) {
            boolean go = false;
            t.monitor().lockNoHandshake();
            // NOTE: if threads are being removed, we may see a thread twice
            if (t.requesting_osr) {
                t.requesting_osr = false;
                go = true;
            }
            t.monitor().unlock();
            if (go) {
                Controller.controllerInputQueue.insert(5.0, t.onStackReplacementEvent);
            }
        }
    }
}
Also used : RVMThread(org.jikesrvm.scheduler.RVMThread)

Example 4 with RVMThread

use of org.jikesrvm.scheduler.RVMThread in project JikesRVM by JikesRVM.

the class BaselineExceptionDeliverer 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) {
    Address fp = registers.getInnermostFramePointer();
    RVMThread myThread = RVMThread.getCurrentThread();
    // reset sp to "empty expression stack" state
    // 
    Address sp = fp.plus(((ArchBaselineCompiledMethod) compiledMethod).getEmptyStackOffset());
    // push exception object as argument to catch block
    // 
    sp = sp.minus(BYTES_IN_ADDRESS);
    sp.store(Magic.objectAsAddress(exceptionObject));
    registers.getGPRs().set(SP.value(), sp.toWord());
    // set address at which to resume executing frame
    registers.setIP(catchBlockInstructionAddress);
    // branch to catch block
    // 
    // 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);
    Magic.restoreHardwareExceptionState(registers);
    if (VM.VerifyAssertions)
        VM._assert(NOT_REACHED);
}
Also used : Address(org.vmmagic.unboxed.Address) RVMThread(org.jikesrvm.scheduler.RVMThread) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

Example 5 with RVMThread

use of org.jikesrvm.scheduler.RVMThread 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)

Aggregations

RVMThread (org.jikesrvm.scheduler.RVMThread)22 Unpreemptible (org.vmmagic.pragma.Unpreemptible)7 Address (org.vmmagic.unboxed.Address)7 Entrypoint (org.vmmagic.pragma.Entrypoint)6 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)5 Offset (org.vmmagic.unboxed.Offset)5 NoInline (org.vmmagic.pragma.NoInline)4 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)3 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)2 Test (org.junit.Test)2 Inline (org.vmmagic.pragma.Inline)2 UnpreemptibleNoWarn (org.vmmagic.pragma.UnpreemptibleNoWarn)2 LockInfo (java.lang.management.LockInfo)1 MonitorInfo (java.lang.management.MonitorInfo)1 ThreadInfo (java.lang.management.ThreadInfo)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 RVMMethod (org.jikesrvm.classloader.RVMMethod)1 RVMType (org.jikesrvm.classloader.RVMType)1 ArchBaselineCompiledMethod (org.jikesrvm.compilers.baseline.ppc.ArchBaselineCompiledMethod)1 Assembler (org.jikesrvm.compilers.common.assembler.ia32.Assembler)1