Commit aed65cb4 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Fix runtime-profiler ticks for Interpreted functions.

Fix two bugs with the runtime-profiler optimization heuristics for
interpreted code:
 - Reset shared->tick_count for interpreted functions when optimizing
 - Update ticks after checking whether to optimize functions, to be the
   same as the FCG profiler checks (where updates are done to the code
   ticks after deciding whether to optimize).

BUG=chromium:662071

Review-Url: https://codereview.chromium.org/2497933002
Cr-Commit-Position: refs/heads/master@{#40978}
parent 1bde8304
......@@ -640,8 +640,10 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
}
// Reset profiler ticks, function is no longer considered hot.
if (shared->is_compiled()) {
if (shared->HasBaselineCode()) {
shared->code()->set_profiler_ticks(0);
} else if (shared->HasBytecodeArray()) {
shared->set_profiler_ticks(0);
}
VMState<COMPILER> state(isolate);
......@@ -734,7 +736,13 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job) {
"V8.RecompileSynchronous");
Handle<SharedFunctionInfo> shared = info->shared_info();
shared->code()->set_profiler_ticks(0);
// Reset profiler ticks, function is no longer considered hot.
if (shared->HasBaselineCode()) {
shared->code()->set_profiler_ticks(0);
} else if (shared->HasBytecodeArray()) {
shared->set_profiler_ticks(0);
}
DCHECK(!shared->HasDebugInfo());
......
......@@ -22,7 +22,7 @@ namespace internal {
// Number of times a function has to be seen on the stack before it is
// compiled for baseline.
static const int kProfilerTicksBeforeBaseline = 1;
static const int kProfilerTicksBeforeBaseline = 0;
// Number of times a function has to be seen on the stack before it is
// optimized.
static const int kProfilerTicksBeforeOptimization = 2;
......@@ -447,16 +447,6 @@ void RuntimeProfiler::MarkCandidatesForOptimization() {
JavaScriptFrame* frame = it.frame();
JSFunction* function = frame->function();
List<JSFunction*> functions(4);
frame->GetFunctions(&functions);
for (int i = functions.length(); --i >= 0; ) {
SharedFunctionInfo* shared_function_info = functions[i]->shared();
int ticks = shared_function_info->profiler_ticks();
if (ticks < Smi::kMaxValue) {
shared_function_info->set_profiler_ticks(ticks + 1);
}
}
Compiler::CompilationTier next_tier =
Compiler::NextCompilationTier(function);
if (function->shared()->IsInterpreted()) {
......@@ -470,6 +460,19 @@ void RuntimeProfiler::MarkCandidatesForOptimization() {
DCHECK_EQ(next_tier, Compiler::OPTIMIZED);
MaybeOptimizeFullCodegen(function, frame, frame_count);
}
// Update shared function info ticks after checking for whether functions
// should be optimized to keep FCG (which updates ticks on code) and
// Ignition (which updates ticks on shared function info) in sync.
List<JSFunction*> functions(4);
frame->GetFunctions(&functions);
for (int i = functions.length(); --i >= 0;) {
SharedFunctionInfo* shared_function_info = functions[i]->shared();
int ticks = shared_function_info->profiler_ticks();
if (ticks < Smi::kMaxValue) {
shared_function_info->set_profiler_ticks(ticks + 1);
}
}
}
any_ic_changed_ = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment