| 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" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return true; // Return true so we can ASSERT the reset code. | 128 return true; // Return true so we can ASSERT the reset code. |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 static void ValidateUseListsInInstruction(Instruction* instr) { | 132 static void ValidateUseListsInInstruction(Instruction* instr) { |
| 133 ASSERT(instr != NULL); | 133 ASSERT(instr != NULL); |
| 134 ASSERT(!instr->IsJoinEntry()); | 134 ASSERT(!instr->IsJoinEntry()); |
| 135 for (intptr_t i = 0; i < instr->InputCount(); ++i) { | 135 for (intptr_t i = 0; i < instr->InputCount(); ++i) { |
| 136 Value* use = instr->InputAt(i); | 136 Value* use = instr->InputAt(i); |
| 137 ASSERT(use->use_index() == i); | 137 ASSERT(use->use_index() == i); |
| 138 ASSERT(1 == MembershipCount(use, use->definition()->input_use_list())); | 138 // TODO(zerny): Make this a slow assert. |
| 139 // ASSERT(1 == MembershipCount(use, use->definition()->input_use_list())); |
| 139 } | 140 } |
| 140 if (instr->env() != NULL) { | 141 if (instr->env() != NULL) { |
| 141 intptr_t use_index = 0; | 142 intptr_t use_index = 0; |
| 142 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { | 143 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { |
| 143 Value* use = it.CurrentValue(); | 144 Value* use = it.CurrentValue(); |
| 144 ASSERT(use->use_index() == use_index++); | 145 ASSERT(use->use_index() == use_index++); |
| 145 ASSERT(1 == MembershipCount(use, use->definition()->env_use_list())); | 146 // TODO(zerny): Make this a slow assert. |
| 147 // ASSERT(1 == MembershipCount(use, use->definition()->env_use_list())); |
| 146 } | 148 } |
| 147 } | 149 } |
| 148 Definition* defn = instr->AsDefinition(); | 150 Definition* defn = instr->AsDefinition(); |
| 149 if (defn != NULL) { | 151 if (defn != NULL) { |
| 150 for (Value* use = defn->input_use_list(); | 152 for (Value* use = defn->input_use_list(); |
| 151 use != NULL; | 153 use != NULL; |
| 152 use = use->next_use()) { | 154 use = use->next_use()) { |
| 153 ASSERT(defn == use->definition()); | 155 ASSERT(defn == use->definition()); |
| 154 ASSERT(use == use->instruction()->InputAt(use->use_index())); | 156 ASSERT(use == use->instruction()->InputAt(use->use_index())); |
| 155 } | 157 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 200 } |
| 199 | 201 |
| 200 | 202 |
| 201 static void RecordInputUses(Instruction* instr) { | 203 static void RecordInputUses(Instruction* instr) { |
| 202 ASSERT(instr != NULL); | 204 ASSERT(instr != NULL); |
| 203 for (intptr_t i = 0; i < instr->InputCount(); ++i) { | 205 for (intptr_t i = 0; i < instr->InputCount(); ++i) { |
| 204 Value* use = instr->InputAt(i); | 206 Value* use = instr->InputAt(i); |
| 205 ASSERT(use->instruction() == NULL); | 207 ASSERT(use->instruction() == NULL); |
| 206 ASSERT(use->use_index() == -1); | 208 ASSERT(use->use_index() == -1); |
| 207 ASSERT(use->next_use() == NULL); | 209 ASSERT(use->next_use() == NULL); |
| 208 DEBUG_ASSERT(0 == MembershipCount(use, | 210 // TODO(zerny): Make this a slow assert. |
| 209 use->definition()->input_use_list())); | 211 // DEBUG_ASSERT(0 == MembershipCount(use, |
| 212 // use->definition()->input_use_list())); |
| 210 use->set_instruction(instr); | 213 use->set_instruction(instr); |
| 211 use->set_use_index(i); | 214 use->set_use_index(i); |
| 212 use->AddToInputUseList(); | 215 use->AddToInputUseList(); |
| 213 } | 216 } |
| 214 } | 217 } |
| 215 | 218 |
| 216 | 219 |
| 217 static void RecordEnvUses(Instruction* instr) { | 220 static void RecordEnvUses(Instruction* instr) { |
| 218 ASSERT(instr != NULL); | 221 ASSERT(instr != NULL); |
| 219 if (instr->env() == NULL) return; | 222 if (instr->env() == NULL) return; |
| 220 intptr_t use_index = 0; | 223 intptr_t use_index = 0; |
| 221 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { | 224 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { |
| 222 Value* use = it.CurrentValue(); | 225 Value* use = it.CurrentValue(); |
| 223 ASSERT(use->instruction() == NULL); | 226 ASSERT(use->instruction() == NULL); |
| 224 ASSERT(use->use_index() == -1); | 227 ASSERT(use->use_index() == -1); |
| 225 ASSERT(use->next_use() == NULL); | 228 ASSERT(use->next_use() == NULL); |
| 226 DEBUG_ASSERT(0 == MembershipCount(use, use->definition()->env_use_list())); | 229 // TODO(zerny): Make this a slow assert. |
| 230 // DEBUG_ASSERT(0 == |
| 231 // MembershipCount(use, use->definition()->env_use_list())); |
| 227 use->set_instruction(instr); | 232 use->set_instruction(instr); |
| 228 use->set_use_index(use_index++); | 233 use->set_use_index(use_index++); |
| 229 use->AddToEnvUseList(); | 234 use->AddToEnvUseList(); |
| 230 } | 235 } |
| 231 } | 236 } |
| 232 | 237 |
| 233 | 238 |
| 234 static void ComputeUseListsRecursive(BlockEntryInstr* block) { | 239 static void ComputeUseListsRecursive(BlockEntryInstr* block) { |
| 235 // Clear phi definitions. | 240 // Clear phi definitions. |
| 236 JoinEntryInstr* join = block->AsJoinEntry(); | 241 JoinEntryInstr* join = block->AsJoinEntry(); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 // Adjust pre/post orders and update the dominator tree. | 914 // Adjust pre/post orders and update the dominator tree. |
| 910 DiscoverBlocks(); | 915 DiscoverBlocks(); |
| 911 // TODO(zerny): Compute the dominator frontier locally. | 916 // TODO(zerny): Compute the dominator frontier locally. |
| 912 GrowableArray<BitVector*> dominance_frontier; | 917 GrowableArray<BitVector*> dominance_frontier; |
| 913 ComputeDominators(&dominance_frontier); | 918 ComputeDominators(&dominance_frontier); |
| 914 } | 919 } |
| 915 } | 920 } |
| 916 | 921 |
| 917 | 922 |
| 918 } // namespace dart | 923 } // namespace dart |
| OLD | NEW |