| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 } else { | 599 } else { |
| 600 return Location::kRegister; | 600 return Location::kRegister; |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 | 603 |
| 604 | 604 |
| 605 static Location::Kind RegisterKindForResult(Instruction* instr) { | 605 static Location::Kind RegisterKindForResult(Instruction* instr) { |
| 606 if ((instr->representation() == kUnboxedDouble) || | 606 if ((instr->representation() == kUnboxedDouble) || |
| 607 (instr->representation() == kUnboxedMint) || | 607 (instr->representation() == kUnboxedMint) || |
| 608 (instr->representation() == kUnboxedFloat32x4) || | 608 (instr->representation() == kUnboxedFloat32x4) || |
| 609 (instr->representation() == kUnboxedInt32x4)) { | 609 (instr->representation() == kUnboxedInt32x4) || |
| 610 (instr->representation() == kUnboxedFloat64x2)) { |
| 610 return Location::kFpuRegister; | 611 return Location::kFpuRegister; |
| 611 } else { | 612 } else { |
| 612 return Location::kRegister; | 613 return Location::kRegister; |
| 613 } | 614 } |
| 614 } | 615 } |
| 615 | 616 |
| 616 | 617 |
| 617 // | 618 // |
| 618 // When describing shape of live ranges in comments below we are going to use | 619 // When describing shape of live ranges in comments below we are going to use |
| 619 // the following notation: | 620 // the following notation: |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 const intptr_t end = last_sibling->End(); | 1596 const intptr_t end = last_sibling->End(); |
| 1596 | 1597 |
| 1597 // During fpu register allocation spill slot indices are computed in terms of | 1598 // During fpu register allocation spill slot indices are computed in terms of |
| 1598 // double (64bit) stack slots. We treat quad stack slot (128bit) as a | 1599 // double (64bit) stack slots. We treat quad stack slot (128bit) as a |
| 1599 // consecutive pair of two double spill slots. | 1600 // consecutive pair of two double spill slots. |
| 1600 // Special care is taken to never allocate the same index to both | 1601 // Special care is taken to never allocate the same index to both |
| 1601 // double and quad spill slots as it complicates disambiguation during | 1602 // double and quad spill slots as it complicates disambiguation during |
| 1602 // parallel move resolution. | 1603 // parallel move resolution. |
| 1603 const bool need_quad = (register_kind_ == Location::kFpuRegister) && | 1604 const bool need_quad = (register_kind_ == Location::kFpuRegister) && |
| 1604 ((range->representation() == kUnboxedFloat32x4) || | 1605 ((range->representation() == kUnboxedFloat32x4) || |
| 1605 (range->representation() == kUnboxedInt32x4)); | 1606 (range->representation() == kUnboxedInt32x4) || |
| 1607 (range->representation() == kUnboxedFloat64x2)); |
| 1606 | 1608 |
| 1607 // Search for a free spill slot among allocated: the value in it should be | 1609 // Search for a free spill slot among allocated: the value in it should be |
| 1608 // dead and its type should match (e.g. it should not be a part of the quad if | 1610 // dead and its type should match (e.g. it should not be a part of the quad if |
| 1609 // we are allocating normal double slot). | 1611 // we are allocating normal double slot). |
| 1610 // For CPU registers we need to take reserved slots for try-catch into | 1612 // For CPU registers we need to take reserved slots for try-catch into |
| 1611 // account. | 1613 // account. |
| 1612 intptr_t idx = register_kind_ == Location::kRegister | 1614 intptr_t idx = register_kind_ == Location::kRegister |
| 1613 ? flow_graph_.graph_entry()->fixed_slot_count() | 1615 ? flow_graph_.graph_entry()->fixed_slot_count() |
| 1614 : 0; | 1616 : 0; |
| 1615 for (; idx < spill_slots_.length(); idx++) { | 1617 for (; idx < spill_slots_.length(); idx++) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1644 range->set_spill_slot(Location::StackSlot(idx)); | 1646 range->set_spill_slot(Location::StackSlot(idx)); |
| 1645 } else { | 1647 } else { |
| 1646 // We use the index of the slot with the lowest address as an index for the | 1648 // We use the index of the slot with the lowest address as an index for the |
| 1647 // FPU register spill slot. In terms of indexes this relation is inverted: | 1649 // FPU register spill slot. In terms of indexes this relation is inverted: |
| 1648 // so we have to take the highest index. | 1650 // so we have to take the highest index. |
| 1649 const intptr_t slot_idx = cpu_spill_slot_count_ + | 1651 const intptr_t slot_idx = cpu_spill_slot_count_ + |
| 1650 idx * kDoubleSpillFactor + (kDoubleSpillFactor - 1); | 1652 idx * kDoubleSpillFactor + (kDoubleSpillFactor - 1); |
| 1651 | 1653 |
| 1652 Location location; | 1654 Location location; |
| 1653 if ((range->representation() == kUnboxedFloat32x4) || | 1655 if ((range->representation() == kUnboxedFloat32x4) || |
| 1654 (range->representation() == kUnboxedInt32x4)) { | 1656 (range->representation() == kUnboxedInt32x4) || |
| 1657 (range->representation() == kUnboxedFloat64x2)) { |
| 1655 ASSERT(need_quad); | 1658 ASSERT(need_quad); |
| 1656 location = Location::QuadStackSlot(slot_idx); | 1659 location = Location::QuadStackSlot(slot_idx); |
| 1657 } else { | 1660 } else { |
| 1658 ASSERT((range->representation() == kUnboxedDouble) || | 1661 ASSERT((range->representation() == kUnboxedDouble) || |
| 1659 (range->representation() == kUnboxedMint)); | 1662 (range->representation() == kUnboxedMint)); |
| 1660 location = Location::DoubleStackSlot(slot_idx); | 1663 location = Location::DoubleStackSlot(slot_idx); |
| 1661 } | 1664 } |
| 1662 range->set_spill_slot(location); | 1665 range->set_spill_slot(location); |
| 1663 } | 1666 } |
| 1664 | 1667 |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2602 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 2605 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
| 2603 function.ToFullyQualifiedCString()); | 2606 function.ToFullyQualifiedCString()); |
| 2604 FlowGraphPrinter printer(flow_graph_, true); | 2607 FlowGraphPrinter printer(flow_graph_, true); |
| 2605 printer.PrintBlocks(); | 2608 printer.PrintBlocks(); |
| 2606 OS::Print("----------------------------------------------\n"); | 2609 OS::Print("----------------------------------------------\n"); |
| 2607 } | 2610 } |
| 2608 } | 2611 } |
| 2609 | 2612 |
| 2610 | 2613 |
| 2611 } // namespace dart | 2614 } // namespace dart |
| OLD | NEW |