Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(923)

Unified Diff: src/factory.cc

Issue 1353363002: Share literals arrays per <NativeContext, SharedFunctionInfo> pair. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 84cc00d2800468e3c6e125c36b586285514eaecc..c1322d7e774fedbefc1a19fbf4618f492babe213 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 (!info->bound()) {
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, undefined_value(), literals, BailoutId::None());
+ }
}
return result;
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698