| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/ast/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
| 10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 passes_turbo_filter) && | 712 passes_turbo_filter) && |
| 713 passes_osr_test; | 713 passes_osr_test; |
| 714 } | 714 } |
| 715 | 715 |
| 716 bool GetOptimizedCodeNow(CompilationInfo* info) { | 716 bool GetOptimizedCodeNow(CompilationInfo* info) { |
| 717 Isolate* isolate = info->isolate(); | 717 Isolate* isolate = info->isolate(); |
| 718 CanonicalHandleScope canonical(isolate); | 718 CanonicalHandleScope canonical(isolate); |
| 719 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); | 719 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); |
| 720 TRACE_EVENT0("v8", "V8.OptimizeCode"); | 720 TRACE_EVENT0("v8", "V8.OptimizeCode"); |
| 721 | 721 |
| 722 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; | 722 bool use_turbofan = UseTurboFan(info); |
| 723 OptimizedCompileJob* job = use_turbofan |
| 724 ? compiler::Pipeline::NewCompilationJob(info) |
| 725 : new (info->zone()) HCompilationJob(info); |
| 726 |
| 727 // Parsing is not required when optimizing from existing bytecode. |
| 728 if (!use_turbofan || !info->shared_info()->HasBytecodeArray()) { |
| 729 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; |
| 730 } |
| 723 | 731 |
| 724 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); | 732 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); |
| 725 TRACE_EVENT0("v8", "V8.RecompileSynchronous"); | 733 TRACE_EVENT0("v8", "V8.RecompileSynchronous"); |
| 726 | 734 |
| 727 OptimizedCompileJob* job = UseTurboFan(info) | |
| 728 ? compiler::Pipeline::NewCompilationJob(info) | |
| 729 : new (info->zone()) HCompilationJob(info); | |
| 730 if (job->CreateGraph() != OptimizedCompileJob::SUCCEEDED || | 735 if (job->CreateGraph() != OptimizedCompileJob::SUCCEEDED || |
| 731 job->OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || | 736 job->OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || |
| 732 job->GenerateCode() != OptimizedCompileJob::SUCCEEDED) { | 737 job->GenerateCode() != OptimizedCompileJob::SUCCEEDED) { |
| 733 if (FLAG_trace_opt) { | 738 if (FLAG_trace_opt) { |
| 734 PrintF("[aborted optimizing "); | 739 PrintF("[aborted optimizing "); |
| 735 info->closure()->ShortPrint(); | 740 info->closure()->ShortPrint(); |
| 736 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); | 741 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); |
| 737 } | 742 } |
| 738 return false; | 743 return false; |
| 739 } | 744 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 755 | 760 |
| 756 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { | 761 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { |
| 757 if (FLAG_trace_concurrent_recompilation) { | 762 if (FLAG_trace_concurrent_recompilation) { |
| 758 PrintF(" ** Compilation queue full, will retry optimizing "); | 763 PrintF(" ** Compilation queue full, will retry optimizing "); |
| 759 info->closure()->ShortPrint(); | 764 info->closure()->ShortPrint(); |
| 760 PrintF(" later.\n"); | 765 PrintF(" later.\n"); |
| 761 } | 766 } |
| 762 return false; | 767 return false; |
| 763 } | 768 } |
| 764 | 769 |
| 770 bool use_turbofan = UseTurboFan(info); |
| 771 OptimizedCompileJob* job = use_turbofan |
| 772 ? compiler::Pipeline::NewCompilationJob(info) |
| 773 : new (info->zone()) HCompilationJob(info); |
| 774 |
| 775 // All handles below this point will be allocated in a deferred handle scope |
| 776 // that is detached and handed off to the background thread when we return. |
| 765 CompilationHandleScope handle_scope(info); | 777 CompilationHandleScope handle_scope(info); |
| 766 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; | 778 |
| 779 // Parsing is not required when optimizing from existing bytecode. |
| 780 if (!use_turbofan || !info->shared_info()->HasBytecodeArray()) { |
| 781 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; |
| 782 } |
| 767 | 783 |
| 768 // Reopen handles in the new CompilationHandleScope. | 784 // Reopen handles in the new CompilationHandleScope. |
| 769 info->ReopenHandlesInNewHandleScope(); | 785 info->ReopenHandlesInNewHandleScope(); |
| 770 info->parse_info()->ReopenHandlesInNewHandleScope(); | 786 info->parse_info()->ReopenHandlesInNewHandleScope(); |
| 771 | 787 |
| 772 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); | 788 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| 773 TRACE_EVENT0("v8", "V8.RecompileSynchronous"); | 789 TRACE_EVENT0("v8", "V8.RecompileSynchronous"); |
| 774 | 790 |
| 775 OptimizedCompileJob* job = UseTurboFan(info) | 791 if (job->CreateGraph() != OptimizedCompileJob::SUCCEEDED) return false; |
| 776 ? compiler::Pipeline::NewCompilationJob(info) | |
| 777 : new (info->zone()) HCompilationJob(info); | |
| 778 OptimizedCompileJob::Status status = job->CreateGraph(); | |
| 779 if (status != OptimizedCompileJob::SUCCEEDED) return false; | |
| 780 isolate->optimizing_compile_dispatcher()->QueueForOptimization(job); | 792 isolate->optimizing_compile_dispatcher()->QueueForOptimization(job); |
| 781 | 793 |
| 782 if (FLAG_trace_concurrent_recompilation) { | 794 if (FLAG_trace_concurrent_recompilation) { |
| 783 PrintF(" ** Queued "); | 795 PrintF(" ** Queued "); |
| 784 info->closure()->ShortPrint(); | 796 info->closure()->ShortPrint(); |
| 785 if (info->is_osr()) { | 797 if (info->is_osr()) { |
| 786 PrintF(" for concurrent OSR at %d.\n", info->osr_ast_id().ToInt()); | 798 PrintF(" for concurrent OSR at %d.\n", info->osr_ast_id().ToInt()); |
| 787 } else { | 799 } else { |
| 788 PrintF(" for concurrent optimization.\n"); | 800 PrintF(" for concurrent optimization.\n"); |
| 789 } | 801 } |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 MaybeHandle<Code> code; | 1672 MaybeHandle<Code> code; |
| 1661 if (cached.code != nullptr) code = handle(cached.code); | 1673 if (cached.code != nullptr) code = handle(cached.code); |
| 1662 Handle<Context> native_context(function->context()->native_context()); | 1674 Handle<Context> native_context(function->context()->native_context()); |
| 1663 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1675 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| 1664 literals, BailoutId::None()); | 1676 literals, BailoutId::None()); |
| 1665 } | 1677 } |
| 1666 } | 1678 } |
| 1667 | 1679 |
| 1668 } // namespace internal | 1680 } // namespace internal |
| 1669 } // namespace v8 | 1681 } // namespace v8 |
| OLD | NEW |