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

Quan Anh Mai qamai at openjdk.org
Sat Dec 13 15:10:37 UTC 2025


> Hi,
> 
> This patch is an alternative to #28764 but it does the analysis during IGVN instead.
> 
> 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. Implementation-wise, when walking at `find_previous_store`, if we encounter a call or memory barrier, we start looking at all nodes that make the allocation escape. If all such nodes have a control input that is not a transitive control input of the call/barrier we are at, then we can decidedly say that the allocation has not escaped at that call/barrier, and walk past that call/barrier to find a corresponding store.
> 
> I do not see a noticeable difference in C2 runtime with and without this patch.
> 
> 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:

  safepoints do not have a memory output

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/28812/files
  - new: https://git.openjdk.org/jdk/pull/28812/files/918d7fe7..ce3ca6ae

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=28812&range=06
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=28812&range=05-06

  Stats: 6 lines in 1 file changed: 0 ins; 6 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/28812.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28812/head:pull/28812

PR: https://git.openjdk.org/jdk/pull/28812


More information about the hotspot-compiler-dev mailing list