Index: src/factory.cc |
diff --git a/src/factory.cc b/src/factory.cc |
index ba93e6c7ff4753fe4ac111d2cc5426b4f948b455..3f14f0267cf90252a57263dfb18782e233103330 100644 |
--- a/src/factory.cc |
+++ b/src/factory.cc |
@@ -1377,24 +1377,22 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
result->MarkForOptimization(); |
} |
- int index = info->SearchOptimizedCodeMap(context->native_context(), |
- BailoutId::None()); |
- if (!info->bound() && index < 0) { |
+ CodeAndLiterals cached = info->SearchOptimizedCodeMap( |
+ 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()) { |
Jarin
2015/06/24 14:01:53
Any reason why not to say something like
...
} el
Michael Starzinger
2015/06/24 14:36:42
I would like to get to an interface where the resu
|
int number_of_literals = info->num_literals(); |
Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); |
result->set_literals(*literals); |
} |
- if (index > 0) { |
- // Caching of optimized code enabled and optimized code found. |
- FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index); |
- if (literals != NULL) result->set_literals(literals); |
- Code* code = info->GetCodeFromOptimizedCodeMap(index); |
- DCHECK(!code->marked_for_deoptimization()); |
- DCHECK(result->shared()->is_compiled()); |
- result->ReplaceCode(code); |
- } |
- |
return result; |
} |