Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 1d2cd69cd95747b73ceaadf426fb8e7a6c4678e9..78f83c45c98ee2051b4019f47446f1e908705cae 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -7546,6 +7546,23 @@ void SharedFunctionInfo::AddToOptimizedCodeMap( |
} |
+void SharedFunctionInfo::InstallFromOptimizedCodeMap(JSFunction* function, |
+ int index) { |
+ ASSERT(index > 0); |
+ ASSERT(optimized_code_map()->IsFixedArray()); |
+ FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
+ if (!bound()) { |
+ FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); |
+ ASSERT(cached_literals != NULL); |
+ function->set_literals(cached_literals); |
+ } |
+ Code* code = Code::cast(code_map->get(index)); |
+ ASSERT(code != NULL); |
+ ASSERT(function->context()->global_context() == code_map->get(index - 1)); |
+ function->ReplaceCode(code); |
+} |
+ |
+ |
bool JSFunction::CompileLazy(Handle<JSFunction> function, |
ClearExceptionFlag flag) { |
bool result = true; |
@@ -8097,6 +8114,7 @@ void SharedFunctionInfo::CompleteInobjectSlackTracking() { |
int SharedFunctionInfo::SearchOptimizedCodeMap(Context* global_context) { |
ASSERT(global_context->IsGlobalContext()); |
+ if (!FLAG_cache_optimized_code) return -1; |
Object* value = optimized_code_map(); |
if (!value->IsSmi()) { |
FixedArray* optimized_code_map = FixedArray::cast(value); |