Skip to content
Permalink
Browse files

Use GetThreadInfo to get vthreads ThreadGroup rather than using the s…

…tashed away ThreadGroup we noted for an earlier carrier thread.
  • Loading branch information
plummercj committed Feb 21, 2020
1 parent 6662418 commit 0e4084efb2f3358242235e7f52dfaedac0e66d2e
@@ -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;
@@ -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");

0 comments on commit 0e4084e

Please sign in to comment.
You can’t perform that action at this time.