RFR: 8259713: Fix comments about ResetNoHandleMark in deoptimization
Coleen Phillimore
coleenp at openjdk.java.net
Thu Jan 14 13:23:04 UTC 2021
On Thu, 14 Jan 2021 07:09:58 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> 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?
>
> My suggestion:
> // JRT_LEAF methods don't normally allocate handles and there is a
> // NoHandleMark to enforce that. It is actually safe to use Handles
> // in a JRT_LEAF method, and sometimes desirable, but to do so we
> // must use ResetNoHandleMark to bypass the NoHandleMark, and
> // then use a HandleMark to ensure any Handles we do create are
> // cleaned up in this scope.
> I still question why such a function declares itself a LEAF instead of just being a JRT_ENTRY but that is a different argument. :)
> Cheers,
> David
Ok, your comment says the same thing as mine and includes what I want to say, so I'll use your comment.
I'm pretty sure this function wants a NoSafepointVerifier but some of the calls it uses might need handles, because we were pretty aggressive about making arguments into handles.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2069
More information about the hotspot-dev
mailing list