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

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: More fixes 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
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;

Powered by Google App Engine
This is Rietveld 408576698