Skip to content
Permalink
Browse files

fiber -> virtual thread rename

  • Loading branch information
plummercj committed Feb 11, 2020
1 parent afa1580 commit 3371ef9ec780b9a0b282d3311da575e4cc59104f
@@ -448,7 +448,7 @@ popFrames(PacketInputStream *in, PacketOutputStream *out)
}

fnum = getFrameNumber(frame);
/* fiber fixme: add fiber support */
/* vthread fixme: add vthread support */
error = threadControl_popFrames(thread, fnum);
if (error != JVMTI_ERROR_NONE) {
serror = map2jdwpError(error);
@@ -90,7 +90,7 @@ children(PacketInputStream *in, PacketOutputStream *out)
{
JNIEnv *env;
jthreadGroup group;
jboolean is_fiber_group;
jboolean is_vthread_group;

env = getEnv();

@@ -99,22 +99,22 @@ children(PacketInputStream *in, PacketOutputStream *out)
return JNI_TRUE;
}

is_fiber_group = isSameObject(env, group, gdata->fiberThreadGroup);
is_vthread_group = isSameObject(env, group, gdata->vthreadThreadGroup);

WITH_LOCAL_REFS(env, 2) {

jvmtiError error = JVMTI_ERROR_NONE;
jint threadCount;
jint fiberCount = 0;
jint vthreadCount = 0;
jint groupCount;
jthread *theThreads;
jthread *theFibers = NULL;
jthread *theVThreads = NULL;
jthread *theGroups;

if (is_fiber_group) {
/* Get all the Fibers so we can return them. */
theFibers = threadControl_allFibers(&fiberCount);
if (theFibers == NULL && fiberCount != 0) {
if (is_vthread_group) {
/* Get all the VThreads so we can return them. */
theVThreads = threadControl_allVThreads(&vthreadCount);
if (theVThreads == NULL && vthreadCount != 0) {
error = JVMTI_ERROR_OUT_OF_MEMORY;
}
}
@@ -134,12 +134,12 @@ children(PacketInputStream *in, PacketOutputStream *out)
/* Squish out all of the debugger-spawned threads */
threadCount = filterDebugThreads(theThreads, threadCount);

(void)outStream_writeInt(out, threadCount + fiberCount);
(void)outStream_writeInt(out, threadCount + vthreadCount);
for (i = 0; i < threadCount; i++) {
(void)outStream_writeObjectRef(env, out, theThreads[i]);
}
for (i = 0; i < fiberCount; i++) {
(void)outStream_writeObjectRef(env, out, theFibers[i]);
for (i = 0; i < vthreadCount; i++) {
(void)outStream_writeObjectRef(env, out, theVThreads[i]);
}
(void)outStream_writeInt(out, groupCount);
for (i = 0; i < groupCount; i++) {
@@ -148,7 +148,7 @@ children(PacketInputStream *in, PacketOutputStream *out)

jvmtiDeallocate(theGroups);
jvmtiDeallocate(theThreads);
jvmtiDeallocate(theFibers);
jvmtiDeallocate(theVThreads);
}

} END_WITH_LOCAL_REFS(env);
@@ -170,12 +170,12 @@ threadGroup(PacketInputStream *in, PacketOutputStream *out)

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

if (is_fiber) {
/* If it's a fiber, use the well known thread group for Fibers. */
JDI_ASSERT(gdata->fiberThreadGroup != NULL);
(void)outStream_writeObjectRef(env, out, gdata->fiberThreadGroup);
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)
@@ -197,8 +197,8 @@ threadGroup(PacketInputStream *in, PacketOutputStream *out)
}

/*
* Validate that the thread or fiber is suspended, and returns a thread that can
* be used for stack operations, even for unmounted fibers.
* Validate that the thread or vthread is suspended, and returns a thread that can
* be used for stack operations, even for unmounted vthreads.
*/
static jthread
validateSuspendedThread(PacketOutputStream *out, jthread thread)
@@ -383,11 +383,11 @@ ownedMonitors(PacketInputStream *in, PacketOutputStream *out)
return JNI_TRUE;
}

// fiber fixme: for now fibers are assumed to have 0 owned monitors. However it is
// actually possible for them to own one or more. Currently that implies the fiber
// vthread fixme: for now vthreads are assumed to have 0 owned monitors. However it is
// actually possible for them to own one or more. Currently that implies the vthread
// is pinned to a carrier thread, so we could attempt to get the count from it, but
// in the future this might not be the case, and we would need JVMTI support.
if (isFiber(thread)) {
if (isVThread(thread)) {
(void)outStream_writeInt(out, 0);
return JNI_TRUE;
}
@@ -442,11 +442,11 @@ currentContendedMonitor(PacketInputStream *in, PacketOutputStream *out)
return JNI_TRUE;
}

// fiber fixme: for now fibers are assumed to have 0 contended monitors. However it is
// actually possible for them to own one or more. Currently that implies the fiber
// vthread fixme: for now vthreads are assumed to have 0 contended monitors. However it is
// actually possible for them to own one or more. Currently that implies the vthread
// is pinned to a carrier thread, so we could attempt to get the count from it, but
// in the future this might not be the case, and we would need JVMTI support.
if (isFiber(thread)) {
if (isVThread(thread)) {
(void)outStream_writeInt(out, 0);
return JNI_TRUE;
}
@@ -494,7 +494,7 @@ stop(PacketInputStream *in, PacketOutputStream *out)
return JNI_TRUE;
}

if (isFiber(thread)) {
if (isVThread(thread)) {
outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
return JNI_TRUE;
}
@@ -522,8 +522,8 @@ interrupt(PacketInputStream *in, PacketOutputStream *out)
return JNI_TRUE;
}

/* fiber fixme: add fiber support */
if (isFiber(thread)) {
/* vthread fixme: add vthread support */
if (isVThread(thread)) {
outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
return JNI_TRUE;
}
@@ -583,11 +583,11 @@ ownedMonitorsWithStackDepth(PacketInputStream *in, PacketOutputStream *out)
return JNI_TRUE;
}

// fiber fixme: for now fibers are assumed to have 0 owned monitors. However it is
// actually possible for them to own one or more. Currently that implies the fiber
// vthread fixme: for now vthreads are assumed to have 0 owned monitors. However it is
// actually possible for them to own one or more. Currently that implies the vthread
// is pinned to a carrier thread, so we could attempt to get the count from it, but
// in the future this might not be the case, and we would need JVMTI support.
if (isFiber(thread)) {
if (isVThread(thread)) {
(void)outStream_writeInt(out, 0);
return JNI_TRUE;
}
@@ -644,8 +644,8 @@ forceEarlyReturn(PacketInputStream *in, PacketOutputStream *out)
return JNI_TRUE;
}

/* fiber fixme: add fiber support */
if (isFiber(thread)) {
/* vthread fixme: add vthread support */
if (isVThread(thread)) {
outStream_setError(out, JDWP_ERROR(INVALID_THREAD));
return JNI_TRUE;
}
@@ -537,29 +537,29 @@ getAllThreads(PacketInputStream *in, PacketOutputStream *out)

int i;
jint threadCount;
jint fiberCount;
jint vthreadCount;
jthread *theThreads;
jthread *theFibers;
jthread *theVThreads;

theThreads = allThreads(&threadCount);
theFibers = threadControl_allFibers(&fiberCount);
theVThreads = threadControl_allVThreads(&vthreadCount);

if (theThreads == NULL || (theFibers == NULL && fiberCount != 0)) {
if (theThreads == NULL || (theVThreads == NULL && vthreadCount != 0)) {
outStream_setError(out, JDWP_ERROR(OUT_OF_MEMORY));
} else {
/* Squish out all of the debugger-spawned threads */
threadCount = filterDebugThreads(theThreads, threadCount);

(void)outStream_writeInt(out, threadCount + fiberCount);
for (i = 0; i < fiberCount; i++) {
(void)outStream_writeObjectRef(env, out, theFibers[i]);
(void)outStream_writeInt(out, threadCount + vthreadCount);
for (i = 0; i < vthreadCount; i++) {
(void)outStream_writeObjectRef(env, out, theVThreads[i]);
}
for (i = 0; i < threadCount; i++) {
(void)outStream_writeObjectRef(env, out, theThreads[i]);
}

jvmtiDeallocate(theThreads);
jvmtiDeallocate(theFibers);
jvmtiDeallocate(theVThreads);
}

} END_WITH_LOCAL_REFS(env);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -875,7 +875,7 @@ printUsage(void)
"onthrow=<exception name> debug on throw none\n"
"onuncaught=y|n debug on any uncaught? n\n"
"timeout=<timeout value> for listen/attach in milliseconds n\n"
"fibers=y|n|all support for debugging fibers y\n"
"virtualthreads=y|n|all support debugging virtual threads y\n"
"mutf8=y|n output modified utf-8 n\n"
"quiet=y|n control over terminal messages n\n"));

@@ -1022,9 +1022,9 @@ parseOptions(char *options)
gdata->assertFatal = DEFAULT_ASSERT_FATAL;
logfile = DEFAULT_LOGFILE;

/* Set fiber debugging level. */
gdata->fibersSupported = JNI_TRUE;
gdata->notifyDebuggerOfAllFibers = JNI_FALSE;
/* Set vthread debugging level. */
gdata->vthreadsSupported = JNI_TRUE;
gdata->notifyDebuggerOfAllVThreads = JNI_FALSE;

/* Options being NULL will end up being an error. */
if (options == NULL) {
@@ -1128,19 +1128,19 @@ parseOptions(char *options)
}
currentTransport->timeout = atol(current);
current += strlen(current) + 1;
} else if (strcmp(buf, "fibers") == 0) {
} else if (strcmp(buf, "virtualthreads") == 0) {
if (!get_tok(&str, current, (int)(end - current), ',')) {
goto syntax_error;
}
if (strcmp(current, "y") == 0) {
gdata->fibersSupported = JNI_TRUE;
gdata->notifyDebuggerOfAllFibers = JNI_FALSE;
gdata->vthreadsSupported = JNI_TRUE;
gdata->notifyDebuggerOfAllVThreads = JNI_FALSE;
} else if (strcmp(current, "all") == 0) {
gdata->fibersSupported = JNI_TRUE;
gdata->notifyDebuggerOfAllFibers = JNI_TRUE;
gdata->vthreadsSupported = JNI_TRUE;
gdata->notifyDebuggerOfAllVThreads = JNI_TRUE;
} else if (strcmp(current, "n") == 0) {
gdata->fibersSupported = JNI_FALSE;
gdata->notifyDebuggerOfAllFibers = JNI_FALSE;
gdata->vthreadsSupported = JNI_FALSE;
gdata->notifyDebuggerOfAllVThreads = JNI_FALSE;
} else {
goto syntax_error;
}
@@ -159,7 +159,7 @@ debugLoop_run(void)
outStream_setError(&out, JDWP_ERROR(VM_DEAD));
} else {
/* Provide 64 localrefs by default. */
/* fiber fixme: Now that this default set of localrefs is in place, we can remove a
/* vthread fixme: Now that this default set of localrefs is in place, we can remove a
* bunch of WITH_LOCAL_REFS/END_WITH_LOCAL_REFS blocks. The only ones needed are
* ones that could potentially go over 64, likes ones within loops. Note this only
* refers to command handlers called from here, not all uses of WITH_LOCAL_REFS. */

0 comments on commit 3371ef9

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