From 9d60300feea12d353fcd6c806b196ace2df02d05 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Tue, 19 Nov 2024 10:01:49 +0000 Subject: [PATCH] 8344199: Incorrect excluded field value set by getEventWriter intrinsic Co-authored-by: Patricio Chilano Mateo Reviewed-by: syan, mgronlun --- src/hotspot/share/opto/library_call.cpp | 14 ++++++++++---- test/jdk/ProblemList-Xcomp.txt | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index 226fddce29b..39bac0bc14f 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -3257,7 +3257,10 @@ bool LibraryCallKit::inline_native_getEventWriter() { set_all_memory(input_memory_state); Node* input_io_state = i_o(); - Node* excluded_mask = _gvn.intcon(32768); + // The most significant bit of the u2 is used to denote thread exclusion + Node* excluded_shift = _gvn.intcon(15); + Node* excluded_mask = _gvn.intcon(1 << 15); + // The epoch generation is the range [1-32767] Node* epoch_mask = _gvn.intcon(32767); // TLS @@ -3411,7 +3414,7 @@ bool LibraryCallKit::inline_native_getEventWriter() { record_for_igvn(vthread_compare_io); PhiNode* tid = new PhiNode(vthread_compare_rgn, TypeLong::LONG); record_for_igvn(tid); - PhiNode* exclusion = new PhiNode(vthread_compare_rgn, TypeInt::BOOL); + PhiNode* exclusion = new PhiNode(vthread_compare_rgn, TypeInt::CHAR); record_for_igvn(exclusion); PhiNode* pinVirtualThread = new PhiNode(vthread_compare_rgn, TypeInt::BOOL); record_for_igvn(pinVirtualThread); @@ -3476,7 +3479,8 @@ bool LibraryCallKit::inline_native_getEventWriter() { store_to_memory(tid_is_not_equal, event_writer_pin_field, _gvn.transform(pinVirtualThread), T_BOOLEAN, MemNode::unordered); // Store the exclusion state to the event writer. - store_to_memory(tid_is_not_equal, event_writer_excluded_field, _gvn.transform(exclusion), T_BOOLEAN, MemNode::unordered); + Node* excluded_bool = _gvn.transform(new URShiftINode(_gvn.transform(exclusion), excluded_shift)); + store_to_memory(tid_is_not_equal, event_writer_excluded_field, excluded_bool, T_BOOLEAN, MemNode::unordered); // Store the tid to the event writer. store_to_memory(tid_is_not_equal, event_writer_tid_field, tid, T_LONG, MemNode::unordered); @@ -3543,7 +3547,9 @@ void LibraryCallKit::extend_setCurrentThread(Node* jt, Node* thread) { Node* input_memory_state = reset_memory(); set_all_memory(input_memory_state); - Node* excluded_mask = _gvn.intcon(32768); + // The most significant bit of the u2 is used to denote thread exclusion + Node* excluded_mask = _gvn.intcon(1 << 15); + // The epoch generation is the range [1-32767] Node* epoch_mask = _gvn.intcon(32767); Node* const carrierThread = generate_current_thread(jt); diff --git a/test/jdk/ProblemList-Xcomp.txt b/test/jdk/ProblemList-Xcomp.txt index 1577bb6f7f1..680806e6e31 100644 --- a/test/jdk/ProblemList-Xcomp.txt +++ b/test/jdk/ProblemList-Xcomp.txt @@ -30,4 +30,3 @@ java/lang/invoke/MethodHandles/CatchExceptionTest.java 8146623 generic-all java/lang/reflect/callerCache/ReflectionCallerCacheTest.java 8332028 generic-all com/sun/jdi/InterruptHangTest.java 8043571 generic-all -jdk/jfr/jvm/TestVirtualThreadExclusion.java 8344199 generic-all