RFR: 8358821: patch_verified_entry causes problems, use nmethod entry barriers instead [v4]

Dean Long dlong at openjdk.org
Thu Jun 19 00:22:30 UTC 2025


On Wed, 18 Jun 2025 20:25:44 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:

>> Doesn't the old code have the same limitation? If thread 1 patches the entry point after thread 2 has executed the first instruction, thread 2 will be inside the nmethod if GC has disarmed the nmethod entry barrier.
>
> Well, yeah sort of. And hence the comment that it's probably fine in terms of correctness. They were also a bit more independent systems then though. Just thought that if we now take the step to merge compiler and GC entry trap mechanisms into the nmethod entry barrier, that we could seemingly also make it a bit less slippery here and establish some sort of invariant that if we while holding the lock protecting the entry barrier find that the nmethod entry barrier is not entrant, for whatever reason, we should not enter it. Would make it easier to understand the code I suspect. What do you think?

I think making it less slippery in one place but still leaving other races gives a false sense of security and makes the code harder to understand.  Arming the barrier is not guaranteed to be visible until there is a safepoint.  Note that AArch64 and RISCV only call increment_patching_epoch() when the guard value is set to the disarmed value, so there is no invalidation of the CPU pipeline or instruction buffer (cross modification fence) when arming.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25764#discussion_r2155757120


More information about the shenandoah-dev mailing list