RFR: 8290892: C2: Intrinsify Reference.reachabilityFence [v22]

Vladimir Ivanov vlivanov at openjdk.org
Mon Nov 10 02:40:11 UTC 2025


On Fri, 7 Nov 2025 10:21:50 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Vladimir Ivanov has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   update
>
> src/hotspot/share/opto/reachability.cpp line 108:
> 
>> 106:       return true; // ignore fences on boxed primitives produced by valueOf methods
>> 107:     }
>> 108:   }
> 
> Nice, thanks for adding the comment. I'm trying to understand the reason why that is ok.
> 
> So someone would have set a RF for a boxed primitive. But we don't expect anything to ever be attached to a boxed primitive, and so we can just ignore these RF? Is that the reason? Might be worth writing it in a code comment explicitly.

I stumbled upon it while inspecting IR with `-XX:+StressReachabiltiyFences` when RF is added for auto-boxed argument.  (`is_boxing_method()` matches `valueOf` factory, not an explicitly allocated box).

Thinking more about it, there's a way to observe the absence of RF on a auto-boxed instance when (1) value is out of range for internal caches; and (2) there's java.lang.ref.Reference instance registered for it.

So, I moved the logic under `StressReachabilityFences` instead.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25315#discussion_r2508550244


More information about the hotspot-compiler-dev mailing list