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

Side by Side Diff: src/compiler.cc

Issue 2274253003: [compiler] Don't canonicalize handles in Crankshaft. (Closed)
Patch Set: Move handle scopes into GetOptimizedCode. Created 4 years, 3 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 | « no previous file | no next file » | 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 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-js.h" 10 #include "src/asmjs/asm-js.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context, 59 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context,
60 Handle<Context>::null()) 60 Handle<Context>::null())
61 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) 61 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info)
62 62
63 #undef PARSE_INFO_GETTER 63 #undef PARSE_INFO_GETTER
64 #undef PARSE_INFO_GETTER_WITH_DEFAULT 64 #undef PARSE_INFO_GETTER_WITH_DEFAULT
65 65
66 // A wrapper around a CompilationInfo that detaches the Handles from 66 // A wrapper around a CompilationInfo that detaches the Handles from
67 // the underlying DeferredHandleScope and stores them in info_ on 67 // the underlying DeferredHandleScope and stores them in info_ on
68 // destruction. 68 // destruction.
69 class CompilationHandleScope BASE_EMBEDDED { 69 class CompilationHandleScope final {
70 public: 70 public:
71 explicit CompilationHandleScope(CompilationInfo* info) 71 explicit CompilationHandleScope(CompilationInfo* info)
72 : deferred_(info->isolate()), info_(info) {} 72 : deferred_(info->isolate()), info_(info) {}
73 ~CompilationHandleScope() { info_->set_deferred_handles(deferred_.Detach()); } 73 ~CompilationHandleScope() { info_->set_deferred_handles(deferred_.Detach()); }
74 74
75 private: 75 private:
76 DeferredHandleScope deferred_; 76 DeferredHandleScope deferred_;
77 CompilationInfo* info_; 77 CompilationInfo* info_;
78 }; 78 };
79 79
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 bool passes_turbo_filter = shared->PassesFilter(FLAG_turbo_filter); 651 bool passes_turbo_filter = shared->PassesFilter(FLAG_turbo_filter);
652 652
653 return is_turbofanable_asm || is_unsupported_by_crankshaft_but_turbofanable || 653 return is_turbofanable_asm || is_unsupported_by_crankshaft_but_turbofanable ||
654 passes_turbo_filter; 654 passes_turbo_filter;
655 } 655 }
656 656
657 bool GetOptimizedCodeNow(CompilationJob* job) { 657 bool GetOptimizedCodeNow(CompilationJob* job) {
658 CompilationInfo* info = job->info(); 658 CompilationInfo* info = job->info();
659 Isolate* isolate = info->isolate(); 659 Isolate* isolate = info->isolate();
660 660
661 // All handles below this point will be canonicalized.
662 CanonicalHandleScope canonical(isolate);
663
664 // Parsing is not required when optimizing from existing bytecode. 661 // Parsing is not required when optimizing from existing bytecode.
665 if (!info->is_optimizing_from_bytecode()) { 662 if (!info->is_optimizing_from_bytecode()) {
666 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 663 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
667 EnsureFeedbackMetadata(info); 664 EnsureFeedbackMetadata(info);
668 } 665 }
669 666
670 JSFunction::EnsureLiterals(info->closure()); 667 JSFunction::EnsureLiterals(info->closure());
671 668
672 // Reopen handles in the new CompilationHandleScope.
673 info->ReopenHandlesInNewHandleScope();
674 info->parse_info()->ReopenHandlesInNewHandleScope();
675
676 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); 669 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
677 RuntimeCallTimerScope runtimeTimer(isolate, 670 RuntimeCallTimerScope runtimeTimer(isolate,
678 &RuntimeCallStats::RecompileSynchronous); 671 &RuntimeCallStats::RecompileSynchronous);
679 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( 672 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
680 isolate, &tracing::TraceEventStatsTable::RecompileSynchronous); 673 isolate, &tracing::TraceEventStatsTable::RecompileSynchronous);
681 674
682 if (job->PrepareJob() != CompilationJob::SUCCEEDED || 675 if (job->PrepareJob() != CompilationJob::SUCCEEDED ||
683 job->ExecuteJob() != CompilationJob::SUCCEEDED || 676 job->ExecuteJob() != CompilationJob::SUCCEEDED ||
684 job->FinalizeJob() != CompilationJob::SUCCEEDED) { 677 job->FinalizeJob() != CompilationJob::SUCCEEDED) {
685 if (FLAG_trace_opt) { 678 if (FLAG_trace_opt) {
(...skipping 27 matching lines...) Expand all
713 706
714 if (isolate->heap()->HighMemoryPressure()) { 707 if (isolate->heap()->HighMemoryPressure()) {
715 if (FLAG_trace_concurrent_recompilation) { 708 if (FLAG_trace_concurrent_recompilation) {
716 PrintF(" ** High memory pressure, will retry optimizing "); 709 PrintF(" ** High memory pressure, will retry optimizing ");
717 info->closure()->ShortPrint(); 710 info->closure()->ShortPrint();
718 PrintF(" later.\n"); 711 PrintF(" later.\n");
719 } 712 }
720 return false; 713 return false;
721 } 714 }
722 715
723 // All handles below this point will be canonicalized and allocated in a
724 // deferred handle scope that is detached and handed off to the background
725 // thread when we return.
726 CompilationHandleScope handle_scope(info);
727 CanonicalHandleScope canonical(isolate);
728
729 // Parsing is not required when optimizing from existing bytecode. 716 // Parsing is not required when optimizing from existing bytecode.
730 if (!info->is_optimizing_from_bytecode()) { 717 if (!info->is_optimizing_from_bytecode()) {
731 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 718 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
732 EnsureFeedbackMetadata(info); 719 EnsureFeedbackMetadata(info);
733 } 720 }
734 721
735 JSFunction::EnsureLiterals(info->closure()); 722 JSFunction::EnsureLiterals(info->closure());
736 723
737 // Reopen handles in the new CompilationHandleScope.
738 info->ReopenHandlesInNewHandleScope();
739 info->parse_info()->ReopenHandlesInNewHandleScope();
740
741 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); 724 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate());
742 RuntimeCallTimerScope runtimeTimer(info->isolate(), 725 RuntimeCallTimerScope runtimeTimer(info->isolate(),
743 &RuntimeCallStats::RecompileSynchronous); 726 &RuntimeCallStats::RecompileSynchronous);
744 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( 727 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
745 isolate, &tracing::TraceEventStatsTable::RecompileSynchronous); 728 isolate, &tracing::TraceEventStatsTable::RecompileSynchronous);
746 729
747 if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false; 730 if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false;
748 isolate->optimizing_compile_dispatcher()->QueueForOptimization(job); 731 isolate->optimizing_compile_dispatcher()->QueueForOptimization(job);
749 732
750 if (FLAG_trace_concurrent_recompilation) { 733 if (FLAG_trace_concurrent_recompilation) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } 815 }
833 816
834 if (IsEvalToplevel(shared)) { 817 if (IsEvalToplevel(shared)) {
835 parse_info->set_eval(); 818 parse_info->set_eval();
836 if (function->context()->IsNativeContext()) parse_info->set_global(); 819 if (function->context()->IsNativeContext()) parse_info->set_global();
837 parse_info->set_toplevel(); 820 parse_info->set_toplevel();
838 parse_info->set_allow_lazy_parsing(false); 821 parse_info->set_allow_lazy_parsing(false);
839 parse_info->set_lazy(false); 822 parse_info->set_lazy(false);
840 } 823 }
841 824
825 // In case of concurrent recompilation, all handles below this point will be
826 // allocated in a deferred handle scope that is detached and handed off to
827 // the background thread when we return.
828 std::unique_ptr<CompilationHandleScope> compilation;
829 if (mode == Compiler::CONCURRENT) {
830 compilation.reset(new CompilationHandleScope(info));
831 }
832
833 // In case of TurboFan, all handles below will be canonicalized.
834 std::unique_ptr<CanonicalHandleScope> canonical;
835 if (use_turbofan) canonical.reset(new CanonicalHandleScope(info->isolate()));
836
837 // Reopen handles in the new CompilationHandleScope.
838 info->ReopenHandlesInNewHandleScope();
839 parse_info->ReopenHandlesInNewHandleScope();
840
842 if (mode == Compiler::CONCURRENT) { 841 if (mode == Compiler::CONCURRENT) {
843 if (GetOptimizedCodeLater(job.get())) { 842 if (GetOptimizedCodeLater(job.get())) {
844 job.release(); // The background recompile job owns this now. 843 job.release(); // The background recompile job owns this now.
845 return isolate->builtins()->InOptimizationQueue(); 844 return isolate->builtins()->InOptimizationQueue();
846 } 845 }
847 } else { 846 } else {
848 if (GetOptimizedCodeNow(job.get())) return info->code(); 847 if (GetOptimizedCodeNow(job.get())) return info->code();
849 } 848 }
850 849
851 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); 850 if (isolate->has_pending_exception()) isolate->clear_pending_exception();
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 DCHECK(shared->is_compiled()); 1984 DCHECK(shared->is_compiled());
1986 function->set_literals(cached.literals); 1985 function->set_literals(cached.literals);
1987 } else if (shared->is_compiled()) { 1986 } else if (shared->is_compiled()) {
1988 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1987 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1989 JSFunction::EnsureLiterals(function); 1988 JSFunction::EnsureLiterals(function);
1990 } 1989 }
1991 } 1990 }
1992 1991
1993 } // namespace internal 1992 } // namespace internal
1994 } // namespace v8 1993 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698