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/assert.h" | |
7 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
8 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
9 #include "vm/intermediate_language.h" | 10 #include "vm/intermediate_language.h" |
10 #include "vm/longjump.h" | 11 #include "vm/longjump.h" |
11 #include "vm/growable_array.h" | 12 #include "vm/growable_array.h" |
12 | 13 |
13 namespace dart { | 14 namespace dart { |
14 | 15 |
15 DECLARE_FLAG(bool, trace_optimization); | 16 DECLARE_FLAG(bool, trace_optimization); |
16 | 17 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 return true; // Return true so we can ASSERT the reset code. | 127 return true; // Return true so we can ASSERT the reset code. |
127 } | 128 } |
128 | 129 |
129 | 130 |
130 static void ValidateUseListsInInstruction(Instruction* instr) { | 131 static void ValidateUseListsInInstruction(Instruction* instr) { |
131 ASSERT(instr != NULL); | 132 ASSERT(instr != NULL); |
132 ASSERT(!instr->IsJoinEntry()); | 133 ASSERT(!instr->IsJoinEntry()); |
133 for (intptr_t i = 0; i < instr->InputCount(); ++i) { | 134 for (intptr_t i = 0; i < instr->InputCount(); ++i) { |
134 Value* use = instr->InputAt(i); | 135 Value* use = instr->InputAt(i); |
135 ASSERT(use->use_index() == i); | 136 ASSERT(use->use_index() == i); |
136 ASSERT(1 == MembershipCount(use, use->definition()->input_use_list())); | 137 ASSERT(1 == MembershipCount(use, use->definition()->input_use_list())); |
Kevin Millikin (Google)
2012/10/01 11:38:26
Can we make this a slow assert?
And the same for
zerny-google
2012/10/01 11:50:36
Done.
| |
137 } | 138 } |
138 if (instr->env() != NULL) { | 139 if (instr->env() != NULL) { |
139 intptr_t use_index = 0; | 140 intptr_t use_index = 0; |
140 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { | 141 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { |
141 Value* use = it.CurrentValue(); | 142 Value* use = it.CurrentValue(); |
142 ASSERT(use->use_index() == use_index++); | 143 ASSERT(use->use_index() == use_index++); |
143 ASSERT(1 == MembershipCount(use, use->definition()->env_use_list())); | 144 ASSERT(1 == MembershipCount(use, use->definition()->env_use_list())); |
144 } | 145 } |
145 } | 146 } |
146 Definition* defn = instr->AsDefinition(); | 147 Definition* defn = instr->AsDefinition(); |
(...skipping 128 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 |