Skip to content

Commit 375722f

Browse files
committed
8351839: RISC-V: Fix base offset calculation introduced in JDK-8347489
Reviewed-by: mli, fjiang
1 parent 4c5956d commit 375722f

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,8 +1385,7 @@ void C2_MacroAssembler::string_compare_long_same_encoding(Register result, Regis
13851385
const int STUB_THRESHOLD, Label *STUB, Label *SHORT_STRING, Label *DONE) {
13861386
Label TAIL_CHECK, TAIL, NEXT_WORD, DIFFERENCE;
13871387

1388-
const int base_offset = isLL ? arrayOopDesc::base_offset_in_bytes(T_BYTE)
1389-
: arrayOopDesc::base_offset_in_bytes(T_CHAR);
1388+
const int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE);
13901389
assert((base_offset % (UseCompactObjectHeaders ? 4 :
13911390
(UseCompressedClassPointers ? 8 : 4))) == 0, "Must be");
13921391

@@ -1480,7 +1479,7 @@ void C2_MacroAssembler::string_compare_long_different_encoding(Register result,
14801479
const int STUB_THRESHOLD, Label *STUB, Label *DONE) {
14811480
Label TAIL, NEXT_WORD, DIFFERENCE;
14821481

1483-
const int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
1482+
const int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE);
14841483
assert((base_offset % (UseCompactObjectHeaders ? 4 :
14851484
(UseCompressedClassPointers ? 8 : 4))) == 0, "Must be");
14861485

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,8 +2436,7 @@ class StubGenerator: public StubCodeGenerator {
24362436
Register strL, Register strU, Label& DIFF) {
24372437
const Register tmp = x30, tmpLval = x12;
24382438

2439-
int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
2440-
2439+
int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE);
24412440
assert((base_offset % (UseCompactObjectHeaders ? 4 :
24422441
(UseCompressedClassPointers ? 8 : 4))) == 0, "Must be");
24432442

@@ -2495,25 +2494,21 @@ class StubGenerator: public StubCodeGenerator {
24952494
const Register result = x10, str1 = x11, str2 = x13, cnt2 = x14,
24962495
tmp1 = x28, tmp2 = x29, tmp3 = x30, tmp4 = x12;
24972496

2498-
int base_offset1 = arrayOopDesc::base_offset_in_bytes(T_BYTE);
2499-
int base_offset2 = arrayOopDesc::base_offset_in_bytes(T_CHAR);
2500-
2501-
assert((base_offset1 % (UseCompactObjectHeaders ? 4 :
2502-
(UseCompressedClassPointers ? 8 : 4))) == 0, "Must be");
2503-
assert((base_offset2 % (UseCompactObjectHeaders ? 4 :
2504-
(UseCompressedClassPointers ? 8 : 4))) == 0, "Must be");
2497+
int base_offset = arrayOopDesc::base_offset_in_bytes(T_BYTE);
2498+
assert((base_offset % (UseCompactObjectHeaders ? 4 :
2499+
(UseCompressedClassPointers ? 8 : 4))) == 0, "Must be");
25052500

25062501
Register strU = isLU ? str2 : str1,
25072502
strL = isLU ? str1 : str2,
25082503
tmpU = isLU ? tmp2 : tmp1, // where to keep U for comparison
25092504
tmpL = isLU ? tmp1 : tmp2; // where to keep L for comparison
25102505

2511-
if (AvoidUnalignedAccesses && (base_offset1 % 8) != 0) {
2506+
if (AvoidUnalignedAccesses && (base_offset % 8) != 0) {
25122507
// Load 4 bytes from strL to make sure main loop is 8-byte aligned
25132508
// cnt2 is >= 68 here, no need to check it for >= 0
25142509
__ lwu(tmpL, Address(strL));
25152510
__ addi(strL, strL, wordSize / 2);
2516-
__ load_long_misaligned(tmpU, Address(strU), tmp4, (base_offset2 % 8) != 0 ? 4 : 8);
2511+
__ load_long_misaligned(tmpU, Address(strU), tmp4, (base_offset % 8) != 0 ? 4 : 8);
25172512
__ addi(strU, strU, wordSize);
25182513
__ inflate_lo32(tmp3, tmpL);
25192514
__ mv(tmpL, tmp3);

0 commit comments

Comments
 (0)