RFR: 8254029: ObjectMonitor cleanup/minor bug-fix changes extracted from JDK-8253064

Erik Österlund eosterlund at openjdk.java.net
Mon Oct 19 20:26:15 UTC 2020


On Mon, 19 Oct 2020 16:23:24 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

>> src/hotspot/share/runtime/synchronizer.cpp line 2366:
>> 
>>> 2364:   GVars.stw_random = os::random();
>>> 2365:
>>> 2366:   if (self->is_Java_thread()) {
>> 
>> When would this not be run by a Java thread?
>
> `ObjectSynchronizer::do_final_audit_and_print_stats()` calls:
> 
>> L2958:   ObjectSynchronizer::deflate_idle_monitors();
> 
> and do_final_audit_and_print_stats() is called from two places:
> 
> - void VM_Exit::doit() - The do_final_audit_and_print_stats() call happens
>   when the VMThread is executing the VM_Exit VM-op. That happens as
>   a result of a vm_exit() call a.k.a. System.exit().
> 
> - VMThread::run() - The do_final_audit_and_print_stats() call happens
>   after the VMThread has been terminated and finished processing
>   VM-ops. So this is the jni_DestroyJavaVM() path that happens when
>   the program falls off the end of main() and that thread does an
>   orderly shutdown of the VMThread.
> 
> A key piece of this changeset is moving the final audit to be executed
> by the VMThread on one of its two exit code paths. The final audit
> includes a calls to deflate_idle_monitors() to make sure things are as
> clean as possible before doing the audit_and_print_stats() call.
> 
> None of this happens if the right logging is not enabled.

Okay, that makes sense. Thanks for the explanation.

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

PR: https://git.openjdk.java.net/jdk/pull/641


More information about the hotspot-runtime-dev mailing list