Skip to content

Commit cbda758

Browse files
committed
8343122: RISC-V: C2: Small improvement for real runtime callouts
Reviewed-by: rehn, fjiang
1 parent 803612e commit cbda758

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/hotspot/cpu/riscv/riscv.ad

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,21 +1259,21 @@ int MachCallRuntimeNode::ret_addr_offset() {
12591259
// jal(addr)
12601260
// or with far branches
12611261
// jal(trampoline_stub)
1262-
// for real runtime callouts it will be 11 instructions
1262+
// for real runtime callouts it will be 9 instructions
12631263
// see riscv_enc_java_to_runtime
12641264
// la(t0, retaddr) -> auipc + addi
1265-
// la(t1, RuntimeAddress(addr)) -> lui + addi + slli + addi + slli + addi
12661265
// addi(sp, sp, -2 * wordSize) -> addi
1267-
// sd(t1, Address(sp, wordSize)) -> sd
1268-
// jalr(t1) -> jalr
1266+
// sd(t0, Address(sp, wordSize)) -> sd
1267+
// movptr(t1, addr, offset, t0) -> lui + lui + slli + add
1268+
// jalr(t1, offset) -> jalr
12691269
CodeBlob *cb = CodeCache::find_blob(_entry_point);
12701270
if (cb != nullptr) {
12711271
if (UseTrampolines) {
12721272
return 1 * NativeInstruction::instruction_size;
12731273
}
12741274
return 3 * NativeInstruction::instruction_size;
12751275
} else {
1276-
return 11 * NativeInstruction::instruction_size;
1276+
return 9 * NativeInstruction::instruction_size;
12771277
}
12781278
}
12791279

@@ -2505,11 +2505,13 @@ encode %{
25052505
} else {
25062506
Label retaddr;
25072507
__ la(t0, retaddr);
2508-
__ la(t1, RuntimeAddress(entry));
25092508
// Leave a breadcrumb for JavaFrameAnchor::capture_last_Java_pc()
25102509
__ addi(sp, sp, -2 * wordSize);
25112510
__ sd(t0, Address(sp, wordSize));
2512-
__ jalr(t1);
2511+
int32_t offset = 0;
2512+
// No relocation needed
2513+
__ movptr(t1, entry, offset, t0); // lui + lui + slli + add
2514+
__ jalr(t1, offset);
25132515
__ bind(retaddr);
25142516
__ post_call_nop();
25152517
__ addi(sp, sp, 2 * wordSize);

0 commit comments

Comments
 (0)