Chromium Code Reviews| Index: src/factory.cc |
| =================================================================== |
| --- src/factory.cc (revision 11527) |
| +++ src/factory.cc (working copy) |
| @@ -551,17 +551,43 @@ |
| result->set_context(*context); |
| if (!function_info->bound()) { |
| - 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()); |
| + int index = FLAG_cache_optimized_code |
| + ? function_info->SearchOptimizedCodeMap(context->global_context()) |
| + : -1; |
| + if (index > 0) { |
| + FixedArray* code_map = |
| + FixedArray::cast(function_info->optimized_code_map()); |
| + FixedArray* cached_literals = |
| + FixedArray::cast(code_map->get(index + 1)); |
|
Michael Starzinger
2012/05/23 11:16:29
It would be nice to have constants for these offse
fschneider
2012/06/14 11:08:23
Agree. Though I'd have the constants relative to t
|
| + ASSERT(cached_literals != NULL); |
|
Michael Starzinger
2012/05/23 11:16:29
Better add an ASSERT that the global context store
fschneider
2012/06/14 11:08:23
Done.
|
| + 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); |
| } |
| - result->set_literals(*literals); |
| } |
| + |
| + if (FLAG_cache_optimized_code) { |
| + int index = |
| + function_info->SearchOptimizedCodeMap(context->global_context()); |
| + if (index > 0) { |
| + Code* code = Code::cast( |
| + FixedArray::cast(function_info->optimized_code_map())->get(index)); |
| + ASSERT(code != NULL); |
| + result->ReplaceCode(code); |
| + return result; |
| + } |
| + } |
| + |
| if (V8::UseCrankshaft() && |
| FLAG_always_opt && |
| result->is_compiled() && |