8357434: x86: Simplify Interpreter::profile_taken_branch

Reviewed-by: kvn, vlivanov
This commit is contained in:
Aleksey Shipilev 2025-06-04 06:02:49 +00:00
parent f17b2bc06a
commit b918dc84ec
3 changed files with 5 additions and 17 deletions

View File

@ -1355,25 +1355,15 @@ void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {
} }
void InterpreterMacroAssembler::profile_taken_branch(Register mdp, void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
Register bumped_count) {
if (ProfileInterpreter) { if (ProfileInterpreter) {
Label profile_continue; Label profile_continue;
// If no method data exists, go to profile_continue. // If no method data exists, go to profile_continue.
// Otherwise, assign to mdp
test_method_data_pointer(mdp, profile_continue); test_method_data_pointer(mdp, profile_continue);
// We are taking a branch. Increment the taken count. // We are taking a branch. Increment the taken count.
// We inline increment_mdp_data_at to return bumped_count in a register increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
//increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
Address data(mdp, in_bytes(JumpData::taken_offset()));
movptr(bumped_count, data);
assert(DataLayout::counter_increment == 1,
"flow-free idiom only works with 1");
addptr(bumped_count, DataLayout::counter_increment);
sbbptr(bumped_count, 0);
movptr(data, bumped_count); // Store back out
// The method data pointer needs to be updated to reflect the new target. // The method data pointer needs to be updated to reflect the new target.
update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset())); update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
@ -1389,7 +1379,7 @@ void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
// If no method data exists, go to profile_continue. // If no method data exists, go to profile_continue.
test_method_data_pointer(mdp, profile_continue); test_method_data_pointer(mdp, profile_continue);
// We are taking a branch. Increment the not taken count. // We are not taking a branch. Increment the not taken count.
increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset())); increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
// The method data pointer needs to be updated to correspond to // The method data pointer needs to be updated to correspond to

View File

@ -236,7 +236,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
void update_mdp_by_constant(Register mdp_in, int constant); void update_mdp_by_constant(Register mdp_in, int constant);
void update_mdp_for_ret(Register return_bci); void update_mdp_for_ret(Register return_bci);
void profile_taken_branch(Register mdp, Register bumped_count); void profile_taken_branch(Register mdp);
void profile_not_taken_branch(Register mdp); void profile_not_taken_branch(Register mdp);
void profile_call(Register mdp); void profile_call(Register mdp);
void profile_final_call(Register mdp); void profile_final_call(Register mdp);

View File

@ -1687,8 +1687,7 @@ void TemplateTable::float_cmp(bool is_float, int unordered_result) {
void TemplateTable::branch(bool is_jsr, bool is_wide) { void TemplateTable::branch(bool is_jsr, bool is_wide) {
__ get_method(rcx); // rcx holds method __ get_method(rcx); // rcx holds method
__ profile_taken_branch(rax, rbx); // rax holds updated MDP, rbx __ profile_taken_branch(rax); // rax holds updated MDP
// holds bumped taken count
const ByteSize be_offset = MethodCounters::backedge_counter_offset() + const ByteSize be_offset = MethodCounters::backedge_counter_offset() +
InvocationCounter::counter_offset(); InvocationCounter::counter_offset();
@ -1739,7 +1738,6 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
if (UseLoopCounter) { if (UseLoopCounter) {
// increment backedge counter for backward branches // increment backedge counter for backward branches
// rax: MDO // rax: MDO
// rbx: MDO bumped taken-count
// rcx: method // rcx: method
// rdx: target offset // rdx: target offset
// r13: target bcp // r13: target bcp