Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: src/compiler.cc

Issue 1891663004: [compiler] Prevent unnecessary parsing with interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 passes_turbo_filter) && 701 passes_turbo_filter) &&
702 passes_osr_test; 702 passes_osr_test;
703 } 703 }
704 704
705 bool GetOptimizedCodeNow(CompilationInfo* info) { 705 bool GetOptimizedCodeNow(CompilationInfo* info) {
706 Isolate* isolate = info->isolate(); 706 Isolate* isolate = info->isolate();
707 CanonicalHandleScope canonical(isolate); 707 CanonicalHandleScope canonical(isolate);
708 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); 708 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate);
709 TRACE_EVENT0("v8", "V8.OptimizeCode"); 709 TRACE_EVENT0("v8", "V8.OptimizeCode");
710 710
711 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 711 bool use_turbofan = UseTurboFan(info);
712 OptimizedCompileJob* job = use_turbofan
713 ? compiler::Pipeline::NewCompilationJob(info)
714 : new (info->zone()) HCompilationJob(info);
715
716 // Parsing is not required when optimizing from existing bytecode.
717 if (!use_turbofan || !info->shared_info()->HasBytecodeArray()) {
718 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
719 } else {
720 info->MarkAsOptimizeFromBytecode();
721 }
712 722
713 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); 723 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
714 TRACE_EVENT0("v8", "V8.RecompileSynchronous"); 724 TRACE_EVENT0("v8", "V8.RecompileSynchronous");
715 725
716 OptimizedCompileJob* job = UseTurboFan(info)
717 ? compiler::Pipeline::NewCompilationJob(info)
718 : new (info->zone()) HCompilationJob(info);
719 if (job->CreateGraph() != OptimizedCompileJob::SUCCEEDED || 726 if (job->CreateGraph() != OptimizedCompileJob::SUCCEEDED ||
720 job->OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || 727 job->OptimizeGraph() != OptimizedCompileJob::SUCCEEDED ||
721 job->GenerateCode() != OptimizedCompileJob::SUCCEEDED) { 728 job->GenerateCode() != OptimizedCompileJob::SUCCEEDED) {
722 if (FLAG_trace_opt) { 729 if (FLAG_trace_opt) {
723 PrintF("[aborted optimizing "); 730 PrintF("[aborted optimizing ");
724 info->closure()->ShortPrint(); 731 info->closure()->ShortPrint();
725 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); 732 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason()));
726 } 733 }
727 return false; 734 return false;
728 } 735 }
(...skipping 15 matching lines...) Expand all
744 751
745 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { 752 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) {
746 if (FLAG_trace_concurrent_recompilation) { 753 if (FLAG_trace_concurrent_recompilation) {
747 PrintF(" ** Compilation queue full, will retry optimizing "); 754 PrintF(" ** Compilation queue full, will retry optimizing ");
748 info->closure()->ShortPrint(); 755 info->closure()->ShortPrint();
749 PrintF(" later.\n"); 756 PrintF(" later.\n");
750 } 757 }
751 return false; 758 return false;
752 } 759 }
753 760
761 bool use_turbofan = UseTurboFan(info);
762 OptimizedCompileJob* job = use_turbofan
763 ? compiler::Pipeline::NewCompilationJob(info)
764 : new (info->zone()) HCompilationJob(info);
765
766 // All handles below this point will be allocated in a deferred handle scope
767 // that is detached and handed off to the background thread when we return.
754 CompilationHandleScope handle_scope(info); 768 CompilationHandleScope handle_scope(info);
755 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 769
770 // Parsing is not required when optimizing from existing bytecode.
771 if (!use_turbofan || !info->shared_info()->HasBytecodeArray()) {
772 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
773 } else {
774 info->MarkAsOptimizeFromBytecode();
775 }
756 776
757 // Reopen handles in the new CompilationHandleScope. 777 // Reopen handles in the new CompilationHandleScope.
758 info->ReopenHandlesInNewHandleScope(); 778 info->ReopenHandlesInNewHandleScope();
759 info->parse_info()->ReopenHandlesInNewHandleScope(); 779 info->parse_info()->ReopenHandlesInNewHandleScope();
760 780
761 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); 781 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate());
762 TRACE_EVENT0("v8", "V8.RecompileSynchronous"); 782 TRACE_EVENT0("v8", "V8.RecompileSynchronous");
763 783
764 OptimizedCompileJob* job = UseTurboFan(info) 784 if (job->CreateGraph() != OptimizedCompileJob::SUCCEEDED) return false;
765 ? compiler::Pipeline::NewCompilationJob(info)
766 : new (info->zone()) HCompilationJob(info);
767 OptimizedCompileJob::Status status = job->CreateGraph();
768 if (status != OptimizedCompileJob::SUCCEEDED) return false;
769 isolate->optimizing_compile_dispatcher()->QueueForOptimization(job); 785 isolate->optimizing_compile_dispatcher()->QueueForOptimization(job);
770 786
771 if (FLAG_trace_concurrent_recompilation) { 787 if (FLAG_trace_concurrent_recompilation) {
772 PrintF(" ** Queued "); 788 PrintF(" ** Queued ");
773 info->closure()->ShortPrint(); 789 info->closure()->ShortPrint();
774 if (info->is_osr()) { 790 if (info->is_osr()) {
775 PrintF(" for concurrent OSR at %d.\n", info->osr_ast_id().ToInt()); 791 PrintF(" for concurrent OSR at %d.\n", info->osr_ast_id().ToInt());
776 } else { 792 } else {
777 PrintF(" for concurrent optimization.\n"); 793 PrintF(" for concurrent optimization.\n");
778 } 794 }
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 MaybeHandle<Code> code; 1681 MaybeHandle<Code> code;
1666 if (cached.code != nullptr) code = handle(cached.code); 1682 if (cached.code != nullptr) code = handle(cached.code);
1667 Handle<Context> native_context(function->context()->native_context()); 1683 Handle<Context> native_context(function->context()->native_context());
1668 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 1684 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
1669 literals, BailoutId::None()); 1685 literals, BailoutId::None());
1670 } 1686 }
1671 } 1687 }
1672 1688
1673 } // namespace internal 1689 } // namespace internal
1674 } // namespace v8 1690 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698