8222518: Remove unnecessary caching of Parker object in java.lang.Thread
Reviewed-by: dcubed, rehn
--- a/src/hotspot/share/classfile/javaClasses.cpp Thu Apr 25 15:54:21 2019 -0700
+++ b/src/hotspot/share/classfile/javaClasses.cpp Fri Apr 26 00:57:03 2019 -0400
@@ -1613,7 +1613,6 @@
int java_lang_Thread::_tid_offset = 0;
int java_lang_Thread::_thread_status_offset = 0;
int java_lang_Thread::_park_blocker_offset = 0;
-int java_lang_Thread::_park_event_offset = 0 ;
#define THREAD_FIELDS_DO(macro) \
macro(_name_offset, k, vmSymbols::name_name(), string_signature, false); \
@@ -1627,8 +1626,7 @@
macro(_stackSize_offset, k, "stackSize", long_signature, false); \
macro(_tid_offset, k, "tid", long_signature, false); \
macro(_thread_status_offset, k, "threadStatus", int_signature, false); \
- macro(_park_blocker_offset, k, "parkBlocker", object_signature, false); \
- macro(_park_event_offset, k, "nativeParkEventPointer", long_signature, false)
+ macro(_park_blocker_offset, k, "parkBlocker", object_signature, false)
void java_lang_Thread::compute_offsets() {
assert(_group_offset == 0, "offsets should be initialized only once");
@@ -1745,15 +1743,6 @@
return java_thread->obj_field(_park_blocker_offset);
}
-jlong java_lang_Thread::park_event(oop java_thread) {
- return java_thread->long_field(_park_event_offset);
-}
-
-bool java_lang_Thread::set_park_event(oop java_thread, jlong ptr) {
- java_thread->long_field_put(_park_event_offset, ptr);
- return true;
-}
-
const char* java_lang_Thread::thread_status_name(oop java_thread) {
ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
switch (status) {
--- a/src/hotspot/share/classfile/javaClasses.hpp Thu Apr 25 15:54:21 2019 -0700
+++ b/src/hotspot/share/classfile/javaClasses.hpp Fri Apr 26 00:57:03 2019 -0400
@@ -371,7 +371,6 @@
static int _tid_offset;
static int _thread_status_offset;
static int _park_blocker_offset;
- static int _park_event_offset ;
static void compute_offsets();
@@ -413,12 +412,6 @@
// Blocker object responsible for thread parking
static oop park_blocker(oop java_thread);
- // Pointer to type-stable park handler, encoded as jlong.
- // Should be set when apparently null
- // For details, see unsafe.cpp Unsafe_Unpark
- static jlong park_event(oop java_thread);
- static bool set_park_event(oop java_thread, jlong ptr);
-
// Java Thread Status for JVMTI and M&M use.
// This thread status info is saved in threadStatus field of
// java.lang.Thread java class.
--- a/src/hotspot/share/prims/unsafe.cpp Thu Apr 25 15:54:21 2019 -0700
+++ b/src/hotspot/share/prims/unsafe.cpp Fri Apr 26 00:57:03 2019 -0400
@@ -949,27 +949,16 @@
(void) tlh.cv_internal_thread_to_JavaThread(jthread, &thr, &java_thread);
if (java_thread != NULL) {
// This is a valid oop.
- jlong lp = java_lang_Thread::park_event(java_thread);
- if (lp != 0) {
- // This cast is OK even though the jlong might have been read
- // non-atomically on 32bit systems, since there, one word will
- // always be zero anyway and the value set is always the same
- p = (Parker*)addr_from_java(lp);
- } else {
- // Not cached in the java.lang.Thread oop yet (could be an
- // older version of library).
- if (thr != NULL) {
- // The JavaThread is alive.
- p = thr->parker();
- if (p != NULL) {
- // Cache the Parker in the java.lang.Thread oop for next time.
- java_lang_Thread::set_park_event(java_thread, addr_to_java(p));
- }
- }
+ if (thr != NULL) {
+ // The JavaThread is alive.
+ p = thr->parker();
}
}
} // ThreadsListHandle is destroyed here.
+ // 'p' points to type-stable-memory if non-NULL. If the target
+ // thread terminates before we get here the new user of this
+ // Parker will get a 'spurious' unpark - which is perfectly valid.
if (p != NULL) {
HOTSPOT_THREAD_UNPARK((uintptr_t) p);
p->unpark();
--- a/src/java.base/share/classes/java/lang/Thread.java Thu Apr 25 15:54:21 2019 -0700
+++ b/src/java.base/share/classes/java/lang/Thread.java Fri Apr 26 00:57:03 2019 -0400
@@ -194,11 +194,6 @@
private final long stackSize;
/*
- * JVM-private state that persists after native thread termination.
- */
- private long nativeParkEventPointer;
-
- /*
* Thread ID
*/
private final long tid;