@@ -92,11 +92,6 @@ static void doHandshake(Object node) {
9292 SINGLETON .processHandshake ((Node ) node );
9393 }
9494
95- @ Override
96- protected void setFastPending (Thread t ) {
97- setVolatile (t , 1 );
98- }
99-
10095 @ Override
10196 @ TruffleBoundary
10297 public TruffleSafepointImpl getCurrent () {
@@ -110,21 +105,24 @@ public TruffleSafepointImpl getCurrent() {
110105
111106 @ Override
112107 protected void clearFastPending () {
113- setVolatile (Thread .currentThread (), 0 );
108+ Thread carrierThread = JAVA_LANG_ACCESS .currentCarrierThread ();
109+ long eetop = UNSAFE .getLongVolatile (carrierThread , THREAD_EETOP_OFFSET );
110+ UNSAFE .putIntVolatile (null , eetop + PENDING_OFFSET , 0 );
114111 }
115112
116- private static void setVolatile (Thread thread , int value ) {
113+ @ Override
114+ protected void setFastPending (Thread thread ) {
117115 /*
118116 * The thread will not go away here because the Truffle implementation ensures that this
119117 * method is no longer used if the thread is no longer active. It only sets this state for
120118 * contexts that are currently entered on a thread. Being entered implies that the thread is
121119 * active.
122120 */
123- assert thread .isAlive () : "thread must remain alive while setting fast pending" ;
121+ assert thread .isAlive () : "thread must remain alive while setting the pending flag " ;
124122
125123 long eetop = UNSAFE .getLongVolatile (thread , THREAD_EETOP_OFFSET );
126124 if (eetop != 0 ) {
127- UNSAFE .putIntVolatile (null , eetop + PENDING_OFFSET , value );
125+ UNSAFE .putIntVolatile (null , eetop + PENDING_OFFSET , 1 );
128126 } else { // only the case for VirtualThreads
129127 Object carrierThread = UNSAFE .getObjectVolatile (thread , THREAD_CARRIER_THREAD_OFFSET );
130128 if (carrierThread == null ) {
@@ -137,7 +135,7 @@ private static void setVolatile(Thread thread, int value) {
137135 return ;
138136 }
139137 eetop = UNSAFE .getLongVolatile (carrierThread , THREAD_EETOP_OFFSET );
140- UNSAFE .putIntVolatile (null , eetop + PENDING_OFFSET , value );
138+ UNSAFE .putIntVolatile (null , eetop + PENDING_OFFSET , 1 );
141139 /*
142140 * If the VirtualThread moves to another carrier thread after this method returns, the
143141 * pending flag will still be set correctly thanks to setPendingFlagForVirtualThread()
0 commit comments