Skip to content

Commit dda805d

Browse files
RealFYangpull[bot]
authored andcommitted
8345047: RISC-V: Remove explicit use of AvoidUnalignedAccesses in interpreter
Reviewed-by: mli, fjiang
1 parent 4d03a11 commit dda805d

File tree

2 files changed

+13
-36
lines changed

2 files changed

+13
-36
lines changed

src/hotspot/cpu/riscv/interp_masm_riscv.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,10 @@ void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread)
179179

180180
void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) {
181181
assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode");
182-
if (AvoidUnalignedAccesses && (bcp_offset % 2)) {
183-
lbu(t1, Address(xbcp, bcp_offset));
184-
lbu(reg, Address(xbcp, bcp_offset + 1));
185-
slli(t1, t1, 8);
186-
add(reg, reg, t1);
187-
} else {
188-
lhu(reg, Address(xbcp, bcp_offset));
189-
revb_h_h_u(reg, reg);
190-
}
182+
lbu(t1, Address(xbcp, bcp_offset));
183+
lbu(reg, Address(xbcp, bcp_offset + 1));
184+
slli(t1, t1, 8);
185+
add(reg, reg, t1);
191186
}
192187

193188
void InterpreterMacroAssembler::get_dispatch() {
@@ -200,15 +195,7 @@ void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index,
200195
size_t index_size) {
201196
assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
202197
if (index_size == sizeof(u2)) {
203-
if (AvoidUnalignedAccesses) {
204-
assert_different_registers(index, tmp);
205-
load_unsigned_byte(index, Address(xbcp, bcp_offset));
206-
load_unsigned_byte(tmp, Address(xbcp, bcp_offset + 1));
207-
slli(tmp, tmp, 8);
208-
add(index, index, tmp);
209-
} else {
210-
load_unsigned_short(index, Address(xbcp, bcp_offset));
211-
}
198+
load_short_misaligned(index, Address(xbcp, bcp_offset), tmp, false);
212199
} else if (index_size == sizeof(u4)) {
213200
load_int_misaligned(index, Address(xbcp, bcp_offset), tmp, false);
214201
} else if (index_size == sizeof(u1)) {

src/hotspot/cpu/riscv/templateTable_riscv.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,10 @@ void TemplateTable::bipush() {
292292

293293
void TemplateTable::sipush() {
294294
transition(vtos, itos);
295-
if (AvoidUnalignedAccesses) {
296-
__ load_signed_byte(x10, at_bcp(1));
297-
__ load_unsigned_byte(t1, at_bcp(2));
298-
__ slli(x10, x10, 8);
299-
__ add(x10, x10, t1);
300-
} else {
301-
__ load_unsigned_short(x10, at_bcp(1));
302-
__ revb_h_h(x10, x10); // reverse bytes in half-word and sign-extend
303-
}
295+
__ load_signed_byte(x10, at_bcp(1));
296+
__ load_unsigned_byte(t1, at_bcp(2));
297+
__ slli(x10, x10, 8);
298+
__ add(x10, x10, t1);
304299
}
305300

306301
void TemplateTable::ldc(LdcType type) {
@@ -1626,15 +1621,10 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
16261621

16271622
// load branch displacement
16281623
if (!is_wide) {
1629-
if (AvoidUnalignedAccesses) {
1630-
__ lb(x12, at_bcp(1));
1631-
__ lbu(t1, at_bcp(2));
1632-
__ slli(x12, x12, 8);
1633-
__ add(x12, x12, t1);
1634-
} else {
1635-
__ lhu(x12, at_bcp(1));
1636-
__ revb_h_h(x12, x12); // reverse bytes in half-word and sign-extend
1637-
}
1624+
__ lb(x12, at_bcp(1));
1625+
__ lbu(t1, at_bcp(2));
1626+
__ slli(x12, x12, 8);
1627+
__ add(x12, x12, t1);
16381628
} else {
16391629
__ lwu(x12, at_bcp(1));
16401630
__ revb_w_w(x12, x12); // reverse bytes in word and sign-extend

0 commit comments

Comments
 (0)