Skip to content

8358655: AArch64: Simplify Interpreter::profile_taken_branch #25906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,31 +1016,16 @@ void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {
}


void InterpreterMacroAssembler::profile_taken_branch(Register mdp,
Register bumped_count) {
void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
if (ProfileInterpreter) {
Label profile_continue;

// If no method data exists, go to profile_continue.
// Otherwise, assign to mdp
test_method_data_pointer(mdp, profile_continue);

// 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()));
Address data(mdp, in_bytes(JumpData::taken_offset()));
ldr(bumped_count, data);
assert(DataLayout::counter_increment == 1,
"flow-free idiom only works with 1");
// Intel does this to catch overflow
// addptr(bumped_count, DataLayout::counter_increment);
// sbbptr(bumped_count, 0);
// so we do this
adds(bumped_count, bumped_count, DataLayout::counter_increment);
Label L;
br(Assembler::CS, L); // skip store if counter overflow
str(bumped_count, data);
bind(L);
increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));

// The method data pointer needs to be updated to reflect the new target.
update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
bind(profile_continue);
Expand All @@ -1055,7 +1040,7 @@ void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
// If no method data exists, go to 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()));

// The method data pointer needs to be updated to correspond to
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
// narrow int return value
void narrow(Register result);

void profile_taken_branch(Register mdp, Register bumped_count);
void profile_taken_branch(Register mdp);
void profile_not_taken_branch(Register mdp);
void profile_call(Register mdp);
void profile_final_call(Register mdp);
Expand Down
5 changes: 1 addition & 4 deletions src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ void TemplateTable::float_cmp(bool is_float, int unordered_result)

void TemplateTable::branch(bool is_jsr, bool is_wide)
{
__ profile_taken_branch(r0, r1);
__ profile_taken_branch(r0);
const ByteSize be_offset = MethodCounters::backedge_counter_offset() +
InvocationCounter::counter_offset();
const ByteSize inv_offset = MethodCounters::invocation_counter_offset() +
Expand Down Expand Up @@ -1809,7 +1809,6 @@ void TemplateTable::branch(bool is_jsr, bool is_wide)
if (UseLoopCounter) {
// increment backedge counter for backward branches
// r0: MDO
// w1: MDO bumped taken-count
// r2: target offset
__ cmp(r2, zr);
__ br(Assembler::GT, dispatch); // count only if backward branch
Expand All @@ -1820,12 +1819,10 @@ void TemplateTable::branch(bool is_jsr, bool is_wide)
__ ldr(rscratch1, Address(rmethod, Method::method_counters_offset()));
__ cbnz(rscratch1, has_counters);
__ push(r0);
__ push(r1);
__ push(r2);
__ call_VM(noreg, CAST_FROM_FN_PTR(address,
InterpreterRuntime::build_method_counters), rmethod);
__ pop(r2);
__ pop(r1);
__ pop(r0);
__ ldr(rscratch1, Address(rmethod, Method::method_counters_offset()));
__ cbz(rscratch1, dispatch); // No MethodCounters allocated, OutOfMemory
Expand Down