From 522c15ba70c3b2f56a8ca6519acfc8d5debe1ed3 Mon Sep 17 00:00:00 2001 From: jiangfeilong Date: Wed, 22 Nov 2023 21:54:48 +0800 Subject: [PATCH] replace la_patchable + jalr with far_call/far_jump and rename la_patchable into auipc --- src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp | 9 +- .../cpu/riscv/c1_LIRAssembler_riscv.cpp | 4 +- src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp | 14 +-- src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp | 9 +- .../gc/shared/barrierSetAssembler_riscv.cpp | 7 +- .../riscv/gc/x/xBarrierSetAssembler_riscv.cpp | 8 +- src/hotspot/cpu/riscv/icBuffer_riscv.cpp | 3 +- src/hotspot/cpu/riscv/interp_masm_riscv.cpp | 2 +- .../cpu/riscv/jniFastGetField_riscv.cpp | 11 +- .../cpu/riscv/macroAssembler_riscv.cpp | 103 +++++++----------- .../cpu/riscv/macroAssembler_riscv.hpp | 16 +-- src/hotspot/cpu/riscv/riscv.ad | 4 +- src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp | 65 ++--------- src/hotspot/cpu/riscv/templateTable_riscv.cpp | 8 +- 14 files changed, 75 insertions(+), 188 deletions(-) diff --git a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp index 530b99dd06b7f..a6f2d98d6a1b3 100644 --- a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp @@ -44,7 +44,7 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) { InternalAddress safepoint_pc(__ pc() - __ offset() + safepoint_offset()); __ relocate(safepoint_pc.rspec(), [&] { int32_t offset; - __ la_patchable(t0, safepoint_pc.target(), offset); + __ auipc(t0, safepoint_pc.target(), offset); __ addi(t0, t0, offset); }); __ sd(t0, Address(xthread, JavaThread::saved_exception_pc_offset())); @@ -92,12 +92,7 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ mv(t1, _array->as_pointer_register()); stub_id = Runtime1::throw_range_check_failed_id; } - RuntimeAddress target(Runtime1::entry_for(stub_id)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(ra, target, offset); - __ jalr(ra, ra, offset); - }); + __ far_call(RuntimeAddress(Runtime1::entry_for(stub_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); debug_only(__ should_not_reach_here()); diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp index 953478d05ae7e..4b4ad60d077df 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp @@ -1426,7 +1426,7 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit InternalAddress pc_for_athrow(__ pc()); __ relocate(pc_for_athrow.rspec(), [&] { int32_t offset; - __ la_patchable(exceptionPC->as_register(), pc_for_athrow, offset); + __ auipc(exceptionPC->as_register(), pc_for_athrow, offset); __ addi(exceptionPC->as_register(), exceptionPC->as_register(), offset); }); add_call_info(pc_for_athrow_offset, info); // for exception handler @@ -1860,7 +1860,7 @@ void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* arg RuntimeAddress target(dest); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(t0, target, offset); + __ movptr(t0, target, offset); __ jalr(x1, t0, offset); }); } diff --git a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp index ea086d46bdac2..8a9a31eed5b03 100644 --- a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp @@ -67,12 +67,7 @@ int StubAssembler::call_RT(Register oop_result, Register metadata_result, addres set_last_Java_frame(sp, fp, retaddr, t0); // do the call - RuntimeAddress target(entry); - relocate(target.rspec(), [&] { - int32_t offset; - la_patchable(t0, target, offset); - jalr(x1, t0, offset); - }); + far_call(RuntimeAddress(entry)); bind(retaddr); int call_offset = offset(); // verify callee-saved register @@ -578,12 +573,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { Label retaddr; __ set_last_Java_frame(sp, fp, retaddr, t0); // do the call - RuntimeAddress addr(target); - __ relocate(addr.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, addr, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(RuntimeAddress(target)); __ bind(retaddr); OopMapSet* oop_maps = new OopMapSet(); assert_cond(oop_maps != nullptr); diff --git a/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp index d1c66ce1da76a..e381cae028230 100644 --- a/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp @@ -46,7 +46,7 @@ void C2SafepointPollStub::emit(C2_MacroAssembler& masm) { InternalAddress safepoint_pc(__ pc() - __ offset() + _safepoint_offset); __ relocate(safepoint_pc.rspec(), [&] { int32_t offset; - __ la_patchable(t0, safepoint_pc.target(), offset); + __ auipc(t0, safepoint_pc.target(), offset); __ addi(t0, t0, offset); }); __ sd(t0, Address(xthread, JavaThread::saved_exception_pc_offset())); @@ -60,12 +60,7 @@ int C2EntryBarrierStub::max_size() const { void C2EntryBarrierStub::emit(C2_MacroAssembler& masm) { __ bind(entry()); - RuntimeAddress target(StubRoutines::method_entry_barrier()); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(ra, t0, offset); - }); + __ far_call(RuntimeAddress(StubRoutines::method_entry_barrier())); __ j(continuation()); diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp index a4440890b0961..782c298c17e22 100644 --- a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp @@ -308,12 +308,7 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm, Label* slo Label skip_barrier; __ beq(t0, t1, skip_barrier); - RuntimeAddress target(StubRoutines::method_entry_barrier()); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(ra, t0, offset); - }); + __ far_call(RuntimeAddress(StubRoutines::method_entry_barrier())); __ j(skip_barrier); diff --git a/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.cpp index c48eac944c129..19615869a5f92 100644 --- a/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.cpp @@ -339,13 +339,7 @@ void XBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, X XSaveLiveRegisters save_live_registers(masm, stub); XSetupArguments setup_arguments(masm, stub); - Address target(stub->slow_path()); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); - } + __ far_call(Address(stub->slow_path())); // Stub exit __ j(*stub->continuation()); diff --git a/src/hotspot/cpu/riscv/icBuffer_riscv.cpp b/src/hotspot/cpu/riscv/icBuffer_riscv.cpp index 997611df4a3ab..387cafb035653 100644 --- a/src/hotspot/cpu/riscv/icBuffer_riscv.cpp +++ b/src/hotspot/cpu/riscv/icBuffer_riscv.cpp @@ -36,8 +36,7 @@ int InlineCacheBuffer::ic_stub_code_size() { // 6: auipc + ld + auipc + jalr + address(2 * instruction_size) - // 5: auipc + ld + j + address(2 * instruction_size) - return (MacroAssembler::far_branches() ? 6 : 5) * NativeInstruction::instruction_size; + return 6 * NativeInstruction::instruction_size; } #define __ masm-> diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp index 1240566e26cc4..1d3d0d7a0b107 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp @@ -194,7 +194,7 @@ void InterpreterMacroAssembler::get_dispatch() { ExternalAddress target((address)Interpreter::dispatch_table()); relocate(target.rspec(), [&] { int32_t offset; - la_patchable(xdispatch, target, offset); + auipc(xdispatch, target, offset); addi(xdispatch, xdispatch, offset); }); } diff --git a/src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp b/src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp index 87890d359ee91..c654200ba7406 100644 --- a/src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp +++ b/src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp @@ -76,7 +76,7 @@ address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) { Address target(SafepointSynchronize::safepoint_counter_addr()); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(rcounter_addr, target, offset); + __ auipc(rcounter_addr, target, offset); __ addi(rcounter_addr, rcounter_addr, offset); }); @@ -96,7 +96,7 @@ address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) { ExternalAddress target((address) JvmtiExport::get_field_access_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(result, target, offset); + __ auipc(result, target, offset); __ lwu(result, Address(result, offset)); }); __ bnez(result, slow); @@ -173,12 +173,7 @@ address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) { { __ enter(); - ExternalAddress target(slow_case_addr); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(ExternalAddress(slow_case_addr)); __ leave(); __ ret(); } diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 5201486c8c634..669bc28514d3b 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -337,12 +337,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_patchable(t0, target, offset); - jalr(x0, t0, offset); - }); + far_jump(RuntimeAddress(StubRoutines::forward_exception_entry())); bind(ok); } @@ -421,7 +416,7 @@ void MacroAssembler::_verify_oop(Register reg, const char* s, const char* file, ExternalAddress target(StubRoutines::verify_oop_subroutine_entry_address()); relocate(target.rspec(), [&] { int32_t offset; - la_patchable(t1, target, offset); + auipc(t1, target, offset); ld(t1, Address(t1, offset)); }); jalr(t1); @@ -466,7 +461,7 @@ void MacroAssembler::_verify_oop_addr(Address addr, const char* s, const char* f ExternalAddress target(StubRoutines::verify_oop_subroutine_entry_address()); relocate(target.rspec(), [&] { int32_t offset; - la_patchable(t1, target, offset); + auipc(t1, target, offset); ld(t1, Address(t1, offset)); }); jalr(t1); @@ -1564,7 +1559,7 @@ void MacroAssembler::reinit_heapbase() { ExternalAddress target(CompressedOops::ptrs_base_addr()); relocate(target.rspec(), [&] { int32_t offset; - la_patchable(xheapbase, target, offset); + auipc(xheapbase, target, offset); ld(xheapbase, Address(xheapbase, offset)); }); } @@ -2136,7 +2131,7 @@ SkipIfEqual::SkipIfEqual(MacroAssembler* masm, const bool* flag_addr, bool value ExternalAddress target((address)flag_addr); _masm->relocate(target.rspec(), [&] { int32_t offset; - _masm->la_patchable(t0, target, offset); + _masm->auipc(t0, target, offset); _masm->lbu(t0, Address(t0, offset)); }); if (value) { @@ -2910,46 +2905,36 @@ ATOMIC_XCHGU(xchgalwu, xchgalw) #undef ATOMIC_XCHGU -void MacroAssembler::far_jump(Address entry, Register tmp) { +void MacroAssembler::far_jump(const Address &entry, Register tmp) { assert(ReservedCodeCacheSize < 4*G, "branch out of range"); assert(CodeCache::find_blob(entry.target()) != nullptr, "destination of far call not found in code cache"); assert(entry.rspec().type() == relocInfo::external_word_type || entry.rspec().type() == relocInfo::runtime_call_type || entry.rspec().type() == relocInfo::none, "wrong entry relocInfo type"); - IncompressibleRegion ir(this); // Fixed length: see MacroAssembler::far_branch_size() - if (far_branches()) { - // We can use auipc + jalr here because we know that the total size of - // the code cache cannot exceed 2Gb. - relocate(entry.rspec(), [&] { - int32_t offset; - la_patchable(tmp, entry, offset); - jalr(x0, tmp, offset); - }); - } else { - j(entry); - } + // Fixed length: see MacroAssembler::far_branch_size() + relocate(entry.rspec(), [&] { + int32_t offset; + auipc(tmp, entry, offset); + jalr(x0, tmp, offset); + }); } -void MacroAssembler::far_call(Address entry, Register tmp) { +void MacroAssembler::far_call(const Address &entry, Register tmp) { assert(ReservedCodeCacheSize < 4*G, "branch out of range"); assert(CodeCache::find_blob(entry.target()) != nullptr, "destination of far call not found in code cache"); assert(entry.rspec().type() == relocInfo::external_word_type || entry.rspec().type() == relocInfo::runtime_call_type || entry.rspec().type() == relocInfo::none, "wrong entry relocInfo type"); - IncompressibleRegion ir(this); // Fixed length: see MacroAssembler::far_branch_size() - if (far_branches()) { - // We can use auipc + jalr here because we know that the total size of - // the code cache cannot exceed 2Gb. - relocate(entry.rspec(), [&] { - int32_t offset; - la_patchable(tmp, entry, offset); - jalr(x1, tmp, offset); // link - }); - } else { - jal(entry); // link - } + // Fixed length: see MacroAssembler::far_branch_size() + // We can use auipc + jalr here because we know that the total size of + // the code cache cannot exceed 2Gb. + relocate(entry.rspec(), [&] { + int32_t offset; + auipc(tmp, entry, offset); + jalr(x1, tmp, offset); // link + }); } void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, @@ -3172,14 +3157,14 @@ void MacroAssembler::load_byte_map_base(Register reg) { mv(reg, (uint64_t)byte_map_base); } -void MacroAssembler::la_patchable(Register reg1, const Address &dest, int32_t &offset) { +void MacroAssembler::auipc(Register reg, const Address &dest, int32_t &offset) { unsigned long low_address = (uintptr_t)CodeCache::low_bound(); unsigned long high_address = (uintptr_t)CodeCache::high_bound(); unsigned long dest_address = (uintptr_t)dest.target(); long offset_low = dest_address - low_address; long offset_high = dest_address - high_address; - assert(dest.getMode() == Address::literal, "la_patchable must be applied to a literal address"); + assert(dest.getMode() == Address::literal, "auipc must be applied to a literal address"); assert((uintptr_t)dest.target() < (1ull << 48), "bad address"); // RISC-V doesn't compute a page-aligned address, in order to partially @@ -3188,10 +3173,10 @@ void MacroAssembler::la_patchable(Register reg1, const Address &dest, int32_t &o // [-(2G + 2K), 2G - 2K). if (offset_high >= -((1L << 31) + (1L << 11)) && offset_low < (1L << 31) - (1L << 11)) { int64_t distance = dest.target() - pc(); - auipc(reg1, (int32_t)distance + 0x800); + auipc(reg, (int32_t)distance + 0x800); offset = ((int32_t)distance << 20) >> 20; } else { - movptr(reg1, dest.target(), offset); + movptr(reg, dest.target(), offset); } } @@ -3222,22 +3207,14 @@ void MacroAssembler::reserved_stack_check() { enter(); // RA and FP are live. mv(c_rarg0, xthread); RuntimeAddress target(CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone)); - relocate(target.rspec(), [&] { - int32_t offset; - la_patchable(t0, target, offset); - jalr(x1, t0, offset); - }); + far_call(target); leave(); // We have already removed our own frame. // throw_delayed_StackOverflowError will think that it's been // called by our caller. target = RuntimeAddress(StubRoutines::throw_delayed_StackOverflowError_entry()); - relocate(target.rspec(), [&] { - int32_t offset; - la_patchable(t0, target, offset); - jalr(x0, t0, offset); - }); + far_jump(target); should_not_reach_here(); bind(no_reserved_zone_enabling); @@ -3297,21 +3274,19 @@ address MacroAssembler::trampoline_call(Address entry) { address target = entry.target(); // We need a trampoline if branches are far. - if (far_branches()) { - if (!in_scratch_emit_size()) { - if (entry.rspec().type() == relocInfo::runtime_call_type) { - assert(CodeBuffer::supports_shared_stubs(), "must support shared stubs"); - code()->share_trampoline_for(entry.target(), offset()); - } else { - address stub = emit_trampoline_stub(offset(), target); - if (stub == nullptr) { - postcond(pc() == badAddress); - return nullptr; // CodeCache is full - } + if (!in_scratch_emit_size()) { + if (entry.rspec().type() == relocInfo::runtime_call_type) { + assert(CodeBuffer::supports_shared_stubs(), "must support shared stubs"); + code()->share_trampoline_for(entry.target(), offset()); + } else { + address stub = emit_trampoline_stub(offset(), target); + if (stub == nullptr) { + postcond(pc() == badAddress); + return nullptr; // CodeCache is full } } - target = pc(); } + target = pc(); address call_pc = pc(); #ifdef ASSERT @@ -3459,7 +3434,7 @@ void MacroAssembler::cmpptr(Register src1, Address src2, Label& equal) { assert_different_registers(src1, t0); relocate(src2.rspec(), [&] { int32_t offset; - la_patchable(t0, src2, offset); + auipc(t0, src2, offset); ld(t0, Address(t0, offset)); }); beq(src1, t0, equal); @@ -4688,7 +4663,7 @@ void MacroAssembler::rt_call(address dest, Register tmp) { } else { relocate(target.rspec(), [&] { int32_t offset; - la_patchable(tmp, target, offset); + movptr(tmp, target, offset); jalr(x1, tmp, offset); }); } diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 51bcba2f1a3fc..e0170a8c954a1 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -1057,10 +1057,6 @@ class MacroAssembler: public Assembler { void atomic_xchgwu(Register prev, Register newv, Register addr); void atomic_xchgalwu(Register prev, Register newv, Register addr); - static bool far_branches() { - return ReservedCodeCacheSize > branch_range; - } - // Emit a direct call/jump if the entry address will always be in range, // otherwise a far call/jump. // The address must be inside the code cache. @@ -1070,15 +1066,11 @@ class MacroAssembler: public Assembler { // - relocInfo::none // In the case of a far call/jump, the entry address is put in the tmp register. // The tmp register is invalidated. - void far_call(Address entry, Register tmp = t0); - void far_jump(Address entry, Register tmp = t0); + void far_call(const Address &entry, Register tmp = t0); + void far_jump(const Address &entry, Register tmp = t0); static int far_branch_size() { - if (far_branches()) { return 2 * 4; // auipc + jalr, see far_call() & far_jump() - } else { - return 4; - } } void load_byte_map_base(Register reg); @@ -1090,7 +1082,7 @@ class MacroAssembler: public Assembler { sd(zr, Address(t0)); } - void la_patchable(Register reg1, const Address &dest, int32_t &offset); + void auipc(Register reg, const Address &dest, int32_t &offset); virtual void _call_Unimplemented(address call_site) { mv(t1, call_site); @@ -1461,7 +1453,7 @@ class MacroAssembler: public Assembler { InternalAddress target(const_addr.target()); relocate(target.rspec(), [&] { int32_t offset; - la_patchable(dest, target, offset); + auipc(dest, target, offset); ld(dest, Address(dest, offset)); }); } diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 87f240873a85b..7ac33ca2494ff 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -1848,10 +1848,8 @@ uint MachUEPNode::size(PhaseRegAlloc* ra_) const // Emit exception handler code. int HandlerImpl::emit_exception_handler(CodeBuffer& cbuf) { - // la_patchable t0, #exception_blob_entry_point + // auipc t0, #exception_blob_entry_point // jr (offset)t0 - // or - // j #exception_blob_entry_point // Note that the code buffer's insts_mark is always relative to insts. // That's why we must use the macroassembler to generate a handler. C2_MacroAssembler _masm(&cbuf); diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp index fa718e5b08e86..7db93cdd078ab 100644 --- a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp +++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp @@ -345,11 +345,7 @@ static void patch_callers_callsite(MacroAssembler *masm) { __ mv(c_rarg0, xmethod); __ mv(c_rarg1, ra); RuntimeAddress target(CAST_FROM_FN_PTR(address, SharedRuntime::fixup_callers_callsite)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); __ pop_CPU_state(); // restore sp @@ -1622,7 +1618,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, ExternalAddress target((address)&DTraceMethodProbes); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(t0, target, offset); + __ auipc(t0, target, offset); __ lbu(t0, Address(t0, offset)); }); __ bnez(t0, dtrace_method_entry); @@ -1846,7 +1842,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, ExternalAddress target((address)&DTraceMethodProbes); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(t0, target, offset); + __ auipc(t0, target, offset); __ lbu(t0, Address(t0, offset)); }); __ bnez(t0, dtrace_method_exit); @@ -1980,11 +1976,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, assert(frame::arg_reg_save_area_bytes == 0, "not expecting frame reg save area"); #endif RuntimeAddress target(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); // Restore any method result value restore_native_result(masm, ret_type, stack_slots); @@ -2157,11 +2149,7 @@ void SharedRuntime::generate_deopt_blob() { __ mv(c_rarg0, xthread); __ orrw(c_rarg2, zr, xcpool); // exec mode RuntimeAddress target(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); __ bind(retaddr); oop_maps->add_gc_map( __ pc()-start, map->deep_copy()); @@ -2254,11 +2242,7 @@ void SharedRuntime::generate_deopt_blob() { __ mv(c_rarg0, xthread); __ mv(c_rarg1, xcpool); RuntimeAddress target(CAST_FROM_FN_PTR(address, Deoptimization::fetch_unroll_info)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); __ bind(retaddr); // Need to have an oopmap that tells fetch_unroll_info where to @@ -2401,11 +2385,7 @@ void SharedRuntime::generate_deopt_blob() { __ mv(c_rarg0, xthread); __ mv(c_rarg1, xcpool); // second arg: exec_mode target = RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); // Set an oopmap for the call site // Use the same PC we used for the last java frame @@ -2496,11 +2476,7 @@ void SharedRuntime::generate_uncommon_trap_blob() { __ mv(c_rarg0, xthread); __ mv(c_rarg2, Deoptimization::Unpack_uncommon_trap); RuntimeAddress target(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); __ bind(retaddr); // Set an oopmap for the call site @@ -2623,11 +2599,7 @@ void SharedRuntime::generate_uncommon_trap_blob() { __ mv(c_rarg0, xthread); __ mv(c_rarg1, Deoptimization::Unpack_uncommon_trap); target = RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); // Set an oopmap for the call site // Use the same PC we used for the last java frame @@ -2697,11 +2669,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // Do the call __ mv(c_rarg0, xthread); RuntimeAddress target(call_ptr); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); __ bind(retaddr); // Set an oopmap for the call site. This oopmap will map all @@ -2810,11 +2778,7 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha __ mv(c_rarg0, xthread); RuntimeAddress target(destination); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); + __ far_call(target); __ bind(retaddr); } @@ -2944,12 +2908,7 @@ void OptoRuntime::generate_exception_blob() { __ set_last_Java_frame(sp, noreg, the_pc, t0); __ mv(c_rarg0, xthread); RuntimeAddress target(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)); - __ relocate(target.rspec(), [&] { - int32_t offset; - __ la_patchable(t0, target, offset); - __ jalr(x1, t0, offset); - }); - + __ far_call(target); // handle_exception_C is a special VM call which does not require an explicit // instruction sync afterwards. diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp index ecc4520164d52..649ced7810ad1 100644 --- a/src/hotspot/cpu/riscv/templateTable_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp @@ -2471,7 +2471,7 @@ void TemplateTable::jvmti_post_field_access(Register cache, Register index, ExternalAddress target((address) JvmtiExport::get_field_access_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(t0, target, offset); + __ auipc(t0, target, offset); __ lwu(x10, Address(t0, offset)); }); @@ -2682,7 +2682,7 @@ void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is ExternalAddress target((address)JvmtiExport::get_field_modification_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(t0, target, offset); + __ auipc(t0, target, offset); __ lwu(x10, Address(t0, offset)); }); __ beqz(x10, L1); @@ -2975,7 +2975,7 @@ void TemplateTable::jvmti_post_fast_field_mod() { ExternalAddress target((address)JvmtiExport::get_field_modification_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(t0, target, offset); + __ auipc(t0, target, offset); __ lwu(c_rarg3, Address(t0, offset)); }); __ beqz(c_rarg3, L2); @@ -3111,7 +3111,7 @@ void TemplateTable::fast_accessfield(TosState state) { ExternalAddress target((address)JvmtiExport::get_field_access_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; - __ la_patchable(t0, target, offset); + __ auipc(t0, target, offset); __ lwu(x12, Address(t0, offset)); }); __ beqz(x12, L1);