Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index ac34e79e52fcd51bb51f7a60e0894d7314bf89de..e5ebae9294d5eb1868f13788968278876674ae37 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -598,13 +598,14 @@ MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeMap( |
&RuntimeCallStats::CompileGetFromOptimizedCodeMap); |
Handle<SharedFunctionInfo> shared(function->shared()); |
DisallowHeapAllocation no_gc; |
- Code* code = shared->SearchOptimizedCodeMap( |
+ CodeAndLiterals cached = shared->SearchOptimizedCodeMap( |
function->context()->native_context(), osr_ast_id); |
- if (code != nullptr) { |
+ if (cached.code != nullptr) { |
// Caching of optimized code enabled and optimized code found. |
- DCHECK(!code->marked_for_deoptimization()); |
+ if (cached.literals != nullptr) function->set_literals(cached.literals); |
+ DCHECK(!cached.code->marked_for_deoptimization()); |
DCHECK(function->shared()->is_compiled()); |
- return Handle<Code>(code); |
+ return Handle<Code>(cached.code); |
} |
return MaybeHandle<Code>(); |
} |
@@ -626,9 +627,10 @@ void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
// Cache optimized context-specific code. |
Handle<JSFunction> function = info->closure(); |
Handle<SharedFunctionInfo> shared(function->shared()); |
+ Handle<LiteralsArray> literals(function->literals()); |
Handle<Context> native_context(function->context()->native_context()); |
SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
- info->osr_ast_id()); |
+ literals, info->osr_ast_id()); |
} |
bool GetOptimizedCodeNow(CompilationJob* job) { |
@@ -864,8 +866,10 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job) { |
} else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) { |
job->RecordOptimizedCompilationStats(); |
RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); |
- if (shared->SearchOptimizedCodeMap(info->context()->native_context(), |
- info->osr_ast_id()) == nullptr) { |
+ if (shared |
+ ->SearchOptimizedCodeMap(info->context()->native_context(), |
+ info->osr_ast_id()) |
+ .code == nullptr) { |
InsertCodeIntoOptimizedCodeMap(info); |
} |
if (FLAG_trace_opt) { |
@@ -1752,16 +1756,19 @@ void Compiler::PostInstantiation(Handle<JSFunction> function, |
function->MarkForOptimization(); |
} |
- Code* code = shared->SearchOptimizedCodeMap( |
+ CodeAndLiterals cached = shared->SearchOptimizedCodeMap( |
function->context()->native_context(), BailoutId::None()); |
- if (code != nullptr) { |
+ if (cached.code != nullptr) { |
// Caching of optimized code enabled and optimized code found. |
- DCHECK(!code->marked_for_deoptimization()); |
+ DCHECK(!cached.code->marked_for_deoptimization()); |
DCHECK(function->shared()->is_compiled()); |
- function->ReplaceCode(code); |
+ function->ReplaceCode(cached.code); |
} |
- if (shared->is_compiled()) { |
+ if (cached.literals != nullptr) { |
+ DCHECK(shared->is_compiled()); |
+ function->set_literals(cached.literals); |
+ } else if (shared->is_compiled()) { |
// TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
JSFunction::EnsureLiterals(function); |
} |