RFR: 8373495: C2: Aggressively fold loads from objects that have not escaped [v4]

Vladimir Kozlov kvn at openjdk.org
Thu Dec 11 21:28:09 UTC 2025


On Thu, 11 Dec 2025 19:52:37 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

>> src/hotspot/share/opto/phaseloadfolding.cpp line 133:
>> 
>>> 131: //       int x = o.value;
>>> 132: //   In this case, even if the load x = o.value is declared after the store of o to p that allows o
>>> 133: //   to escape, it is valid for the load to actually happen before the store. As a result, we can
>> 
>> I don't think it is correct. If `p` is external other thread can modify its fields concurrently.
>> Or are you saying that if `p` is external we will always have memory barrier?
>
> I think the Java memory model allows this reordering and places the responsibility on the programmer to use a synchronization mechanism if the reordering is undesirable, no?

Yes, I think. May be we should add comment about that.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28764#discussion_r2612117694


More information about the hotspot-compiler-dev mailing list