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();
}
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();
}
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);
}
}
}
}
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);
}
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);
}
Aggregations