Skip to content

Commit 4d10bd7

Browse files
authored
Update (2023.07.03, 2nd)
31295: Provide information when hitting a HaltNode 30973: serviceability/jvmti/events/FramePop/framepop02/framepop02.java crash with -Xcomp 25064: Enable NUMA Mode on LoongArch by Default 31006: Fix VectorInsert
1 parent d846929 commit 4d10bd7

16 files changed

+643
-41
lines changed

src/hotspot/cpu/loongarch/assembler_loongarch.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,7 @@ class Assembler : public AbstractAssembler {
12891289
stptr_w_op = 0b00100101,
12901290
ldptr_d_op = 0b00100110,
12911291
stptr_d_op = 0b00100111,
1292+
csr_op = 0b00000100,
12921293

12931294
unknow_ops8 = 0b11111111
12941295
};
@@ -2024,6 +2025,8 @@ class Assembler : public AbstractAssembler {
20242025
void stptr_w (Register rd, Register rj, int si16) { assert(is_simm(si16, 16) && ((si16 & 0x3) == 0), "not a signed 16-bit int"); emit_int32(insn_I14RR(stptr_w_op, si16>>2, (int)rj->encoding(), (int)rd->encoding())); }
20252026
void ldptr_d (Register rd, Register rj, int si16) { assert(is_simm(si16, 16) && ((si16 & 0x3) == 0), "not a signed 16-bit int"); emit_int32(insn_I14RR(ldptr_d_op, si16>>2, (int)rj->encoding(), (int)rd->encoding())); }
20262027
void stptr_d (Register rd, Register rj, int si16) { assert(is_simm(si16, 16) && ((si16 & 0x3) == 0), "not a signed 16-bit int"); emit_int32(insn_I14RR(stptr_d_op, si16>>2, (int)rj->encoding(), (int)rd->encoding())); }
2028+
void csrrd (Register rd, int csr) { emit_int32(insn_I14RR(csr_op, csr, 0, (int)rd->encoding())); }
2029+
void csrwr (Register rd, int csr) { emit_int32(insn_I14RR(csr_op, csr, 1, (int)rd->encoding())); }
20272030

20282031
void ld_b (Register rd, Register rj, int si12) { assert(is_simm(si12, 12), "not a signed 12-bit int"); emit_int32(insn_I12RR(ld_b_op, si12, (int)rj->encoding(), (int)rd->encoding())); }
20292032
void ld_h (Register rd, Register rj, int si12) { assert(is_simm(si12, 12), "not a signed 12-bit int"); emit_int32(insn_I12RR(ld_h_op, si12, (int)rj->encoding(), (int)rd->encoding())); }

src/hotspot/cpu/loongarch/globals_loongarch.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,14 @@ define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
105105
"Enables intrinsification of BigInteger.shiftLeft/Right()") \
106106
\
107107
product(bool, UseActiveCoresMP, false, \
108-
"Eliminate barriers for single active cpu")
108+
"Eliminate barriers for single active cpu") \
109+
\
110+
product(uintx, NUMAMinHeapSizePerNode, 128 * M, \
111+
"The minimum heap size required for each NUMA node to init VM") \
112+
\
113+
product(bool, TraceTraps, false, "Trace all traps the signal handler") \
114+
product(uintx, NUMAMinG1RegionNumberPerNode, 8, \
115+
"Min initial region number for per NUMA node while using G1GC")
109116

110117
// end of ARCH_FLAGS
111118

src/hotspot/cpu/loongarch/loongarch_64.ad

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11550,13 +11550,13 @@ instruct ShouldNotReachHere( )
1155011550
ins_cost(300);
1155111551

1155211552
// Use the following format syntax
11553-
format %{ "ILLTRAP ;#@ShouldNotReachHere" %}
11553+
format %{ "stop; #@ShouldNotReachHere" %}
1155411554
ins_encode %{
1155511555
if (is_reachable()) {
11556-
// Here we should emit illtrap!
11557-
__ stop("ShouldNotReachHere");
11556+
__ stop(_halt_reason);
1155811557
}
1155911558
%}
11559+
1156011560
ins_pipe( pipe_jump );
1156111561
%}
1156211562

@@ -16589,13 +16589,19 @@ instruct insert32B(vecY dst, mRegI val, immIU5 idx) %{
1658916589
match(Set dst (VectorInsert (Binary dst val) idx));
1659016590
format %{ "xvinsert $dst, $val, $idx\t# @insert32B" %}
1659116591
ins_encode %{
16592-
if ($idx$$constant < 16) {
16593-
__ vinsgr2vr_b($dst$$FloatRegister, $val$$Register, $idx$$constant);
16594-
} else {
16595-
__ xvpermi_d($dst$$FloatRegister, $dst$$FloatRegister, 0b01001110);
16596-
__ vinsgr2vr_b($dst$$FloatRegister, $val$$Register, $idx$$constant-16);
16597-
__ xvpermi_d($dst$$FloatRegister, $dst$$FloatRegister, 0b01001110);
16592+
int idx = $idx$$constant;
16593+
int msbw, lsbw;
16594+
switch (idx % 4) {
16595+
case 0: msbw = 7, lsbw = 0; break;
16596+
case 1: msbw = 15, lsbw = 8; break;
16597+
case 2: msbw = 23, lsbw = 16; break;
16598+
case 3: msbw = 31, lsbw = 24; break;
16599+
default:
16600+
ShouldNotReachHere();
1659816601
}
16602+
__ xvpickve2gr_w(SCR1, $dst$$FloatRegister, idx >> 2);
16603+
__ bstrins_w(SCR1, $val$$Register, msbw, lsbw);
16604+
__ xvinsgr2vr_w($dst$$FloatRegister, SCR1, idx >> 2);
1659916605
%}
1660016606
ins_pipe( pipe_slow );
1660116607
%}
@@ -16605,13 +16611,12 @@ instruct insert16S(vecY dst, mRegI val, immIU4 idx) %{
1660516611
match(Set dst (VectorInsert (Binary dst val) idx));
1660616612
format %{ "xvinsert $dst, $val, $idx\t# @insert16S" %}
1660716613
ins_encode %{
16608-
if ($idx$$constant < 8) {
16609-
__ vinsgr2vr_h($dst$$FloatRegister, $val$$Register, $idx$$constant);
16610-
} else {
16611-
__ xvpermi_d($dst$$FloatRegister, $dst$$FloatRegister, 0b01001110);
16612-
__ vinsgr2vr_h($dst$$FloatRegister, $val$$Register, $idx$$constant-8);
16613-
__ xvpermi_d($dst$$FloatRegister, $dst$$FloatRegister, 0b01001110);
16614-
}
16614+
int idx = $idx$$constant;
16615+
int msbw = (idx % 2) ? 31 : 15;
16616+
int lsbw = (idx % 2) ? 16 : 0;
16617+
__ xvpickve2gr_w(SCR1, $dst$$FloatRegister, idx >> 1);
16618+
__ bstrins_w(SCR1, $val$$Register, msbw, lsbw);
16619+
__ xvinsgr2vr_w($dst$$FloatRegister, SCR1, idx >> 1);
1661516620
%}
1661616621
ins_pipe( pipe_slow );
1661716622
%}

src/hotspot/cpu/loongarch/macroAssembler_loongarch.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -633,22 +633,11 @@ void MacroAssembler::debug(char* msg/*, RegistersForDebugging* regs*/) {
633633
}
634634

635635
void MacroAssembler::stop(const char* msg) {
636-
li(A0, (long)msg);
637-
call(CAST_FROM_FN_PTR(address, MacroAssembler::debug), relocInfo::runtime_call_type);
638-
brk(17);
639-
}
640-
641-
void MacroAssembler::warn(const char* msg) {
642-
push_call_clobbered_registers();
643-
li(A0, (long)msg);
644-
push(S2);
645-
move(S2, SP); // use S2 as a sender SP holder
646-
assert(StackAlignmentInBytes == 16, "must be");
647-
bstrins_d(SP, R0, 3, 0); // align stack as required by ABI
648-
call(CAST_FROM_FN_PTR(address, MacroAssembler::debug), relocInfo::runtime_call_type);
649-
move(SP, S2); // use S2 as a sender SP holder
650-
pop(S2);
651-
pop_call_clobbered_registers();
636+
#ifndef PRODUCT
637+
block_comment(msg);
638+
#endif
639+
csrrd(R0, 0);
640+
emit_int64((uintptr_t)msg);
652641
}
653642

654643
void MacroAssembler::increment(Register reg, int imm) {

src/hotspot/cpu/loongarch/macroAssembler_loongarch.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,6 @@ class MacroAssembler: public Assembler {
407407
// prints msg, dumps registers and stops execution
408408
void stop(const char* msg);
409409

410-
// prints msg and continues
411-
void warn(const char* msg);
412-
413410
static void debug(char* msg/*, RegistersForDebugging* regs*/);
414411
static void debug64(char* msg, int64_t pc, int64_t regs[]);
415412

src/hotspot/cpu/loongarch/nativeInst_loongarch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ bool NativeInstruction::is_sigill_not_entrant() {
401401
return uint_at(0) == NativeIllegalInstruction::instruction_code;
402402
}
403403

404+
bool NativeInstruction::is_stop() {
405+
return uint_at(0) == 0x04000000; // csrrd R0 0
406+
}
407+
404408
void NativeIllegalInstruction::insert(address code_pos) {
405409
*(juint*)code_pos = instruction_code;
406410
ICache::invalidate_range(code_pos, instruction_size);

src/hotspot/cpu/loongarch/nativeInst_loongarch.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class NativeInstruction {
8686
inline bool is_NativeCallTrampolineStub_at();
8787
//We use an illegal instruction for marking a method as not_entrant or zombie.
8888
bool is_sigill_not_entrant();
89+
bool is_stop();
8990

9091
protected:
9192
address addr_at(int offset) const { return address(this) + offset; }

src/hotspot/cpu/loongarch/sharedRuntime_loongarch_64.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ static void patch_callers_callsite(MacroAssembler *masm) {
414414
__ beqz(AT, L);
415415

416416
__ enter();
417+
__ bstrins_d(SP, R0, 3, 0); // align the stack
417418
__ push_call_clobbered_registers();
418419

419420
// VM needs caller's callsite
@@ -427,8 +428,6 @@ static void patch_callers_callsite(MacroAssembler *masm) {
427428

428429
__ move(c_rarg0, Rmethod);
429430
__ move(c_rarg1, RA);
430-
assert(StackAlignmentInBytes == 16, "must be");
431-
__ bstrins_d(SP, R0, 3, 0); // align the stack
432431
__ call(CAST_FROM_FN_PTR(address, SharedRuntime::fixup_callers_callsite),
433432
relocInfo::runtime_call_type);
434433

src/hotspot/os/linux/os_linux.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4394,6 +4394,44 @@ void os::Linux::numa_init() {
43944394
// If there's only one node (they start from 0) or if the process
43954395
// is bound explicitly to a single node using membind, disable NUMA
43964396
UseNUMA = false;
4397+
#ifdef LOONGARCH64
4398+
} else if (InitialHeapSize < NUMAMinHeapSizePerNode * os::numa_get_groups_num()) {
4399+
// The MaxHeapSize is not actually used by the JVM unless your program
4400+
// creates enough objects to require it. A much smaller amount, called
4401+
// the InitialHeapSize, is allocated during JVM initialization.
4402+
//
4403+
// Setting the minimum and maximum heap size to the same value is typically
4404+
// not a good idea because garbage collection is delayed until the heap is
4405+
// full. Therefore, the first time that the GC runs, the process can take
4406+
// longer. Also, the heap is more likely to be fragmented and require a heap
4407+
// compaction. Start your application with the minimum heap size that your
4408+
// application requires. When the GC starts up, it runs frequently and
4409+
// efficiently because the heap is small.
4410+
//
4411+
// If the GC cannot find enough garbage, it runs compaction. If the GC finds
4412+
// enough garbage, or any of the other conditions for heap expansion are met,
4413+
// the GC expands the heap.
4414+
//
4415+
// Therefore, an application typically runs until the heap is full. Then,
4416+
// successive garbage collection cycles recover garbage. When the heap is
4417+
// full of live objects, the GC compacts the heap. If sufficient garbage
4418+
// is still not recovered, the GC expands the heap.
4419+
if (FLAG_IS_DEFAULT(UseNUMA)) {
4420+
FLAG_SET_ERGO(UseNUMA, false);
4421+
} else if (UseNUMA) {
4422+
log_info(os)("UseNUMA is disabled since insufficient initial heap size.");
4423+
UseNUMA = false;
4424+
}
4425+
} else if (FLAG_IS_CMDLINE(NewSize) &&
4426+
(NewSize < ScaleForWordSize(1*M) * os::numa_get_groups_num())) {
4427+
if (FLAG_IS_DEFAULT(UseNUMA)) {
4428+
FLAG_SET_ERGO(UseNUMA, false);
4429+
} else if (UseNUMA) {
4430+
log_info(os)("Handcrafted MaxNewSize should be large enough "
4431+
"to avoid GC trigger before VM initialization completed.");
4432+
UseNUMA = false;
4433+
}
4434+
#endif
43974435
} else {
43984436
LogTarget(Info,os) log;
43994437
LogStream ls(log);

src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,24 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
266266
#ifdef PRINT_SIGNAL_HANDLE
267267
tty->print_cr("continuation_for_implicit_exception stub: %lx", stub);
268268
#endif
269+
} else if (sig == SIGILL && nativeInstruction_at(pc)->is_stop()) {
270+
// Pull a pointer to the error message out of the instruction
271+
// stream.
272+
const uint64_t *detail_msg_ptr
273+
= (uint64_t*)(pc + 4/*NativeInstruction::instruction_size*/);
274+
const char *detail_msg = (const char *)*detail_msg_ptr;
275+
const char *msg = "stop";
276+
if (TraceTraps) {
277+
tty->print_cr("trap: %s: (SIGILL)", msg);
278+
}
279+
280+
// End life with a fatal error, message and detail message and the context.
281+
// Note: no need to do any post-processing here (e.g. signal chaining)
282+
va_list va_dummy;
283+
VMError::report_and_die(thread, uc, nullptr, 0, msg, detail_msg, va_dummy);
284+
va_end(va_dummy);
285+
286+
ShouldNotReachHere();
269287
}
270288
} else if ((thread->thread_state() == _thread_in_vm ||
271289
thread->thread_state() == _thread_in_native) &&
@@ -456,9 +474,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {
456474
// point to garbage if entry point in an nmethod is corrupted. Leave
457475
// this at the end, and hope for the best.
458476
address pc = os::fetch_frame_from_context(uc).pc();
459-
st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc));
460-
print_hex_dump(st, pc - 64, pc + 64, sizeof(char));
461-
Disassembler::decode(pc - 80, pc + 80, st);
477+
print_instructions(st, pc, 4/*native instruction size*/);
478+
st->cr();
462479
}
463480

464481
void os::setup_fpu() {

0 commit comments

Comments
 (0)