| 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_allocator.h" | 5 #include "vm/flow_graph_allocator.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/il_printer.h" | 9 #include "vm/il_printer.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 static bool IsInstructionEndPosition(intptr_t pos) { | 48 static bool IsInstructionEndPosition(intptr_t pos) { |
| 49 return (pos & 1) == 1; | 49 return (pos & 1) == 1; |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 static intptr_t ToInstructionStart(intptr_t pos) { | 53 static intptr_t ToInstructionStart(intptr_t pos) { |
| 54 return (pos & ~1); | 54 return (pos & ~1); |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 static intptr_t ToInstructionEnd(intptr_t pos) { |
| 59 return (pos | 1); |
| 60 } |
| 61 |
| 62 |
| 58 FlowGraphAllocator::FlowGraphAllocator(const FlowGraph& flow_graph) | 63 FlowGraphAllocator::FlowGraphAllocator(const FlowGraph& flow_graph) |
| 59 : flow_graph_(flow_graph), | 64 : flow_graph_(flow_graph), |
| 60 block_order_(flow_graph.reverse_postorder()), | 65 block_order_(flow_graph.reverse_postorder()), |
| 61 postorder_(flow_graph.postorder()), | 66 postorder_(flow_graph.postorder()), |
| 62 live_out_(block_order_.length()), | 67 live_out_(block_order_.length()), |
| 63 kill_(block_order_.length()), | 68 kill_(block_order_.length()), |
| 64 live_in_(block_order_.length()), | 69 live_in_(block_order_.length()), |
| 65 vreg_count_(flow_graph.max_virtual_register_number()), | 70 vreg_count_(flow_graph.max_virtual_register_number()), |
| 66 live_ranges_(flow_graph.max_virtual_register_number()), | 71 live_ranges_(flow_graph.max_virtual_register_number()), |
| 67 cpu_regs_(), | 72 cpu_regs_(), |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 if ((uses_ != NULL) && | 302 if ((uses_ != NULL) && |
| 298 (uses_->pos() == pos) && | 303 (uses_->pos() == pos) && |
| 299 (uses_->location_slot() == location_slot)) { | 304 (uses_->location_slot() == location_slot)) { |
| 300 return; | 305 return; |
| 301 } | 306 } |
| 302 uses_ = new UsePosition(pos, uses_, location_slot); | 307 uses_ = new UsePosition(pos, uses_, location_slot); |
| 303 } | 308 } |
| 304 | 309 |
| 305 | 310 |
| 306 void LiveRange::AddSafepoint(intptr_t pos, LocationSummary* locs) { | 311 void LiveRange::AddSafepoint(intptr_t pos, LocationSummary* locs) { |
| 307 SafepointPosition* safepoint = new SafepointPosition(pos, locs); | 312 ASSERT(IsInstructionStartPosition(pos)); |
| 313 SafepointPosition* safepoint = |
| 314 new SafepointPosition(ToInstructionEnd(pos), locs); |
| 308 | 315 |
| 309 if (first_safepoint_ == NULL) { | 316 if (first_safepoint_ == NULL) { |
| 310 ASSERT(last_safepoint_ == NULL); | 317 ASSERT(last_safepoint_ == NULL); |
| 311 first_safepoint_ = last_safepoint_ = safepoint; | 318 first_safepoint_ = last_safepoint_ = safepoint; |
| 312 } else { | 319 } else { |
| 313 ASSERT(last_safepoint_ != NULL); | 320 ASSERT(last_safepoint_ != NULL); |
| 314 // We assume that safepoints list is sorted by position and that | 321 // We assume that safepoints list is sorted by position and that |
| 315 // safepoints are added in this order. | 322 // safepoints are added in this order. |
| 316 ASSERT(last_safepoint_->pos() < pos); | 323 ASSERT(last_safepoint_->pos() < pos); |
| 317 last_safepoint_->set_next(safepoint); | 324 last_safepoint_->set_next(safepoint); |
| (...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2194 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 2201 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
| 2195 function.ToFullyQualifiedCString()); | 2202 function.ToFullyQualifiedCString()); |
| 2196 FlowGraphPrinter printer(flow_graph_, true); | 2203 FlowGraphPrinter printer(flow_graph_, true); |
| 2197 printer.PrintBlocks(); | 2204 printer.PrintBlocks(); |
| 2198 OS::Print("----------------------------------------------\n"); | 2205 OS::Print("----------------------------------------------\n"); |
| 2199 } | 2206 } |
| 2200 } | 2207 } |
| 2201 | 2208 |
| 2202 | 2209 |
| 2203 } // namespace dart | 2210 } // namespace dart |
| OLD | NEW |