@@ -1281,10 +1281,14 @@ commonResumeList(JNIEnv *env)
12811281 /* count number of threads to hard resume */
12821282 (void ) enumerateOverThreadList (env , & runningThreads , resumeCountHelper ,
12831283 & reqCnt );
1284+ (void ) enumerateOverThreadList (env , & runningVThreads , resumeCountHelper ,
1285+ & reqCnt );
12841286 if (reqCnt == 0 ) {
12851287 /* nothing to hard resume so do just the accounting part */
12861288 (void ) enumerateOverThreadList (env , & runningThreads , resumeCopyHelper ,
12871289 NULL );
1290+ (void ) enumerateOverThreadList (env , & runningVThreads , resumeCopyHelper ,
1291+ NULL );
12881292 return JVMTI_ERROR_NONE ;
12891293 }
12901294
@@ -1303,13 +1307,15 @@ commonResumeList(JNIEnv *env)
13031307 reqPtr = reqList ;
13041308 (void ) enumerateOverThreadList (env , & runningThreads , resumeCopyHelper ,
13051309 & reqPtr );
1310+ (void ) enumerateOverThreadList (env , & runningVThreads , resumeCopyHelper ,
1311+ & reqPtr );
13061312
13071313 error = JVMTI_FUNC_PTR (gdata -> jvmti ,ResumeThreadList )
13081314 (gdata -> jvmti , reqCnt , reqList , results );
13091315 for (i = 0 ; i < reqCnt ; i ++ ) {
13101316 ThreadNode * node ;
13111317
1312- node = findThread ( & runningThreads , reqList [i ]);
1318+ node = findRunningThread ( reqList [i ]);
13131319 if (node == NULL ) {
13141320 EXIT_ERROR (AGENT_ERROR_INVALID_THREAD ,"missing entry in running thread table" );
13151321 }
@@ -1619,7 +1625,12 @@ threadControl_suspendAll(void)
16191625 }
16201626 }
16211627
1622- /* Increment suspend count of each virtual thread that we are tracking. */
1628+ /*
1629+ * Increment suspendCount of each virtual thread that we are tracking. Note the
1630+ * compliment to this that happens during the resumeAll() is handled by
1631+ * commonResumeList(), so it's a bit orthogonal to how we handle incrementing
1632+ * the suspendCount.
1633+ */
16231634 error = enumerateOverThreadList (env , & runningVThreads , incrementSupendCountHelper , NULL );
16241635 JDI_ASSERT (error == JVMTI_ERROR_NONE );
16251636 }
@@ -1677,16 +1688,6 @@ threadControl_suspendAll(void)
16771688 return error ;
16781689}
16791690
1680- static jvmtiError
1681- decrementSupendCountHelper (JNIEnv * env , ThreadNode * node , void * arg )
1682- {
1683- // Some vthreads might already have a suspendCount of 0. Just ignore them.
1684- if (node -> suspendCount > 0 ) {
1685- node -> suspendCount -- ;
1686- }
1687- return JVMTI_ERROR_NONE ;
1688- }
1689-
16901691static jvmtiError
16911692resumeHelper (JNIEnv * env , ThreadNode * node , void * ignored )
16921693{
@@ -1723,10 +1724,6 @@ threadControl_resumeAll(void)
17231724 EXIT_ERROR (error , "cannot resume all virtual threads" );
17241725 }
17251726 }
1726-
1727- /* Decrement suspend count of each virtual thread that we are tracking. */
1728- error = enumerateOverThreadList (env , & runningVThreads , decrementSupendCountHelper , NULL );
1729- JDI_ASSERT (error == JVMTI_ERROR_NONE );
17301727 }
17311728
17321729 /*
@@ -2563,6 +2560,18 @@ threadControl_reset(void)
25632560 env = getEnv ();
25642561 eventHandler_lock (); /* for proper lock order */
25652562 debugMonitorEnter (threadLock );
2563+
2564+ if (gdata -> vthreadsSupported ) {
2565+ if (suspendAllCount > 0 ) {
2566+ /* Tell JVMTI to resume all virtual threads. */
2567+ jvmtiError error = JVMTI_FUNC_PTR (gdata -> jvmti ,ResumeAllVirtualThreads )
2568+ (gdata -> jvmti );
2569+ if (error != JVMTI_ERROR_NONE ) {
2570+ EXIT_ERROR (error , "cannot resume all virtual threads" );
2571+ }
2572+ }
2573+ }
2574+
25662575 (void )enumerateOverThreadList (env , & runningThreads , resetHelper , NULL );
25672576 (void )enumerateOverThreadList (env , & otherThreads , resetHelper , NULL );
25682577 (void )enumerateOverThreadList (env , & runningVThreads , resetHelper , NULL );
0 commit comments