RFR: 8290892: C2: Intrinsify Reference.reachabilityFence [v22]
Vladimir Ivanov
vlivanov at openjdk.org
Fri Nov 7 20:02:15 UTC 2025
On Fri, 7 Nov 2025 11:06:57 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> src/hotspot/share/opto/reachability.cpp line 461:
>>
>>> 459: if (!is_redundant_rf(rf, false /*rf_only*/)) {
>>> 460: Node_List safepoints;
>>> 461: enumerate_interfering_sfpts(rf, this, safepoints);
>>
>> Could this explode if we have a lot of RF in the graph? Do we need a ResouceMark, or reuse the `safeponts` node list?
>>
>> Imagine something like this:
>>
>> referent
>> if (flag1) { something } else { something }
>> ...
>> if (flag100) { something } else { something }
>> if (x1) { RF(referent); }
>> ...
>> if (x100) { RF(referent); }
>>
>> So we would call `enumerate_interfering_sfpts` 100x, and then traverse the graph with about 100-400 nodes each time. You can see how that grows quadratically. Maybe that's fine for runtime, but is it also ok for memory?
>
> And what if we find a lot of SafePoints for each RF? Do we end up attaching quadratically many referent edges over all?
In the worst case the number of new edges added is `(# of unique referents) * (# of safepoints)`. Multiple reachability fences can share the same referent.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25315#discussion_r2505270350
More information about the hotspot-compiler-dev
mailing list