RFR: 8268052: [JVMCI] non-default installed code must be marked as in_use
Erik Österlund
eosterlund at openjdk.java.net
Tue Jun 1 19:46:00 UTC 2021
On Tue, 1 Jun 2021 15:54:30 GMT, Tom Rodriguez <never at openjdk.org> wrote:
>> 8268052: [JVMCI] non-default installed code must be marked as in_use
>
> src/hotspot/share/jvmci/jvmciRuntime.cpp line 1789:
>
>> 1787: method->set_code(method, nm);
>> 1788: } else {
>> 1789: result = JVMCI::nmethod_reclaimed;
>
> Is it really possible for the make_in_use call to fail if the nmethod is nmethodLocker'ed? The copy of this logic in ciEnv.cpp doesn't treat a failure of this call to be a compilation failure but it certainly seems like it should. It would be better if it weren't possible for this call to fail.
The issue is that the nmethod is published to Method code pointers before it is made in_use. That means a concurrent JavaThread may enter it and make the nmethod not_entrant, before it is made in_use. Making it in_use after it became not_entrant would cause a non-monotonic state transition which isn't great and comes with problems.
I agree it feels like there is room for improvement here, but at least that is the reason why make_in_use can fail; to prevent non-monotonic state transitions in this race.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4283
More information about the hotspot-compiler-dev
mailing list