Skip to content

Commit

Permalink
Working secondary supers table with -XX:+UsePopCountInstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
zifeihan committed May 24, 2024
1 parent e1187df commit f77598f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
35 changes: 2 additions & 33 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3382,36 +3382,6 @@ void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
bind(L_fallthrough);
}

void MacroAssembler::population_count(Register dst, Register src,
Register temp1, Register temp2) {

if (UsePopCountInstruction) {
cpop(dst, src);
} else {
assert_different_registers(src, temp1, temp2);
assert_different_registers(dst, temp1, temp2);
Label loop, done;

mv(temp1, src);
// dst = 0;
// while(temp1 != 0) {
// dst++;
// temp1 &= (temp1 - 1);
// }
mv(dst, zr);
beqz(temp1, done);
{
bind(loop);
addi(dst, dst, 1);
mv(temp2, temp1);
addi(temp2, temp2, -1);
andr(temp1, temp1, temp2);
bnez(temp1, loop);
}
bind(done);
}
}

// Ensure that the inline code and the stub are using the same registers.
#define LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS \
do { \
Expand Down Expand Up @@ -3463,7 +3433,7 @@ bool MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass,
// Get the first array index that can contain super_klass into r_array_index.
if (bit != 0) {
slli(r_array_index, r_bitmap, (Klass::SECONDARY_SUPERS_TABLE_MASK - bit));
population_count(r_array_index, r_array_index, t0, temp1);
cpop(r_array_index, r_array_index);
} else {
mv(r_array_index, (u1)1);
}
Expand Down Expand Up @@ -3624,8 +3594,7 @@ void MacroAssembler::verify_secondary_supers_table(Register r_sub_klass,
// And adjust the array base to point to the data.
addi(r_array_base, r_array_base, Array<Klass*>::base_offset_in_bytes());

repne_scan(r_array_base, r_super_klass, r_array_length, t1);
mv(t0, t1);
repne_scan(r_array_base, r_super_klass, r_array_length, t0);
Label success;
beq(r_super_klass, t0, success);
mv(t0, zr);
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,6 @@ class MacroAssembler: public Assembler {
Label* L_success,
Label* L_failure);

void population_count(Register dst, Register src, Register temp1, Register temp2);

// As above, but with a constant super_klass.
// The result is in Register result, not the condition codes.
bool lookup_secondary_supers_table(Register r_sub_klass,
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/cpu/riscv/vm_version_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ void VM_Version::initialize() {
FLAG_SET_DEFAULT(UsePopCountInstruction, false);
}

if (!UsePopCountInstruction) {
if (UseSecondarySupersTable) {
if (!FLAG_IS_DEFAULT(UseSecondarySupersTable)) {
warning("UseSecondarySupersTable is not supported on this CPU");
}
FLAG_SET_DEFAULT(UseSecondarySupersTable, false);
}
}

if (UseZicboz) {
if (FLAG_IS_DEFAULT(UseBlockZeroing)) {
FLAG_SET_DEFAULT(UseBlockZeroing, true);
Expand Down

0 comments on commit f77598f

Please sign in to comment.