8357223: AArch64: Optimize interpreter profile updates

Reviewed-by: shade, aph
This commit is contained in:
Chad Rakoczy 2025-06-03 08:55:34 +00:00 committed by Aleksey Shipilev
parent 8674f49127
commit 4402527683
2 changed files with 10 additions and 47 deletions

View File

@ -926,60 +926,26 @@ void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in,
void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
int constant,
bool decrement) {
increment_mdp_data_at(mdp_in, noreg, constant, decrement);
int constant) {
increment_mdp_data_at(mdp_in, noreg, constant);
}
void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
Register reg,
int constant,
bool decrement) {
Register index,
int constant) {
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(rscratch2, rscratch1, mdp_in, reg);
assert_different_registers(rscratch2, rscratch1, mdp_in, index);
Address addr1(mdp_in, constant);
Address addr2(rscratch2, reg, Address::lsl(0));
Address addr2(rscratch2, index, Address::lsl(0));
Address &addr = addr1;
if (reg != noreg) {
if (index != noreg) {
lea(rscratch2, addr1);
addr = addr2;
}
if (decrement) {
// Decrement the register. Set condition codes.
// Intel does this
// addptr(data, (int32_t) -DataLayout::counter_increment);
// If the decrement causes the counter to overflow, stay negative
// Label L;
// jcc(Assembler::negative, L);
// addptr(data, (int32_t) DataLayout::counter_increment);
// so we do this
ldr(rscratch1, addr);
subs(rscratch1, rscratch1, (unsigned)DataLayout::counter_increment);
Label L;
br(Assembler::LO, L); // skip store if counter underflow
str(rscratch1, addr);
bind(L);
} else {
assert(DataLayout::counter_increment == 1,
"flow-free idiom only works with 1");
// Intel does this
// Increment the register. Set carry flag.
// addptr(data, DataLayout::counter_increment);
// If the increment causes the counter to overflow, pull back by 1.
// sbbptr(data, (int32_t)0);
// so we do this
ldr(rscratch1, addr);
adds(rscratch1, rscratch1, DataLayout::counter_increment);
Label L;
br(Assembler::CS, L); // skip store if counter overflow
str(rscratch1, addr);
bind(L);
}
increment(addr, DataLayout::counter_increment);
}
void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in,

View File

@ -247,11 +247,8 @@ class InterpreterMacroAssembler: public MacroAssembler {
void verify_method_data_pointer();
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,
bool decrement = false);
void increment_mdp_data_at(Register mdp_in, Register reg, int constant,
bool decrement = false);
void increment_mdp_data_at(Register mdp_in, int constant);
void increment_mdp_data_at(Register mdp_in, Register index, int constant);
void increment_mask_and_jump(Address counter_addr,
int increment, Address mask,
Register scratch, Register scratch2,