| 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_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 blocked_cpu_regs_[CTX] = true; | 76 blocked_cpu_regs_[CTX] = true; |
| 77 if (TMP != kNoRegister) { | 77 if (TMP != kNoRegister) { |
| 78 blocked_cpu_regs_[TMP] = true; | 78 blocked_cpu_regs_[TMP] = true; |
| 79 } | 79 } |
| 80 blocked_cpu_regs_[SPREG] = true; | 80 blocked_cpu_regs_[SPREG] = true; |
| 81 blocked_cpu_regs_[FPREG] = true; | 81 blocked_cpu_regs_[FPREG] = true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 void FlowGraphAllocator::EliminateEnvironmentUses() { |
| 86 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 87 BlockEntryInstr* block = block_order_[i]; |
| 88 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
| 89 Instruction* current = it.Current(); |
| 90 if (!current->CanDeoptimize()) current->set_env(NULL); |
| 91 } |
| 92 } |
| 93 } |
| 94 |
| 95 |
| 85 void FlowGraphAllocator::ComputeInitialSets() { | 96 void FlowGraphAllocator::ComputeInitialSets() { |
| 86 const intptr_t block_count = postorder_.length(); | 97 const intptr_t block_count = postorder_.length(); |
| 87 for (intptr_t i = 0; i < block_count; i++) { | 98 for (intptr_t i = 0; i < block_count; i++) { |
| 88 BlockEntryInstr* block = postorder_[i]; | 99 BlockEntryInstr* block = postorder_[i]; |
| 89 | 100 |
| 90 BitVector* kill = kill_[i]; | 101 BitVector* kill = kill_[i]; |
| 91 BitVector* live_in = live_in_[i]; | 102 BitVector* live_in = live_in_[i]; |
| 92 | 103 |
| 93 // Iterate backwards starting at the last instruction. | 104 // Iterate backwards starting at the last instruction. |
| 94 for (BackwardInstructionIterator it(block); !it.Done(); it.Advance()) { | 105 for (BackwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
| (...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 LiveRange* range = GetLiveRange(it.Current()); | 1658 LiveRange* range = GetLiveRange(it.Current()); |
| 1648 for (intptr_t j = 0; j < block->PredecessorCount(); j++) { | 1659 for (intptr_t j = 0; j < block->PredecessorCount(); j++) { |
| 1649 ConnectSplitSiblings(range, block->PredecessorAt(j), block); | 1660 ConnectSplitSiblings(range, block->PredecessorAt(j), block); |
| 1650 } | 1661 } |
| 1651 } | 1662 } |
| 1652 } | 1663 } |
| 1653 } | 1664 } |
| 1654 | 1665 |
| 1655 | 1666 |
| 1656 void FlowGraphAllocator::AllocateRegisters() { | 1667 void FlowGraphAllocator::AllocateRegisters() { |
| 1668 EliminateEnvironmentUses(); |
| 1669 |
| 1657 AnalyzeLiveness(); | 1670 AnalyzeLiveness(); |
| 1658 | 1671 |
| 1659 BuildLiveRanges(); | 1672 BuildLiveRanges(); |
| 1660 | 1673 |
| 1661 if (FLAG_print_ssa_liveness) { | 1674 if (FLAG_print_ssa_liveness) { |
| 1662 DumpLiveness(); | 1675 DumpLiveness(); |
| 1663 } | 1676 } |
| 1664 | 1677 |
| 1665 if (FLAG_trace_ssa_allocator) { | 1678 if (FLAG_trace_ssa_allocator) { |
| 1666 PrintLiveRanges(); | 1679 PrintLiveRanges(); |
| 1667 } | 1680 } |
| 1668 | 1681 |
| 1669 AllocateCPURegisters(); | 1682 AllocateCPURegisters(); |
| 1670 | 1683 |
| 1671 ResolveControlFlow(); | 1684 ResolveControlFlow(); |
| 1672 | 1685 |
| 1673 GraphEntryInstr* entry = block_order_[0]->AsGraphEntry(); | 1686 GraphEntryInstr* entry = block_order_[0]->AsGraphEntry(); |
| 1674 ASSERT(entry != NULL); | 1687 ASSERT(entry != NULL); |
| 1675 entry->set_spill_slot_count(spill_slots_.length()); | 1688 entry->set_spill_slot_count(spill_slots_.length()); |
| 1676 | 1689 |
| 1677 if (FLAG_trace_ssa_allocator) { | 1690 if (FLAG_trace_ssa_allocator) { |
| 1678 OS::Print("-- ir after allocation -------------------------\n"); | 1691 OS::Print("-- ir after allocation -------------------------\n"); |
| 1679 FlowGraphPrinter printer(Function::Handle(), block_order_, true); | 1692 FlowGraphPrinter printer(Function::Handle(), block_order_, true); |
| 1680 printer.PrintBlocks(); | 1693 printer.PrintBlocks(); |
| 1681 } | 1694 } |
| 1682 } | 1695 } |
| 1683 | 1696 |
| 1684 | 1697 |
| 1685 } // namespace dart | 1698 } // namespace dart |
| OLD | NEW |