public final class RVMThread extends ThreadContext
Threads use a state machine to indicate to other threads, as well as VM services, how this thread should be treated in the case of an asynchronous request, for example in the case of GC. The state machine uses the following states:
CollectorThread
,
FinalizerThread
,
Organizer
Modifier and Type | Class and Description |
---|---|
(package private) static class |
RVMThread.AllButGCHardHandshakeVisitor |
static class |
RVMThread.BlockAdapter
A block adapter specifies the reason for blocking or unblocking a thread.
|
static class |
RVMThread.GCBlockAdapter |
static class |
RVMThread.HandshakeBlockAdapter |
static class |
RVMThread.HardHandshakeVisitor |
static class |
RVMThread.SoftHandshakeVisitor
Provides a skeleton implementation for use in soft handshakes.
|
static class |
RVMThread.SuspendBlockAdapter |
static class |
RVMThread.ThreadStackTraceBlockAdapter |
protected static class |
RVMThread.Waiting
An enumeration that describes the different manners in which a thread might
be voluntarily waiting.
|
Modifier and Type | Field and Description |
---|---|
private static int[] |
aboutToTerminate
Thread slots of threads that are about to terminate.
|
private static int |
aboutToTerminateN
Number of threads that are about to terminate.
|
static NoYieldpointsMonitor |
acctLock
Lock (mutex) used for creating and destroying threads as well as thread
accounting.
|
boolean |
activeMutatorContext
Is this a "registered mutator?"
|
static RVMThread.AllButGCHardHandshakeVisitor |
allButGC |
static boolean |
ALWAYS_LOCK_ON_STATE_TRANSITION |
(package private) int |
arrayIndexTrapParam
"hidden parameter" from ArrayIndexOutOfBounds trap to C trap handler
|
boolean |
asyncDebugRequestedForThisThread |
(package private) Throwable |
asyncThrowable
Exception to throw in this thread at the earliest possible point.
|
(package private) boolean |
atYieldpoint
Are we at a yieldpoint right now?
|
static int |
availableProcessors
The number of processors to use.
|
(package private) SpinLock |
awaitingSpinLock
Used to handle contention for spin locks
|
static int |
BACKEDGE |
int |
barriersEntered |
int |
barriersExited |
(package private) static RVMThread.BlockAdapter[] |
blockAdapters |
static int |
BLOCKED_IN_JNI
like BLOCKED_IN_NATIVE, but indicates that the thread is in JNI rather than
VM native code.
|
static int |
BLOCKED_IN_NATIVE
thread is in native code, and is to block before returning to Java code.
|
static RVMThread |
bootThread
The boot thread, can't be final so as to allow initialization during boot
image writing.
|
CodeArray |
bridgeInstructions
Before call new instructions, we need a bridge to recover register states
from the stack frame.
|
Lock |
cachedFreeLock
A cached free lock.
|
boolean |
codePatchSyncRequested
flag indicating this processor needs to execute a memory synchronization
sequence Used for code patching on SMP PowerPCs.
|
private int |
collectionAttempt
Used by GC to determine collection success
|
private static Monitor[] |
communicationLockBySlot |
(package private) RVMThread |
contenderLink |
AbstractRegisters |
contextRegisters
Place to save register state when this thread is not actually running.
|
AbstractRegisters |
contextRegistersSave
Place to save register state when this thread is not actually running.
|
private AbstractRegisters |
contextRegistersSaveShadow |
private AbstractRegisters |
contextRegistersShadow |
int |
countdownCBSCall
Number of call yieldpoints between CBS samples
|
int |
countdownCBSMethod
Number of counter ticks between CBS samples
|
protected boolean |
daemon
The virtual machine terminates when the last non-daemon (user) thread
terminates.
|
static boolean |
DEBUG_STACK_TRAMPOLINE
debugging flag for return barrier trampoline
|
static NoYieldpointsMonitor |
debugLock
Lock (mutex) used for servicing debug requests.
|
static boolean |
debugRequested
Flag set by external signal to request debugger activation at next thread
switch.
|
static RVMThread[] |
debugThreads
Preallocated array for use in debug requested.
|
private int |
disableGCDepth
Counts the depth of outstanding calls to
VM.disableGC() . |
private boolean |
disallowAllocationsByThisThread
Assertion checking while manipulating raw addresses -- see
VM.disableGC() /VM.enableGC() . |
static Latch |
doProfileReport
The latch for reporting profile data.
|
static Monitor |
dumpLock
Lock used for dumping stack and such.
|
protected static boolean |
dumpStackOnBlock |
static int |
EPILOGUE |
private AbstractRegisters |
exceptionRegisters
Place to save register state during hardware(C signal trap handler) or
software (RuntimeEntrypoints.athrow) trap handling.
|
private AbstractRegisters |
exceptionRegistersShadow |
private int |
execStatus
Thread state.
|
(package private) static int[] |
execStatusTransitionHistogram |
protected static boolean |
exitInProgress
In dump stack and dying
|
Feedlet |
feedlet
The Feedlet instance for this thread to use to make addEvent calls.
|
int |
firstCBSCallSample
round robin starting point for CBS samples
|
int |
firstCBSMethodSample
round robin starting point for CBS samples
|
boolean |
flushRequested
Is there a flush request for this thread?
|
Offset |
fooFPOffset
Foo frame pointer offset
|
(package private) Address |
framePointer
FP for current frame, saved in the prologue of every method
|
private static int |
freeSlotN
Number of free thread slots.
|
private static int[] |
freeSlots
Free thread slots
|
static RVMThread.GCBlockAdapter |
gcBlockAdapter |
static RVMThread.HandshakeBlockAdapter |
handshakeBlockAdapter |
static Monitor |
handshakeLock
Lock that prevents multiple (soft or hard) handshakes from proceeding
concurrently.
|
static RVMThread[] |
handshakeThreads
Preallocated array for use in handshakes.
|
(package private) boolean |
hasInterrupt
Has the thread been interrupted?
|
(package private) int |
hiddenSignatureId
"hidden parameter" for interface invocation thru the IMT
|
private Address |
hijackedReturnAddress
Return address of stack frame hijacked by return barrier
|
private Address |
hijackedReturnCalleeFp
Callee frame pointer for stack frame hijacked by return barrier
|
private Address |
hijackedReturnCallerFp
Caller frame pointer for stack frame hijacked by return barrier
|
static int |
IN_JAVA
Thread is executing "normal" Java bytecode
|
static int |
IN_JAVA_TO_BLOCK
thread is in Java code but is expected to block. the transition from IN_JAVA
to IN_jAVA_TO_BLOCK happens as a result of an asynchronous call by the GC
or any other internal VM code that requires this thread to perform an
asynchronous activity (another example is the request to do an isync on PPC).
|
static int |
IN_JNI
Same as IN_NATIVE, except that we're executing JNI code and thus have a
JNI stack frame and JNI environment, and thus the GC can load registers
from there rather than using contextRegisters.
|
static int |
IN_NATIVE
A state used by the scheduler to mark that a thread is in privileged code
that does not need to synchronize with the collector.
|
protected int |
inDumpStack
Number of times dump stack has been called recursively
|
private boolean |
isAboutToTerminate
Is the thread about to terminate?
|
(package private) boolean |
isBlockedForGC
Is the thread blocked for thread-to-thread communication?
|
(package private) boolean |
isBlockedForHandshake
Is the thread blocked for handshake?
|
(package private) boolean |
isBlockedForStackTrace
Is the thread blocked because another thread wants to get a stack trace for it?
|
(package private) boolean |
isBlocking
Is this thread in the process of blocking?
|
(package private) boolean |
isJoinable
Is the thread no longer executing user code?
|
(package private) boolean |
isSuspended
Is the thread suspended?
|
boolean |
isWaitingForOsr
The flag indicates whether this thread is waiting for on stack replacement
before being rescheduled.
|
private long |
jniEnteredBlocked |
private JNIEnvironment |
jniEnv
Cached JNI environment for this thread
|
private JNIEnvironment |
jniEnvShadow |
static int |
LAST_EXEC_STATUS
Not actually a state but just a marker.
|
int |
lockingId |
static int |
LOG_MAX_THREADS
Maximum number of RVMThread's that we can support.
|
static int |
MAX_THREADS |
private static NoYieldpointsMonitor[] |
monitorBySlot
Per-thread monitors.
|
private String |
name
Name of the thread (can be changed during execution)
|
static int |
NATIVE_EPILOGUE |
static int |
NATIVE_PROLOGUE |
private long |
nativeEnteredBlocked |
private static boolean |
neverKillThreads
Never kill threads.
|
static int |
NEW
Thread has not yet started.
|
(package private) RVMThread |
next
Link pointer for queues (specifically ThreadQueue).
|
static int |
nextSlot
When there are no thread slots on the free list, this is the next one to
use.
|
(package private) static int |
notifyAllOperations
Number of notifyAll operations
|
(package private) static int |
notifyOperations
Number of notify operations
|
private static int |
numActiveDaemons
Number of active daemon threads.
|
private static int |
numActiveSystemThreads
Number of active system threads.
|
private static int |
numActiveThreads
Number of active threads in the system.
|
int |
numCBSCallSamples
Number of CBS samples to take in this window
|
int |
numCBSMethodSamples
Number of CBS samples to take in this window
|
static int |
numThreads
Number of threads in the system (some of which may not be active).
|
Object |
onStackReplacementEvent
Only used by OSR when VM.BuildForAdaptiveSystem.
|
boolean |
osr_done
Flag to indicate that the last OSR request is done.
|
static int |
OSROPT |
private static OutOfMemoryError |
outOfMemoryError
The OOME to throw
|
private static NoYieldpointsMonitor |
outputLock
Lock used for generating debug output.
|
private boolean |
parkingPermit
Is a running thread permitted to ignore the next park request
|
private boolean |
physicalAllocationFailed
Used by GC to determine collection success
|
static int |
PRIMORDIAL_THREAD_INDEX
Index of thread in which "VM.boot()" runs
|
private int |
priority
Scheduling priority for this thread.
|
Word |
priority_handle
Thread priority handle.
|
static int |
PROLOGUE |
Word |
pthread_id
Thread handle.
|
(package private) ThreadQueue |
queuedOn
The queue that the thread is on, or null if the thread is not on a queue
(specifically ThreadQueue).
|
private static String[] |
READABLE_EXEC_STATUS |
boolean |
requesting_osr
Flag to synchronize with osr organizer, the trigger sets osr requests the
organizer clear the requests
|
private double |
scratchStorage
Scratch area for use for gpr <=> fpr transfers by PPC baseline compiler.
|
(package private) boolean |
shouldBlockForGC
Should the thread block for a thread-to-thread communication?
|
(package private) boolean |
shouldBlockForHandshake
Should the thread block for handshake?
|
(package private) boolean |
shouldBlockForStackTrace
Should the thread block so that another thread can get a stack trace for it?
|
(package private) int |
shouldBlockForStackTraceToken
An integer token identifying the last stack trace request
|
(package private) boolean |
shouldSuspend
Should the thread suspend?
|
(package private) int |
shouldSuspendToken
An integer token identifying the last suspend request
|
private static boolean |
SHOW_FP_IN_STACK_DUMP
Toggle display of frame pointer address in stack dump
|
(package private) static int[] |
sloppyExecStatusHistogram |
static Monitor |
softHandshakeDataLock
Lock that protects soft handshake fields.
|
static int |
softHandshakeLeft
How many threads have not yet reached the soft handshake?
|
boolean |
softHandshakeRequested
Is a soft handshake requested?
|
private byte[] |
stack
Execution stack for this thread.
|
Address |
stackLimit
|
static RVMThread.ThreadStackTraceBlockAdapter |
stackTraceBlockAdapter |
static CodeArray |
stackTrampolineBridgeInstructions
pointer to bridge code for return barrier trampoline
|
private static boolean |
STATS
Generate statistics?
|
(package private) static int[] |
statusAtSTWHistogram |
static RVMThread.SuspendBlockAdapter |
suspendBlockAdapter |
private static boolean |
systemShuttingDown
Is the system in the process of shutting down (has System.exit been called)
|
private SystemThread |
systemThread
Non-null indicates this is a system thread, that is one used by the system and as such
doesn't have a Runnable...
|
int |
takeYieldpoint
Should the next executed yieldpoint be taken?
|
static int |
TERMINATED
Thread has died.
|
private Thread |
thread
java.lang.Thread wrapper for this Thread.
|
int |
thread_cbs_counter
For builds using counter-based sampling.
|
static RVMThread[] |
threadBySlot
thread array - all threads are stored in this array according to their
threadSlot.
|
private int |
threadIdx
Current index of this thread in the threads array.
|
static boolean |
threadingInitialized
Is the threading system initialized?
|
static RVMThread[] |
threads
Packed and unordered array or active threads.
|
int |
threadSlot
Index of this thread in
threadBySlot []. |
(package private) static long |
timedWaitOperations
Number of timed wait operations
|
static long |
timerTicks
Number of timer ticks we've seen
|
int |
timeSliceExpired
How many times has the "timeslice" expired?
|
(package private) static long |
totalResumeTime |
(package private) static long |
totalSuspendTime |
(package private) static long |
totalWaitTime
total number of milliseconds this thread has waited
|
protected static boolean |
trace
Trace execution
|
protected static boolean |
traceAboutToTerminate |
protected static boolean |
traceAcct
Trace thread start/stop
|
private static boolean |
traceAdjustments
Trace adjustments to stack size
|
protected static boolean |
traceBind |
protected static boolean |
traceBlock
Trace thread blockage
|
protected static boolean |
traceDetails
Extra debug from traces
|
private static boolean |
tracePriority
Trace thread priority
|
protected static boolean |
traceReallyBlock
Trace when a thread is really blocked
|
private static boolean |
traceTermination
Trace thread termination
|
private AbstractRegisters |
trampolineRegisters
Registers used by return barrier trampoline
|
Offset |
tsFPOffset
Thread switch frame pointer offset
|
private int |
uncaughtExceptionCount
Count of recursive uncaught exceptions, we need to bail out at some point
|
protected int |
waitCount
Lock recursion count for this thread's monitor.
|
protected RVMThread.Waiting |
waiting
Accounting of whether or not a thread is waiting (in the Java thread state
sense), and if so, how it's waiting.
|
protected Object |
waitObject
Place to save/restore this thread's monitor state during
Object.wait(long) and Object.notify() . |
(package private) static long |
waitOperations
Number of wait operations
|
(package private) static long |
waitTimeStart
start time of the last wait
|
private static boolean |
worldStopped |
boolean |
yieldForCBSCall
Is CBS enabled for 'call' yieldpoints?
|
boolean |
yieldForCBSMethod
Is CBS enabled for 'method' yieldpoints?
|
(package private) boolean |
yieldpointRequestPending
Is a takeYieldpoint request pending on this thread?
|
private int |
yieldpointsEnabledCount
Should this thread yield at yieldpoints?
|
private long |
yieldpointsTaken |
private long |
yieldpointsTakenFully |
boolean |
yieldToOSRRequested
Is the next taken yieldpoint in response to a request to perform OSR?
|
collectorContext
arrayRemset, nursery, remset
Constructor and Description |
---|
RVMThread(byte[] stack,
Thread thread,
String name,
boolean daemon,
SystemThread systemThread,
int priority)
Create a new RVM Thread
|
RVMThread(SystemThread systemThread,
byte[] stack,
String name)
Create a thread with the given stack and name.
|
RVMThread(SystemThread systemThread,
String name)
Creates a thread with default stack and with the given name.
|
RVMThread(Thread thread,
long stacksize,
String name,
boolean daemon,
int priority)
Create a thread with ... called by java.lang.VMThread.create.
|
Modifier and Type | Method and Description |
---|---|
private static void |
_trace(String who,
String what,
int howmany,
boolean hex) |
private void |
acknowledgeBlockRequests()
Check if the thread has block requests (for example, for suspension and GC).
|
private void |
addAboutToTerminate()
Add this thread to the termination watchlist.
|
private static void |
adjustRegisters(AbstractRegisters registers,
Offset delta)
A thread's stack has been moved or resized.
|
private static void |
adjustStack(byte[] stack,
Address fp,
Offset delta)
A thread's stack has been moved or resized.
|
void |
assertAcceptableStates(int expected) |
void |
assertAcceptableStates(int expected1,
int expected2) |
void |
assertUnacceptableStates(int unexpected) |
void |
assertUnacceptableStates(int unexpected1,
int unexpected2) |
(package private) void |
assignThreadSlot()
Find a thread slot not in use by any other live thread and bind the given
thread to it.
|
int |
asyncBlock(RVMThread.BlockAdapter ba) |
private boolean |
attemptFastExecStatusTransition(int oldState,
int newState) |
static boolean |
attemptLeaveNativeNoBlock()
Attempt to transition from IN_JNI or IN_NATIVE to IN_JAVA, fail if execStatus is
anything but IN_JNI or IN_NATIVE.
|
void |
beginPairHandshake() |
void |
beginPairWith(RVMThread other) |
void |
beginPairWithCurrent() |
(package private) static void |
bind(int cpuId) |
(package private) static void |
bindIfRequested() |
int |
block(RVMThread.BlockAdapter ba) |
(package private) int |
block(RVMThread.BlockAdapter ba,
boolean asynchronous)
Attempts to block the thread, and return the state it is in after the
attempt.
|
static void |
blockAllMutatorsForGC()
Stop all mutator threads.
|
boolean |
blockedFor(RVMThread.BlockAdapter ba) |
static void |
boot()
Boot the threading subsystem.
|
private void |
callSystemExit(int exitStatus)
Calls
System.exit(int) with the correct security status. |
(package private) void |
checkBlock()
Check if the thread is supposed to block, and if so, block it.
|
private void |
checkBlockNoSaveContext()
A variant of checkBlock() that does not save the thread state.
|
static void |
checkDebugRequest() |
void |
clearDisallowAllocationsByThisThread()
Allow allocations by this thread
|
void |
clearInterrupted()
Clear the interrupted status of this thread
|
void |
clearPhysicalAllocationFailed()
Clear the physical allocation failed flag.
|
Monitor |
communicationLock() |
Monitor |
communicationLockForSlot(int slot) |
private static Offset |
copyStack(byte[] newStack)
Initialize a new stack with the live portion of the stack we're currently
running on.
|
int |
countStackFrames()
Counts the stack frames of this thread.
|
void |
deInstallStackTrampoline()
de-install the stack trampoline (disabling return barriers).
|
void |
disableYieldpoints()
Disable yieldpoints on this thread.
|
void |
dump()
Dump this thread's identifying information, for debugging, via
VM.sysWrite(String) . |
int |
dump(char[] dest)
Dump this thread's info, for debugging.
|
int |
dump(char[] dest,
int offset)
Dump this thread's info, for debugging.
|
void |
dump(int verbosity)
Dump this thread's identifying information, for debugging, via
VM.sysWrite(String) . |
(package private) static void |
dump1DHisto(String name,
int[] histo) |
static void |
dumpAcct() |
static void |
dumpAll(int verbosity)
Dump information for all threads, via
VM.sysWrite(String) . |
private static void |
dumpFrame(Address fp)
Dump the specified frame in a format useful for debugging the stack
trampoline
|
static void |
dumpStack()
Dump stack of calling thread, starting at callers frame
|
static void |
dumpStack(Address fp)
Dump state of a (stopped) thread's stack.
|
static void |
dumpStack(Address ip,
Address fp)
Dump state of a (stopped) thread's stack.
|
static void |
dumpStackAndDie(Address fp)
Dump state of a (stopped) thread's stack and exit the virtual machine.
|
(package private) static void |
dumpStats()
Dump statistics gather on operations
|
private static void |
dumpThread(RVMThread t) |
private static void |
dumpThreadArray(RVMThread[] array,
int bound) |
private static void |
dumpThreadArray(String name,
RVMThread[] array,
int bound) |
private static void |
dumpThreadSlotArray(int[] array,
int bound) |
private static void |
dumpThreadSlotArray(String name,
int[] array,
int bound) |
static void |
dumpVirtualMachine()
Dump state of virtual machine.
|
void |
dumpWithPadding(int leftJustify)
Dump this thread's identifying information, for debugging, via
VM.sysWrite(String) . |
void |
enableYieldpoints()
Enable yieldpoints on this thread.
|
void |
endPairHandshake() |
void |
endPairWith(RVMThread other) |
void |
endPairWithCurrent() |
private void |
enterJNIBlocked() |
static void |
enterJNIBlockedFromCallIntoNative() |
static void |
enterJNIBlockedFromJNIFunctionCall() |
static void |
enterJNIFromCallIntoNative() |
static void |
enterJNIFromJNIFunctionCall() |
static void |
enterNative()
Indicate that we'd like the current thread to be executing privileged code that
does not require synchronization with the GC.
|
private void |
enterNativeBlocked() |
private void |
enterNativeBlockedImpl(boolean jni)
Internal method for transitioning a thread from IN_JAVA or IN_JAVA_TO_BLOCK to
either BLOCKED_IN_NATIVE or BLOCKED_IN_JNI, depending on the value of the jni
parameter.
|
void |
extDump() |
void |
failIfYieldpointsDisabled()
Fail if yieldpoints are disabled on this thread
|
(package private) void |
finishThreadTermination()
Uninterruptible final portion of thread termination.
|
void |
fixupMovedStack(Offset delta)
This (suspended) thread's stack has been moved.
|
static boolean |
gcEnabled() |
int |
getCollectionAttempt() |
CollectorThread |
getCollectorThread() |
AbstractRegisters |
getContextRegisters() |
static Feedlet |
getCurrentFeedlet() |
static RVMThread |
getCurrentThread() |
static int |
getCurrentThreadSlot() |
int |
getDisableGCDepth() |
boolean |
getDisallowAllocationsByThisThread() |
AbstractRegisters |
getExceptionRegisters() |
int |
getExecStatus() |
static Address |
getHijackedReturnAddress(Address hijackedFp)
Given a frame that has been hijacked by the stack trampoline,
return the real (hijacked) return address.
|
Address |
getHijackedReturnCalleeFp() |
boolean |
getIsAboutToTerminate() |
Thread |
getJavaLangThread() |
JNIEnvironment |
getJNIEnv() |
static Thread[] |
getLiveThreadsForJMX()
Gets live threads.
|
int |
getLockingId()
Get this thread's id for use in lock ownership tests.
|
String |
getName()
Gets the name of the thread
|
Address |
getNextUnencounteredFrame() |
static int |
getNumActiveDaemons() |
static int |
getNumActiveSystemThreads() |
static int |
getNumActiveThreads() |
static OutOfMemoryError |
getOutOfMemoryError() |
int |
getPriority()
Get the priority of the thread
|
byte[] |
getStack() |
int |
getStackLength() |
private Address |
getStackTrampolineBridgeIP() |
Thread.State |
getState()
Get the state of the thread in a manner compatible with the Java API
|
int |
getThreadSlot() |
(package private) long |
getTotalWaitedTime() |
(package private) long |
getTotalWaitingCount() |
Address |
getTrampolineHijackedReturnAddress() |
private void |
handleDebugRequestForThread() |
(package private) void |
handleHandshakeRequest()
Handle requests that required a soft handshake.
|
private void |
handlePossibleRecursiveException()
Handle the case of exception handling triggering new exceptions.
|
void |
handleUncaughtException(Throwable exceptionObject)
Handles uncaught exceptions for subclasses of
SystemThread . |
static void |
hardHandshakeResume() |
static void |
hardHandshakeResume(RVMThread.BlockAdapter ba,
RVMThread.HardHandshakeVisitor hhv) |
static void |
hardHandshakeSuspend() |
static void |
hardHandshakeSuspend(RVMThread.BlockAdapter ba,
RVMThread.HardHandshakeVisitor hhv) |
boolean |
hasNativeStackFrame()
Indicate whether the stack of this Thread contains any C frame (used in
RuntimeEntrypoints.deliverHardwareException for stack resize)
|
boolean |
holdsLock(Object obj)
Does the currently running Thread hold the lock on an obj?
|
boolean |
ignoreHandshakesAndGC() |
static void |
init()
Initialize the threading subsystem for the boot image.
|
void |
initializeJNIEnv()
Initialize JNI environment for system threads.
|
void |
installStackTrampolineBridge(Address targetFp)
Install the stack trampoline bridge at a given frame, hijacking
that frame, saving the hijacked return address and callee fp
in thread-local state to allow execution of the hijacked frame
later.
|
void |
interrupt()
Interrupt this thread
|
private static boolean |
isAddressValidFramePointer(Address address)
Return true if the supplied address could be a valid frame pointer.
|
boolean |
isAlive() |
boolean |
isBlocked()
Checks if the thread system has acknowledged that the thread is supposed
to be blocked.
|
boolean |
isBootThread() |
boolean |
isDaemonThread() |
boolean |
isInJava()
Checks if the thread is executing Java code.
|
(package private) boolean |
isInNativeAccordingToJMX()
Checks whether the thread is in native code as understood by the JMX ThreadInfo.
|
boolean |
isInterrupted()
Was this thread interrupted?
|
private boolean |
isMainThread() |
boolean |
isOnQueue() |
boolean |
isSystemThread() |
static boolean |
isTrampolineIP(Address ip)
Determine whether a given method is the stack trampoline
|
void |
join(long ms,
int ns)
Wait for the thread to die or for the timeout to occur
|
private void |
leaveJNIBlocked() |
static void |
leaveJNIBlockedFromCallIntoNative()
Called when JNI code tried to transition from IN_JNI to IN_JAVA but failed
|
(package private) static void |
leaveJNIBlockedFromJNIFunctionCall() |
static void |
leaveJNIFromCallIntoNative() |
static void |
leaveJNIFromJNIFunctionCall() |
static void |
leaveNative()
Leave privileged code.
|
private void |
leaveNativeBlocked() |
private void |
leaveNativeBlockedImpl() |
void |
makeDaemon(boolean on)
Set the "isDaemon" status of this thread.
|
NoYieldpointsMonitor |
monitor() |
(package private) static NoYieldpointsMonitor |
monitorForSlot(int slot) |
static void |
notify(Object o)
Support for Java
Object.notify() synchronization
primitive. |
static void |
notifyAll(Object o)
Support for Java synchronization primitive.
|
static boolean |
notRunning(int state) |
(package private) void |
observeExecStatus() |
static void |
observeExecStatusAtSTW(int execStatus) |
(package private) static void |
observeStateTransition(int oldState,
int newState) |
void |
park(boolean isAbsolute,
long time) |
boolean |
physicalAllocationFailed() |
static void |
processAboutToTerminate()
Method called after processing a list of threads, or before starting a new
thread.
|
static void |
raiseIllegalMonitorStateException(String msg,
Object o) |
(package private) void |
releaseThreadSlot()
Release a thread's slot in the threads array.
|
void |
reportCollectionAttempt()
Set the initial attempt.
|
static void |
reportThreadTransitionCounts() |
void |
resetCollectionAttempts()
Resets the attempts.
|
static void |
resizeCurrentStack(int newSize,
AbstractRegisters exceptionRegisters)
Change the size of the currently executing thread's stack.
|
void |
resume()
Resume execution of a thread that has been suspended.
|
static void |
returnBarrier()
The return barrier.
|
void |
run()
Method to be executed when this thread starts running.
|
int |
safeAsyncBlock(RVMThread.BlockAdapter ba) |
int |
safeBlock(RVMThread.BlockAdapter ba) |
private int |
safeBlock(RVMThread.BlockAdapter ba,
boolean asynchronous) |
static boolean |
safeToForceGCs() |
static void |
saveThreadState()
Save the current thread state.
|
private int |
setBlockedExecStatus() |
void |
setDisableGCDepth(int d) |
void |
setDisallowAllocationsByThisThread()
Disallow allocations by this thread
|
private void |
setExecStatus(int newState) |
void |
setName(String name)
Sets the name of the thread
|
void |
setPhysicalAllocationFailed()
Set the physical allocation failed flag.
|
void |
setPriority(int priority)
Set the priority of the thread
|
void |
setupBootJavaThread()
Called during booting to give the boot thread a java.lang.Thread
|
static RVMThread |
setupBootThread()
Set up the initial thread and processors as part of boot image writing
|
boolean |
shouldBeSampled()
Should the thread by eligible for sampling by the timer thread?
|
private static void |
showMethod(int compiledMethodId,
Address fp)
Show a method where getCompiledMethod returns null
|
private static void |
showMethod(RVMMethod method,
int lineNumber,
Address fp,
int bci,
Offset mcOffset)
Helper function for
dumpStack(Address,Address) . |
private static void |
showMethod(String name,
Address fp)
Shows a method that we can't show (ie just a text description of the stack
frame
|
private static void |
showPrologue(Address fp) |
static void |
sleep(long ns)
Suspend execution of current thread for specified number of seconds (or
fraction).
|
static void |
sleep(long millis,
int ns)
Suspend execution of current thread for specified number of seconds (or
fraction).
|
static int |
snapshotHandshakeThreads(RVMThread.SoftHandshakeVisitor v) |
static void |
softHandshake(RVMThread.SoftHandshakeVisitor v)
Tell each thread to take a yieldpoint and wait until all of them have done
so at least once.
|
void |
softRendezvous()
Rendezvous with a soft handshake request.
|
boolean |
softRendezvousCheckAndClear()
Checks and clears the need for a soft handshake rendezvous.
|
void |
softRendezvousCommit()
Commits the soft handshake rendezvous.
|
void |
start()
Start execution of 'this' by creating and starting a native thread.
|
private static void |
startoff()
Begin execution of current thread by calling its "run" method.
|
void |
stop(Throwable cause) |
void |
suspend()
Suspend execution of current thread until it is resumed.
|
void |
terminate()
Terminate execution of current thread by abandoning all references to it
and resuming execution in some other (ready) thread.
|
private void |
terminateUnpreemptible()
Unpreemptible portion of thread termination.
|
private static void |
throwFromUninterruptible(Throwable e) |
(package private) void |
timerTick() |
String |
toString()
String representation of thread
|
static void |
trace(String who,
String what)
Prints out message in format
"[j] (td) who: what" , where:
j = java thread id
t = numActiveThreads
d = numActiveDaemon
The parenthetical values are printed only if traceDetails is true. |
static void |
trace(String who,
String what,
Address addr) |
static void |
trace(String who,
String what,
int howmany)
Prints out message in format
"[j] (td) who: what howmany" , where:
j = java thread id
t = numActiveThreads
d = numActiveDaemon
The parenthetical values are printed only if traceDetails is true. |
static void |
traceback(String message)
Print interesting scheduler information, starting with a stack traceback.
|
static void |
traceback(String message,
int number) |
(package private) static void |
tracebackWithoutLock() |
static void |
traceHex(String who,
String what,
int howmany) |
private static void |
transferExecutionToNewStack(byte[] newStack,
AbstractRegisters exceptionRegisters) |
(package private) static int |
transitionHistogramIndex(int oldState,
int newState) |
void |
unblock(RVMThread.BlockAdapter ba) |
static void |
unblockAllMutatorsForGC()
Unblock all mutators blocked for GC.
|
void |
unpark() |
static void |
wait(Object o)
Support for Java
Object.wait() synchronization primitive. |
static void |
wait(Object o,
long millis)
Support for Java
Object.wait() synchronization primitive. |
static void |
waitAbsoluteNanos(Object o,
long whenNanos)
Support for RTSJ- and pthread-style absolute wait.
|
(package private) void |
waitImpl(Object o,
boolean hasTimeout,
long whenWakeupNanos) |
static boolean |
worldStopped() |
static void |
yieldNoHandshake() |
static void |
yieldpoint(int whereFrom,
Address yieldpointServiceMethodFP)
Process a taken yieldpoint.
|
static void |
yieldpointFromBackedge()
Yieldpoint taken on backedge.
|
static void |
yieldpointFromEpilogue()
Yieldpoint taken in epilogue.
|
static void |
yieldpointFromPrologue()
Yieldpoint taken in prologue.
|
boolean |
yieldpointsEnabled() |
static void |
yieldWithHandshake() |
getCollectorContext, isCollectorThread
get, getThread
alloc, collectionPhase, getAllocatorFromSpace, postAlloc
assertRemsetsFlushed, flushRememberedSets, objectReferenceBulkCopy, objectReferenceNonHeapWrite, objectReferenceTryCompareAndSwap, objectReferenceWrite
addressBulkCopy, addressRead, addressTryCompareAndSwap, addressWrite, booleanBulkCopy, booleanRead, booleanWrite, byteBulkCopy, byteRead, byteWrite, charBulkCopy, charRead, charWrite, checkAllocator, deinitMutator, doubleBulkCopy, doubleRead, doubleWrite, extentBulkCopy, extentRead, extentWrite, floatBulkCopy, floatRead, floatWrite, flush, getId, getLog, initMutator, intBulkCopy, intRead, intTryCompareAndSwap, intWrite, javaLangReferenceReadBarrier, longBulkCopy, longRead, longTryCompareAndSwap, longWrite, objectReferenceNonHeapRead, objectReferenceRead, offsetBulkCopy, offsetRead, offsetWrite, shortBulkCopy, shortRead, shortWrite, wordBulkCopy, wordRead, wordTryCompareAndSwap, wordWrite
protected static final boolean traceBlock
protected static final boolean traceReallyBlock
protected static final boolean traceAboutToTerminate
protected static final boolean dumpStackOnBlock
protected static final boolean traceBind
protected static final boolean traceAcct
protected static final boolean trace
private static final boolean traceTermination
private static final boolean traceAdjustments
private static final boolean tracePriority
private static final boolean neverKillThreads
private static final boolean STATS
static long waitOperations
static long timedWaitOperations
static long totalWaitTime
static long waitTimeStart
static int notifyOperations
static int notifyAllOperations
public static final boolean ALWAYS_LOCK_ON_STATE_TRANSITION
public static final int NEW
public static final int IN_JAVA
public static final int IN_NATIVE
public static final int IN_JNI
public static final int IN_JAVA_TO_BLOCK
public static final int BLOCKED_IN_NATIVE
the point of this state is that the thread is guaranteed not to execute any Java code until:
public static final int BLOCKED_IN_JNI
public static final int TERMINATED
public static final int LAST_EXEC_STATUS
private static final String[] READABLE_EXEC_STATUS
private final AbstractRegisters trampolineRegisters
private Address hijackedReturnAddress
private Address hijackedReturnCalleeFp
private Address hijackedReturnCallerFp
public static final boolean DEBUG_STACK_TRAMPOLINE
public static CodeArray stackTrampolineBridgeInstructions
private int execStatus
private boolean isAboutToTerminate
boolean isBlocking
boolean isJoinable
RVMThread next
queuedOn
.volatile ThreadQueue queuedOn
next
field is used as a link pointer.SpinLock awaitingSpinLock
RVMThread contenderLink
private Thread thread
protected boolean daemon
private int priority
Thread.MIN_PRIORITY
<= priority <=
Thread.MAX_PRIORITY
.public int threadSlot
threadBySlot
[]. This value must be non-zero
because it is shifted and used in Object
lock ownership tests.public int lockingId
private final SystemThread systemThread
public static RVMThread bootThread
public static boolean threadingInitialized
public static long timerTicks
private long yieldpointsTaken
private long yieldpointsTakenFully
private long nativeEnteredBlocked
private long jniEnteredBlocked
private boolean disallowAllocationsByThisThread
VM.disableGC()
/VM.enableGC()
. A value of "true" means
it's an error for this thread to call "new". This is only used for
assertion checking; we do not bother to set it when
Configuration.VerifyAssertions
is false.private int disableGCDepth
VM.disableGC()
. If this
is set, then we should also have disallowAllocationsByThisThread
set. The converse also holds.public int barriersEntered
public int barriersExited
private byte[] stack
public Address stackLimit
Address framePointer
int hiddenSignatureId
int arrayIndexTrapParam
public boolean yieldToOSRRequested
public boolean yieldForCBSCall
public boolean yieldForCBSMethod
public int numCBSCallSamples
public int countdownCBSCall
public int firstCBSCallSample
public int numCBSMethodSamples
public int countdownCBSMethod
public int firstCBSMethodSample
public boolean codePatchSyncRequested
public int thread_cbs_counter
private int yieldpointsEnabledCount
boolean yieldpointRequestPending
boolean atYieldpoint
public boolean flushRequested
public boolean softHandshakeRequested
public static int softHandshakeLeft
public static Monitor softHandshakeDataLock
public static Monitor handshakeLock
public final AbstractRegisters contextRegisters
private final AbstractRegisters contextRegistersShadow
public final AbstractRegisters contextRegistersSave
private final AbstractRegisters contextRegistersSaveShadow
private final AbstractRegisters exceptionRegisters
private final AbstractRegisters exceptionRegistersShadow
private int uncaughtExceptionCount
public Lock cachedFreeLock
protected Object waitObject
Object.wait(long)
and Object.notify()
.protected int waitCount
boolean shouldSuspend
int shouldSuspendToken
boolean isSuspended
boolean shouldBlockForHandshake
boolean isBlockedForHandshake
boolean shouldBlockForGC
boolean isBlockedForGC
int shouldBlockForStackTraceToken
boolean shouldBlockForStackTrace
boolean isBlockedForStackTrace
public static final RVMThread.SuspendBlockAdapter suspendBlockAdapter
public static final RVMThread.ThreadStackTraceBlockAdapter stackTraceBlockAdapter
public static final RVMThread.HandshakeBlockAdapter handshakeBlockAdapter
public static final RVMThread.GCBlockAdapter gcBlockAdapter
static final RVMThread.BlockAdapter[] blockAdapters
protected RVMThread.Waiting waiting
Invariant: the RVM runtime does not ever use this field for any purpose other than updating it so that the java.lang.Thread knows the state. Thus, if you get sloppy with this field, the worst case outcome is that some Java program that queries the thread state will get something other than what it may or may not have expected.
Throwable asyncThrowable
boolean hasInterrupt
public int takeYieldpoint
To support efficient sampling of only prologue/epilogues we also encode some extra information into this field. 0 means that the yieldpoint should not be taken. >0 means that the next yieldpoint of any type should be taken <0 means that the next prologue/epilogue yieldpoint should be taken
Note the following rules:
public int timeSliceExpired
private boolean parkingPermit
private JNIEnvironment jniEnv
private JNIEnvironment jniEnvShadow
private boolean physicalAllocationFailed
private int collectionAttempt
private static OutOfMemoryError outOfMemoryError
public static final int PROLOGUE
public static final int BACKEDGE
public static final int EPILOGUE
public static final int NATIVE_PROLOGUE
public static final int NATIVE_EPILOGUE
public static final int OSROPT
public final Object onStackReplacementEvent
public boolean isWaitingForOsr
public CodeArray bridgeInstructions
public Offset fooFPOffset
public Offset tsFPOffset
public boolean requesting_osr
public boolean osr_done
public static int availableProcessors
public Word pthread_id
public Word priority_handle
private double scratchStorage
private int threadIdx
private static boolean systemShuttingDown
public static volatile boolean debugRequested
public volatile boolean asyncDebugRequestedForThisThread
public static Latch doProfileReport
protected int inDumpStack
public boolean activeMutatorContext
protected static boolean exitInProgress
private static boolean worldStopped
protected static final boolean traceDetails
private static final boolean SHOW_FP_IN_STACK_DUMP
public static final int PRIMORDIAL_THREAD_INDEX
public static final int LOG_MAX_THREADS
public static final int MAX_THREADS
public static RVMThread[] threadBySlot
private static final NoYieldpointsMonitor[] monitorBySlot
Question: what is the outcome, if any, of taking a yieldpoint while holding this lock?
private static final Monitor[] communicationLockBySlot
public static NoYieldpointsMonitor acctLock
public static NoYieldpointsMonitor debugLock
private static NoYieldpointsMonitor outputLock
private static final int[] aboutToTerminate
private static int aboutToTerminateN
private static final int[] freeSlots
private static int freeSlotN
public static int nextSlot
public static int numThreads
public static final RVMThread[] threads
Note further that threads remain in this array even after the Java libraries no longer consider the thread to be active.
public static final RVMThread[] handshakeThreads
public static final RVMThread[] debugThreads
private static int numActiveThreads
private static int numActiveSystemThreads
private static int numActiveDaemons
public static final RVMThread.AllButGCHardHandshakeVisitor allButGC
static long totalSuspendTime
static long totalResumeTime
static final int[] sloppyExecStatusHistogram
static final int[] statusAtSTWHistogram
static final int[] execStatusTransitionHistogram
public RVMThread(byte[] stack, Thread thread, String name, boolean daemon, SystemThread systemThread, int priority)
stack
- The stack on which to execute the thread.thread
- The corresponding java.lang.Thread.name
- The name of the threaddaemon
- True if this is a daemon thread.systemThread
- True if this is a system thread.priority
- The threads execution priority.public RVMThread(SystemThread systemThread, String name)
Thread
object.systemThread
- the associated system threadname
- human-readable namepublic RVMThread(SystemThread systemThread, byte[] stack, String name)
CollectorThread
and the
boot image writer for the boot thread.systemThread
- the associated system threadstack
- the thread's stackname
- human-readable name of the threadpublic RVMThread(Thread thread, long stacksize, String name, boolean daemon, int priority)
thread
- the associated Java threadstacksize
- stack size in bytesname
- human-readable namedaemon
- whether the thread is a daemonpriority
- the priority for the threadpublic static boolean notRunning(int state)
public Address getHijackedReturnCalleeFp()
public int getExecStatus()
private boolean attemptFastExecStatusTransition(int oldState, int newState)
private void setExecStatus(int newState)
public boolean getIsAboutToTerminate()
public boolean isOnQueue()
static NoYieldpointsMonitor monitorForSlot(int slot)
slot
- the thread's slotpublic NoYieldpointsMonitor monitor()
public Monitor communicationLockForSlot(int slot)
public Monitor communicationLock()
public static void init()
public void assertAcceptableStates(int expected)
public void assertAcceptableStates(int expected1, int expected2)
public void assertUnacceptableStates(int unexpected)
public void assertUnacceptableStates(int unexpected1, int unexpected2)
static void bind(int cpuId)
static void bindIfRequested()
public static void boot()
private void addAboutToTerminate()
public static void processAboutToTerminate()
void assignThreadSlot()
void releaseThreadSlot()
private void acknowledgeBlockRequests()
public boolean isBlocked()
public boolean isInJava()
execStatus
is IN_JAVA
or
IN_JAVA_TO_BLOCK
, and if it is not
aboutToTerminate
, and if it is not blocked. Only call this
method when already holding the monitor(), and probably only after calling
setBlockedExecStatus(), for two reasons:
boolean isInNativeAccordingToJMX()
Note: this method is NOT designed for internal use by the RVMThread class and
must not be used for scheduling. For comparison see a method used for
internal scheduling decisions such as isInJava()
.
public boolean shouldBeSampled()
Heuristically, we use timer-based sampling the in the adaptive system to determine where the program is spending time (and thus what to optimize). This doesn't have to be a 100% accurate, but it must be non-blocking and also closely approximate whether or not the thread is executing. For now, approximate just as being in JAVA.
As a future item, we may want to actually correctly attribute time spent in native code to the top native method on the frame when the timer goes off. This will require work in the JNI enter/exit sequence to deal with timer samples appropriately.
private void checkBlockNoSaveContext()
void checkBlock()
execStatus
) is set to IN_JAVA
once all blocking requests are cleared, and that other threads are notified
that this thread is in the middle of blocking by setting the appropriate
flag (isBlocking
). Note that this thread acquires the
monitor(), though it may release it completely either by calling wait() or
by calling unlockCompletely(). Thus, although it isn't generally a problem
to call this method while holding the monitor() lock, you should only do so
if the loss of atomicity is acceptable.
Generally, this method should be called from the following four places:
private void enterNativeBlockedImpl(boolean jni)
This method takes care of all bookkeeping and notifications required when a a thread that has been requested to block instead decides to run native code. Threads enter native code never need to block, since they will not be executing any Java code. However, such threads must ensure that any system services (like GC) that are waiting for this thread to stop are notified that the thread has instead chosen to exit Java. As well, any requests to perform a soft handshake must be serviced and acknowledged.
jni
- whether this method is called for entering JNI or notprivate void leaveNativeBlockedImpl()
private void enterNativeBlocked()
private void leaveNativeBlocked()
private void enterJNIBlocked()
private void leaveJNIBlocked()
public static void enterJNIBlockedFromJNIFunctionCall()
public static void enterJNIBlockedFromCallIntoNative()
static void leaveJNIBlockedFromJNIFunctionCall()
public static void leaveJNIBlockedFromCallIntoNative()
private int setBlockedExecStatus()
int block(RVMThread.BlockAdapter ba, boolean asynchronous)
Note that this method is ridiculously dangerous, especially if you pass asynchronous==false. Waiting for another thread to stop is not in itself interruptible - so if you ask another thread to block and they ask you to block, you might deadlock.
ba
- the adapter to block onasynchronous
- true
if the request is asynchronous (i.e. the
receiver is only notified), false
if the caller waits for the
receiver to blockpublic boolean blockedFor(RVMThread.BlockAdapter ba)
public int asyncBlock(RVMThread.BlockAdapter ba)
public int block(RVMThread.BlockAdapter ba)
public void beginPairWith(RVMThread other)
public void endPairWith(RVMThread other)
public void beginPairWithCurrent()
public void endPairWithCurrent()
private int safeBlock(RVMThread.BlockAdapter ba, boolean asynchronous)
public int safeAsyncBlock(RVMThread.BlockAdapter ba)
public int safeBlock(RVMThread.BlockAdapter ba)
public void beginPairHandshake()
public void endPairHandshake()
public static void saveThreadState()
public static void enterNative()
public static boolean attemptLeaveNativeNoBlock()
public static void leaveNative()
public static void enterJNIFromCallIntoNative()
public static void leaveJNIFromCallIntoNative()
public static void enterJNIFromJNIFunctionCall()
public static void leaveJNIFromJNIFunctionCall()
public void unblock(RVMThread.BlockAdapter ba)
private void handleDebugRequestForThread()
public static void checkDebugRequest()
void timerTick()
public boolean yieldpointsEnabled()
public void enableYieldpoints()
public void disableYieldpoints()
public void failIfYieldpointsDisabled()
public static RVMThread getCurrentThread()
public static int getCurrentThreadSlot()
public int getThreadSlot()
public void setupBootJavaThread()
public Thread getJavaLangThread()
public JNIEnvironment getJNIEnv()
public int getDisableGCDepth()
public void setDisableGCDepth(int d)
public boolean getDisallowAllocationsByThisThread()
public void setDisallowAllocationsByThisThread()
public void clearDisallowAllocationsByThisThread()
public void initializeJNIEnv()
public boolean hasNativeStackFrame()
false
during the prolog of the first Java to C transition,
true
afterwardpublic void run()
This method will catch all uncaught throwables from the thread and pass them to the thread's uncaught exception handler.
private static void startoff()
public void start()
public void terminate()
private void callSystemExit(int exitStatus)
System.exit(int)
with the correct security status.exitStatus
- the exit status to pass onprivate void terminateUnpreemptible()
void finishThreadTermination()
public static void yieldpointFromPrologue()
public static void yieldpointFromBackedge()
public static void returnBarrier()
The following code implements return barriers as described for Lisp by Yuasa http://www.yuasa.kuis.kyoto-u.ac.jp/~yuasa/ilc2002/index.html http://dx.doi.org/10.1109/ISORC.2005.45 and for Jikes RVM by Kumar et al http://dx.doi.org/10.1145/2398857.2384639
This code is executed when a method returns into a frame that has been hijacked by the return barrier mechanism. The return barrier trampoline will save state, execute this method, and then upon return from this method will transparently return into the frame that had been hijacked.
In this default implementation, the barrier reinstalls itself in the caller's frame thus incrementally moving the barrier down the stack.
The execution of this method is fragile. It is generally safest to call some other method from here that does the substantive work of the barrier.
public void installStackTrampolineBridge(Address targetFp)
targetFp
- The frame to be hijacked.public void deInstallStackTrampoline()
private Address getStackTrampolineBridgeIP()
public Address getTrampolineHijackedReturnAddress()
public static boolean isTrampolineIP(Address ip)
ip
- the code to be checkedtrue
if the code is the stack trampoline.public static Address getHijackedReturnAddress(Address hijackedFp)
hijackedFp
- a frame that has been hijacked by the stack trampolineprivate static void dumpFrame(Address fp)
fp
- The frame to be dumped.public Address getNextUnencounteredFrame()
public static void yieldpointFromEpilogue()
public void suspend()
public void resume()
public static void yieldNoHandshake()
public static void yieldWithHandshake()
public static void sleep(long ns) throws InterruptedException
ns
- the number of nanoseconds to sleep forInterruptedException
- when the sleep is interruptedpublic static void sleep(long millis, int ns) throws InterruptedException
ns
- the number of nanoseconds to sleep formillis
- the number of milliseconds to sleep forInterruptedException
- when the sleep is interruptedpublic static void wait(Object o)
Object.wait()
synchronization primitive.o
- the object synchronized onpublic static void wait(Object o, long millis)
Object.wait()
synchronization primitive.o
- the object synchronized onmillis
- the number of milliseconds to wait for notificationlong getTotalWaitingCount()
long getTotalWaitedTime()
public static void waitAbsoluteNanos(Object o, long whenNanos)
o
- the object synchronized onwhenNanos
- the absolute time in nanoseconds when we should wake uppublic static void raiseIllegalMonitorStateException(String msg, Object o)
public static void notify(Object o)
Object.notify()
synchronization
primitive.o
- the object synchronized onpublic static void notifyAll(Object o)
o
- the object synchronized onObject.notifyAll()
public void unpark()
public int getLockingId()
getThreadSlot()
, shifted appropriately
so it can be directly used in the ownership tests.public static int snapshotHandshakeThreads(RVMThread.SoftHandshakeVisitor v)
public static void softHandshake(RVMThread.SoftHandshakeVisitor v)
visit()
method is called with both the
thread's monitor held, and the softHandshakeDataLock
held.
Currently we only use this mechanism for code patch isync requests on PPC, but this mechanism is powerful enough to be used by sliding-views style concurrent GC.
v
- the visitor to use for the handshakepublic boolean softRendezvousCheckAndClear()
public void softRendezvousCommit()
public void softRendezvous()
void handleHandshakeRequest()
This is almost always called with the monitor() lock held, but that's not guaranteed. If you need that lock, you can grab it (since it's a recursive lock). But you should avoid grabbing other sorts of locks since that might cause deadlock.
public static void blockAllMutatorsForGC()
public static void unblockAllMutatorsForGC()
public static void hardHandshakeSuspend(RVMThread.BlockAdapter ba, RVMThread.HardHandshakeVisitor hhv)
public static void hardHandshakeResume(RVMThread.BlockAdapter ba, RVMThread.HardHandshakeVisitor hhv)
public static void hardHandshakeSuspend()
public static void hardHandshakeResume()
public static boolean worldStopped()
public static void yieldpoint(int whereFrom, Address yieldpointServiceMethodFP)
whereFrom
- source of the yieldpoint (e.g. backedge)yieldpointServiceMethodFP
- the frame pointer of the service
method that called this methodprivate static void throwFromUninterruptible(Throwable e)
public static void resizeCurrentStack(int newSize, AbstractRegisters exceptionRegisters)
newSize
- new size (in bytes)exceptionRegisters
- register state at which stack overflow trap was encountered (null
--> normal method call, not a trap)private static void transferExecutionToNewStack(byte[] newStack, AbstractRegisters exceptionRegisters)
public void fixupMovedStack(Offset delta)
delta
- displacement to be applied to all interior referencesprivate static void adjustRegisters(AbstractRegisters registers, Offset delta)
registers
- registers to be adjusteddelta
- displacement to be appliedprivate static void adjustStack(byte[] stack, Address fp, Offset delta)
stack
- stack to be adjustedfp
- pointer to its innermost framedelta
- displacement to be applied to all its interior referencesprivate static Offset copyStack(byte[] newStack)
lo-mem hi-mem |<---myDepth----| +----------+---------------+ | empty | live | +----------+---------------+ ˆmyStack ˆmyFP ˆmyTop +-------------------+---------------+ | empty | live | +-------------------+---------------+ ˆnewStack ˆnewFP ˆnewTop
newStack
- space for the new stackpublic void makeDaemon(boolean on)
Note: This method might need to be uninterruptible so it is final, which is why it isn't called setDaemon.
Public so that java.lang.Thread can use it.
on
- new status for daemon flagpublic static void dumpAll(int verbosity)
VM.sysWrite(String)
. Each
thread's info is newline-terminated.verbosity
- Ignored.public boolean isBootThread()
private boolean isMainThread()
public boolean isSystemThread()
public CollectorThread getCollectorThread()
public boolean isDaemonThread()
daemon
.public boolean ignoreHandshakesAndGC()
public boolean isAlive()
public void setName(String name)
name
- the new name for the threadThread.setName(String)
public String getName()
Thread.getName()
public boolean holdsLock(Object obj)
obj
- the object to checkThread.holdsLock(Object)
public boolean isInterrupted()
Thread.isInterrupted()
public void clearInterrupted()
Thread.interrupted()
public void interrupt()
Thread.interrupt()
public int getPriority()
Thread.getPriority()
public void setPriority(int priority)
priority
- the thread's priorityThread.getPriority()
public Thread.State getState()
Thread.getState()
public void join(long ms, int ns) throws InterruptedException
ms
- milliseconds to waitns
- nanoseconds to waitInterruptedException
- when the thread is interruptedpublic static Thread[] getLiveThreadsForJMX()
Note: this is an expensive operation operation because we're grabbing the accounting lock and thus prevent the threading system from changing the set of active threads.
public int countStackFrames()
public int getStackLength()
public byte[] getStack()
public AbstractRegisters getExceptionRegisters()
public AbstractRegisters getContextRegisters()
public void reportCollectionAttempt()
public int getCollectionAttempt()
public void resetCollectionAttempts()
public boolean physicalAllocationFailed()
public void setPhysicalAllocationFailed()
public void clearPhysicalAllocationFailed()
public static OutOfMemoryError getOutOfMemoryError()
public static int getNumActiveThreads()
public static int getNumActiveSystemThreads()
public static int getNumActiveDaemons()
public void handleUncaughtException(Throwable exceptionObject)
SystemThread
.
Uncaught exceptions for normal threads will end up in that thread's run()
method which will invoke the thread's uncaught exception handler.exceptionObject
- the exception object that wasn't caughtrun() method of application threads
,
run() method of system threads
private void handlePossibleRecursiveException()
private static void dumpThread(RVMThread t)
private static void dumpThreadArray(RVMThread[] array, int bound)
private static void dumpThreadSlotArray(int[] array, int bound)
private static void dumpThreadArray(String name, RVMThread[] array, int bound)
private static void dumpThreadSlotArray(String name, int[] array, int bound)
public static void dumpAcct()
public void extDump()
public void dump()
VM.sysWrite(String)
. We do not use any spacing or newline
characters. Callers are responsible for space-separating or
newline-terminating output.public void dumpWithPadding(int leftJustify)
VM.sysWrite(String)
. We pad to a minimum of leftJustify
characters. We do not use any spacing characters. Callers are responsible
for space-separating or newline-terminating output.leftJustify
- minimum number of characters emitted, with any extra characters
being spaces.public void dump(int verbosity)
VM.sysWrite(String)
. We do not use any spacing or newline
characters. Callers are responsible for space-separating or
newline-terminating output.
This function avoids write barriers and allocation.verbosity
- Ignored.public int dump(char[] dest, int offset)
IndexOutOfBoundsException
.dest
- char array to copy the source info into.offset
- Offset into dest
where we start copyingoffset
. This is intended to represent the first
unused position in the array dest
. However, it also
serves as a pseudo-overflow check: It may have the value
dest.length
, if the array dest
was
completely filled by the call, or it may have a value greater than
dest.length
, if the info needs more than
dest.length - offset
characters of space.
-1 if offset
is negative.public int dump(char[] dest)
This is identical to calling dump(char[],int)
with an
offset
of zero.
dest
- array to dump the info intodump(char[], int)
static void dumpStats()
public static void trace(String who, String what)
"[j] (td) who: what"
, where:
j = java thread id
t = numActiveThreads
d = numActiveDaemon
traceDetails
is true.
We serialize against a mutex to avoid intermingling debug output from multiple threads.
who
- the string for the who parameterwhat
- the string for the what parameterpublic static void trace(String who, String what, int howmany)
"[j] (td) who: what howmany"
, where:
j = java thread id
t = numActiveThreads
d = numActiveDaemon
traceDetails
is true.
We serialize against a mutex to avoid intermingling debug output from multiple threads.
who
- the string for the who parameterwhat
- the string for the what parameterhowmany
- the count for the howmany parameterpublic static void traceback(String message)
Note: the system could be in a fragile state when this method is called, so we try to rely on as little runtime functionality as possible (eg. use no bytecodes that require RuntimeEntrypoints support).
message
- the message to write before the actual tracebackstatic void tracebackWithoutLock()
public static void dumpStack()
public static void dumpStack(Address fp)
fp
- address of starting frame. first frame output is the calling
frame of passed framepublic static void dumpStack(Address ip, Address fp)
ip
- instruction pointer for first frame to dumpfp
- frame pointer for first frame to dumpprivate static boolean isAddressValidFramePointer(Address address)
or it is StackFrameLayout.getStackFrameSentinelFP()
.
STACKFRAME_SENTINEL_FP
is possible when the thread has been created
but has yet to be scheduled.
address
- the address.private static void showPrologue(Address fp)
private static void showMethod(int compiledMethodId, Address fp)
compiledMethodId
- the id of the compiled methodfp
- the frame pointer of the method's frameprivate static void showMethod(String name, Address fp)
name
- the method's namefp
- the frame pointer of the method's frameprivate static void showMethod(RVMMethod method, int lineNumber, Address fp, int bci, Offset mcOffset)
dumpStack(Address,Address)
. Print a stack
frame showing the method.method
- the underlying methodlineNumber
- the line number for the stack tracefp
- the frame pointer of the method's framebci
- byte code index (value < 0 if unknown)mcOffset
- machine code offset for the instruction (Offset.max()
if unknown)public static void dumpStackAndDie(Address fp)
fp
- address of starting frame Returned: doesn't return. This method is
called from sysSignal*.c when something goes horrifically wrong
with exception handling and we want to die with useful
diagnostics.public static boolean safeToForceGCs()
public static boolean gcEnabled()
public static RVMThread setupBootThread()
public static void dumpVirtualMachine()
public static Feedlet getCurrentFeedlet()
public static void reportThreadTransitionCounts()
static void dump1DHisto(String name, int[] histo)
void observeExecStatus()
public static void observeExecStatusAtSTW(int execStatus)
static int transitionHistogramIndex(int oldState, int newState)
static void observeStateTransition(int oldState, int newState)