Skip to content

Commit

Permalink
All but one case fixed for jump
Browse files Browse the repository at this point in the history
  • Loading branch information
robehn committed Feb 21, 2024
1 parent a28bb54 commit 338e901
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
22 changes: 22 additions & 0 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1862,21 +1862,21 @@ 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);
__ bnez(t0, L_copy_longs);
__ 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
Expand All @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 338e901

Please sign in to comment.