RFR: 8259713: Fix comments about ResetNoHandleMark in deoptimization

Coleen Phillimore coleenp at openjdk.java.net
Thu Jan 14 01:50:05 UTC 2021


On Thu, 14 Jan 2021 01:30:21 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

>> This is a small part of the withdrawn change for https://github.com/openjdk/jdk/pull/1990 to fix the out-of-date comments in deoptimization.cpp.
>> Tested with tier1-3.
>
> src/hotspot/share/runtime/deoptimization.cpp line 693:
> 
>> 691:   // Handles will be leaked.
>> 692:   ResetNoHandleMark rnhm;
>> 693:   HandleMark hm(thread);
> 
> Here's a simpler rewrite for L687 -> L693:
> 
>     // This code wants to allocate handles which is okay in a leaf method,
>     // but JRT_LEAF contains a NoHandleMark so we have to work around
>     // that with ResetNoHandleMark in order to create a HandleMark here:
>     ResetNoHandleMark rnhm;
>     HandleMark hm(thread);

Unfortunately this is not entirely what I want to say.
I want to say that you *must* have a HandleMark if you have ResetNoHandleMark in a JRT_LEAF.
You need a ResetNoHandleMark to create Handles but there are no asserts to make sure you have a HandleMark.
ie:

     ResetNoHandleMark rnhm;
     Handle h(THREAD, obj);  // OK no problem

But the Handle will leak once this function returns (until the next JRT_ENTRY anyway).

    // This code wants to allocate handles which is okay in a leaf method,
    // but JRT_LEAF contains a NoHandleMark so we have to work around
    // that with ResetNoHandleMark in order to create a Handles here.
    // There must also be a HandleMark here to clean up any handles created in this scope.

How about that?

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

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


More information about the hotspot-dev mailing list