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