Skip to content

Commit 988e1df

Browse files
zifeihanRealFYang
authored andcommitted
8318953: RISC-V: Small refactoring for MacroAssembler::test_bit
Reviewed-by: fyang, fjiang, luhenry
1 parent ce0ca47 commit 988e1df

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg, Register
6363
if (DiagnoseSyncOnValueBasedClasses != 0) {
6464
load_klass(flag, oop);
6565
lwu(flag, Address(flag, Klass::access_flags_offset()));
66-
test_bit(flag, flag, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS), tmp /* tmp */);
66+
test_bit(flag, flag, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
6767
bnez(flag, cont, true /* is_far */);
6868
}
6969

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -4677,13 +4677,19 @@ void MacroAssembler::rt_call(address dest, Register tmp) {
46774677
}
46784678
}
46794679

4680-
void MacroAssembler::test_bit(Register Rd, Register Rs, uint32_t bit_pos, Register tmp) {
4680+
void MacroAssembler::test_bit(Register Rd, Register Rs, uint32_t bit_pos) {
46814681
assert(bit_pos < 64, "invalid bit range");
46824682
if (UseZbs) {
46834683
bexti(Rd, Rs, bit_pos);
46844684
return;
46854685
}
4686-
andi(Rd, Rs, 1UL << bit_pos, tmp);
4686+
int64_t imm = (int64_t)(1UL << bit_pos);
4687+
if (is_simm12(imm)) {
4688+
and_imm12(Rd, Rs, imm);
4689+
} else {
4690+
srli(Rd, Rs, bit_pos);
4691+
and_imm12(Rd, Rd, 1);
4692+
}
46874693
}
46884694

46894695
// Implements lightweight-locking.

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ class MacroAssembler: public Assembler {
12401240
void shadd(Register Rd, Register Rs1, Register Rs2, Register tmp, int shamt);
12411241

12421242
// test single bit in Rs, result is set to Rd
1243-
void test_bit(Register Rd, Register Rs, uint32_t bit_pos, Register tmp = t0);
1243+
void test_bit(Register Rd, Register Rs, uint32_t bit_pos);
12441244

12451245
// Here the float instructions with safe deal with some exceptions.
12461246
// e.g. convert from NaN, +Inf, -Inf to int, float, double

0 commit comments

Comments
 (0)