mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 01:24:33 +02:00
8265933: Move Java monitor related fields from class Thread to JavaThread
Reviewed-by: rehn, dcubed, coleenp, dholmes
This commit is contained in:
parent
1afbab6394
commit
42af7da94d
4 changed files with 46 additions and 53 deletions
|
@ -263,9 +263,6 @@ Thread::Thread() {
|
||||||
NOT_PRODUCT(_skip_gcalot = false;)
|
NOT_PRODUCT(_skip_gcalot = false;)
|
||||||
_jvmti_env_iteration_count = 0;
|
_jvmti_env_iteration_count = 0;
|
||||||
set_allocated_bytes(0);
|
set_allocated_bytes(0);
|
||||||
_current_pending_monitor = NULL;
|
|
||||||
_current_pending_monitor_is_from_java = true;
|
|
||||||
_current_waiting_monitor = NULL;
|
|
||||||
_current_pending_raw_monitor = NULL;
|
_current_pending_raw_monitor = NULL;
|
||||||
|
|
||||||
_suspend_flags = 0;
|
_suspend_flags = 0;
|
||||||
|
@ -276,10 +273,6 @@ Thread::Thread() {
|
||||||
_hashStateZ = 0x8767; // (int)(3579807591LL & 0xffff) ;
|
_hashStateZ = 0x8767; // (int)(3579807591LL & 0xffff) ;
|
||||||
_hashStateW = 273326509;
|
_hashStateW = 273326509;
|
||||||
|
|
||||||
_OnTrap = 0;
|
|
||||||
_Stalled = 0;
|
|
||||||
_TypeTag = 0x2BAD;
|
|
||||||
|
|
||||||
// Many of the following fields are effectively final - immutable
|
// Many of the following fields are effectively final - immutable
|
||||||
// Note that nascent threads can't use the Native Monitor-Mutex
|
// Note that nascent threads can't use the Native Monitor-Mutex
|
||||||
// construct until the _MutexEvent is initialized ...
|
// construct until the _MutexEvent is initialized ...
|
||||||
|
@ -1053,6 +1046,11 @@ JavaThread::JavaThread() :
|
||||||
_vm_result(nullptr),
|
_vm_result(nullptr),
|
||||||
_vm_result_2(nullptr),
|
_vm_result_2(nullptr),
|
||||||
|
|
||||||
|
_current_pending_monitor(NULL),
|
||||||
|
_current_pending_monitor_is_from_java(true),
|
||||||
|
_current_waiting_monitor(NULL),
|
||||||
|
_Stalled(0),
|
||||||
|
|
||||||
_monitor_chunks(nullptr),
|
_monitor_chunks(nullptr),
|
||||||
_special_runtime_exit_condition(_no_async_condition),
|
_special_runtime_exit_condition(_no_async_condition),
|
||||||
_pending_async_exception(nullptr),
|
_pending_async_exception(nullptr),
|
||||||
|
|
|
@ -308,16 +308,8 @@ class Thread: public ThreadShadow {
|
||||||
|
|
||||||
JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;) // Thread-local data for jfr
|
JFR_ONLY(DEFINE_THREAD_LOCAL_FIELD_JFR;) // Thread-local data for jfr
|
||||||
|
|
||||||
ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread
|
|
||||||
// is waiting to lock
|
|
||||||
bool _current_pending_monitor_is_from_java; // locking is from Java code
|
|
||||||
JvmtiRawMonitor* _current_pending_raw_monitor; // JvmtiRawMonitor this thread
|
JvmtiRawMonitor* _current_pending_raw_monitor; // JvmtiRawMonitor this thread
|
||||||
// is waiting to lock
|
// is waiting to lock
|
||||||
|
|
||||||
|
|
||||||
// ObjectMonitor on which this thread called Object.wait()
|
|
||||||
ObjectMonitor* _current_waiting_monitor;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Thread();
|
Thread();
|
||||||
|
@ -490,28 +482,6 @@ class Thread: public ThreadShadow {
|
||||||
|
|
||||||
bool is_obj_deopt_suspend() { return (_suspend_flags & _obj_deopt) != 0; }
|
bool is_obj_deopt_suspend() { return (_suspend_flags & _obj_deopt) != 0; }
|
||||||
|
|
||||||
// For tracking the heavyweight monitor the thread is pending on.
|
|
||||||
ObjectMonitor* current_pending_monitor() {
|
|
||||||
return _current_pending_monitor;
|
|
||||||
}
|
|
||||||
void set_current_pending_monitor(ObjectMonitor* monitor) {
|
|
||||||
_current_pending_monitor = monitor;
|
|
||||||
}
|
|
||||||
void set_current_pending_monitor_is_from_java(bool from_java) {
|
|
||||||
_current_pending_monitor_is_from_java = from_java;
|
|
||||||
}
|
|
||||||
bool current_pending_monitor_is_from_java() {
|
|
||||||
return _current_pending_monitor_is_from_java;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For tracking the ObjectMonitor on which this thread called Object.wait()
|
|
||||||
ObjectMonitor* current_waiting_monitor() {
|
|
||||||
return _current_waiting_monitor;
|
|
||||||
}
|
|
||||||
void set_current_waiting_monitor(ObjectMonitor* monitor) {
|
|
||||||
_current_waiting_monitor = monitor;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For tracking the Jvmti raw monitor the thread is pending on.
|
// For tracking the Jvmti raw monitor the thread is pending on.
|
||||||
JvmtiRawMonitor* current_pending_raw_monitor() {
|
JvmtiRawMonitor* current_pending_raw_monitor() {
|
||||||
return _current_pending_raw_monitor;
|
return _current_pending_raw_monitor;
|
||||||
|
@ -689,8 +659,6 @@ protected:
|
||||||
JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
|
JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
volatile intptr_t _Stalled;
|
|
||||||
volatile int _TypeTag;
|
|
||||||
ParkEvent * volatile _ParkEvent; // for Object monitors, JVMTI raw monitors,
|
ParkEvent * volatile _ParkEvent; // for Object monitors, JVMTI raw monitors,
|
||||||
// and ObjectSynchronizer::read_stable_mark
|
// and ObjectSynchronizer::read_stable_mark
|
||||||
|
|
||||||
|
@ -699,7 +667,6 @@ protected:
|
||||||
// (which can't itself be read from the signal handler if a signal hits during the Thread destructor).
|
// (which can't itself be read from the signal handler if a signal hits during the Thread destructor).
|
||||||
bool has_terminated() { return Atomic::load(&_ParkEvent) == NULL; };
|
bool has_terminated() { return Atomic::load(&_ParkEvent) == NULL; };
|
||||||
|
|
||||||
volatile int _OnTrap; // Resume-at IP delta
|
|
||||||
jint _hashStateW; // Marsaglia Shift-XOR thread-local RNG
|
jint _hashStateW; // Marsaglia Shift-XOR thread-local RNG
|
||||||
jint _hashStateX; // thread-specific hashCode generator state
|
jint _hashStateX; // thread-specific hashCode generator state
|
||||||
jint _hashStateY;
|
jint _hashStateY;
|
||||||
|
@ -809,6 +776,33 @@ class JavaThread: public Thread {
|
||||||
// elided card-marks for performance along the fast-path.
|
// elided card-marks for performance along the fast-path.
|
||||||
MemRegion _deferred_card_mark;
|
MemRegion _deferred_card_mark;
|
||||||
|
|
||||||
|
ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread is waiting to lock
|
||||||
|
bool _current_pending_monitor_is_from_java; // locking is from Java code
|
||||||
|
ObjectMonitor* _current_waiting_monitor; // ObjectMonitor on which this thread called Object.wait()
|
||||||
|
public:
|
||||||
|
volatile intptr_t _Stalled;
|
||||||
|
|
||||||
|
// For tracking the heavyweight monitor the thread is pending on.
|
||||||
|
ObjectMonitor* current_pending_monitor() {
|
||||||
|
return _current_pending_monitor;
|
||||||
|
}
|
||||||
|
void set_current_pending_monitor(ObjectMonitor* monitor) {
|
||||||
|
_current_pending_monitor = monitor;
|
||||||
|
}
|
||||||
|
void set_current_pending_monitor_is_from_java(bool from_java) {
|
||||||
|
_current_pending_monitor_is_from_java = from_java;
|
||||||
|
}
|
||||||
|
bool current_pending_monitor_is_from_java() {
|
||||||
|
return _current_pending_monitor_is_from_java;
|
||||||
|
}
|
||||||
|
ObjectMonitor* current_waiting_monitor() {
|
||||||
|
return _current_waiting_monitor;
|
||||||
|
}
|
||||||
|
void set_current_waiting_monitor(ObjectMonitor* monitor) {
|
||||||
|
_current_waiting_monitor = monitor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
MonitorChunk* _monitor_chunks; // Contains the off stack monitors
|
MonitorChunk* _monitor_chunks; // Contains the off stack monitors
|
||||||
// allocated during deoptimization
|
// allocated during deoptimization
|
||||||
// and by JNI_MonitorEnter/Exit
|
// and by JNI_MonitorEnter/Exit
|
||||||
|
|
|
@ -734,15 +734,15 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||||
nonstatic_field(Thread, _active_handles, JNIHandleBlock*) \
|
nonstatic_field(Thread, _active_handles, JNIHandleBlock*) \
|
||||||
nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \
|
nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \
|
||||||
nonstatic_field(Thread, _allocated_bytes, jlong) \
|
nonstatic_field(Thread, _allocated_bytes, jlong) \
|
||||||
nonstatic_field(Thread, _current_pending_monitor, ObjectMonitor*) \
|
|
||||||
nonstatic_field(Thread, _current_pending_monitor_is_from_java, bool) \
|
|
||||||
nonstatic_field(Thread, _current_waiting_monitor, ObjectMonitor*) \
|
|
||||||
nonstatic_field(NamedThread, _name, char*) \
|
nonstatic_field(NamedThread, _name, char*) \
|
||||||
nonstatic_field(NamedThread, _processed_thread, Thread*) \
|
nonstatic_field(NamedThread, _processed_thread, Thread*) \
|
||||||
nonstatic_field(JavaThread, _threadObj, OopHandle) \
|
nonstatic_field(JavaThread, _threadObj, OopHandle) \
|
||||||
nonstatic_field(JavaThread, _anchor, JavaFrameAnchor) \
|
nonstatic_field(JavaThread, _anchor, JavaFrameAnchor) \
|
||||||
nonstatic_field(JavaThread, _vm_result, oop) \
|
nonstatic_field(JavaThread, _vm_result, oop) \
|
||||||
nonstatic_field(JavaThread, _vm_result_2, Metadata*) \
|
nonstatic_field(JavaThread, _vm_result_2, Metadata*) \
|
||||||
|
nonstatic_field(JavaThread, _current_pending_monitor, ObjectMonitor*) \
|
||||||
|
nonstatic_field(JavaThread, _current_pending_monitor_is_from_java, bool) \
|
||||||
|
nonstatic_field(JavaThread, _current_waiting_monitor, ObjectMonitor*) \
|
||||||
nonstatic_field(JavaThread, _pending_async_exception, oop) \
|
nonstatic_field(JavaThread, _pending_async_exception, oop) \
|
||||||
volatile_nonstatic_field(JavaThread, _exception_oop, oop) \
|
volatile_nonstatic_field(JavaThread, _exception_oop, oop) \
|
||||||
volatile_nonstatic_field(JavaThread, _exception_pc, address) \
|
volatile_nonstatic_field(JavaThread, _exception_pc, address) \
|
||||||
|
|
|
@ -52,16 +52,17 @@ public class Thread extends VMObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static synchronized void initialize(TypeDataBase db) {
|
private static synchronized void initialize(TypeDataBase db) {
|
||||||
Type type = db.lookupType("Thread");
|
Type typeThread = db.lookupType("Thread");
|
||||||
|
Type typeJavaThread = db.lookupType("JavaThread");
|
||||||
|
|
||||||
suspendFlagsField = type.getCIntegerField("_suspend_flags");
|
suspendFlagsField = typeThread.getCIntegerField("_suspend_flags");
|
||||||
HAS_ASYNC_EXCEPTION = db.lookupIntConstant("Thread::_has_async_exception").intValue();
|
HAS_ASYNC_EXCEPTION = db.lookupIntConstant("Thread::_has_async_exception").intValue();
|
||||||
|
|
||||||
tlabFieldOffset = type.getField("_tlab").getOffset();
|
tlabFieldOffset = typeThread.getField("_tlab").getOffset();
|
||||||
activeHandlesField = type.getAddressField("_active_handles");
|
activeHandlesField = typeThread.getAddressField("_active_handles");
|
||||||
currentPendingMonitorField = type.getAddressField("_current_pending_monitor");
|
currentPendingMonitorField = typeJavaThread.getAddressField("_current_pending_monitor");
|
||||||
currentWaitingMonitorField = type.getAddressField("_current_waiting_monitor");
|
currentWaitingMonitorField = typeJavaThread.getAddressField("_current_waiting_monitor");
|
||||||
allocatedBytesField = type.getJLongField("_allocated_bytes");
|
allocatedBytesField = typeThread.getJLongField("_allocated_bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Thread(Address addr) {
|
public Thread(Address addr) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue