Skip to content

Commit aec3865

Browse files
feilongjiangRealFYang
andcommittedDec 5, 2023
8320697: RISC-V: Small refactoring for runtime calls
Co-authored-by: Fei Yang <fyang@openjdk.org> Reviewed-by: fyang, rehn
1 parent 50d1839 commit aec3865

15 files changed

+116
-227
lines changed
 

‎src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
4-
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
4+
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
77
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) {
4444
InternalAddress safepoint_pc(__ pc() - __ offset() + safepoint_offset());
4545
__ relocate(safepoint_pc.rspec(), [&] {
4646
int32_t offset;
47-
__ la_patchable(t0, safepoint_pc.target(), offset);
47+
__ la(t0, safepoint_pc.target(), offset);
4848
__ addi(t0, t0, offset);
4949
});
5050
__ sd(t0, Address(xthread, JavaThread::saved_exception_pc_offset()));
@@ -92,12 +92,9 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) {
9292
__ mv(t1, _array->as_pointer_register());
9393
stub_id = Runtime1::throw_range_check_failed_id;
9494
}
95-
RuntimeAddress target(Runtime1::entry_for(stub_id));
96-
__ relocate(target.rspec(), [&] {
97-
int32_t offset;
98-
__ la_patchable(ra, target, offset);
99-
__ jalr(ra, ra, offset);
100-
});
95+
// t0 and t1 are used as args in generate_exception_throw,
96+
// so use ra as the tmp register for rt_call.
97+
__ rt_call(Runtime1::entry_for(stub_id), ra);
10198
ce->add_call_info_here(_info);
10299
ce->verify_oop_map(_info);
103100
debug_only(__ should_not_reach_here());

‎src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit
14251425
InternalAddress pc_for_athrow(__ pc());
14261426
__ relocate(pc_for_athrow.rspec(), [&] {
14271427
int32_t offset;
1428-
__ la_patchable(exceptionPC->as_register(), pc_for_athrow, offset);
1428+
__ la(exceptionPC->as_register(), pc_for_athrow.target(), offset);
14291429
__ addi(exceptionPC->as_register(), exceptionPC->as_register(), offset);
14301430
});
14311431
add_call_info(pc_for_athrow_offset, info); // for exception handler
@@ -1868,7 +1868,7 @@ void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* arg
18681868
RuntimeAddress target(dest);
18691869
__ relocate(target.rspec(), [&] {
18701870
int32_t offset;
1871-
__ la_patchable(t0, target, offset);
1871+
__ movptr(t0, target.target(), offset);
18721872
__ jalr(x1, t0, offset);
18731873
});
18741874
}

‎src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
4-
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
4+
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
77
* This code is free software; you can redistribute it and/or modify it
@@ -67,12 +67,7 @@ int StubAssembler::call_RT(Register oop_result, Register metadata_result, addres
6767
set_last_Java_frame(sp, fp, retaddr, t0);
6868

6969
// do the call
70-
RuntimeAddress target(entry);
71-
relocate(target.rspec(), [&] {
72-
int32_t offset;
73-
la_patchable(t0, target, offset);
74-
jalr(x1, t0, offset);
75-
});
70+
rt_call(entry);
7671
bind(retaddr);
7772
int call_offset = offset();
7873
// verify callee-saved register
@@ -578,12 +573,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) {
578573
Label retaddr;
579574
__ set_last_Java_frame(sp, fp, retaddr, t0);
580575
// do the call
581-
RuntimeAddress addr(target);
582-
__ relocate(addr.rspec(), [&] {
583-
int32_t offset;
584-
__ la_patchable(t0, addr, offset);
585-
__ jalr(x1, t0, offset);
586-
});
576+
__ rt_call(target);
587577
__ bind(retaddr);
588578
OopMapSet* oop_maps = new OopMapSet();
589579
assert_cond(oop_maps != nullptr);

‎src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
3+
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@ void C2SafepointPollStub::emit(C2_MacroAssembler& masm) {
4646
InternalAddress safepoint_pc(__ pc() - __ offset() + _safepoint_offset);
4747
__ relocate(safepoint_pc.rspec(), [&] {
4848
int32_t offset;
49-
__ la_patchable(t0, safepoint_pc.target(), offset);
49+
__ la(t0, safepoint_pc.target(), offset);
5050
__ addi(t0, t0, offset);
5151
});
5252
__ sd(t0, Address(xthread, JavaThread::saved_exception_pc_offset()));
@@ -60,12 +60,7 @@ int C2EntryBarrierStub::max_size() const {
6060

6161
void C2EntryBarrierStub::emit(C2_MacroAssembler& masm) {
6262
__ bind(entry());
63-
RuntimeAddress target(StubRoutines::method_entry_barrier());
64-
__ relocate(target.rspec(), [&] {
65-
int32_t offset;
66-
__ la_patchable(t0, target, offset);
67-
__ jalr(ra, t0, offset);
68-
});
63+
__ rt_call(StubRoutines::method_entry_barrier());
6964

7065
__ j(continuation());
7166

‎src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
3+
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -187,7 +187,6 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
187187

188188
BarrierSet* bs = BarrierSet::barrier_set();
189189
CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
190-
CardTable* ct = ctbs->card_table();
191190

192191
Label done;
193192
Label runtime;
@@ -204,7 +203,6 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
204203

205204
// storing region crossing non-null, is card already dirty?
206205

207-
ExternalAddress cardtable((address) ct->byte_map_base());
208206
const Register card_addr = tmp1;
209207

210208
__ srli(card_addr, store_addr, CardTable::card_shift());
@@ -410,7 +408,6 @@ void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler*
410408

411409
BarrierSet* bs = BarrierSet::barrier_set();
412410
CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
413-
CardTable* ct = ctbs->card_table();
414411

415412
Label done;
416413
Label runtime;

‎src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,7 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm, Label* slo
308308
Label skip_barrier;
309309
__ beq(t0, t1, skip_barrier);
310310

311-
RuntimeAddress target(StubRoutines::method_entry_barrier());
312-
__ relocate(target.rspec(), [&] {
313-
int32_t offset;
314-
__ la_patchable(t0, target, offset);
315-
__ jalr(ra, t0, offset);
316-
});
311+
__ rt_call(StubRoutines::method_entry_barrier());
317312

318313
__ j(skip_barrier);
319314

‎src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
3+
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -339,12 +339,8 @@ void XBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, X
339339
XSaveLiveRegisters save_live_registers(masm, stub);
340340
XSetupArguments setup_arguments(masm, stub);
341341

342-
Address target(stub->slow_path());
343-
__ relocate(target.rspec(), [&] {
344-
int32_t offset;
345-
__ la_patchable(t0, target, offset);
346-
__ jalr(x1, t0, offset);
347-
});
342+
__ mv(t0, stub->slow_path());
343+
__ jalr(t0);
348344
}
349345

350346
// Stub exit

‎src/hotspot/cpu/riscv/icBuffer_riscv.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
4-
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
4+
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
77
* This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,7 @@
3636

3737
int InlineCacheBuffer::ic_stub_code_size() {
3838
// 6: auipc + ld + auipc + jalr + address(2 * instruction_size)
39-
// 5: auipc + ld + j + address(2 * instruction_size)
40-
return (MacroAssembler::far_branches() ? 6 : 5) * NativeInstruction::instruction_size;
39+
return 6 * NativeInstruction::instruction_size;
4140
}
4241

4342
#define __ masm->

‎src/hotspot/cpu/riscv/interp_masm_riscv.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
4-
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
4+
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
77
* This code is free software; you can redistribute it and/or modify it
@@ -194,7 +194,7 @@ void InterpreterMacroAssembler::get_dispatch() {
194194
ExternalAddress target((address)Interpreter::dispatch_table());
195195
relocate(target.rspec(), [&] {
196196
int32_t offset;
197-
la_patchable(xdispatch, target, offset);
197+
la(xdispatch, target.target(), offset);
198198
addi(xdispatch, xdispatch, offset);
199199
});
200200
}

‎src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
4-
* Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved.
4+
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
77
* This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,7 @@ address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
7676
Address target(SafepointSynchronize::safepoint_counter_addr());
7777
__ relocate(target.rspec(), [&] {
7878
int32_t offset;
79-
__ la_patchable(rcounter_addr, target, offset);
79+
__ la(rcounter_addr, target.target(), offset);
8080
__ addi(rcounter_addr, rcounter_addr, offset);
8181
});
8282

@@ -96,7 +96,7 @@ address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
9696
ExternalAddress target((address) JvmtiExport::get_field_access_count_addr());
9797
__ relocate(target.rspec(), [&] {
9898
int32_t offset;
99-
__ la_patchable(result, target, offset);
99+
__ la(result, target.target(), offset);
100100
__ lwu(result, Address(result, offset));
101101
});
102102
__ bnez(result, slow);
@@ -176,7 +176,7 @@ address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
176176
ExternalAddress target(slow_case_addr);
177177
__ relocate(target.rspec(), [&] {
178178
int32_t offset;
179-
__ la_patchable(t0, target, offset);
179+
__ la(t0, target.target(), offset);
180180
__ jalr(x1, t0, offset);
181181
});
182182
__ leave();

0 commit comments

Comments
 (0)
Please sign in to comment.