RFR: 8373495: C2: Aggressively fold loads from objects that have not escaped [v5]
Quan Anh Mai
qamai at openjdk.org
Fri Dec 12 03:18:50 UTC 2025
On Fri, 12 Dec 2025 03:03:59 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
>>
>> more detailed explanations
>
> Yes, I got it, but my understanding of the core idea of the optimization is that you can skip over membars when base object is not escaped yet. So, if `MemNode::can_see_stored_value()` encounters a node with a wide memory effect (a membar or a call) while traversing the memory graph upwards, it can step over it if it can prove that the freshly allocated instance hasn't escaped yet. And the traversal of memory graph from there up to corresponding Initialize node should reveal whether the instance escaped or not. Do I get it right?
@iwanowww In principle, I think you are right. However, I don't know how you can prove that a freshly allocated object has not escaped. It seems to me you would need to traverse the whole memory graph to obtain that information. Furthermore, `AllocateNode` and `InitializeNode` do not write to the whole memory, so walking some memory alias classes will make you pass them without knowing until you encounter the start memory. And there is also the issue of other nodes may alias with the base, too (e.g. `Phi`).
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28764#issuecomment-3644728073
More information about the hotspot-compiler-dev
mailing list