RFR: 8315843: C1: Use MDO offsets as int consts instead of intptr consts

Aleksey Shipilev shade at openjdk.org
Thu Sep 7 09:03:06 UTC 2023


Noticed this when looking at C1 profiling code. We use MDO offsets as `intptrConst`, despite them being very small. This leads to loads with `movabs` with large immediates on x86. We can instead just load them as `intConst`-s. This affects tier3 profiling code only. 

Sample branch profiling hunk from C1 tier3 on x86_64:


Before:
   0x00007f269065ed02:   test   %edx,%edx
   0x00007f269065ed04:   movabs $0x7f260a4ddd68,%rax  ;   {metadata(method data for {method} …
   0x00007f269065ed0e:   movabs $0x138,%rsi
 ╭ 0x00007f269065ed18:   je     0x00007f269065ed24
 │ 0x00007f269065ed1a:   movabs $0x148,%rsi
 ↘ 0x00007f269065ed24:   mov    (%rax,%rsi,1),%rdi
   0x00007f269065ed28:   lea    0x1(%rdi),%rdi
   0x00007f269065ed2c:   mov    %rdi,(%rax,%rsi,1)
   0x00007f269065ed30:   je     0x00007f269065ed4e     

After:
   0x00007f1370dcd782:   test   %edx,%edx
   0x00007f1370dcd784:   movabs $0x7f12f64ddd68,%rax   ;   {metadata(method data for {method} …
   0x00007f1370dcd78e:   mov    $0x138,%esi
 ╭ 0x00007f1370dcd793:   je     0x00007f1370dcd79a        
 │ 0x00007f1370dcd795:   mov    $0x148,%esi
 ↘ 0x00007f1370dcd79a:   mov    (%rax,%rsi,1),%rdi        
   0x00007f1370dcd79e:   lea    0x1(%rdi),%rdi
   0x00007f1370dcd7a2:   mov    %rdi,(%rax,%rsi,1)       
   0x00007f1370dcd7a6:   je     0x00007f1370dcd7c4 


In the hunk above, this saves about 8 bytes. This leads to observable code space savings on larger tests, e.g. on `-Xcomp -XX:TieredStopAtLevel=... HelloWorld`.


# Before
tier1: nmethod code size         :   426448 bytes
tier2: nmethod code size         :   463008 bytes
tier3: nmethod code size         :   910656 bytes

# After
tier1: nmethod code size         :   426448 bytes
tier2: nmethod code size         :   463008 bytes
tier3: nmethod code size         :   892448 bytes (-2.0%)


Additional testing:
 - [ ] Linux x86_64 fastdebug `tier1 tier2 tier3`
 - [ ] Linux AArch64 fastdebug `tier1 tier2 tier3`

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

Commit messages:
 - Fix

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

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


More information about the hotspot-compiler-dev mailing list