Index: src/factory.cc |
diff --git a/src/factory.cc b/src/factory.cc |
index 84cc00d2800468e3c6e125c36b586285514eaecc..8249f1faa78a5da96c1a74172ed88fc463f35299 100644 |
--- a/src/factory.cc |
+++ b/src/factory.cc |
@@ -1314,17 +1314,24 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
context->native_context(), BailoutId::None()); |
if (cached.code != nullptr) { |
// Caching of optimized code enabled and optimized code found. |
- if (cached.literals != nullptr) result->set_literals(cached.literals); |
DCHECK(!cached.code->marked_for_deoptimization()); |
DCHECK(result->shared()->is_compiled()); |
result->ReplaceCode(cached.code); |
} |
- if (cached.literals == nullptr && !info->bound()) { |
+ if (cached.literals != nullptr) { |
+ result->set_literals(cached.literals); |
+ |
+ } else if (cached.literals == nullptr && !info->bound()) { |
Michael Starzinger
2015/09/22 10:44:39
nit: The way the condition is written, there is no
Igor Sheludko
2015/09/22 12:58:10
Indeed, the "cached.literals == nullptr &&" part i
|
int number_of_literals = info->num_literals(); |
- // TODO(mstarzinger): Consider sharing the newly created literals array. |
Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); |
result->set_literals(*literals); |
+ // Cache context-specific literals. |
+ if (FLAG_cache_optimized_code) { |
+ Handle<Context> native_context(context->native_context()); |
+ SharedFunctionInfo::AddToOptimizedCodeMap( |
+ info, native_context, Handle<Code>(), literals, BailoutId::None()); |
+ } |
} |
return result; |