From 338e901fdc95bd60be1ff87a7e5584ca578d8b9d Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Wed, 21 Feb 2024 15:42:53 +0100 Subject: [PATCH] All but one case fixed for jump --- .../cpu/riscv/macroAssembler_riscv.cpp | 22 +++++++++++++++++++ .../cpu/riscv/macroAssembler_riscv.hpp | 2 +- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 20 ++++++++--------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index f3e7d8b658216..fc0177bc71255 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -939,6 +939,28 @@ void MacroAssembler::jump_label(Label &lab, Register temp) { } } +void MacroAssembler::jump(const Address &adr, Register temp) { + switch (adr.getMode()) { + case Address::literal: { + relocate(adr.rspec(), [&] { + jump_codecache(adr.target(), temp); + }); + break; + } + case Address::base_plus_offset: { +// Address new_adr = legitimize_address(Rd, adr); + int32_t offset = ((int32_t)adr.offset() << 20) >> 20; + la(temp, Address(adr.base(), adr.offset() - offset)); +// bool mustbe = la_relative(temp, Address(adr.base(), adr.offset() - offset)); +// assert(mustbe, "Must be"); + Assembler::jalr(x0, temp, offset); + break; + } + default: + ShouldNotReachHere(); + } +} + void MacroAssembler::wrap_label(Register Rt, Label &L, Register tmp, load_insn_by_temp insn) { if (L.is_bound()) { (this->*insn)(Rt, target(L), tmp); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 214bbc3ecd603..95da2fc2b4fb5 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -597,7 +597,7 @@ class MacroAssembler: public Assembler { void jump_codecache(const address dest, Register temp = t0); void jump_label(Label &l, Register temp = t0); - void j(const Address &adr, Register temp = t0) { jump_link_relocate(adr, x0, temp); }; + void jump(const Address &adr, Register temp = t0); void call(const address dest, Register temp = t0) { assert_cond(dest != nullptr); diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 88a13d01ee123..bec2a467ef92e 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -1671,17 +1671,17 @@ class StubGenerator: public StubCodeGenerator { __ beqz(t0, L_int_aligned); __ test_bit(t0, t0, 0); __ beqz(t0, L_short_aligned); - __ j(RuntimeAddress(byte_copy_entry)); + __ jump(RuntimeAddress(byte_copy_entry)); __ BIND(L_short_aligned); __ srli(count, count, LogBytesPerShort); // size => short_count - __ j(RuntimeAddress(short_copy_entry)); + __ jump(RuntimeAddress(short_copy_entry)); __ BIND(L_int_aligned); __ srli(count, count, LogBytesPerInt); // size => int_count - __ j(RuntimeAddress(int_copy_entry)); + __ jump(RuntimeAddress(int_copy_entry)); __ BIND(L_long_aligned); __ srli(count, count, LogBytesPerLong); // size => long_count - __ j(RuntimeAddress(long_copy_entry)); + __ jump(RuntimeAddress(long_copy_entry)); return start; } @@ -1862,13 +1862,13 @@ class StubGenerator: public StubCodeGenerator { __ add(from, src, src_pos); // src_addr __ add(to, dst, dst_pos); // dst_addr __ sign_extend(count, scratch_length, 32); // length - __ j(RuntimeAddress(byte_copy_entry)); + __ jump(RuntimeAddress(byte_copy_entry)); __ BIND(L_copy_shorts); __ shadd(from, src_pos, src, t0, 1); // src_addr __ shadd(to, dst_pos, dst, t0, 1); // dst_addr __ sign_extend(count, scratch_length, 32); // length - __ j(RuntimeAddress(short_copy_entry)); + __ jump(RuntimeAddress(short_copy_entry)); __ BIND(L_copy_ints); __ test_bit(t0, x30_elsize, 0); @@ -1876,7 +1876,7 @@ class StubGenerator: public StubCodeGenerator { __ shadd(from, src_pos, src, t0, 2); // src_addr __ shadd(to, dst_pos, dst, t0, 2); // dst_addr __ sign_extend(count, scratch_length, 32); // length - __ j(RuntimeAddress(int_copy_entry)); + __ jump(RuntimeAddress(int_copy_entry)); __ BIND(L_copy_longs); #ifdef ASSERT @@ -1895,7 +1895,7 @@ class StubGenerator: public StubCodeGenerator { __ shadd(from, src_pos, src, t0, 3); // src_addr __ shadd(to, dst_pos, dst, t0, 3); // dst_addr __ sign_extend(count, scratch_length, 32); // length - __ j(RuntimeAddress(long_copy_entry)); + __ jump(RuntimeAddress(long_copy_entry)); // ObjArrayKlass __ BIND(L_objArray); @@ -1916,7 +1916,7 @@ class StubGenerator: public StubCodeGenerator { __ add(to, to, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); __ sign_extend(count, scratch_length, 32); // length __ BIND(L_plain_copy); - __ j(RuntimeAddress(oop_copy_entry)); + __ jump(RuntimeAddress(oop_copy_entry)); __ BIND(L_checkcast_copy); // live at this point: scratch_src_klass, scratch_length, t2 (dst_klass) @@ -1958,7 +1958,7 @@ class StubGenerator: public StubCodeGenerator { assert(c_rarg3 == sco_temp, "#3 already in place"); // Set up arguments for checkcast_copy_entry. __ mv(c_rarg4, dst_klass); // dst.klass.element_klass - __ j(RuntimeAddress(checkcast_copy_entry)); + __ jump(RuntimeAddress(checkcast_copy_entry)); } __ BIND(L_failed);