| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 167 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 168 ResetUseListsInInstruction(it.Current()); | 168 ResetUseListsInInstruction(it.Current()); |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 return true; // Return true so we can ASSERT the reset code. | 171 return true; // Return true so we can ASSERT the reset code. |
| 172 } | 172 } |
| 173 | 173 |
| 174 | 174 |
| 175 static void ValidateUseListsInInstruction(Instruction* instr) { | 175 static void VerifyUseListsInInstruction(Instruction* instr) { |
| 176 ASSERT(instr != NULL); | 176 ASSERT(instr != NULL); |
| 177 ASSERT(!instr->IsJoinEntry()); | 177 ASSERT(!instr->IsJoinEntry()); |
| 178 for (intptr_t i = 0; i < instr->InputCount(); ++i) { | 178 for (intptr_t i = 0; i < instr->InputCount(); ++i) { |
| 179 Value* use = instr->InputAt(i); | 179 Value* use = instr->InputAt(i); |
| 180 ASSERT(use->definition() != NULL); | 180 ASSERT(use->definition() != NULL); |
| 181 ASSERT(use->definition() != instr); | 181 ASSERT(use->definition() != instr); |
| 182 ASSERT(use->instruction() == instr); | 182 ASSERT(use->instruction() == instr); |
| 183 ASSERT(use->use_index() == i); | 183 ASSERT(use->use_index() == i); |
| 184 ASSERT(!FLAG_verify_compiler || | 184 ASSERT(!FLAG_verify_compiler || |
| 185 (1 == MembershipCount(use, use->definition()->input_use_list()))); | 185 (1 == MembershipCount(use, use->definition()->input_use_list()))); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 ASSERT(instr->IsPhi() || | 226 ASSERT(instr->IsPhi() || |
| 227 (instr->IsDefinition() && instr->AsDefinition()->IsComparison()) || | 227 (instr->IsDefinition() && instr->AsDefinition()->IsComparison()) || |
| 228 (instr->previous() != NULL)); | 228 (instr->previous() != NULL)); |
| 229 prev = curr; | 229 prev = curr; |
| 230 curr = curr->next_use(); | 230 curr = curr->next_use(); |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 | 235 |
| 236 bool FlowGraph::ValidateUseLists() { | 236 bool FlowGraph::VerifyUseLists() { |
| 237 // Validate initial definitions. | 237 // Verify the initial definitions. |
| 238 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { | 238 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { |
| 239 ValidateUseListsInInstruction((*graph_entry_->initial_definitions())[i]); | 239 VerifyUseListsInInstruction((*graph_entry_->initial_definitions())[i]); |
| 240 } | 240 } |
| 241 | 241 |
| 242 // Validate phis in join entries and the instructions in each block. | 242 // Verify phis in join entries and the instructions in each block. |
| 243 for (intptr_t i = 0; i < preorder_.length(); ++i) { | 243 for (intptr_t i = 0; i < preorder_.length(); ++i) { |
| 244 BlockEntryInstr* entry = preorder_[i]; | 244 BlockEntryInstr* entry = preorder_[i]; |
| 245 JoinEntryInstr* join = entry->AsJoinEntry(); | 245 JoinEntryInstr* join = entry->AsJoinEntry(); |
| 246 if (join != NULL && join->phis() != NULL) { | 246 if (join != NULL && join->phis() != NULL) { |
| 247 for (intptr_t i = 0; i < join->phis()->length(); ++i) { | 247 for (intptr_t i = 0; i < join->phis()->length(); ++i) { |
| 248 PhiInstr* phi = (*join->phis())[i]; | 248 PhiInstr* phi = (*join->phis())[i]; |
| 249 if (phi != NULL) ValidateUseListsInInstruction(phi); | 249 if (phi != NULL) VerifyUseListsInInstruction(phi); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 252 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 253 ValidateUseListsInInstruction(it.Current()); | 253 VerifyUseListsInInstruction(it.Current()); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 return true; // Return true so we can ASSERT validation. | 256 return true; // Return true so we can ASSERT validation. |
| 257 } | 257 } |
| 258 #endif // DEBUG | 258 #endif // DEBUG |
| 259 | 259 |
| 260 | 260 |
| 261 static void ClearUseLists(Definition* defn) { | 261 static void ClearUseLists(Definition* defn) { |
| 262 ASSERT(defn != NULL); | 262 ASSERT(defn != NULL); |
| 263 ASSERT(!defn->HasUses()); | 263 ASSERT(!defn->HasUses()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 349 } |
| 350 | 350 |
| 351 | 351 |
| 352 void FlowGraph::ComputeUseLists() { | 352 void FlowGraph::ComputeUseLists() { |
| 353 DEBUG_ASSERT(ResetUseLists()); | 353 DEBUG_ASSERT(ResetUseLists()); |
| 354 // Clear initial definitions. | 354 // Clear initial definitions. |
| 355 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { | 355 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { |
| 356 ClearUseLists((*graph_entry_->initial_definitions())[i]); | 356 ClearUseLists((*graph_entry_->initial_definitions())[i]); |
| 357 } | 357 } |
| 358 ComputeUseListsRecursive(graph_entry_); | 358 ComputeUseListsRecursive(graph_entry_); |
| 359 DEBUG_ASSERT(!FLAG_verify_compiler || ValidateUseLists()); | 359 DEBUG_ASSERT(!FLAG_verify_compiler || VerifyUseLists()); |
| 360 } | 360 } |
| 361 | 361 |
| 362 | 362 |
| 363 void FlowGraph::ComputeSSA(intptr_t next_virtual_register_number, | 363 void FlowGraph::ComputeSSA(intptr_t next_virtual_register_number, |
| 364 GrowableArray<Definition*>* inlining_parameters) { | 364 GrowableArray<Definition*>* inlining_parameters) { |
| 365 ASSERT((next_virtual_register_number == 0) || (inlining_parameters != NULL)); | 365 ASSERT((next_virtual_register_number == 0) || (inlining_parameters != NULL)); |
| 366 current_ssa_temp_index_ = next_virtual_register_number; | 366 current_ssa_temp_index_ = next_virtual_register_number; |
| 367 GrowableArray<BitVector*> dominance_frontier; | 367 GrowableArray<BitVector*> dominance_frontier; |
| 368 ComputeDominators(&dominance_frontier); | 368 ComputeDominators(&dominance_frontier); |
| 369 InsertPhis(preorder_, assigned_vars_, dominance_frontier); | 369 InsertPhis(preorder_, assigned_vars_, dominance_frontier); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 !it.Done(); | 830 !it.Done(); |
| 831 it.Advance()) { | 831 it.Advance()) { |
| 832 ++size; | 832 ++size; |
| 833 } | 833 } |
| 834 } | 834 } |
| 835 return size; | 835 return size; |
| 836 } | 836 } |
| 837 | 837 |
| 838 | 838 |
| 839 } // namespace dart | 839 } // namespace dart |
| OLD | NEW |