Commit 21a399c0 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Builtins] Check for SFI being compiled first in CompileLazy.

Swaps around the checks in CompileLazy to ensure we always enter the
runtime to lazy compile if a function's SFI is uncompiled. This
is necessary with bytecode flushing since the function may have
an optimized code marker in the feedback vector, even if the
bytecode has been flushed, and we don't want to try to optimize
this flushed function.

BUG=v8:8395

Change-Id: I7a348c40146673ba4a8f5e14d06995bbcc141695
Reviewed-on: https://chromium-review.googlesource.com/c/1352277
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57929}
parent eee67af3
...@@ -120,6 +120,13 @@ void LazyBuiltinsAssembler::CompileLazy(TNode<JSFunction> function) { ...@@ -120,6 +120,13 @@ void LazyBuiltinsAssembler::CompileLazy(TNode<JSFunction> function) {
// First lookup code, maybe we don't need to compile! // First lookup code, maybe we don't need to compile!
Label compile_function(this, Label::kDeferred); Label compile_function(this, Label::kDeferred);
// Check the code object for the SFI. If SFI's code entry points to
// CompileLazy, then we need to lazy compile regardless of the function or
// feedback vector marker.
TNode<SharedFunctionInfo> shared =
CAST(LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset));
TNode<Code> sfi_code = GetSharedFunctionInfoCode(shared, &compile_function);
// Compile function if we don't have a valid feedback vector. // Compile function if we don't have a valid feedback vector.
TNode<FeedbackVector> feedback_vector = TNode<FeedbackVector> feedback_vector =
LoadFeedbackVector(function, &compile_function); LoadFeedbackVector(function, &compile_function);
...@@ -127,23 +134,14 @@ void LazyBuiltinsAssembler::CompileLazy(TNode<JSFunction> function) { ...@@ -127,23 +134,14 @@ void LazyBuiltinsAssembler::CompileLazy(TNode<JSFunction> function) {
// Is there an optimization marker or optimized code in the feedback vector? // Is there an optimization marker or optimized code in the feedback vector?
MaybeTailCallOptimizedCodeSlot(function, feedback_vector); MaybeTailCallOptimizedCodeSlot(function, feedback_vector);
// We found no optimized code. Infer the code object needed for the SFI. // If not, install the SFI's code entry and jump to that.
TNode<SharedFunctionInfo> shared = CSA_ASSERT(this, WordNotEqual(sfi_code, HeapConstant(BUILTIN_CODE(
CAST(LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset)); isolate(), CompileLazy))));
// If code entry points to anything other than CompileLazy, install that, StoreObjectField(function, JSFunction::kCodeOffset, sfi_code);
// otherwise call runtime to compile the function. GenerateTailCallToJSCode(sfi_code, function);
TNode<Code> code = GetSharedFunctionInfoCode(shared, &compile_function);
CSA_ASSERT(
this,
WordNotEqual(code, HeapConstant(BUILTIN_CODE(isolate(), CompileLazy))));
// Install the SFI's code entry.
StoreObjectField(function, JSFunction::kCodeOffset, code);
GenerateTailCallToJSCode(code, function);
BIND(&compile_function); BIND(&compile_function);
{ GenerateTailCallToReturnedCode(Runtime::kCompileLazy, function); } GenerateTailCallToReturnedCode(Runtime::kCompileLazy, function);
} }
TF_BUILTIN(CompileLazy, LazyBuiltinsAssembler) { TF_BUILTIN(CompileLazy, LazyBuiltinsAssembler) {
......
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