Skip to content

Commit

Permalink
8293524: RISC-V: Use macro-assembler functions as appropriate
Browse files Browse the repository at this point in the history
Reviewed-by: shade, fjiang
  • Loading branch information
RealFYang committed Sep 9, 2022
1 parent 14eb5ad commit 43e191d
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 78 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp
Expand Up @@ -95,14 +95,14 @@ void LIR_Assembler::arraycopy_simple_check(Register src, Register src_pos, Regis
if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) {
__ load_klass(tmp, dst);
__ lw(t0, Address(tmp, in_bytes(Klass::layout_helper_offset())));
__ li(t1, Klass::_lh_neutral_value);
__ mv(t1, Klass::_lh_neutral_value);
__ bge(t0, t1, *stub->entry(), /* is_far */ true);
}

if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) {
__ load_klass(tmp, src);
__ lw(t0, Address(tmp, in_bytes(Klass::layout_helper_offset())));
__ li(t1, Klass::_lh_neutral_value);
__ mv(t1, Klass::_lh_neutral_value);
__ bge(t0, t1, *stub->entry(), /* is_far */ true);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
Expand Up @@ -1069,7 +1069,7 @@ void LIR_Assembler::type_profile_helper(Register mdo, ciMethodData *md, ciProfil
__ ld(t1, recv_addr);
__ bnez(t1, next_test);
__ sd(recv, recv_addr);
__ li(t1, DataLayout::counter_increment);
__ mv(t1, DataLayout::counter_increment);
__ sd(t1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))));
__ j(*update_done);
__ bind(next_test);
Expand Down Expand Up @@ -1634,7 +1634,7 @@ void LIR_Assembler::check_conflict(ciKlass* exact_klass, intptr_t current_klass,

if (TypeEntries::is_type_none(current_klass)) {
__ beqz(t1, none);
__ li(t0, (u1)TypeEntries::null_seen);
__ mv(t0, (u1)TypeEntries::null_seen);
__ beq(t0, t1, none);
// There is a chance that the checks above (re-reading profiling
// data from memory) fail if another thread has just set the
Expand Down Expand Up @@ -1684,7 +1684,7 @@ void LIR_Assembler::check_no_conflict(ciKlass* exact_klass, intptr_t current_kla
Label ok;
__ ld(t0, mdo_addr);
__ beqz(t0, ok);
__ li(t1, (u1)TypeEntries::null_seen);
__ mv(t1, (u1)TypeEntries::null_seen);
__ beq(t0, t1, ok);
// may have been set by another thread
__ membar(MacroAssembler::LoadLoad);
Expand Down Expand Up @@ -2250,7 +2250,7 @@ void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
__ li(t0, c);
__ mv(t0, c);
__ sd(t0, Address(sp, offset_from_rsp_in_bytes));
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp
Expand Up @@ -97,7 +97,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
// assuming both the stack pointer and page_size have their least
// significant 2 bits cleared and page_size is a power of 2
sub(hdr, hdr, sp);
li(t0, aligned_mask - os::vm_page_size());
mv(t0, aligned_mask - os::vm_page_size());
andr(hdr, hdr, t0);
// for recursive locking, the result is zero => save it in the displaced header
// location (NULL in the displaced hdr location indicates recursive locking)
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp
Expand Up @@ -861,7 +861,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
__ check_klass_subtype_slow_path(x14, x10, x12, x15, NULL, &miss);

// fallthrough on success:
__ li(t0, 1);
__ mv(t0, 1);
__ sd(t0, Address(sp, (result_off) * VMRegImpl::stack_slot_size)); // result
__ pop_reg(RegSet::of(x10, x12, x14, x15), sp);
__ ret();
Expand Down Expand Up @@ -1051,7 +1051,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
default:
{
StubFrame f(sasm, "unimplemented entry", dont_gc_arguments, does_not_return);
__ li(x10, (int) id);
__ mv(x10, (int)id);
__ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), x10);
__ should_not_reach_here();
}
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp
Expand Up @@ -845,7 +845,7 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2,
bind(L);

// A very short string
li(t0, minCharsInWord);
mv(t0, minCharsInWord);
ble(cnt2, t0, SHORT_STRING);

// Compare longwords
Expand All @@ -856,7 +856,7 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2,
ld(tmp1, Address(str1));
beq(str1, str2, DONE);
ld(tmp2, Address(str2));
li(t0, STUB_THRESHOLD);
mv(t0, STUB_THRESHOLD);
bge(cnt2, t0, STUB);
sub(cnt2, cnt2, minCharsInWord);
beqz(cnt2, TAIL_CHECK);
Expand All @@ -870,7 +870,7 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2,
} else if (isLU) { // LU case
lwu(tmp1, Address(str1));
ld(tmp2, Address(str2));
li(t0, STUB_THRESHOLD);
mv(t0, STUB_THRESHOLD);
bge(cnt2, t0, STUB);
addi(cnt2, cnt2, -4);
add(str1, str1, cnt2);
Expand All @@ -884,7 +884,7 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2,
} else { // UL case
ld(tmp1, Address(str1));
lwu(tmp2, Address(str2));
li(t0, STUB_THRESHOLD);
mv(t0, STUB_THRESHOLD);
bge(cnt2, t0, STUB);
addi(cnt2, cnt2, -4);
slli(t0, cnt2, 1);
Expand Down Expand Up @@ -1060,7 +1060,7 @@ void C2_MacroAssembler::arrays_equals(Register a1, Register a2, Register tmp3,

assert(elem_size == 1 || elem_size == 2, "must be char or byte");
assert_different_registers(a1, a2, result, cnt1, t0, t1, tmp3, tmp4, tmp5, tmp6);
li(elem_per_word, wordSize / elem_size);
mv(elem_per_word, wordSize / elem_size);

BLOCK_COMMENT("arrays_equals {");

Expand Down
Expand Up @@ -522,7 +522,7 @@ void ShenandoahBarrierSetAssembler::cmpxchg_oop(MacroAssembler* masm,
if (is_cae) {
__ mv(result, expected);
} else {
__ addi(result, zr, 1);
__ mv(result, 1);
}
__ j(done);

Expand Down
30 changes: 15 additions & 15 deletions src/hotspot/cpu/riscv/interp_masm_riscv.cpp
Expand Up @@ -524,7 +524,7 @@ void InterpreterMacroAssembler::dispatch_base(TosState state,
bnez(t1, safepoint);
}
if (table == Interpreter::dispatch_table(state)) {
li(t1, Interpreter::distance_from_dispatch_table(state));
mv(t1, Interpreter::distance_from_dispatch_table(state));
add(t1, Rs, t1);
shadd(t1, t1, xdispatch, t1, 3);
} else {
Expand Down Expand Up @@ -828,7 +828,7 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg)
// least significant 3 bits clear.
// NOTE: the oopMark is in swap_reg x10 as the result of cmpxchg
sub(swap_reg, swap_reg, sp);
li(t0, (int64_t)(7 - os::vm_page_size()));
mv(t0, (int64_t)(7 - os::vm_page_size()));
andr(swap_reg, swap_reg, t0);

// Save the test result, for recursive case, the result is zero
Expand Down Expand Up @@ -1666,7 +1666,7 @@ void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& md

ld(t0, mdo_addr);
beqz(t0, none);
li(tmp, (u1)TypeEntries::null_seen);
mv(tmp, (u1)TypeEntries::null_seen);
beq(t0, tmp, none);
// There is a chance that the checks above (re-reading profiling
// data from memory) fail if another thread has just set the
Expand Down Expand Up @@ -1701,10 +1701,10 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca

lbu(t0, Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start));
if (is_virtual) {
li(tmp, (u1)DataLayout::virtual_call_type_data_tag);
mv(tmp, (u1)DataLayout::virtual_call_type_data_tag);
bne(t0, tmp, profile_continue);
} else {
li(tmp, (u1)DataLayout::call_type_data_tag);
mv(tmp, (u1)DataLayout::call_type_data_tag);
bne(t0, tmp, profile_continue);
}

Expand Down Expand Up @@ -1734,15 +1734,15 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca
mv(index, zr); // index < TypeProfileArgsLimit
bind(loop);
bgtz(index, profileReturnType);
li(t0, (int)MethodData::profile_return());
mv(t0, (int)MethodData::profile_return());
beqz(t0, profileArgument); // (index > 0 || MethodData::profile_return()) == false
bind(profileReturnType);
// If return value type is profiled we may have no argument to profile
ld(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
mv(t1, - TypeStackSlotEntries::per_arg_count());
mul(t1, index, t1);
add(tmp, tmp, t1);
li(t1, TypeStackSlotEntries::per_arg_count());
mv(t1, TypeStackSlotEntries::per_arg_count());
add(t0, mdp, off_to_args);
blt(tmp, t1, done);

Expand All @@ -1753,8 +1753,8 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca
// stack offset o (zero based) from the start of the argument
// list, for n arguments translates into offset n - o - 1 from
// the end of the argument list
li(t0, stack_slot_offset0);
li(t1, slot_step);
mv(t0, stack_slot_offset0);
mv(t1, slot_step);
mul(t1, index, t1);
add(t0, t0, t1);
add(t0, mdp, t0);
Expand All @@ -1764,8 +1764,8 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca
Address arg_addr = argument_address(tmp);
ld(tmp, arg_addr);

li(t0, argument_type_offset0);
li(t1, type_step);
mv(t0, argument_type_offset0);
mv(t1, type_step);
mul(t1, index, t1);
add(t0, t0, t1);
add(mdo_addr, mdp, t0);
Expand All @@ -1777,7 +1777,7 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca

// increment index by 1
addi(index, index, 1);
li(t1, TypeProfileArgsLimit);
mv(t1, TypeProfileArgsLimit);
blt(index, t1, loop);
bind(loopEnd);

Expand Down Expand Up @@ -1832,13 +1832,13 @@ void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret,
// length
Label do_profile;
lbu(t0, Address(xbcp, 0));
li(tmp, (u1)Bytecodes::_invokedynamic);
mv(tmp, (u1)Bytecodes::_invokedynamic);
beq(t0, tmp, do_profile);
li(tmp, (u1)Bytecodes::_invokehandle);
mv(tmp, (u1)Bytecodes::_invokehandle);
beq(t0, tmp, do_profile);
get_method(tmp);
lhu(t0, Address(tmp, Method::intrinsic_id_offset_in_bytes()));
li(t1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
mv(t1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
bne(t0, t1, profile_continue);
bind(do_profile);
}
Expand Down

1 comment on commit 43e191d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.