RFR: 8348261: assert(n->is_Mem()) failed: memory node required

Vladimir Kozlov kvn at openjdk.org
Fri Mar 7 00:49:30 UTC 2025


Add missing check for StrInflatedCopy intrinsic in C2 Escape Analysis.

Very rare case since we not usually use Latin1.inflate(). In failing case we inline both paths in [String.getBytes()](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/String.java#L4808) and eliminate `TreeMap$EntryIterator allocation:


        # java.lang.String::getBytes @ bci:40 (line 4812) L[0]=rsp + #64 L[1]=rsp + #132 L[2]=rsp + #120 L[3]=rsp + #124 STK[0]=rsp + #128 STK[1]=#0 STK[2]=rsp + #132 STK[3]=rsp + #120 STK[4]=rsp + #164
        # java.lang.AbstractStringBuilder::putStringAt @ bci:15 (line 1754) L[0]=rsp + #0 L[1]=rsp + #120 L[2]=rsp + #64
        # java.lang.AbstractStringBuilder::append @ bci:30 (line 592) L[0]=rsp + #0 L[1]=rsp + #64 L[2]=rsp + #28
        # java.lang.StringBuilder::append @ bci:2 (line 179) L[0]=rsp + #0 L[1]=rsp + #64
        # java.lang.StringBuilder::append @ bci:5 (line 173) L[0]=rsp + #0 L[1]=rsp + #32
        # sun.util.locale.LocaleExtensions::toID @ bci:100 (line 206) L[0]=RBP L[1]=rsp + #0 L[2]=rsp + #8 L[3]=#ScObj0 L[4]=rsp + #16 L[5]=rsp + #24 L[6]=rsp + #32
        # ScObj0 java/util/TreeMap$EntryIterator={ [expectedModCount :0]=rsp + #140, [next :1]=rsp + #176, [lastReturned :2]=rsp + #16, [this$0 :3]=rsp + #168 }


Unfortunately I was not able to create standalone test - it seems requires very particular frequencies of executed paths and used features/flags. The fix was verified with compilation replay file from the bug report.

I am running testing and will let you know results.

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

Commit messages:
 - assert(n->is_Mem()) failed: memory node required

Changes: https://git.openjdk.org/jdk/pull/23938/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23938&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8348261
  Stats: 8 lines in 1 file changed: 8 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/23938.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23938/head:pull/23938

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


More information about the hotspot-compiler-dev mailing list