OLD | NEW |
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/flow_graph.h" | 5 #include "vm/flow_graph.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
11 #include "vm/growable_array.h" | 11 #include "vm/growable_array.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
| 15 DECLARE_FLAG(bool, slow_assert); |
15 DECLARE_FLAG(bool, trace_optimization); | 16 DECLARE_FLAG(bool, trace_optimization); |
16 | 17 |
17 FlowGraph::FlowGraph(const FlowGraphBuilder& builder, | 18 FlowGraph::FlowGraph(const FlowGraphBuilder& builder, |
18 GraphEntryInstr* graph_entry) | 19 GraphEntryInstr* graph_entry) |
19 : parent_(), | 20 : parent_(), |
20 assigned_vars_(), | 21 assigned_vars_(), |
21 current_ssa_temp_index_(0), | 22 current_ssa_temp_index_(0), |
22 parsed_function_(builder.parsed_function()), | 23 parsed_function_(builder.parsed_function()), |
23 num_copied_params_(builder.num_copied_params()), | 24 num_copied_params_(builder.num_copied_params()), |
24 num_non_copied_params_(builder.num_non_copied_params()), | 25 num_non_copied_params_(builder.num_non_copied_params()), |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 276 } |
276 | 277 |
277 | 278 |
278 void FlowGraph::ComputeUseLists() { | 279 void FlowGraph::ComputeUseLists() { |
279 DEBUG_ASSERT(ResetUseLists()); | 280 DEBUG_ASSERT(ResetUseLists()); |
280 // Clear initial definitions. | 281 // Clear initial definitions. |
281 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { | 282 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { |
282 ClearUseLists((*graph_entry_->initial_definitions())[i]); | 283 ClearUseLists((*graph_entry_->initial_definitions())[i]); |
283 } | 284 } |
284 ComputeUseListsRecursive(graph_entry_); | 285 ComputeUseListsRecursive(graph_entry_); |
285 DEBUG_ASSERT(ValidateUseLists()); | 286 SLOW_ASSERT(ValidateUseLists()); |
286 } | 287 } |
287 | 288 |
288 | 289 |
289 void FlowGraph::ComputeSSA(intptr_t next_virtual_register_number) { | 290 void FlowGraph::ComputeSSA(intptr_t next_virtual_register_number) { |
290 current_ssa_temp_index_ = next_virtual_register_number; | 291 current_ssa_temp_index_ = next_virtual_register_number; |
291 GrowableArray<BitVector*> dominance_frontier; | 292 GrowableArray<BitVector*> dominance_frontier; |
292 ComputeDominators(&dominance_frontier); | 293 ComputeDominators(&dominance_frontier); |
293 InsertPhis(preorder_, assigned_vars_, dominance_frontier); | 294 InsertPhis(preorder_, assigned_vars_, dominance_frontier); |
294 GrowableArray<PhiInstr*> live_phis; | 295 GrowableArray<PhiInstr*> live_phis; |
295 // Rename uses to reference inserted phis where appropriate. | 296 // Rename uses to reference inserted phis where appropriate. |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 // TODO(zerny): Support multiple exits. | 790 // TODO(zerny): Support multiple exits. |
790 UNREACHABLE(); | 791 UNREACHABLE(); |
791 } | 792 } |
792 | 793 |
793 // TODO(zerny): Adjust pre/post orders. | 794 // TODO(zerny): Adjust pre/post orders. |
794 // TODO(zerny): Update dominator tree. | 795 // TODO(zerny): Update dominator tree. |
795 } | 796 } |
796 | 797 |
797 | 798 |
798 } // namespace dart | 799 } // namespace dart |
OLD | NEW |