| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 for (intptr_t i = 0; i < instr->InputCount(); ++i) { | 226 for (intptr_t i = 0; i < instr->InputCount(); ++i) { |
| 227 Value* use = instr->InputAt(i); | 227 Value* use = instr->InputAt(i); |
| 228 ASSERT(use->instruction() == NULL); | 228 ASSERT(use->instruction() == NULL); |
| 229 ASSERT(use->use_index() == -1); | 229 ASSERT(use->use_index() == -1); |
| 230 ASSERT(use->previous_use() == NULL); | 230 ASSERT(use->previous_use() == NULL); |
| 231 ASSERT(use->next_use() == NULL); | 231 ASSERT(use->next_use() == NULL); |
| 232 DEBUG_ASSERT(!FLAG_verify_compiler || | 232 DEBUG_ASSERT(!FLAG_verify_compiler || |
| 233 (0 == MembershipCount(use, use->definition()->input_use_list()))); | 233 (0 == MembershipCount(use, use->definition()->input_use_list()))); |
| 234 use->set_instruction(instr); | 234 use->set_instruction(instr); |
| 235 use->set_use_index(i); | 235 use->set_use_index(i); |
| 236 use->AddToInputUseList(); | 236 use->definition()->AddInputUse(use); |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 static void RecordEnvUses(Instruction* instr) { | 241 static void RecordEnvUses(Instruction* instr) { |
| 242 ASSERT(instr != NULL); | 242 ASSERT(instr != NULL); |
| 243 if (instr->env() == NULL) return; | 243 if (instr->env() == NULL) return; |
| 244 intptr_t use_index = 0; | 244 intptr_t use_index = 0; |
| 245 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { | 245 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { |
| 246 Value* use = it.CurrentValue(); | 246 Value* use = it.CurrentValue(); |
| 247 ASSERT(use->instruction() == NULL); | 247 ASSERT(use->instruction() == NULL); |
| 248 ASSERT(use->use_index() == -1); | 248 ASSERT(use->use_index() == -1); |
| 249 ASSERT(use->previous_use() == NULL); | 249 ASSERT(use->previous_use() == NULL); |
| 250 ASSERT(use->next_use() == NULL); | 250 ASSERT(use->next_use() == NULL); |
| 251 DEBUG_ASSERT(!FLAG_verify_compiler || | 251 DEBUG_ASSERT(!FLAG_verify_compiler || |
| 252 (0 == MembershipCount(use, use->definition()->env_use_list()))); | 252 (0 == MembershipCount(use, use->definition()->env_use_list()))); |
| 253 use->set_instruction(instr); | 253 use->set_instruction(instr); |
| 254 use->set_use_index(use_index++); | 254 use->set_use_index(use_index++); |
| 255 use->AddToEnvUseList(); | 255 use->definition()->AddEnvUse(use); |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 | 259 |
| 260 static void ComputeUseListsRecursive(BlockEntryInstr* block) { | 260 static void ComputeUseListsRecursive(BlockEntryInstr* block) { |
| 261 // Clear phi definitions. | 261 // Clear phi definitions. |
| 262 JoinEntryInstr* join = block->AsJoinEntry(); | 262 JoinEntryInstr* join = block->AsJoinEntry(); |
| 263 if (join != NULL && join->phis() != NULL) { | 263 if (join != NULL && join->phis() != NULL) { |
| 264 for (intptr_t i = 0; i < join->phis()->length(); ++i) { | 264 for (intptr_t i = 0; i < join->phis()->length(); ++i) { |
| 265 PhiInstr* phi = (*join->phis())[i]; | 265 PhiInstr* phi = (*join->phis())[i]; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 290 if (phi == NULL) continue; | 290 if (phi == NULL) continue; |
| 291 Value* use = phi->InputAt(pred_index); | 291 Value* use = phi->InputAt(pred_index); |
| 292 ASSERT(use->instruction() == NULL); | 292 ASSERT(use->instruction() == NULL); |
| 293 ASSERT(use->use_index() == -1); | 293 ASSERT(use->use_index() == -1); |
| 294 ASSERT(use->previous_use() == NULL); | 294 ASSERT(use->previous_use() == NULL); |
| 295 ASSERT(use->next_use() == NULL); | 295 ASSERT(use->next_use() == NULL); |
| 296 DEBUG_ASSERT(!FLAG_verify_compiler || | 296 DEBUG_ASSERT(!FLAG_verify_compiler || |
| 297 (0 == MembershipCount(use, use->definition()->input_use_list()))); | 297 (0 == MembershipCount(use, use->definition()->input_use_list()))); |
| 298 use->set_instruction(phi); | 298 use->set_instruction(phi); |
| 299 use->set_use_index(pred_index); | 299 use->set_use_index(pred_index); |
| 300 use->AddToInputUseList(); | 300 use->definition()->AddInputUse(use); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 | 306 |
| 307 void FlowGraph::ComputeUseLists() { | 307 void FlowGraph::ComputeUseLists() { |
| 308 DEBUG_ASSERT(ResetUseLists()); | 308 DEBUG_ASSERT(ResetUseLists()); |
| 309 // Clear initial definitions. | 309 // Clear initial definitions. |
| 310 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { | 310 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 !it.Done(); | 785 !it.Done(); |
| 786 it.Advance()) { | 786 it.Advance()) { |
| 787 ++size; | 787 ++size; |
| 788 } | 788 } |
| 789 } | 789 } |
| 790 return size; | 790 return size; |
| 791 } | 791 } |
| 792 | 792 |
| 793 | 793 |
| 794 } // namespace dart | 794 } // namespace dart |
| OLD | NEW |