Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 8662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8673 ASSERT(unoptimized->contains(frame->pc())); | 8673 ASSERT(unoptimized->contains(frame->pc())); |
| 8674 | 8674 |
| 8675 ASSERT(pc_offset == | 8675 ASSERT(pc_offset == |
| 8676 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start())); | 8676 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start())); |
| 8677 #endif // DEBUG | 8677 #endif // DEBUG |
| 8678 | 8678 |
| 8679 // We're not prepared to handle a function with arguments object. | 8679 // We're not prepared to handle a function with arguments object. |
| 8680 ASSERT(!function->shared()->uses_arguments()); | 8680 ASSERT(!function->shared()->uses_arguments()); |
| 8681 | 8681 |
| 8682 Handle<Code> result = Handle<Code>::null(); | 8682 Handle<Code> result = Handle<Code>::null(); |
| 8683 BailoutId ast_id = BailoutId::None(); | 8683 BailoutId ast_id = unoptimized->TranslatePcOffsetToAstId(pc_offset); |
| 8684 ASSERT(!ast_id.IsNone()); | |
| 8684 | 8685 |
| 8685 if (isolate->concurrent_osr_enabled()) { | 8686 int cached_index = function->shared()->SearchOptimizedCodeMap( |
| 8687 function->context()->native_context(), ast_id); | |
| 8688 if (cached_index != -1) { | |
| 8689 if (FLAG_trace_osr) { | |
| 8690 PrintF("[OSR - found cached code for "); | |
| 8691 function->PrintName(); | |
| 8692 PrintF(" with OSR ast id %d]\n", ast_id.ToInt()); | |
| 8693 } | |
| 8694 // TODO(titzer): don't install the OSR code into the function. | |
| 8695 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
| |
| 8696 result = Handle<Code>(function->code()); | |
| 8697 } else if (isolate->concurrent_osr_enabled()) { | |
| 8686 if (isolate->optimizing_compiler_thread()-> | 8698 if (isolate->optimizing_compiler_thread()-> |
| 8687 IsQueuedForOSR(function, pc_offset)) { | 8699 IsQueuedForOSR(function, ast_id)) { |
| 8688 // Still waiting for the optimizing compiler thread to finish. Carry on. | 8700 // Still waiting for the optimizing compiler thread to finish. Carry on. |
| 8689 if (FLAG_trace_osr) { | 8701 if (FLAG_trace_osr) { |
| 8690 PrintF("[COSR - polling recompile tasks for "); | 8702 PrintF("[COSR - polling recompile tasks for "); |
| 8691 function->PrintName(); | 8703 function->PrintName(); |
| 8692 PrintF("]\n"); | 8704 PrintF("]\n"); |
| 8693 } | 8705 } |
| 8694 return NULL; | 8706 return NULL; |
| 8695 } | 8707 } |
| 8696 | 8708 |
| 8697 RecompileJob* job = isolate->optimizing_compiler_thread()-> | 8709 RecompileJob* job = isolate->optimizing_compiler_thread()-> |
| 8698 FindReadyOSRCandidate(function, pc_offset); | 8710 FindReadyOSRCandidate(function, ast_id); |
| 8699 | 8711 |
| 8700 if (job == NULL) { | 8712 if (job == NULL) { |
| 8701 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && | 8713 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && |
| 8702 Compiler::RecompileConcurrent(function, pc_offset)) { | 8714 Compiler::RecompileConcurrent(function, ast_id)) { |
| 8703 if (function->IsMarkedForLazyRecompilation() || | 8715 if (function->IsMarkedForLazyRecompilation() || |
| 8704 function->IsMarkedForConcurrentRecompilation()) { | 8716 function->IsMarkedForConcurrentRecompilation()) { |
| 8705 // Prevent regular recompilation if we queue this for OSR. | 8717 // Prevent regular recompilation if we queue this for OSR. |
| 8706 // TODO(yangguo): remove this as soon as OSR becomes one-shot. | 8718 // TODO(yangguo): remove this as soon as OSR becomes one-shot. |
| 8707 function->ReplaceCode(*unoptimized); | 8719 function->ReplaceCode(*unoptimized); |
| 8708 } | 8720 } |
| 8709 return NULL; | 8721 return NULL; |
| 8710 } | 8722 } |
| 8711 // Fall through to the end in case of failure. | 8723 // Fall through to the end in case of failure. |
| 8712 } else { | 8724 } else { |
| 8713 // TODO(titzer): don't install the OSR code into the function. | 8725 // TODO(titzer): don't install the OSR code into the function. |
| 8714 ast_id = job->info()->osr_ast_id(); | 8726 ast_id = job->info()->osr_ast_id(); |
| 8715 result = Compiler::InstallOptimizedCode(job); | 8727 result = Compiler::InstallOptimizedCode(job); |
| 8716 } | 8728 } |
| 8717 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { | 8729 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { |
| 8718 ast_id = unoptimized->TranslatePcOffsetToAstId(pc_offset); | |
| 8719 ASSERT(!ast_id.IsNone()); | |
| 8720 if (FLAG_trace_osr) { | 8730 if (FLAG_trace_osr) { |
| 8721 PrintF("[OSR - replacing at AST id %d in ", ast_id.ToInt()); | 8731 PrintF("[OSR - replacing at AST id %d in ", ast_id.ToInt()); |
| 8722 function->PrintName(); | 8732 function->PrintName(); |
| 8723 PrintF("]\n"); | 8733 PrintF("]\n"); |
| 8724 } | 8734 } |
| 8725 // Attempt OSR compilation. | 8735 // Attempt OSR compilation. |
| 8726 result = JSFunction::CompileOsr(function, ast_id, CLEAR_EXCEPTION); | 8736 result = JSFunction::CompileOsr(function, ast_id, CLEAR_EXCEPTION); |
| 8727 } | 8737 } |
| 8728 | 8738 |
| 8729 // Revert the patched back edge table, regardless of whether OSR succeeds. | 8739 // Revert the patched back edge table, regardless of whether OSR succeeds. |
| (...skipping 6185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14915 // Handle last resort GC and make sure to allow future allocations | 14925 // Handle last resort GC and make sure to allow future allocations |
| 14916 // to grow the heap without causing GCs (if possible). | 14926 // to grow the heap without causing GCs (if possible). |
| 14917 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14927 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14918 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14928 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14919 "Runtime::PerformGC"); | 14929 "Runtime::PerformGC"); |
| 14920 } | 14930 } |
| 14921 } | 14931 } |
| 14922 | 14932 |
| 14923 | 14933 |
| 14924 } } // namespace v8::internal | 14934 } } // namespace v8::internal |
| OLD | NEW |