RFR: 8357619: [JVMCI] Revisit phantom_ref parameter in JVMCINMethodData::get_nmethod_mirror

Tom Rodriguez never at openjdk.org
Fri May 30 16:07:52 UTC 2025


On Wed, 28 May 2025 10:28:38 GMT, Doug Simon <dnsimon at openjdk.org> wrote:

> The point of the `phantom_ref` parameter (introduced by [JDK-8234359](https://bugs.openjdk.org/browse/JDK-8234359)) of `JVMCINMethodData::get_nmethod_mirror` is to avoid the special resurrection semantics of a phantom read when reading the field during GC, which is when `JVMCINMethodData::invalidate_nmethod_mirror` can be called.
> This case can be handled directly in `JVMCINMethodData::invalidate_nmethod_mirror` and so the `phantom_ref` parameter can be removed.

src/hotspot/share/jvmci/jvmciRuntime.cpp line 801:

> 799: 
> 800: void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm) {
> 801:   if (_nmethod_mirror_index == -1) {

This part is actually wrong as that's the first part of `get_nmethod_mirror` and we must always check that `get_nmethod_mirror` doesn't return nullptr.  I'd assumed that the mirror was always non-null if `_nmethod_mirror_index != -1` but that's not true.  The slot is reserved for all non-default nmethods and must stay around so that `translate` can work.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25488#discussion_r2116193278


More information about the graal-dev mailing list