-
Enhancement
-
Resolution: Fixed
-
P4
-
24
-
b21
-
riscv
Risc-v don't have dedicated call/ret instructions.
Instead CPU assumes based on what registers are used.
The cpu have a return-address stack where it stores return addresses for prediction.
This stack is updated, accordingly (from unpriv manual):
rd is x1/x5 | rs1 is x1/x5 | rd=rs1 | RAS action
No | No | — | None
No | Yes | — | Pop
Yes | No | — | Push
Yes | Yes | No | Pop, then push
Yes | Yes | Yes | Push
Additional:
"A JAL instruction should push the return address onto a return-address stack (RAS) only when rd is 'x1' or x5."
Hotspot only uses x1/ra for calls and return, and do not pop then push (coroutine call):
- calls should plain push, this rd = x1/ra and rs1 != x5/t0
- returns should plain pop, this rd != x5/t0 and rs1 != x1/ra
- jumps rd and rs1 != x1/x5
As today we use x5/t0 as main scratch this gets all wrong, all jumps, calls and return to use x5.
Instead CPU assumes based on what registers are used.
The cpu have a return-address stack where it stores return addresses for prediction.
This stack is updated, accordingly (from unpriv manual):
rd is x1/x5 | rs1 is x1/x5 | rd=rs1 | RAS action
No | No | — | None
No | Yes | — | Pop
Yes | No | — | Push
Yes | Yes | No | Pop, then push
Yes | Yes | Yes | Push
Additional:
"A JAL instruction should push the return address onto a return-address stack (RAS) only when rd is 'x1' or x5."
Hotspot only uses x1/ra for calls and return, and do not pop then push (coroutine call):
- calls should plain push, this rd = x1/ra and rs1 != x5/t0
- returns should plain pop, this rd != x5/t0 and rs1 != x1/ra
- jumps rd and rs1 != x1/x5
As today we use x5/t0 as main scratch this gets all wrong, all jumps, calls and return to use x5.
- links to
-
Commit(master) openjdk/jdk/66ddaaa3
-
Review(master) openjdk/jdk/21406