diff options
author | 2024-01-29 14:24:31 +0000 | |
---|---|---|
committer | 2024-01-30 17:22:07 +0000 | |
commit | 33e9f1a70d5f58639b524f40bf39a8e233c04ba8 (patch) | |
tree | f78d2949cac297400c0854ef57a4190f77d28e1b /runtime/quick_exception_handler.cc | |
parent | 516020a3fbfe3db43f7faf0ac3daf5a45dbeeb6b (diff) |
Reland^2 "Run optimizations with baseline compilation."
This reverts commit 3dccb13f4e92db37a13359e126c5ddc12cb674b5.
Also includes the fix for incrementing hotness that got reverted:
aosp/2906378
Bug: 313040662
Reduces jank on compose view scrolling for 4 iterations:
- For Go Mokey:
- Before: ~698 frames drawn / ~13.87% janky frames
- After: ~937 frames drawn / ~5.52% janky frames
- For Pixel 8 pro:
- Before: ~2440 frames drawn / ~0.90% janky frames
- After: ~2450 frames drawn / ~0.55% janky frames
Reason for revert: Reduce inlining threshold for baseline.
Change-Id: Iee5cd4c3ceb7715caf9299b56551aae6f0259769
Diffstat (limited to 'runtime/quick_exception_handler.cc')
-rw-r--r-- | runtime/quick_exception_handler.cc | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index 05a10485f6..1d4411201a 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -407,6 +407,10 @@ class DeoptimizeStackVisitor final : public StackVisitor { return bottom_shadow_frame_; } + const std::vector<uint32_t>& GetDexPcs() const { + return dex_pcs_; + } + void FinishStackWalk() REQUIRES_SHARED(Locks::mutator_lock_) { // This is the upcall, or the next full frame in single-frame deopt, or the // code isn't deoptimizeable. We remember the frame and last pc so that we @@ -515,11 +519,14 @@ class DeoptimizeStackVisitor final : public StackVisitor { } prev_shadow_frame_ = new_frame; - if (single_frame_deopt_ && !IsInInlinedFrame()) { - // Single-frame deopt ends at the first non-inlined frame and needs to store that method. - single_frame_done_ = true; - single_frame_deopt_method_ = method; - single_frame_deopt_quick_method_header_ = GetCurrentOatQuickMethodHeader(); + if (single_frame_deopt_) { + dex_pcs_.push_back(GetDexPc()); + if (!IsInInlinedFrame()) { + // Single-frame deopt ends at the first non-inlined frame and needs to store that method. + single_frame_done_ = true; + single_frame_deopt_method_ = method; + single_frame_deopt_quick_method_header_ = GetCurrentOatQuickMethodHeader(); + } } callee_method_ = method; return true; @@ -659,6 +666,7 @@ class DeoptimizeStackVisitor final : public StackVisitor { // a deopt after running method exit callbacks if the callback throws or requests events that // need a deopt. bool skip_method_exit_callbacks_; + std::vector<uint32_t> dex_pcs_; DISALLOW_COPY_AND_ASSIGN(DeoptimizeStackVisitor); }; @@ -739,11 +747,26 @@ void QuickExceptionHandler::DeoptimizeSingleFrame(DeoptimizationKind kind) { case Instruction::INVOKE_VIRTUAL: case Instruction::INVOKE_INTERFACE_RANGE: case Instruction::INVOKE_VIRTUAL_RANGE: { - runtime->GetJit()->GetCodeCache()->MaybeUpdateInlineCache( - shadow_frame->GetMethod(), - dex_pc, - shadow_frame->GetVRegReference(inst->VRegC())->GetClass(), - self_); + uint32_t encoded_dex_pc = InlineCache::EncodeDexPc( + visitor.GetSingleFrameDeoptMethod(), + visitor.GetDexPcs(), + runtime->GetJit()->GetJitCompiler()->GetInlineMaxCodeUnits()); + if (encoded_dex_pc != static_cast<uint32_t>(-1)) { + // The inline cache comes from the top-level method. + runtime->GetJit()->GetCodeCache()->MaybeUpdateInlineCache( + visitor.GetSingleFrameDeoptMethod(), + encoded_dex_pc, + shadow_frame->GetVRegReference(inst->VRegC())->GetClass(), + self_); + } else { + // If the top-level inline cache did not exist, update the one for the + // bottom method, we know it's the one that was used for compilation. + runtime->GetJit()->GetCodeCache()->MaybeUpdateInlineCache( + shadow_frame->GetMethod(), + dex_pc, + shadow_frame->GetVRegReference(inst->VRegC())->GetClass(), + self_); + } break; } default: { |