From 85774b713edf8782f162ac25b61ce99a77e116f4 Mon Sep 17 00:00:00 2001 From: Fei Yang Date: Thu, 24 Oct 2024 11:22:01 +0000 Subject: [PATCH] 8342882: RISC-V: Unify handling of jumps to runtime Reviewed-by: rehn --- .../riscv/gc/z/zBarrierSetAssembler_riscv.cpp | 9 ++++--- .../cpu/riscv/macroAssembler_riscv.cpp | 24 ++++++++----------- .../cpu/riscv/macroAssembler_riscv.hpp | 2 +- src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp | 3 +-- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 5 ++-- .../templateInterpreterGenerator_riscv.cpp | 2 +- src/hotspot/cpu/riscv/templateTable_riscv.cpp | 6 ++--- 7 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp index 4c307c282376c..cd83eafcaeba5 100644 --- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp @@ -758,15 +758,14 @@ void ZBarrierSetAssembler::generate_c2_store_barrier_stub(MacroAssembler* masm, __ la(c_rarg0, stub->ref_addr()); if (stub->is_native()) { - __ la(t1, RuntimeAddress(ZBarrierSetRuntime::store_barrier_on_native_oop_field_without_healing_addr())); + __ rt_call(ZBarrierSetRuntime::store_barrier_on_native_oop_field_without_healing_addr()); } else if (stub->is_atomic()) { - __ la(t1, RuntimeAddress(ZBarrierSetRuntime::store_barrier_on_oop_field_with_healing_addr())); + __ rt_call(ZBarrierSetRuntime::store_barrier_on_oop_field_with_healing_addr()); } else if (stub->is_nokeepalive()) { - __ la(t1, RuntimeAddress(ZBarrierSetRuntime::no_keepalive_store_barrier_on_oop_field_without_healing_addr())); + __ rt_call(ZBarrierSetRuntime::no_keepalive_store_barrier_on_oop_field_without_healing_addr()); } else { - __ la(t1, RuntimeAddress(ZBarrierSetRuntime::store_barrier_on_oop_field_without_healing_addr())); + __ rt_call(ZBarrierSetRuntime::store_barrier_on_oop_field_without_healing_addr()); } - __ jalr(t1); } // Stub exit diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 6137323d6109c..7101f7d726e8a 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -454,12 +454,7 @@ void MacroAssembler::call_VM_base(Register oop_result, ld(t0, Address(java_thread, in_bytes(Thread::pending_exception_offset()))); Label ok; beqz(t0, ok); - RuntimeAddress target(StubRoutines::forward_exception_entry()); - relocate(target.rspec(), [&] { - int32_t offset; - la(t1, target.target(), offset); - jr(t1, offset); - }); + j(RuntimeAddress(StubRoutines::forward_exception_entry())); bind(ok); } @@ -977,17 +972,19 @@ void MacroAssembler::j(const address dest, Register temp) { } } -void MacroAssembler::j(const Address &adr, Register temp) { - switch (adr.getMode()) { +void MacroAssembler::j(const Address &dest, Register temp) { + switch (dest.getMode()) { case Address::literal: { - relocate(adr.rspec(), [&] { - j(adr.target(), temp); + relocate(dest.rspec(), [&] { + int32_t offset; + la(temp, dest.target(), offset); + jr(temp, offset); }); break; } case Address::base_plus_offset: { - int32_t offset = ((int32_t)adr.offset() << 20) >> 20; - la(temp, Address(adr.base(), adr.offset() - offset)); + int32_t offset = ((int32_t)dest.offset() << 20) >> 20; + la(temp, Address(dest.base(), dest.offset() - offset)); jr(temp, offset); break; } @@ -4194,8 +4191,7 @@ void MacroAssembler::reserved_stack_check() { // We have already removed our own frame. // throw_delayed_StackOverflowError will think that it's been // called by our caller. - la(t1, RuntimeAddress(SharedRuntime::throw_delayed_StackOverflowError_entry())); - jr(t1); + j(RuntimeAddress(SharedRuntime::throw_delayed_StackOverflowError_entry())); should_not_reach_here(); bind(no_reserved_zone_enabling); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index a2e44fc45dd05..fda3badf35018 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -663,7 +663,7 @@ class MacroAssembler: public Assembler { // For long reach uses temp register for: // la + jr void j(const address dest, Register temp = t1); - void j(const Address &adr, Register temp = t1); + void j(const Address &dest, Register temp = t1); void j(Label &l, Register temp = noreg); // jump register: jalr x0, offset(rs) diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp index 6932d7cf5606c..cec6a5f976046 100644 --- a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp +++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp @@ -1139,8 +1139,7 @@ static void gen_continuation_yield(MacroAssembler* masm, Label ok; __ beqz(t0, ok); __ leave(); - __ la(t1, RuntimeAddress(StubRoutines::forward_exception_entry())); - __ jr(t1); + __ j(RuntimeAddress(StubRoutines::forward_exception_entry())); __ bind(ok); __ leave(); diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 3c0695aa381d6..a4744dfc05c06 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -508,7 +508,7 @@ class StubGenerator: public StubCodeGenerator { // complete return to VM assert(StubRoutines::_call_stub_return_address != nullptr, "_call_stub_return_address must have been generated before"); - __ j(StubRoutines::_call_stub_return_address); + __ j(RuntimeAddress(StubRoutines::_call_stub_return_address)); return start; } @@ -3782,8 +3782,7 @@ class StubGenerator: public StubCodeGenerator { Label thaw_success; // t1 contains the size of the frames to thaw, 0 if overflow or no more frames __ bnez(t1, thaw_success); - __ la(t1, RuntimeAddress(SharedRuntime::throw_StackOverflowError_entry())); - __ jr(t1); + __ j(RuntimeAddress(SharedRuntime::throw_StackOverflowError_entry())); __ bind(thaw_success); // make room for the thawed frames diff --git a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp index 8e5f754fa1c82..0281c66b97db1 100644 --- a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp @@ -421,7 +421,7 @@ address TemplateInterpreterGenerator::generate_exception_handler_common( c_rarg1, c_rarg2); } // throw exception - __ j(address(Interpreter::throw_exception_entry())); + __ j(RuntimeAddress(Interpreter::throw_exception_entry())); return entry; } diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp index 0b7616344c058..0c20f0e3f9286 100644 --- a/src/hotspot/cpu/riscv/templateTable_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp @@ -1085,7 +1085,7 @@ void TemplateTable::aastore() { // Come here on failure // object is at TOS - __ j(Interpreter::_throw_ArrayStoreException_entry); + __ j(RuntimeAddress(Interpreter::_throw_ArrayStoreException_entry)); // Come here on success __ bind(ok_is_subtype); @@ -3672,7 +3672,7 @@ void TemplateTable::checkcast() { // Come here on failure __ push_reg(x13); // object is at TOS - __ j(Interpreter::_throw_ClassCastException_entry); + __ j(RuntimeAddress(Interpreter::_throw_ClassCastException_entry)); // Come here on success __ bind(ok_is_subtype); @@ -3779,7 +3779,7 @@ void TemplateTable::_breakpoint() { void TemplateTable::athrow() { transition(atos, vtos); __ null_check(x10); - __ j(Interpreter::throw_exception_entry()); + __ j(RuntimeAddress(Interpreter::throw_exception_entry())); } //-----------------------------------------------------------------------------