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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 } 1307 }
1308 1308
1309 if (FLAG_always_opt && info->allows_lazy_compilation()) { 1309 if (FLAG_always_opt && info->allows_lazy_compilation()) {
1310 result->MarkForOptimization(); 1310 result->MarkForOptimization();
1311 } 1311 }
1312 1312
1313 CodeAndLiterals cached = info->SearchOptimizedCodeMap( 1313 CodeAndLiterals cached = info->SearchOptimizedCodeMap(
1314 context->native_context(), BailoutId::None()); 1314 context->native_context(), BailoutId::None());
1315 if (cached.code != nullptr) { 1315 if (cached.code != nullptr) {
1316 // Caching of optimized code enabled and optimized code found. 1316 // Caching of optimized code enabled and optimized code found.
1317 if (cached.literals != nullptr) result->set_literals(cached.literals);
1318 DCHECK(!cached.code->marked_for_deoptimization()); 1317 DCHECK(!cached.code->marked_for_deoptimization());
1319 DCHECK(result->shared()->is_compiled()); 1318 DCHECK(result->shared()->is_compiled());
1320 result->ReplaceCode(cached.code); 1319 result->ReplaceCode(cached.code);
1321 } 1320 }
1322 1321
1323 if (cached.literals == nullptr && !info->bound()) { 1322 if (cached.literals != nullptr) {
1323 result->set_literals(cached.literals);
1324
1325 } else if (!info->bound()) {
1324 int number_of_literals = info->num_literals(); 1326 int number_of_literals = info->num_literals();
1325 // TODO(mstarzinger): Consider sharing the newly created literals array.
1326 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); 1327 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure);
1327 result->set_literals(*literals); 1328 result->set_literals(*literals);
1329 // Cache context-specific literals.
1330 if (FLAG_cache_optimized_code) {
1331 Handle<Context> native_context(context->native_context());
1332 SharedFunctionInfo::AddToOptimizedCodeMap(
1333 info, native_context, undefined_value(), literals, BailoutId::None());
1334 }
1328 } 1335 }
1329 1336
1330 return result; 1337 return result;
1331 } 1338 }
1332 1339
1333 1340
1334 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1341 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1335 Handle<FixedArray> array = NewFixedArray(length, TENURED); 1342 Handle<FixedArray> array = NewFixedArray(length, TENURED);
1336 array->set_map_no_write_barrier(*scope_info_map()); 1343 array->set_map_no_write_barrier(*scope_info_map());
1337 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); 1344 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array);
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 } 2373 }
2367 2374
2368 2375
2369 Handle<Object> Factory::ToBoolean(bool value) { 2376 Handle<Object> Factory::ToBoolean(bool value) {
2370 return value ? true_value() : false_value(); 2377 return value ? true_value() : false_value();
2371 } 2378 }
2372 2379
2373 2380
2374 } // namespace internal 2381 } // namespace internal
2375 } // namespace v8 2382 } // namespace v8
OLDNEW
« 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