Navigation Menu

Skip to content

Commit

Permalink
Use GetThreadInfo to get vthreads ThreadGroup rather than using the s…
Browse files Browse the repository at this point in the history
…tashed away ThreadGroup we noted for an earlier carrier thread.
  • Loading branch information
plummercj committed Feb 21, 2020
1 parent 6662418 commit 0e4084e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
28 changes: 10 additions & 18 deletions src/jdk.jdwp.agent/share/native/libjdwp/ThreadReferenceImpl.c
Expand Up @@ -170,27 +170,19 @@ threadGroup(PacketInputStream *in, PacketOutputStream *out)

jvmtiThreadInfo info;
jvmtiError error;
jboolean is_vthread = isVThread(thread);

if (is_vthread) {
/* If it's a vthread, use the well known thread group for vthreads. */
JDI_ASSERT(gdata->vthreadThreadGroup != NULL);
(void)outStream_writeObjectRef(env, out, gdata->vthreadThreadGroup);
} else {
(void)memset(&info, 0, sizeof(info));
error = JVMTI_FUNC_PTR(gdata->jvmti,GetThreadInfo)
(gdata->jvmti, thread, &info);

if (error != JVMTI_ERROR_NONE) {
outStream_setError(out, map2jdwpError(error));
} else {
(void)outStream_writeObjectRef(env, out, info.thread_group);
}
(void)memset(&info, 0, sizeof(info));
error = JVMTI_FUNC_PTR(gdata->jvmti,GetThreadInfo)
(gdata->jvmti, thread, &info);

if ( info.name!=NULL )
jvmtiDeallocate(info.name);
if (error != JVMTI_ERROR_NONE) {
outStream_setError(out, map2jdwpError(error));
} else {
(void)outStream_writeObjectRef(env, out, info.thread_group);
}

if ( info.name!=NULL )
jvmtiDeallocate(info.name);

} END_WITH_LOCAL_REFS(env);

return JNI_TRUE;
Expand Down
7 changes: 1 addition & 6 deletions src/jdk.jdwp.agent/share/native/libjdwp/eventHandler.c
Expand Up @@ -1447,19 +1447,14 @@ cbVThreadScheduled(jvmtiEnv *jvmti_env, JNIEnv *env,
/*
* Now would be a good time to cache the ThreadGroup for vthreads (carrier threads)
* if we haven't already.
*
* vthread fixme: the is kind of a hack. What happens if custom
* scheduler uses carrier threads in multple group? What if as a result of this a
* VThread can move between thread groups? We should have a dedicated
* thread group for all vthreads, or allow a vthread to set its ThreadGroup.
*/
if (gdata->vthreadThreadGroup == NULL) {
jvmtiThreadInfo info;
jvmtiError error;

(void)memset(&info, 0, sizeof(info));
error = JVMTI_FUNC_PTR(gdata->jvmti,GetThreadInfo)
(gdata->jvmti, thread, &info);
(gdata->jvmti, vthread, &info);

if (error != JVMTI_ERROR_NONE) {
EXIT_ERROR(error, "could not get vthread ThreadGroup");
Expand Down

0 comments on commit 0e4084e

Please sign in to comment.