Skip to content

Commit

Permalink
8342882: RISC-V: Unify handling of jumps to runtime
Browse files Browse the repository at this point in the history
Reviewed-by: rehn
  • Loading branch information
RealFYang committed Oct 24, 2024
1 parent 2c31c8e commit 85774b7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 29 deletions.
9 changes: 4 additions & 5 deletions src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 10 additions & 14 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
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 @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/cpu/riscv/templateTable_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()));
}

//-----------------------------------------------------------------------------
Expand Down

0 comments on commit 85774b7

Please sign in to comment.