Skip to content

Commit 57e68ca

Browse files
authored
Update (2022.09.02) (openjdk#2)
27335: [C2] Make FP register allocable 27449: Codebuffer shared stubs enhancement 27464: [C2] Fix conditionally allocatable S5 to get correct ALL_REG_mask.size() 20630: [C2] adjust register pressure closer to allocable size 22010: Refactor fast_lock/unlock assembler 23531: Support monitor count 27499: LA port of JDK-8285435: Show file and line in MacroAssembler::verify_oop for AArch64 and RISC-V platforms (Port from x86) 27338: [JVMCI] Implement JVMCI for LoongArch64 27492: unify offsets of framePoint whether javaFrame of nativeFrame 27576: Revert MacroAssembler::remove_frame 26091: C1: Enable optimizations for RISC-V and LoongArch 27183: [C2] Make T4 allocatable 26733: C2: Load float immediate by vldi 27611: build failed with --disable-precompiled-headers 26284: Rectification of JNI argument shuffling 27604: Add reg class no_CR_reg 27648: Recursive locking case is not triggered in fast_lock
1 parent 1093dc1 commit 57e68ca

File tree

58 files changed

+3421
-794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3421
-794
lines changed

make/autoconf/jvm-features.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_JVMCI],
281281
AC_MSG_RESULT([yes])
282282
elif test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
283283
AC_MSG_RESULT([yes])
284+
elif test "x$OPENJDK_TARGET_CPU" = "xloongarch64"; then
285+
AC_MSG_RESULT([yes])
284286
else
285287
AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
286288
AVAILABLE=false

src/hotspot/cpu/loongarch/abstractInterpreter_loongarch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int AbstractInterpreter::size_activation(int max_stack,
4141
// in AbstractInterpreterGenerator::generate_method_entry.
4242

4343
// fixed size of an interpreter frame:
44-
int overhead = frame::java_frame_sender_sp_offset -
44+
int overhead = frame::sender_sp_offset -
4545
frame::interpreter_frame_initial_sp_offset;
4646
// Our locals were accounted for by the caller (or last_frame_adjust
4747
// on the transition) Since the callee parameters already account

src/hotspot/cpu/loongarch/assembler_loongarch.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,32 @@ Address::Address(address loc, RelocationHolder spec) {
7474
_rspec = spec;
7575
}
7676

77+
bool Assembler::is_vec_imm(float val) {
78+
juint x = *reinterpret_cast<juint*>(&val);
79+
juint masked = x & 0x7e07ffff;
80+
81+
return (masked == 0x3e000000 || masked == 0x40000000);
82+
}
83+
84+
bool Assembler::is_vec_imm(double val) {
85+
julong x = *reinterpret_cast<julong*>(&val);
86+
julong masked = x & 0x7fc0ffffffffffff;
87+
88+
return (masked == 0x3fc0000000000000 || masked == 0x4000000000000000);
89+
}
90+
91+
int Assembler::get_vec_imm(float val) {
92+
juint x = *reinterpret_cast<juint*>(&val);
93+
94+
return simm13((0b11011 << 8) | (((x >> 24) & 0xc0) ^ 0x40) | ((x >> 19) & 0x3f));
95+
}
96+
97+
int Assembler::get_vec_imm(double val) {
98+
julong x = *reinterpret_cast<julong*>(&val);
99+
100+
return simm13((0b11100 << 8) | (((x >> 56) & 0xc0) ^ 0x40) | ((x >> 48) & 0x3f));
101+
}
102+
77103
int AbstractAssembler::code_fill_byte() {
78104
return 0x00; // illegal instruction 0x00000000
79105
}

src/hotspot/cpu/loongarch/assembler_loongarch.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,13 @@ class Assembler : public AbstractAssembler {
16021602
return false;
16031603
}
16041604

1605+
// If x is a vector loadable immediate, return true else return false.
1606+
static bool is_vec_imm(float x);
1607+
static bool is_vec_imm(double x);
1608+
// Return the encoded value.
1609+
static int get_vec_imm(float x);
1610+
static int get_vec_imm(double x);
1611+
16051612
// LoongArch lui is sign extended, so if you wan't to use imm, you have to use the follow
16061613
static int split_low16(int x) {
16071614
return (x & 0xffff);
@@ -1631,6 +1638,12 @@ class Assembler : public AbstractAssembler {
16311638
return (x & 0xfff);
16321639
}
16331640

1641+
static inline void split_simm32(jlong si32, jint& si12, jint& si20) {
1642+
si12 = ((jint)(si32 & 0xfff) << 20) >> 20;
1643+
si32 += (si32 & 0x800) << 1;
1644+
si20 = si32 >> 12;
1645+
}
1646+
16341647
static inline void split_simm38(jlong si38, jint& si18, jint& si20) {
16351648
si18 = ((jint)(si38 & 0x3ffff) << 14) >> 14;
16361649
si38 += (si38 & 0x20000) << 1;
@@ -1643,6 +1656,12 @@ class Assembler : public AbstractAssembler {
16431656
return (x << 20) >> 20;
16441657
}
16451658

1659+
// Convert 13-bit x to a sign-extended 13-bit integer
1660+
static int simm13(int x) {
1661+
assert(x == (x & 0x1FFF), "must be 13-bit only");
1662+
return (x << 19) >> 19;
1663+
}
1664+
16461665
// Convert 26-bit x to a sign-extended 26-bit integer
16471666
static int simm26(int x) {
16481667
assert(x == (x & 0x3FFFFFF), "must be 26-bit only");

src/hotspot/cpu/loongarch/c1_MacroAssembler_loongarch_64.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
105105
bnez(hdr, slow_case);
106106
// done
107107
bind(done);
108+
increment(Address(TREG, JavaThread::held_monitor_count_offset()), 1);
108109
return null_check_offset;
109110
}
110111

@@ -135,6 +136,7 @@ void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_
135136
}
136137
// done
137138
bind(done);
139+
decrement(Address(TREG, JavaThread::held_monitor_count_offset()), 1);
138140
}
139141

140142
// Defines obj, preserves var_size_in_bytes
@@ -304,19 +306,19 @@ void C1_MacroAssembler::verified_entry(bool breakAtEntry) {
304306
}
305307

306308
void C1_MacroAssembler::load_parameter(int offset_in_words, Register reg) {
307-
// rbp, + 0: link
308-
// + 1: return address
309-
// + 2: argument with offset 0
310-
// + 3: argument with offset 1
311-
// + 4: ...
309+
// FP + -2: link
310+
// + -1: return address
311+
// + 0: argument with offset 0
312+
// + 1: argument with offset 1
313+
// + 2: ...
312314

313-
ld_ptr(reg, Address(FP, (offset_in_words + 2) * BytesPerWord));
315+
ld_ptr(reg, Address(FP, offset_in_words * BytesPerWord));
314316
}
315317

316318
#ifndef PRODUCT
317319
void C1_MacroAssembler::verify_stack_oop(int stack_offset) {
318320
if (!VerifyOops) return;
319-
verify_oop_addr(Address(SP, stack_offset), "oop");
321+
verify_oop_addr(Address(SP, stack_offset));
320322
}
321323

322324
void C1_MacroAssembler::verify_not_null_oop(Register r) {

src/hotspot/cpu/loongarch/c1_Runtime1_loongarch_64.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) {
391391
__ st_ptr(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, 1 * BytesPerWord));
394+
__ ld_ptr(exception_pc, Address(FP, frame::return_addr_offset * BytesPerWord));
395395

396396
// make sure that the vm_results are cleared (may be unnecessary)
397397
__ st_ptr(R0, Address(TREG, JavaThread::vm_result_offset()));
@@ -440,7 +440,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) {
440440
__ st_ptr(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, 1 * BytesPerWord));
443+
__ st_ptr(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, 1 * BytesPerWord));
458+
__ st_ptr(A0, Address(FP, frame::return_addr_offset * BytesPerWord));
459459

460460
switch (id) {
461461
case forward_exception_id:
@@ -675,9 +675,9 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
675675
__ enter();
676676
OopMap* map = save_live_registers(sasm);
677677
// Retrieve bci
678-
__ ld_w(bci, Address(FP, 2 * BytesPerWord));
678+
__ ld_w(bci, Address(FP, 0 * BytesPerWord));
679679
// And a pointer to the Method*
680-
__ ld_d(method, Address(FP, 3 * BytesPerWord));
680+
__ ld_d(method, Address(FP, 1 * BytesPerWord));
681681
int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, counter_overflow), bci, method);
682682
oop_maps = new OopMapSet();
683683
oop_maps->add_gc_map(call_offset, map);

0 commit comments

Comments
 (0)