diff options
| author | 2022-10-21 13:28:05 +0000 | |
|---|---|---|
| committer | 2022-11-04 07:46:10 +0000 | |
| commit | bab6beb1f1299c13a0be5fbb4344facb6d7be7e3 (patch) | |
| tree | 2524f91405543bc17e068a051a6932e9a71bfb37 /compiler/optimizing | |
| parent | c232049c9980e6a80baf91f135baf89f23d9075d (diff) | |
Update method exit hooks from JITed code to not use Stack visitor
Using NthCallerStackVisitor is expensive since that involves decoding
method header and other tasks that are reasonably expensive especially
when called on every method exit. When calling method exit hooks from
JITed code a lot of this information like the frame_size, calling method
are already known and can be directly passed to the method exit hook
instead of computing them.
Locally this change improves the performance by 70% on debuggable-cc
config of golem benchmarks.
Bug: 253232638
Test: art/test.py
Change-Id: I3a1d80748c6d85e5fa1d3bd4aec0b29962ba0156
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 3 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_arm_vixl.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 3 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 4 |
4 files changed, 14 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 2cc367f0b2..72ca927897 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -824,6 +824,9 @@ class MethodEntryExitHooksSlowPathARM64 : public SlowPathCodeARM64 { CodeGeneratorARM64* arm64_codegen = down_cast<CodeGeneratorARM64*>(codegen); __ Bind(GetEntryLabel()); SaveLiveRegisters(codegen, locations); + if (instruction_->IsMethodExitHook()) { + __ Mov(vixl::aarch64::x4, arm64_codegen->GetFrameSize()); + } arm64_codegen->InvokeRuntime(entry_point, instruction_, instruction_->GetDexPc(), this); RestoreLiveRegisters(codegen, locations); __ B(GetExitLabel()); diff --git a/compiler/optimizing/code_generator_arm_vixl.cc b/compiler/optimizing/code_generator_arm_vixl.cc index 2a9bc398ac..03a9977a11 100644 --- a/compiler/optimizing/code_generator_arm_vixl.cc +++ b/compiler/optimizing/code_generator_arm_vixl.cc @@ -973,6 +973,10 @@ class MethodEntryExitHooksSlowPathARMVIXL : public SlowPathCodeARMVIXL { (instruction_->IsMethodEntryHook()) ? kQuickMethodEntryHook : kQuickMethodExitHook; __ Bind(GetEntryLabel()); SaveLiveRegisters(codegen, locations); + if (instruction_->IsMethodExitHook()) { + // Load frame size to pass to the exit hooks + __ Mov(vixl::aarch32::Register(R2), arm_codegen->GetFrameSize()); + } arm_codegen->InvokeRuntime(entry_point, instruction_, instruction_->GetDexPc(), this); RestoreLiveRegisters(codegen, locations); __ B(GetExitLabel()); diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index a14ea8b3bf..5cc7270a53 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -966,6 +966,9 @@ class MethodEntryExitHooksSlowPathX86 : public SlowPathCode { (instruction_->IsMethodEntryHook()) ? kQuickMethodEntryHook : kQuickMethodExitHook; __ Bind(GetEntryLabel()); SaveLiveRegisters(codegen, locations); + if (instruction_->IsMethodExitHook()) { + __ movl(EBX, Immediate(codegen->GetFrameSize())); + } x86_codegen->InvokeRuntime(entry_point, instruction_, instruction_->GetDexPc(), this); RestoreLiveRegisters(codegen, locations); __ jmp(GetExitLabel()); diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 3d0f35df63..33c9ae4867 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -985,6 +985,10 @@ class MethodEntryExitHooksSlowPathX86_64 : public SlowPathCode { (instruction_->IsMethodEntryHook()) ? kQuickMethodEntryHook : kQuickMethodExitHook; __ Bind(GetEntryLabel()); SaveLiveRegisters(codegen, locations); + if (instruction_->IsMethodExitHook()) { + // Load FrameSize to pass to the exit hook. + __ movq(CpuRegister(R8), Immediate(codegen->GetFrameSize())); + } x86_64_codegen->InvokeRuntime(entry_point, instruction_, instruction_->GetDexPc(), this); RestoreLiveRegisters(codegen, locations); __ jmp(GetExitLabel()); |