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

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Thu Dec 11 19:55:35 UTC 2025


On Thu, 11 Dec 2025 18:44:47 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> 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 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?

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

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


More information about the hotspot-compiler-dev mailing list