RFR: 8373495: C2: Aggressively fold loads from objects that have not escaped
Quan Anh Mai
qamai at openjdk.org
Thu Dec 11 11:18:24 UTC 2025
On Thu, 11 Dec 2025 10:14:41 GMT, Roberto Castañeda Lozano <rcastanedalo 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.
>
> Interesting improvement, thanks for working in this area, Quan Anh! Please allow us some time to think thoroughly about it and how it relates to other plans to improve escape analysis and scalar replacement in C2.
@robcasloz Thanks for taking a look. I also wonder how this relates to other potential improvements to EA. I think that this can work as an independent step or as a first step toward those goals. I am also pretty excited to realize that we don't need to schedule the graph to know if a load can be folded in such a manner, hope this can also be useful.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28764#issuecomment-3641433608
More information about the hotspot-compiler-dev
mailing list