RFR: 8268052: [JVMCI] non-default installed code must be marked as in_use
Erik Österlund
eosterlund at openjdk.java.net
Wed Jun 2 14:02:31 UTC 2021
On Tue, 1 Jun 2021 20:03:47 GMT, Tom Rodriguez <never at openjdk.org> wrote:
>> 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.
>
> Ok. I see the intent. In that case it seems like the reordering of the in_use and set_code calls was the important part of JDK-8226705. It can't actually fail here since it hasn't been published until the following line, right? Or is there some other way the nmethod is published? Why couldn't the in_use state be set at the end of the nmethod factory method?
I think it's published in the code cache and we had trouble with code walkers using only the CodeCache_lock to shoot down nmethods, but not the Compile_lock. If the walkers used the Compile_lock too then they wouldn't pick these up until they are fully installed. Plenty of room for improvements...
-------------
PR: https://git.openjdk.java.net/jdk/pull/4283
More information about the hotspot-compiler-dev
mailing list