Skip to content

Commit 896b64e

Browse files
authored
Update (2022.09.14) (openjdk#4)
27793: reduce some CodeBuffer size 27659: Make in_scratch_emit_size a virtual method 27683: Method activation needs more stack words 27583: [C2] Remove reg_class no_Ax_reg and no_T8_reg 27627: Basic type should be 64-bit supported 27751: MacroAssembler::argument_address should not blows arg_slot 25965: Allow larger CodeEntryAlignment 27824: Remove redundant ld_ptr/st_ptr assembler 27898: libsaproc: Fix compile errors on upstream system
1 parent e45ae0f commit 896b64e

26 files changed

+510
-636
lines changed

src/hotspot/cpu/loongarch/abstractInterpreter_loongarch.cpp

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,44 @@
2929
#include "oops/klass.inline.hpp"
3030
#include "runtime/frame.inline.hpp"
3131

32+
int AbstractInterpreter::BasicType_as_index(BasicType type) {
33+
int i = 0;
34+
switch (type) {
35+
case T_BOOLEAN: i = 0; break;
36+
case T_CHAR : i = 1; break;
37+
case T_BYTE : i = 2; break;
38+
case T_SHORT : i = 3; break;
39+
case T_INT : i = 4; break;
40+
case T_LONG :
41+
case T_VOID :
42+
case T_FLOAT :
43+
case T_DOUBLE : i = 5; break;
44+
case T_OBJECT :
45+
case T_ARRAY : i = 6; break;
46+
default : ShouldNotReachHere();
47+
}
48+
assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
49+
"index out of bounds");
50+
return i;
51+
}
52+
53+
// How much stack a method activation needs in words.
54+
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
55+
const int entry_size = frame::interpreter_frame_monitor_size();
56+
57+
// total overhead size: entry_size + (saved fp thru expr stack
58+
// bottom). be sure to change this if you add/subtract anything
59+
// to/from the overhead area
60+
const int overhead_size =
61+
-(frame::interpreter_frame_initial_sp_offset) + entry_size;
62+
63+
const int stub_code = frame::entry_frame_after_call_words;
64+
assert(method != NULL, "invalid method");
65+
const int method_stack = (method->max_locals() + method->max_stack()) *
66+
Interpreter::stackElementWords;
67+
return (overhead_size + method_stack + stub_code);
68+
}
69+
3270
// asm based interpreter deoptimization helpers
3371
int AbstractInterpreter::size_activation(int max_stack,
3472
int temps,
@@ -55,22 +93,6 @@ int AbstractInterpreter::size_activation(int max_stack,
5593
return size;
5694
}
5795

58-
// How much stack a method activation needs in words.
59-
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
60-
61-
const int entry_size = frame::interpreter_frame_monitor_size();
62-
63-
// total overhead size: entry_size + (saved ebp thru expr stack bottom).
64-
// be sure to change this if you add/subtract anything to/from the overhead area
65-
const int overhead_size = -(frame::interpreter_frame_initial_sp_offset) + entry_size;
66-
67-
const int stub_code = 6; // see generate_call_stub
68-
// return overhead_size + method->max_locals() + method->max_stack() + stub_code;
69-
const int method_stack = (method->max_locals() + method->max_stack()) *
70-
Interpreter::stackElementWords;
71-
return overhead_size + method_stack + stub_code;
72-
}
73-
7496
void AbstractInterpreter::layout_activation(Method* method,
7597
int tempcount,
7698
int popframe_extra_args,

src/hotspot/cpu/loongarch/c1_CodeStubs_loongarch_64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) {
4444
__ bind(_entry);
4545
InternalAddress safepoint_pc(ce->masm()->pc() - ce->masm()->offset() + safepoint_offset());
4646
__ lea(SCR2, safepoint_pc);
47-
__ st_ptr(SCR2, TREG, in_bytes(JavaThread::saved_exception_pc_offset()));
47+
__ st_d(SCR2, Address(TREG, JavaThread::saved_exception_pc_offset()));
4848

4949
assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
5050
"polling page return stub not created yet");

src/hotspot/cpu/loongarch/c1_LIRAssembler_loongarch_64.cpp

Lines changed: 113 additions & 113 deletions
Large diffs are not rendered by default.

src/hotspot/cpu/loongarch/c1_MacroAssembler_loongarch_64.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
5858
verify_oop(obj);
5959

6060
// save object being locked into the BasicObjectLock
61-
st_ptr(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
61+
st_d(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
6262

6363
null_check_offset = offset();
6464

@@ -71,11 +71,11 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
7171
}
7272

7373
// Load object header
74-
ld_ptr(hdr, Address(obj, hdr_offset));
74+
ld_d(hdr, Address(obj, hdr_offset));
7575
// and mark it as unlocked
7676
ori(hdr, hdr, markWord::unlocked_value);
7777
// save unlocked object header into the displaced header location on the stack
78-
st_ptr(hdr, Address(disp_hdr, 0));
78+
st_d(hdr, Address(disp_hdr, 0));
7979
// test if object header is still the same (i.e. unlocked), and if so, store the
8080
// displaced header address in the object header - if it is not the same, get the
8181
// object header instead
@@ -100,7 +100,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
100100
andr(hdr, hdr, SCR1);
101101
// for recursive locking, the result is zero => save it in the displaced header
102102
// location (NULL in the displaced hdr location indicates recursive locking)
103-
st_ptr(hdr, Address(disp_hdr, 0));
103+
st_d(hdr, Address(disp_hdr, 0));
104104
// otherwise we don't care about the result and handle locking via runtime call
105105
bnez(hdr, slow_case);
106106
// done
@@ -116,12 +116,12 @@ void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_
116116
Label done;
117117

118118
// load displaced header
119-
ld_ptr(hdr, Address(disp_hdr, 0));
119+
ld_d(hdr, Address(disp_hdr, 0));
120120
// if the loaded hdr is NULL we had recursive locking
121121
// if we had recursive locking, we are done
122122
beqz(hdr, done);
123123
// load object
124-
ld_ptr(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
124+
ld_d(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
125125
verify_oop(obj);
126126
// test if object header is pointing to the displaced header, and if so, restore
127127
// the displaced header in the object - if the object header is not pointing to
@@ -155,13 +155,13 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register
155155
assert_different_registers(obj, klass, len);
156156
// This assumes that all prototype bits fit in an int32_t
157157
li(t1, (int32_t)(intptr_t)markWord::prototype().value());
158-
st_ptr(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
158+
st_d(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
159159

160160
if (UseCompressedClassPointers) { // Take care not to kill klass
161161
encode_klass_not_null(t1, klass);
162162
st_w(t1, Address(obj, oopDesc::klass_offset_in_bytes()));
163163
} else {
164-
st_ptr(klass, Address(obj, oopDesc::klass_offset_in_bytes()));
164+
st_d(klass, Address(obj, oopDesc::klass_offset_in_bytes()));
165165
}
166166

167167
if (len->is_valid()) {
@@ -312,7 +312,7 @@ void C1_MacroAssembler::load_parameter(int offset_in_words, Register reg) {
312312
// + 1: argument with offset 1
313313
// + 2: ...
314314

315-
ld_ptr(reg, Address(FP, offset_in_words * BytesPerWord));
315+
ld_d(reg, Address(FP, offset_in_words * BytesPerWord));
316316
}
317317

318318
#ifndef PRODUCT

src/hotspot/cpu/loongarch/c1_Runtime1_loongarch_64.cpp

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre
100100
// check for pending exceptions
101101
{ Label L;
102102
// check for pending exceptions (java_thread is set upon return)
103-
ld_ptr(SCR1, Address(TREG, in_bytes(Thread::pending_exception_offset())));
103+
ld_d(SCR1, Address(TREG, Thread::pending_exception_offset()));
104104
beqz(SCR1, L);
105105
// exception pending => remove activation and forward to exception handler
106106
// make sure that the vm_results are cleared
107107
if (oop_result1->is_valid()) {
108-
st_ptr(R0, Address(TREG, JavaThread::vm_result_offset()));
108+
st_d(R0, Address(TREG, JavaThread::vm_result_offset()));
109109
}
110110
if (metadata_result->is_valid()) {
111-
st_ptr(R0, Address(TREG, JavaThread::vm_result_2_offset()));
111+
st_d(R0, Address(TREG, JavaThread::vm_result_2_offset()));
112112
}
113113
if (frame_size() == no_frame_size) {
114114
leave();
@@ -161,12 +161,12 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result,
161161
arg2 == A1 || arg2 == A3 ||
162162
arg3 == A1 || arg3 == A2) {
163163
addi_d(SP, SP, -4 * wordSize);
164-
st_ptr(arg1, Address(SP, 0 * wordSize));
165-
st_ptr(arg2, Address(SP, 1 * wordSize));
166-
st_ptr(arg3, Address(SP, 2 * wordSize));
167-
ld_ptr(arg1, Address(SP, 0 * wordSize));
168-
ld_ptr(arg2, Address(SP, 1 * wordSize));
169-
ld_ptr(arg3, Address(SP, 2 * wordSize));
164+
st_d(arg1, Address(SP, 0 * wordSize));
165+
st_d(arg2, Address(SP, 1 * wordSize));
166+
st_d(arg3, Address(SP, 2 * wordSize));
167+
ld_d(arg1, Address(SP, 0 * wordSize));
168+
ld_d(arg2, Address(SP, 1 * wordSize));
169+
ld_d(arg3, Address(SP, 2 * wordSize));
170170
addi_d(SP, SP, 4 * wordSize);
171171
} else {
172172
move(A1, arg1);
@@ -294,7 +294,7 @@ static OopMap* save_live_registers(StubAssembler* sasm,
294294
__ addi_d(SP, SP, -(32 - 4 + 32) * wordSize);
295295

296296
for (int i = 4; i < 32; i++)
297-
__ st_ptr(as_Register(i), Address(SP, (32 + i - 4) * wordSize));
297+
__ st_d(as_Register(i), Address(SP, (32 + i - 4) * wordSize));
298298

299299
if (save_fpu_registers) {
300300
for (int i = 0; i < 32; i++)
@@ -311,7 +311,7 @@ static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registe
311311
}
312312

313313
for (int i = 4; i < 32; i++)
314-
__ ld_ptr(as_Register(i), Address(SP, (32 + i - 4) * wordSize));
314+
__ ld_d(as_Register(i), Address(SP, (32 + i - 4) * wordSize));
315315

316316
__ addi_d(SP, SP, (32 - 4 + 32) * wordSize);
317317
}
@@ -323,7 +323,7 @@ static void restore_live_registers_except_a0(StubAssembler* sasm, bool restore_f
323323
}
324324

325325
for (int i = 5; i < 32; i++)
326-
__ ld_ptr(as_Register(i), Address(SP, (32 + i - 4) * wordSize));
326+
__ ld_d(as_Register(i), Address(SP, (32 + i - 4) * wordSize));
327327

328328
__ addi_d(SP, SP, (32 - 4 + 32) * wordSize);
329329
}
@@ -387,15 +387,15 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) {
387387
oop_map = generate_oop_map(sasm, 1 /*thread*/);
388388

389389
// load and clear pending exception oop into A0
390-
__ ld_ptr(exception_oop, Address(TREG, Thread::pending_exception_offset()));
391-
__ st_ptr(R0, Address(TREG, Thread::pending_exception_offset()));
390+
__ ld_d(exception_oop, Address(TREG, Thread::pending_exception_offset()));
391+
__ st_d(R0, Address(TREG, Thread::pending_exception_offset()));
392392

393393
// load issuing PC (the return address for this stub) into A1
394-
__ ld_ptr(exception_pc, Address(FP, frame::return_addr_offset * BytesPerWord));
394+
__ ld_d(exception_pc, Address(FP, frame::return_addr_offset * BytesPerWord));
395395

396396
// make sure that the vm_results are cleared (may be unnecessary)
397-
__ st_ptr(R0, Address(TREG, JavaThread::vm_result_offset()));
398-
__ st_ptr(R0, Address(TREG, JavaThread::vm_result_2_offset()));
397+
__ st_d(R0, Address(TREG, JavaThread::vm_result_offset()));
398+
__ st_d(R0, Address(TREG, JavaThread::vm_result_2_offset()));
399399
break;
400400
case handle_exception_nofpu_id:
401401
case handle_exception_id:
@@ -422,25 +422,25 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) {
422422
// check that fields in JavaThread for exception oop and issuing pc are
423423
// empty before writing to them
424424
Label oop_empty;
425-
__ ld_ptr(SCR1, Address(TREG, JavaThread::exception_oop_offset()));
425+
__ ld_d(SCR1, Address(TREG, JavaThread::exception_oop_offset()));
426426
__ beqz(SCR1, oop_empty);
427427
__ stop("exception oop already set");
428428
__ bind(oop_empty);
429429

430430
Label pc_empty;
431-
__ ld_ptr(SCR1, Address(TREG, JavaThread::exception_pc_offset()));
431+
__ ld_d(SCR1, Address(TREG, JavaThread::exception_pc_offset()));
432432
__ beqz(SCR1, pc_empty);
433433
__ stop("exception pc already set");
434434
__ bind(pc_empty);
435435
#endif
436436

437437
// save exception oop and issuing pc into JavaThread
438438
// (exception handler will load it from here)
439-
__ st_ptr(exception_oop, Address(TREG, JavaThread::exception_oop_offset()));
440-
__ st_ptr(exception_pc, Address(TREG, JavaThread::exception_pc_offset()));
439+
__ st_d(exception_oop, Address(TREG, JavaThread::exception_oop_offset()));
440+
__ st_d(exception_pc, Address(TREG, JavaThread::exception_pc_offset()));
441441

442442
// patch throwing pc into return address (has bci & oop map)
443-
__ st_ptr(exception_pc, Address(FP, frame::return_addr_offset * BytesPerWord));
443+
__ st_d(exception_pc, Address(FP, frame::return_addr_offset * BytesPerWord));
444444

445445
// compute the exception handler.
446446
// the exception oop and the throwing pc are read from the fields in JavaThread
@@ -455,7 +455,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) {
455455
__ invalidate_registers(false, true, true, true, true, true);
456456

457457
// patch the return address, this stub will directly return to the exception handler
458-
__ st_ptr(A0, Address(FP, frame::return_addr_offset * BytesPerWord));
458+
__ st_d(A0, Address(FP, frame::return_addr_offset * BytesPerWord));
459459

460460
switch (id) {
461461
case forward_exception_id:
@@ -487,13 +487,13 @@ void Runtime1::generate_unwind_exception(StubAssembler *sasm) {
487487
#ifdef ASSERT
488488
// check that fields in JavaThread for exception oop and issuing pc are empty
489489
Label oop_empty;
490-
__ ld_ptr(SCR1, Address(TREG, JavaThread::exception_oop_offset()));
490+
__ ld_d(SCR1, Address(TREG, JavaThread::exception_oop_offset()));
491491
__ beqz(SCR1, oop_empty);
492492
__ stop("exception oop must be empty");
493493
__ bind(oop_empty);
494494

495495
Label pc_empty;
496-
__ ld_ptr(SCR1, Address(TREG, JavaThread::exception_pc_offset()));
496+
__ ld_d(SCR1, Address(TREG, JavaThread::exception_pc_offset()));
497497
__ beqz(SCR1, pc_empty);
498498
__ stop("exception pc must be empty");
499499
__ bind(pc_empty);
@@ -503,8 +503,8 @@ void Runtime1::generate_unwind_exception(StubAssembler *sasm) {
503503
// exception_handler_for_return_address will destroy it. We also
504504
// save exception_oop
505505
__ addi_d(SP, SP, -2 * wordSize);
506-
__ st_ptr(RA, Address(SP, 0 * wordSize));
507-
__ st_ptr(exception_oop, Address(SP, 1 * wordSize));
506+
__ st_d(RA, Address(SP, 0 * wordSize));
507+
__ st_d(exception_oop, Address(SP, 1 * wordSize));
508508

509509
// search the exception handler address of the caller (using the return address)
510510
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), TREG, RA);
@@ -519,8 +519,8 @@ void Runtime1::generate_unwind_exception(StubAssembler *sasm) {
519519

520520
// get throwing pc (= return address).
521521
// RA has been destroyed by the call
522-
__ ld_ptr(RA, Address(SP, 0 * wordSize));
523-
__ ld_ptr(exception_oop, Address(SP, 1 * wordSize));
522+
__ ld_d(RA, Address(SP, 0 * wordSize));
523+
__ ld_d(exception_oop, Address(SP, 1 * wordSize));
524524
__ addi_d(SP, SP, 2 * wordSize);
525525
__ move(A1, RA);
526526

@@ -571,13 +571,13 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) {
571571
#ifdef ASSERT
572572
// check that fields in JavaThread for exception oop and issuing pc are empty
573573
Label oop_empty;
574-
__ ld_ptr(SCR1, Address(TREG, Thread::pending_exception_offset()));
574+
__ ld_d(SCR1, Address(TREG, Thread::pending_exception_offset()));
575575
__ beqz(SCR1, oop_empty);
576576
__ stop("exception oop must be empty");
577577
__ bind(oop_empty);
578578

579579
Label pc_empty;
580-
__ ld_ptr(SCR1, Address(TREG, JavaThread::exception_pc_offset()));
580+
__ ld_d(SCR1, Address(TREG, JavaThread::exception_pc_offset()));
581581
__ beqz(SCR1, pc_empty);
582582
__ stop("exception pc must be empty");
583583
__ bind(pc_empty);
@@ -828,34 +828,34 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
828828

829829
__ set_info("slow_subtype_check", dont_gc_arguments);
830830
__ addi_d(SP, SP, -4 * wordSize);
831-
__ st_ptr(A0, Address(SP, a0_off * VMRegImpl::stack_slot_size));
832-
__ st_ptr(A2, Address(SP, a2_off * VMRegImpl::stack_slot_size));
833-
__ st_ptr(A4, Address(SP, a4_off * VMRegImpl::stack_slot_size));
834-
__ st_ptr(A5, Address(SP, a5_off * VMRegImpl::stack_slot_size));
831+
__ st_d(A0, Address(SP, a0_off * VMRegImpl::stack_slot_size));
832+
__ st_d(A2, Address(SP, a2_off * VMRegImpl::stack_slot_size));
833+
__ st_d(A4, Address(SP, a4_off * VMRegImpl::stack_slot_size));
834+
__ st_d(A5, Address(SP, a5_off * VMRegImpl::stack_slot_size));
835835

836836
// This is called by pushing args and not with C abi
837-
__ ld_ptr(A4, Address(SP, klass_off * VMRegImpl::stack_slot_size)); // subclass
838-
__ ld_ptr(A0, Address(SP, sup_k_off * VMRegImpl::stack_slot_size)); // superclass
837+
__ ld_d(A4, Address(SP, klass_off * VMRegImpl::stack_slot_size)); // subclass
838+
__ ld_d(A0, Address(SP, sup_k_off * VMRegImpl::stack_slot_size)); // superclass
839839

840840
Label miss;
841841
__ check_klass_subtype_slow_path<false>(A4, A0, A2, A5, NULL, &miss);
842842

843843
// fallthrough on success:
844844
__ li(SCR1, 1);
845-
__ st_ptr(SCR1, Address(SP, result_off * VMRegImpl::stack_slot_size)); // result
846-
__ ld_ptr(A0, Address(SP, a0_off * VMRegImpl::stack_slot_size));
847-
__ ld_ptr(A2, Address(SP, a2_off * VMRegImpl::stack_slot_size));
848-
__ ld_ptr(A4, Address(SP, a4_off * VMRegImpl::stack_slot_size));
849-
__ ld_ptr(A5, Address(SP, a5_off * VMRegImpl::stack_slot_size));
845+
__ st_d(SCR1, Address(SP, result_off * VMRegImpl::stack_slot_size)); // result
846+
__ ld_d(A0, Address(SP, a0_off * VMRegImpl::stack_slot_size));
847+
__ ld_d(A2, Address(SP, a2_off * VMRegImpl::stack_slot_size));
848+
__ ld_d(A4, Address(SP, a4_off * VMRegImpl::stack_slot_size));
849+
__ ld_d(A5, Address(SP, a5_off * VMRegImpl::stack_slot_size));
850850
__ addi_d(SP, SP, 4 * wordSize);
851851
__ jr(RA);
852852

853853
__ bind(miss);
854-
__ st_ptr(R0, Address(SP, result_off * VMRegImpl::stack_slot_size)); // result
855-
__ ld_ptr(A0, Address(SP, a0_off * VMRegImpl::stack_slot_size));
856-
__ ld_ptr(A2, Address(SP, a2_off * VMRegImpl::stack_slot_size));
857-
__ ld_ptr(A4, Address(SP, a4_off * VMRegImpl::stack_slot_size));
858-
__ ld_ptr(A5, Address(SP, a5_off * VMRegImpl::stack_slot_size));
854+
__ st_d(R0, Address(SP, result_off * VMRegImpl::stack_slot_size)); // result
855+
__ ld_d(A0, Address(SP, a0_off * VMRegImpl::stack_slot_size));
856+
__ ld_d(A2, Address(SP, a2_off * VMRegImpl::stack_slot_size));
857+
__ ld_d(A4, Address(SP, a4_off * VMRegImpl::stack_slot_size));
858+
__ ld_d(A5, Address(SP, a5_off * VMRegImpl::stack_slot_size));
859859
__ addi_d(SP, SP, 4 * wordSize);
860860
__ jr(RA);
861861
}

0 commit comments

Comments
 (0)