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

Side by Side Diff: src/compiler.cc

Issue 2276953004: [compiler] Properly canonicalize handles even with concurrent recompilation. (Closed)
Patch Set: 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 640 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
661 // Parsing is not required when optimizing from existing bytecode. 664 // Parsing is not required when optimizing from existing bytecode.
662 if (!info->is_optimizing_from_bytecode()) { 665 if (!info->is_optimizing_from_bytecode()) {
663 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 666 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
664 EnsureFeedbackMetadata(info); 667 EnsureFeedbackMetadata(info);
665 } 668 }
666 669
667 JSFunction::EnsureLiterals(info->closure()); 670 JSFunction::EnsureLiterals(info->closure());
668 671
672 // Reopen handles in the new CompilationHandleScope.
673 info->ReopenHandlesInNewHandleScope();
674 info->parse_info()->ReopenHandlesInNewHandleScope();
675
669 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); 676 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
670 RuntimeCallTimerScope runtimeTimer(isolate, 677 RuntimeCallTimerScope runtimeTimer(isolate,
671 &RuntimeCallStats::RecompileSynchronous); 678 &RuntimeCallStats::RecompileSynchronous);
672 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( 679 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
673 isolate, &tracing::TraceEventStatsTable::RecompileSynchronous); 680 isolate, &tracing::TraceEventStatsTable::RecompileSynchronous);
674 681
675 if (job->PrepareJob() != CompilationJob::SUCCEEDED || 682 if (job->PrepareJob() != CompilationJob::SUCCEEDED ||
676 job->ExecuteJob() != CompilationJob::SUCCEEDED || 683 job->ExecuteJob() != CompilationJob::SUCCEEDED ||
677 job->FinalizeJob() != CompilationJob::SUCCEEDED) { 684 job->FinalizeJob() != CompilationJob::SUCCEEDED) {
678 if (FLAG_trace_opt) { 685 if (FLAG_trace_opt) {
(...skipping 27 matching lines...) Expand all
706 713
707 if (isolate->heap()->HighMemoryPressure()) { 714 if (isolate->heap()->HighMemoryPressure()) {
708 if (FLAG_trace_concurrent_recompilation) { 715 if (FLAG_trace_concurrent_recompilation) {
709 PrintF(" ** High memory pressure, will retry optimizing "); 716 PrintF(" ** High memory pressure, will retry optimizing ");
710 info->closure()->ShortPrint(); 717 info->closure()->ShortPrint();
711 PrintF(" later.\n"); 718 PrintF(" later.\n");
712 } 719 }
713 return false; 720 return false;
714 } 721 }
715 722
716 // All handles below this point will be allocated in a deferred handle scope 723 // All handles below this point will be canonicalized and allocated in a
717 // that is detached and handed off to the background thread when we return. 724 // deferred handle scope that is detached and handed off to the background
725 // thread when we return.
718 CompilationHandleScope handle_scope(info); 726 CompilationHandleScope handle_scope(info);
727 CanonicalHandleScope canonical(isolate);
719 728
720 // Parsing is not required when optimizing from existing bytecode. 729 // Parsing is not required when optimizing from existing bytecode.
721 if (!info->is_optimizing_from_bytecode()) { 730 if (!info->is_optimizing_from_bytecode()) {
722 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 731 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
723 EnsureFeedbackMetadata(info); 732 EnsureFeedbackMetadata(info);
724 } 733 }
725 734
726 JSFunction::EnsureLiterals(info->closure()); 735 JSFunction::EnsureLiterals(info->closure());
727 736
728 // Reopen handles in the new CompilationHandleScope. 737 // Reopen handles in the new CompilationHandleScope.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 } 810 }
802 811
803 // Limit the number of times we try to optimize functions. 812 // Limit the number of times we try to optimize functions.
804 const int kMaxOptCount = 813 const int kMaxOptCount =
805 FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000; 814 FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000;
806 if (info->shared_info()->opt_count() > kMaxOptCount) { 815 if (info->shared_info()->opt_count() > kMaxOptCount) {
807 info->AbortOptimization(kOptimizedTooManyTimes); 816 info->AbortOptimization(kOptimizedTooManyTimes);
808 return MaybeHandle<Code>(); 817 return MaybeHandle<Code>();
809 } 818 }
810 819
811 CanonicalHandleScope canonical(isolate);
812 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); 820 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate);
813 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::OptimizeCode); 821 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::OptimizeCode);
814 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( 822 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
815 isolate, &tracing::TraceEventStatsTable::OptimizeCode); 823 isolate, &tracing::TraceEventStatsTable::OptimizeCode);
816 824
817 // TurboFan can optimize directly from existing bytecode. 825 // TurboFan can optimize directly from existing bytecode.
818 if (FLAG_turbo_from_bytecode && use_turbofan && ShouldUseIgnition(info)) { 826 if (FLAG_turbo_from_bytecode && use_turbofan && ShouldUseIgnition(info)) {
819 if (!Compiler::EnsureBytecode(info)) { 827 if (!Compiler::EnsureBytecode(info)) {
820 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); 828 if (isolate->has_pending_exception()) isolate->clear_pending_exception();
821 return MaybeHandle<Code>(); 829 return MaybeHandle<Code>();
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 DCHECK(shared->is_compiled()); 1985 DCHECK(shared->is_compiled());
1978 function->set_literals(cached.literals); 1986 function->set_literals(cached.literals);
1979 } else if (shared->is_compiled()) { 1987 } else if (shared->is_compiled()) {
1980 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1988 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1981 JSFunction::EnsureLiterals(function); 1989 JSFunction::EnsureLiterals(function);
1982 } 1990 }
1983 } 1991 }
1984 1992
1985 } // namespace internal 1993 } // namespace internal
1986 } // namespace v8 1994 } // 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