Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index 7dc96f201970eec90466b79f20fa2823271fe737..c469a57dbff9de81e4a24b61e8d39c1964325dd4 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -8680,11 +8680,23 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
| ASSERT(!function->shared()->uses_arguments()); |
| Handle<Code> result = Handle<Code>::null(); |
| - BailoutId ast_id = BailoutId::None(); |
| + BailoutId ast_id = unoptimized->TranslatePcOffsetToAstId(pc_offset); |
| + ASSERT(!ast_id.IsNone()); |
| - if (isolate->concurrent_osr_enabled()) { |
| + int cached_index = function->shared()->SearchOptimizedCodeMap( |
| + function->context()->native_context(), ast_id); |
| + if (cached_index != -1) { |
| + if (FLAG_trace_osr) { |
| + PrintF("[OSR - found cached code for "); |
| + function->PrintName(); |
| + PrintF(" with OSR ast id %d]\n", ast_id.ToInt()); |
| + } |
| + // TODO(titzer): don't install the OSR code into the function. |
| + function->shared()->InstallFromOptimizedCodeMap(*function, cached_index); |
|
Toon Verwaest
2013/12/04 13:06:25
I'd prefer to have a single choke-point that sets
|
| + result = Handle<Code>(function->code()); |
| + } else if (isolate->concurrent_osr_enabled()) { |
| if (isolate->optimizing_compiler_thread()-> |
| - IsQueuedForOSR(function, pc_offset)) { |
| + IsQueuedForOSR(function, ast_id)) { |
| // Still waiting for the optimizing compiler thread to finish. Carry on. |
| if (FLAG_trace_osr) { |
| PrintF("[COSR - polling recompile tasks for "); |
| @@ -8695,11 +8707,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
| } |
| RecompileJob* job = isolate->optimizing_compiler_thread()-> |
| - FindReadyOSRCandidate(function, pc_offset); |
| + FindReadyOSRCandidate(function, ast_id); |
| if (job == NULL) { |
| if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && |
| - Compiler::RecompileConcurrent(function, pc_offset)) { |
| + Compiler::RecompileConcurrent(function, ast_id)) { |
| if (function->IsMarkedForLazyRecompilation() || |
| function->IsMarkedForConcurrentRecompilation()) { |
| // Prevent regular recompilation if we queue this for OSR. |
| @@ -8715,8 +8727,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
| result = Compiler::InstallOptimizedCode(job); |
| } |
| } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { |
| - ast_id = unoptimized->TranslatePcOffsetToAstId(pc_offset); |
| - ASSERT(!ast_id.IsNone()); |
| if (FLAG_trace_osr) { |
| PrintF("[OSR - replacing at AST id %d in ", ast_id.ToInt()); |
| function->PrintName(); |