RFR: 8373495: C2: Aggressively fold loads from objects that have not escaped [v4]
Vladimir Kozlov
kvn at openjdk.org
Thu Dec 11 21:28:06 UTC 2025
On Thu, 11 Dec 2025 13:38:24 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> Hi,
>>
>> The current escape analysis mechanism is all-or-nothing: either the object does not escape, or it does. If the object escapes, we lose the ability to analyse the values of its fields completely, even if the object only escapes at return.
>>
>> This PR tries to find the escape status of an object at a load, and if it is decided that the object has not escaped there, we can try folding the load aggressively, ignoring calls and memory barriers to find a corresponding store that the load observes.
>>
>> For the runtime cost, this phase runs very fast, around 5 - 7% the runtime of EA, and about 0.5% the total runtime of C2.
>>
>> Please take a look and leave your thoughts, thanks a lot.
>
> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
>
> store values need normalizing
src/hotspot/share/opto/phaseloadfolding.cpp line 94:
> 92: // We can see that the object can be considered non-escape at NarrowMemProj, CallJava(null), and
> 93: // Proj2, while it is considered escape at CallJava(o), Proj1, Phi. The loads x and z will be
> 94: // from NarrowMemProj and Proj2, respectively, which means they can be considered loads from an
So this optimization is based on JDK-8327963 changes which introduced NarrowMemProj. But I don't see you can for it in code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28764#discussion_r2612121903
More information about the hotspot-compiler-dev
mailing list