On Sat, 25 Jun 2022 01:35:38 GMT, Serguei Spitsyn <sspit...@openjdk.org> wrote:
>> src/hotspot/share/prims/jvmtiExport.cpp line 1702: >> >>> 1700: } else { >>> 1701: post_object_free_on_java_thread(env, objects); >>> 1702: } >> >> Can you explain why sometimes it is a VMThread and why sometimes it is a >> JavaThread? > > I hope, it is okay if I explain it. :) > The `post_object_free` can be called in different contexts. > It is (recursively) called from `JvmtiTagMap::check_hashmaps_for_heapwalk()` > which is used in VM_ops: > - VM_HeapIterateOperation > - VM_HeapWalkOperation > > Also, the `post_object_free` is called from `JvmtiTagMap` functions: > - flush_object_free_events > - get_objects_with_tags > which can be called from the `ServiceThread` or the JVMTI functions like > `SetEvenNotificationMode`, `SetEventCallBacks` or `GetObjectsWithTags`. @sspitsyn Thanks. Yes, `JvmtiTagMap::check_hashmaps_for_heapwalk()` is where I saw the call from `VMThread`. This patch is intended to **not** post `ObjectFree` events on `VMThread`, so I am going to move this PR back to draft state and take another look. ------------- PR: https://git.openjdk.org/jdk/pull/9168