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

Unified Diff: src/factory.cc

Issue 10649008: Fix sharing of literal boilerplates for optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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/compiler.cc ('k') | src/flag-definitions.h » ('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 682125e3af5f90ae53d284f4cad85f36238cb015..c33b7152b4cb1ac320d9ce127acbf530f43305c3 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -555,40 +555,23 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
result->set_context(*context);
- int index = FLAG_cache_optimized_code
- ? function_info->SearchOptimizedCodeMap(context->global_context())
- : -1;
- if (!function_info->bound()) {
- if (index > 0) {
- FixedArray* code_map =
- FixedArray::cast(function_info->optimized_code_map());
- FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1));
- ASSERT(cached_literals != NULL);
- ASSERT(function_info->num_literals() == 0 ||
- (code_map->get(index - 1) ==
- cached_literals->get(JSFunction::kLiteralGlobalContextIndex)));
- result->set_literals(cached_literals);
- } else {
- int number_of_literals = function_info->num_literals();
- Handle<FixedArray> literals =
- NewFixedArray(number_of_literals, pretenure);
- if (number_of_literals > 0) {
- // Store the object, regexp and array functions in the literals
- // array prefix. These functions will be used when creating
- // object, regexp and array literals in this function.
- literals->set(JSFunction::kLiteralGlobalContextIndex,
- context->global_context());
- }
- result->set_literals(*literals);
+ int index = function_info->SearchOptimizedCodeMap(context->global_context());
+ if (!function_info->bound() && index < 0) {
+ int number_of_literals = function_info->num_literals();
+ Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure);
+ if (number_of_literals > 0) {
+ // Store the global context in the literals array prefix. This
+ // context will be used when creating object, regexp and array
+ // literals in this function.
+ literals->set(JSFunction::kLiteralGlobalContextIndex,
+ context->global_context());
}
+ result->set_literals(*literals);
}
if (index > 0) {
// Caching of optimized code enabled and optimized code found.
- Code* code = Code::cast(
- FixedArray::cast(function_info->optimized_code_map())->get(index));
- ASSERT(code != NULL);
- result->ReplaceCode(code);
+ function_info->InstallFromOptimizedCodeMap(*result, index);
return result;
}
« no previous file with comments | « src/compiler.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698