RFR: 8299414: JVMTI FollowReferences should support references from VirtualThread stack [v9]
Serguei Spitsyn
sspitsyn at openjdk.org
Tue May 2 10:23:18 UTC 2023
On Mon, 1 May 2023 18:26:30 GMT, Alex Menkov <amenkov at openjdk.org> wrote:
>> The fix updates JVMTI FollowReferences implementation to report references from virtual threads:
>> - unmounted vthreads are detected, their stack references for JVMTI_HEAP_REFERENCE_STACK_LOCAL/JVMTI_HEAP_REFERENCE_JNI_LOCAL;
>> - stacks of mounted vthreads are splitted into 2 parts (virtual thread stack and carrier thread stack), references are reported with correct thread id/class tag/object tags/frame depth;
>> - common code to handle stack frames are moved into separate class;
>>
>> Threads are reported as:
>> - platform threads: JVMTI_HEAP_REFERENCE_THREAD (as before);
>> - mounted vthreads (synthetic references, consider them as heap roots because carrier threads are roots): JVMTI_HEAP_REFERENCE_OTHER;
>> - unmounted vthreads: not reported as heap roots.
>
> Alex Menkov has updated the pull request incrementally with one additional commit since the last revision:
>
> Added "no continuations" test case
src/hotspot/share/prims/jvmtiTagMap.cpp line 2319:
> 2317: }
> 2318: }
> 2319: }
The fragments 2289-2303 and 2305-2319 are based on the `StackValueCollection` and look very similar.
It can be worth to refactor these fragments into two function calls:
bool report_stack_value_collection(jmethodID method, int idx_base,
StackValueCollection* elems, jlocation bci) {
for (int index = 0; index < exprs->size(); index++) {
if (exprs->at(index)->type() == T_OBJECT) {
oop obj = elems->obj_at(index)();
if (obj == nullptr) {
continue;
}
// stack reference
if (!CallbackInvoker::report_stack_ref_root(thread_tag, tid, depth, method,
bci, idx_base + index, obj)) {
return false;
}
}
}
return true; // ???
. . . . .
jlocation bci = (jlocation)jvf->bci();
StackValueCollection* locals = jvf->locals();
if (!report_stack_value_collection(method, locals, 0 /* idx_base*/, bci)) {
return false;
}
StackValueCollection* exprs = jvf->expressions();
if (!report_stack_value_collection(method, exprs, locals->size(), bci)) {
return false;
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13254#discussion_r1182363174
More information about the hotspot-dev
mailing list