-
Enhancement
-
Resolution: Fixed
-
P4
-
24
-
b10
-
riscv
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8339388 | 23.0.2 | Fei Yang | P4 | Resolved | Fixed | b01 |
JDK-8339397 | 21.0.6 | Fei Yang | P4 | Resolved | Fixed | b01 |
JDK-8339398 | 17.0.14 | Fei Yang | P4 | Resolved | Fixed | b01 |
This could reduce the frame size by 16 bytes for each C2 runtime stub as we do not have to save sp on the method entry.
Here is an example, when sp is SOE, the generated code would be:
```
Decoding RuntimeStub - _complete_monitor_locking_Java 0x0000003f676d6a08 [0x0000003f676d6a80, 0x0000003f676d6b08] (136 bytes)
--------------------------------------------------------------------------------
0x0000003f676d6a80: nop
0x0000003f676d6a84: addi sp,sp,-32
0x0000003f676d6a86: sd s0,16(sp)
0x0000003f676d6a88: sd ra,24(sp)
0x0000003f676d6a8a: sd sp,0(sp)
0x0000003f676d6a8c: sd sp,928(s7)
0x0000003f676d6a90: mv a0,a1
0x0000003f676d6a92: mv a1,a2
0x0000003f676d6a94: mv a2,s7
0x0000003f676d6a96: auipc t1,0x0
0x0000003f676d6a9a: addi t1,t1,44 # 0x0000003f676d6ac2
0x0000003f676d6a9e: lui t0,0x1fc
0x0000003f676d6aa2: addi t0,t0,-108 # 0x00000000001fbf94
0x0000003f676d6aa6: slli t0,t0,0xb
0x0000003f676d6aaa: addi t0,t0,1589
0x0000003f676d6aae: slli t0,t0,0x6
0x0000003f676d6ab2: addi t0,t0,14
0x0000003f676d6ab6: addi sp,sp,-16
0x0000003f676d6aba: sd t1,8(sp)
0x0000003f676d6abe: jalr t0
0x0000003f676d6ac2: nop
0x0000003f676d6ac6: lui zero,0x0
0x0000003f676d6aca: sext.w zero,zero
0x0000003f676d6ace: addi sp,sp,16
0x0000003f676d6ad2: sd zero,928(s7)
0x0000003f676d6ad6: sd zero,936(s7)
0x0000003f676d6ada: ld t2,8(s7)
0x0000003f676d6ade: bnez t2,0x0000003f676d6aec
0x0000003f676d6ae2: ld sp,0(sp)
0x0000003f676d6ae4: ld s0,16(sp)
0x0000003f676d6ae6: ld ra,24(sp)
0x0000003f676d6ae8: addi sp,sp,32
0x0000003f676d6aea: ret
0x0000003f676d6aec: li t6,0
0x0000003f676d6af0: lui t2,0x3f67
0x0000003f676d6af4: addiw t2,t2,1487 # 0x0000000003f675cf
0x0000003f676d6af8: slli t2,t2,0xc
0x0000003f676d6afa: addi t2,t2,832
0x0000003f676d6afe: ld sp,0(sp)
0x0000003f676d6b00: ld s0,16(sp)
0x0000003f676d6b02: ld ra,24(sp)
0x0000003f676d6b04: addi sp,sp,32
0x0000003f676d6b06: jr
```
after we change to NS, it only generates the following code:
```
Decoding RuntimeStub - _complete_monitor_locking_Java 0x0000003f676d6688 [0x0000003f676d6700, 0x0000003f676d6788] (136 bytes)
--------------------------------------------------------------------------------
0x0000003f676d6700: nop
0x0000003f676d6704: addi sp,sp,-16
0x0000003f676d6706: sd s0,0(sp)
0x0000003f676d6708: sd ra,8(sp)
0x0000003f676d670a: sd sp,928(s7)
0x0000003f676d670e: mv a0,a1
0x0000003f676d6710: mv a1,a2
0x0000003f676d6712: mv a2,s7
0x0000003f676d6714: auipc t1,0x0
0x0000003f676d6718: addi t1,t1,44 # 0x0000003f676d6740
0x0000003f676d671c: lui t0,0x1fc
0x0000003f676d6720: addi t0,t0,-107 # 0x00000000001fbf95
0x0000003f676d6724: slli t0,t0,0xb
0x0000003f676d6728: addi t0,t0,316
0x0000003f676d672c: slli t0,t0,0x6
0x0000003f676d6730: addi t0,t0,12
0x0000003f676d6734: addi sp,sp,-16
0x0000003f676d6738: sd t1,8(sp)
0x0000003f676d673c: jalr t0
0x0000003f676d6740: nop
0x0000003f676d6744: lui zero,0x0
0x0000003f676d6748: sext.w zero,zero
0x0000003f676d674c: addi sp,sp,16
0x0000003f676d6750: sd zero,928(s7)
0x0000003f676d6754: sd zero,936(s7)
0x0000003f676d6758: ld t2,8(s7)
0x0000003f676d675c: bnez t2,0x0000003f676d6768
0x0000003f676d6760: ld s0,0(sp)
0x0000003f676d6762: ld ra,8(sp)
0x0000003f676d6764: addi sp,sp,16
0x0000003f676d6766: ret
0x0000003f676d6768: li t6,0
0x0000003f676d676c: lui t2,0x3f67
0x0000003f676d6770: addiw t2,t2,1487 # 0x0000000003f675cf
0x0000003f676d6774: slli t2,t2,0xc
0x0000003f676d6776: addi t2,t2,832
0x0000003f676d677a: ld s0,0(sp)
0x0000003f676d677c: ld ra,8(sp)
0x0000003f676d677e: addi sp,sp,16
0x0000003f676d6780: jr t2
```
We also checked the calling convention type for sp on other platforms (AArch64, PPC, x86, x64, S390), and they are all treated as NS.
- backported by
-
JDK-8339388 RISC-V: C2: Change C calling convention for sp to NS
- Resolved
-
JDK-8339397 RISC-V: C2: Change C calling convention for sp to NS
- Resolved
-
JDK-8339398 RISC-V: C2: Change C calling convention for sp to NS
- Resolved
- links to
-
Commit(master) openjdk/jdk17u-dev/9150f50f
-
Commit(master) openjdk/jdk21u-dev/d78c446f
-
Commit(master) openjdk/jdk23u/7bdece39
-
Commit(master) openjdk/jdk/53db937d
-
Commit(riscv-port) openjdk/riscv-port-jdk11u/1f90ddd3
-
Review(master) openjdk/jdk17u-dev/2823
-
Review(master) openjdk/jdk21u-dev/945
-
Review(master) openjdk/jdk23u/87
-
Review(master) openjdk/jdk/20449
-
Review(riscv-port) openjdk/riscv-port-jdk11u/26