Commit 4e43fc65 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Compiler] Only look in optimized code cache if function is compiled.

We make assumptions that baseline code exists if we run the optimized code
(e.g., to deopt to the baseline code). If the baseline code has been
cleared by code flushing (only full-codegen) then it might not exist
but there is still optimized code in the map.

BUG=v8:6389

Change-Id: Id4db664afee96c2da3a36a177f425293aae9a0a3
Reviewed-on: https://chromium-review.googlesource.com/503010Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45278}
parent fe9c60c1
...@@ -1051,6 +1051,9 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { ...@@ -1051,6 +1051,9 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode");
AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy());
if (function->shared()->is_compiled()) {
// Function has already been compiled, get the optimized code if possible,
// otherwise return baseline code.
Handle<Code> cached_code; Handle<Code> cached_code;
if (GetCodeFromOptimizedCodeCache(function, BailoutId::None()) if (GetCodeFromOptimizedCodeCache(function, BailoutId::None())
.ToHandle(&cached_code)) { .ToHandle(&cached_code)) {
...@@ -1063,8 +1066,7 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { ...@@ -1063,8 +1066,7 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
return cached_code; return cached_code;
} }
if (function->shared()->is_compiled() && if (function->shared()->marked_for_tier_up()) {
function->shared()->marked_for_tier_up()) {
DCHECK(FLAG_mark_shared_functions_for_tier_up); DCHECK(FLAG_mark_shared_functions_for_tier_up);
function->shared()->set_marked_for_tier_up(false); function->shared()->set_marked_for_tier_up(false);
...@@ -1081,15 +1083,10 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { ...@@ -1081,15 +1083,10 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
} }
} }
if (function->shared()->is_compiled()) {
return Handle<Code>(function->shared()->code()); return Handle<Code>(function->shared()->code());
} } else {
// Function doesn't have any baseline compiled code, compile now.
if (function->shared()->HasBytecodeArray()) { DCHECK(!function->shared()->HasBytecodeArray());
Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline();
function->shared()->ReplaceCode(*entry);
return entry;
}
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handle(function->shared()));
Zone compile_zone(isolate->allocator(), ZONE_NAME); Zone compile_zone(isolate->allocator(), ZONE_NAME);
...@@ -1118,6 +1115,7 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { ...@@ -1118,6 +1115,7 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
} }
return result; return result;
}
} }
......
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