| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 282 } |
| 283 | 283 |
| 284 ComputeInitialSets(); | 284 ComputeInitialSets(); |
| 285 ComputeLiveInAndLiveOutSets(); | 285 ComputeLiveInAndLiveOutSets(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 | 288 |
| 289 static void PrintBitVector(const char* tag, BitVector* v) { | 289 static void PrintBitVector(const char* tag, BitVector* v) { |
| 290 OS::Print("%s:", tag); | 290 OS::Print("%s:", tag); |
| 291 for (BitVector::Iterator it(v); !it.Done(); it.Advance()) { | 291 for (BitVector::Iterator it(v); !it.Done(); it.Advance()) { |
| 292 OS::Print(" %"Pd"", it.Current()); | 292 OS::Print(" %" Pd "", it.Current()); |
| 293 } | 293 } |
| 294 OS::Print("\n"); | 294 OS::Print("\n"); |
| 295 } | 295 } |
| 296 | 296 |
| 297 | 297 |
| 298 void LivenessAnalysis::Dump() { | 298 void LivenessAnalysis::Dump() { |
| 299 const intptr_t block_count = postorder_.length(); | 299 const intptr_t block_count = postorder_.length(); |
| 300 for (intptr_t i = 0; i < block_count; i++) { | 300 for (intptr_t i = 0; i < block_count; i++) { |
| 301 BlockEntryInstr* block = postorder_[i]; | 301 BlockEntryInstr* block = postorder_[i]; |
| 302 OS::Print("block @%"Pd" -> ", block->block_id()); | 302 OS::Print("block @%" Pd " -> ", block->block_id()); |
| 303 | 303 |
| 304 Instruction* last = block->last_instruction(); | 304 Instruction* last = block->last_instruction(); |
| 305 for (intptr_t j = 0; j < last->SuccessorCount(); j++) { | 305 for (intptr_t j = 0; j < last->SuccessorCount(); j++) { |
| 306 BlockEntryInstr* succ = last->SuccessorAt(j); | 306 BlockEntryInstr* succ = last->SuccessorAt(j); |
| 307 OS::Print(" @%"Pd"", succ->block_id()); | 307 OS::Print(" @%" Pd "", succ->block_id()); |
| 308 } | 308 } |
| 309 OS::Print("\n"); | 309 OS::Print("\n"); |
| 310 | 310 |
| 311 PrintBitVector(" live out", live_out_[i]); | 311 PrintBitVector(" live out", live_out_[i]); |
| 312 PrintBitVector(" kill", kill_[i]); | 312 PrintBitVector(" kill", kill_[i]); |
| 313 PrintBitVector(" live in", live_in_[i]); | 313 PrintBitVector(" live in", live_in_[i]); |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 | 317 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 BlockEntryInstr* q = p->PredecessorAt(i); | 977 BlockEntryInstr* q = p->PredecessorAt(i); |
| 978 if (!loop->Contains(q->preorder_number())) { | 978 if (!loop->Contains(q->preorder_number())) { |
| 979 loop->Add(q->preorder_number()); | 979 loop->Add(q->preorder_number()); |
| 980 stack.Add(q); | 980 stack.Add(q); |
| 981 } | 981 } |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 n->set_loop_info(loop); | 984 n->set_loop_info(loop); |
| 985 if (FLAG_trace_optimization) { | 985 if (FLAG_trace_optimization) { |
| 986 for (BitVector::Iterator it(loop); !it.Done(); it.Advance()) { | 986 for (BitVector::Iterator it(loop); !it.Done(); it.Advance()) { |
| 987 OS::Print(" B%"Pd"\n", preorder_[it.Current()]->block_id()); | 987 OS::Print(" B%" Pd "\n", preorder_[it.Current()]->block_id()); |
| 988 } | 988 } |
| 989 } | 989 } |
| 990 } | 990 } |
| 991 | 991 |
| 992 | 992 |
| 993 ZoneGrowableArray<BlockEntryInstr*>* FlowGraph::ComputeLoops() { | 993 ZoneGrowableArray<BlockEntryInstr*>* FlowGraph::ComputeLoops() { |
| 994 ZoneGrowableArray<BlockEntryInstr*>* loop_headers = | 994 ZoneGrowableArray<BlockEntryInstr*>* loop_headers = |
| 995 new ZoneGrowableArray<BlockEntryInstr*>(); | 995 new ZoneGrowableArray<BlockEntryInstr*>(); |
| 996 | 996 |
| 997 for (BlockIterator it = postorder_iterator(); | 997 for (BlockIterator it = postorder_iterator(); |
| 998 !it.Done(); | 998 !it.Done(); |
| 999 it.Advance()) { | 999 it.Advance()) { |
| 1000 BlockEntryInstr* block = it.Current(); | 1000 BlockEntryInstr* block = it.Current(); |
| 1001 for (intptr_t i = 0; i < block->PredecessorCount(); ++i) { | 1001 for (intptr_t i = 0; i < block->PredecessorCount(); ++i) { |
| 1002 BlockEntryInstr* pred = block->PredecessorAt(i); | 1002 BlockEntryInstr* pred = block->PredecessorAt(i); |
| 1003 if (block->Dominates(pred)) { | 1003 if (block->Dominates(pred)) { |
| 1004 if (FLAG_trace_optimization) { | 1004 if (FLAG_trace_optimization) { |
| 1005 OS::Print("Back edge B%"Pd" -> B%"Pd"\n", pred->block_id(), | 1005 OS::Print("Back edge B%" Pd " -> B%" Pd "\n", pred->block_id(), |
| 1006 block->block_id()); | 1006 block->block_id()); |
| 1007 } | 1007 } |
| 1008 FindLoop(pred, block); | 1008 FindLoop(pred, block); |
| 1009 loop_headers->Add(block); | 1009 loop_headers->Add(block); |
| 1010 } | 1010 } |
| 1011 } | 1011 } |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 return loop_headers; | 1014 return loop_headers; |
| 1015 } | 1015 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 | 1146 |
| 1147 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, | 1147 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, |
| 1148 BlockEntryInstr* to) const { | 1148 BlockEntryInstr* to) const { |
| 1149 return available_at_[to->postorder_number()]->Contains( | 1149 return available_at_[to->postorder_number()]->Contains( |
| 1150 from->postorder_number()); | 1150 from->postorder_number()); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 } // namespace dart | 1153 } // namespace dart |
| OLD | NEW |