8358105: RISC-V: Optimize interpreter profile updates

Reviewed-by: fjiang, fyang
This commit is contained in:
Anjian Wen 2025-06-04 02:03:22 +00:00 committed by Feilong Jiang
parent 2345065166
commit 939521b8e4
2 changed files with 12 additions and 33 deletions

View File

@ -955,47 +955,29 @@ void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in,
void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
int constant, int constant) {
bool decrement) { increment_mdp_data_at(mdp_in, noreg, constant);
increment_mdp_data_at(mdp_in, noreg, constant, decrement);
} }
void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
Register reg, Register index,
int constant, int constant) {
bool decrement) {
assert(ProfileInterpreter, "must be profiling interpreter"); assert(ProfileInterpreter, "must be profiling interpreter");
// %%% this does 64bit counters at best it is wasting space
// at worst it is a rare bug when counters overflow
assert_different_registers(t1, t0, mdp_in, reg); assert_different_registers(t1, t0, mdp_in, index);
Address addr1(mdp_in, constant); Address addr1(mdp_in, constant);
Address addr2(t1, 0); Address addr2(t1, 0);
Address &addr = addr1; Address &addr = addr1;
if (reg != noreg) { if (index != noreg) {
la(t1, addr1); la(t1, addr1);
add(t1, t1, reg); add(t1, t1, index);
addr = addr2; addr = addr2;
} }
if (decrement) { ld(t0, addr);
ld(t0, addr); addi(t0, t0, DataLayout::counter_increment);
subi(t0, t0, DataLayout::counter_increment); sd(t0, addr);
Label L;
bltz(t0, L); // skip store if counter underflow
sd(t0, addr);
bind(L);
} else {
assert(DataLayout::counter_increment == 1,
"flow-free idiom only works with 1");
ld(t0, addr);
addi(t0, t0, DataLayout::counter_increment);
Label L;
blez(t0, L); // skip store if counter overflow
sd(t0, addr);
bind(L);
}
} }
void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in, void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in,

View File

@ -233,11 +233,8 @@ class InterpreterMacroAssembler: public MacroAssembler {
void verify_method_data_pointer(); void verify_method_data_pointer();
void set_mdp_data_at(Register mdp_in, int constant, Register value); void set_mdp_data_at(Register mdp_in, int constant, Register value);
void increment_mdp_data_at(Address data, bool decrement = false); void increment_mdp_data_at(Register mdp_in, int constant);
void increment_mdp_data_at(Register mdp_in, int constant, void increment_mdp_data_at(Register mdp_in, Register index, int constant);
bool decrement = false);
void increment_mdp_data_at(Register mdp_in, Register reg, int constant,
bool decrement = false);
void increment_mask_and_jump(Address counter_addr, void increment_mask_and_jump(Address counter_addr,
int increment, Address mask, int increment, Address mask,
Register tmp1, Register tmp2, Register tmp1, Register tmp2,