Mark functions for optimization only on bytecode budget interrupts

We used to mark functions for optimization on any interrupt. This sometimes
causes functions to OSR when not needed. The implementation was such because
we didn't have a different runtime function to distinguish bytecode budget
interrupts from other interrupts. For lazy feedback allocation we added a
new runtime function for bytecode budget interrupts so it makes it easier
to actually mark functions only when needed.

This also includes a fix to reduce the stack limits for interrupts when
entering a scope that allows interrupts from a postponed interrupt scope.

Bug: chromium:993061
Change-Id: Iaf7b4dccb7a503e5b6bfcbb993bc7482aa593955
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1829218
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64048}
This commit is contained in:
Mythri A 2019-09-30 14:45:32 +01:00 committed by Commit Bot
parent 3b9f815557
commit 9efe315ee2
2 changed files with 6 additions and 4 deletions

View File

@ -87,6 +87,8 @@ void StackGuard::PushInterruptsScope(InterruptsScope* scope) {
current->intercepted_flags_ &= ~scope->intercept_mask_;
}
thread_local_.interrupt_flags_ |= restored_flags;
if (has_pending_interrupts(access)) set_interrupt_limits(access);
}
if (!has_pending_interrupts(access)) reset_limits(access);
// Add scope to the chain.
@ -305,8 +307,6 @@ Object StackGuard::HandleInterrupts() {
}
isolate_->counters()->stack_interrupts()->Increment();
isolate_->counters()->runtime_profiler_ticks()->Increment();
isolate_->runtime_profiler()->MarkCandidatesForOptimization();
return ReadOnlyRoots(isolate_).undefined_value();
}

View File

@ -14,6 +14,7 @@
#include "src/execution/frames-inl.h"
#include "src/execution/isolate-inl.h"
#include "src/execution/messages.h"
#include "src/execution/runtime-profiler.h"
#include "src/handles/maybe-handles.h"
#include "src/init/bootstrapper.h"
#include "src/logging/counters.h"
@ -296,10 +297,11 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterrupt) {
function->feedback_vector().set_invocation_count(1);
return ReadOnlyRoots(isolate).undefined_value();
}
// Handle interrupts.
{
SealHandleScope shs(isolate);
return isolate->stack_guard()->HandleInterrupts();
isolate->counters()->runtime_profiler_ticks()->Increment();
isolate->runtime_profiler()->MarkCandidatesForOptimization();
return ReadOnlyRoots(isolate).undefined_value();
}
}