RFR: 8299414: JVMTI FollowReferences should support references from VirtualThread stack [v5]

Alex Menkov amenkov at openjdk.org
Wed Apr 12 04:07:36 UTC 2023


On Wed, 12 Apr 2023 02:17:14 GMT, David Holmes <dholmes at openjdk.org> wrote:

> If an object is only reachable from the stack of a VT and the VT itself is not followed then we don't find that object either. But as I said a VT should be found via the object it is parked on, or via the scheduler. So is it the case that the current logic will not follow the stack of an unmounted Virtual thread? If so that seems wrong - especially if a mounted VT would find those objects. A VT is not a GC root but now I'm unsure exactly what that means.

Right, unmounted VTs are reachable from other objects.
And that's correct that current logic does not follow their stack references (current logic considers VT object as normal object, i.e. follows reference to its class and to its fields (iterate_over_object method, line 2687)).
Mounted VT does follow stack references as its stack is a part of carrier thread stack and carrier stack locals are followed (collect_stack_roots method, line 2775). The fix just splits carrier thread stack and report some references as references from VT stack (not carrier thread stack).

As for "heap roots" FollowReferences spec says:
`The heap root are the set of system classes, JNI globals, references from thread stacks, and other objects used as roots for the purposes of garbage collection.`
As far as I understand the idea here is all other heap objects are reachable from "heap roots".

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13254#issuecomment-1504564223


More information about the serviceability-dev mailing list