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

Side by Side Diff: runtime/vm/compiler.cc

Issue 2771013002: Add more safe points in compiler (Closed)
Patch Set: Created 3 years, 9 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 | runtime/vm/heap.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 // position of the inlined call until later. A side effect of this 828 // position of the inlined call until later. A side effect of this
829 // is that the length of |inline_id_to_function| is always larger 829 // is that the length of |inline_id_to_function| is always larger
830 // than the length of |inline_id_to_token_pos| by one. 830 // than the length of |inline_id_to_token_pos| by one.
831 // Top scope function has no caller (-1). We do this because we expect 831 // Top scope function has no caller (-1). We do this because we expect
832 // all token positions to be at an inlined call. 832 // all token positions to be at an inlined call.
833 caller_inline_id.Add(-1); 833 caller_inline_id.Add(-1);
834 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer); 834 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer);
835 835
836 JitOptimizer optimizer(flow_graph); 836 JitOptimizer optimizer(flow_graph);
837 837
838 optimizer.ApplyICData(); 838 {
839 NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), compiler_timeline,
840 "ApplyICData"));
841 optimizer.ApplyICData();
842 SafepointOperationScope safepoint_scope(thread());
Vyacheslav Egorov (Google) 2017/03/23 10:24:02 Here and below: I think you need thread()->Chec
erikcorry 2017/03/27 10:23:28 Done.
843 }
839 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 844 DEBUG_ASSERT(flow_graph->VerifyUseLists());
840 845
841 // Optimize (a << b) & c patterns, merge operations. 846 // Optimize (a << b) & c patterns, merge operations.
842 // Run early in order to have more opportunity to optimize left shifts. 847 // Run early in order to have more opportunity to optimize left shifts.
843 flow_graph->TryOptimizePatterns(); 848 flow_graph->TryOptimizePatterns();
844 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 849 DEBUG_ASSERT(flow_graph->VerifyUseLists());
845 850
846 FlowGraphInliner::SetInliningId(flow_graph, 0); 851 FlowGraphInliner::SetInliningId(flow_graph, 0);
847 852
848 // Inlining (mutates the flow graph) 853 // Inlining (mutates the flow graph)
(...skipping 10 matching lines...) Expand all
859 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 864 DEBUG_ASSERT(flow_graph->VerifyUseLists());
860 865
861 FlowGraphInliner inliner(flow_graph, &inline_id_to_function, 866 FlowGraphInliner inliner(flow_graph, &inline_id_to_function,
862 &inline_id_to_token_pos, &caller_inline_id, 867 &inline_id_to_token_pos, &caller_inline_id,
863 use_speculative_inlining, 868 use_speculative_inlining,
864 /*inlining_black_list=*/NULL, 869 /*inlining_black_list=*/NULL,
865 /*precompiler=*/NULL); 870 /*precompiler=*/NULL);
866 inliner.Inline(); 871 inliner.Inline();
867 // Use lists are maintained and validated by the inliner. 872 // Use lists are maintained and validated by the inliner.
868 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 873 DEBUG_ASSERT(flow_graph->VerifyUseLists());
874 SafepointOperationScope safepoint_scope(thread());
869 } 875 }
870 876
871 // Propagate types and eliminate more type tests. 877 // Propagate types and eliminate more type tests.
872 FlowGraphTypePropagator::Propagate(flow_graph); 878 FlowGraphTypePropagator::Propagate(flow_graph);
873 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 879 DEBUG_ASSERT(flow_graph->VerifyUseLists());
874 880
875 { 881 {
876 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline, 882 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline,
877 "ApplyClassIds")); 883 "ApplyClassIds"));
878 // Use propagated class-ids to optimize further. 884 // Use propagated class-ids to optimize further.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 // it depends on the numbering of loads from the previous 977 // it depends on the numbering of loads from the previous
972 // load-elimination. 978 // load-elimination.
973 if (FLAG_loop_invariant_code_motion) { 979 if (FLAG_loop_invariant_code_motion) {
974 flow_graph->RenameUsesDominatedByRedefinitions(); 980 flow_graph->RenameUsesDominatedByRedefinitions();
975 DEBUG_ASSERT(flow_graph->VerifyRedefinitions()); 981 DEBUG_ASSERT(flow_graph->VerifyRedefinitions());
976 LICM licm(flow_graph); 982 LICM licm(flow_graph);
977 licm.Optimize(); 983 licm.Optimize();
978 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 984 DEBUG_ASSERT(flow_graph->VerifyUseLists());
979 } 985 }
980 flow_graph->RemoveRedefinitions(); 986 flow_graph->RemoveRedefinitions();
987 SafepointOperationScope safepoint_scope(thread());
981 } 988 }
982 989
983 // Optimize (a << b) & c patterns, merge operations. 990 // Optimize (a << b) & c patterns, merge operations.
984 // Run after CSE in order to have more opportunity to merge 991 // Run after CSE in order to have more opportunity to merge
985 // instructions that have same inputs. 992 // instructions that have same inputs.
986 flow_graph->TryOptimizePatterns(); 993 flow_graph->TryOptimizePatterns();
987 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 994 DEBUG_ASSERT(flow_graph->VerifyUseLists());
988 995
989 { 996 {
990 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline, 997 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 // Attempt to sink allocations of temporary non-escaping objects to 1057 // Attempt to sink allocations of temporary non-escaping objects to
1051 // the deoptimization path. 1058 // the deoptimization path.
1052 AllocationSinking* sinking = NULL; 1059 AllocationSinking* sinking = NULL;
1053 if (FLAG_allocation_sinking && 1060 if (FLAG_allocation_sinking &&
1054 (flow_graph->graph_entry()->SuccessorCount() == 1)) { 1061 (flow_graph->graph_entry()->SuccessorCount() == 1)) {
1055 NOT_IN_PRODUCT(TimelineDurationScope tds2( 1062 NOT_IN_PRODUCT(TimelineDurationScope tds2(
1056 thread(), compiler_timeline, "AllocationSinking::Optimize")); 1063 thread(), compiler_timeline, "AllocationSinking::Optimize"));
1057 // TODO(fschneider): Support allocation sinking with try-catch. 1064 // TODO(fschneider): Support allocation sinking with try-catch.
1058 sinking = new AllocationSinking(flow_graph); 1065 sinking = new AllocationSinking(flow_graph);
1059 sinking->Optimize(); 1066 sinking->Optimize();
1067 SafepointOperationScope safepoint_scope(thread());
1060 } 1068 }
1061 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 1069 DEBUG_ASSERT(flow_graph->VerifyUseLists());
1062 1070
1063 DeadCodeElimination::EliminateDeadPhis(flow_graph); 1071 DeadCodeElimination::EliminateDeadPhis(flow_graph);
1064 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 1072 DEBUG_ASSERT(flow_graph->VerifyUseLists());
1065 1073
1066 FlowGraphTypePropagator::Propagate(flow_graph); 1074 FlowGraphTypePropagator::Propagate(flow_graph);
1067 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 1075 DEBUG_ASSERT(flow_graph->VerifyUseLists());
1068 1076
1069 { 1077 {
(...skipping 29 matching lines...) Expand all
1099 // to be later used by the inliner. 1107 // to be later used by the inliner.
1100 FlowGraphInliner::CollectGraphInfo(flow_graph, true); 1108 FlowGraphInliner::CollectGraphInfo(flow_graph, true);
1101 1109
1102 flow_graph->RemoveRedefinitions(); 1110 flow_graph->RemoveRedefinitions();
1103 { 1111 {
1104 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline, 1112 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline,
1105 "AllocateRegisters")); 1113 "AllocateRegisters"));
1106 // Perform register allocation on the SSA graph. 1114 // Perform register allocation on the SSA graph.
1107 FlowGraphAllocator allocator(*flow_graph); 1115 FlowGraphAllocator allocator(*flow_graph);
1108 allocator.AllocateRegisters(); 1116 allocator.AllocateRegisters();
1117 SafepointOperationScope safepoint_scope(thread());
1109 } 1118 }
1110 1119
1111 if (reorder_blocks) { 1120 if (reorder_blocks) {
1112 NOT_IN_PRODUCT(TimelineDurationScope tds( 1121 NOT_IN_PRODUCT(TimelineDurationScope tds(
1113 thread(), compiler_timeline, "BlockScheduler::ReorderBlocks")); 1122 thread(), compiler_timeline, "BlockScheduler::ReorderBlocks"));
1114 block_scheduler.ReorderBlocks(); 1123 block_scheduler.ReorderBlocks();
1115 } 1124 }
1116 1125
1117 if (print_flow_graph) { 1126 if (print_flow_graph) {
1118 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); 1127 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph);
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 2306
2298 2307
2299 bool BackgroundCompiler::IsDisabled() { 2308 bool BackgroundCompiler::IsDisabled() {
2300 UNREACHABLE(); 2309 UNREACHABLE();
2301 return true; 2310 return true;
2302 } 2311 }
2303 2312
2304 #endif // DART_PRECOMPILED_RUNTIME 2313 #endif // DART_PRECOMPILED_RUNTIME
2305 2314
2306 } // namespace dart 2315 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698