| 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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 range->DefineAt(pos); | 761 range->DefineAt(pos); |
| 762 range->AddUse(pos, out); | 762 range->AddUse(pos, out); |
| 763 } | 763 } |
| 764 | 764 |
| 765 AddToUnallocated(range); | 765 AddToUnallocated(range); |
| 766 } | 766 } |
| 767 | 767 |
| 768 | 768 |
| 769 static ParallelMoveInstr* CreateParallelMoveBefore(Instruction* instr, | 769 static ParallelMoveInstr* CreateParallelMoveBefore(Instruction* instr, |
| 770 intptr_t pos) { | 770 intptr_t pos) { |
| 771 ASSERT(pos > 0); |
| 771 Instruction* prev = instr->previous(); | 772 Instruction* prev = instr->previous(); |
| 772 ParallelMoveInstr* move = prev->AsParallelMove(); | 773 ParallelMoveInstr* move = prev->AsParallelMove(); |
| 773 if ((move == NULL) || (move->lifetime_position() != pos)) { | 774 if ((move == NULL) || (move->lifetime_position() != pos)) { |
| 774 move = new ParallelMoveInstr(); | 775 move = new ParallelMoveInstr(); |
| 775 move->set_next(prev->next()); | 776 move->set_next(prev->next()); |
| 776 prev->set_next(move); | 777 prev->set_next(move); |
| 777 move->next()->set_previous(move); | 778 move->next()->set_previous(move); |
| 778 move->set_previous(prev); | 779 move->set_previous(prev); |
| 779 move->set_lifetime_position(pos); | 780 move->set_lifetime_position(pos); |
| 780 } | 781 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { | 814 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
| 814 Instruction* current = it.Current(); | 815 Instruction* current = it.Current(); |
| 815 // Do not assign numbers to parallel move instructions. | 816 // Do not assign numbers to parallel move instructions. |
| 816 if (!current->IsParallelMove()) { | 817 if (!current->IsParallelMove()) { |
| 817 instructions_.Add(current); | 818 instructions_.Add(current); |
| 818 current->set_lifetime_position(pos + 1); | 819 current->set_lifetime_position(pos + 1); |
| 819 pos += 2; | 820 pos += 2; |
| 820 } | 821 } |
| 821 } | 822 } |
| 822 block->set_end_pos(pos); | 823 block->set_end_pos(pos); |
| 824 } |
| 825 |
| 826 // Create parallel moves in join predecessors. This must be done after |
| 827 // all instructions are numbered. |
| 828 for (intptr_t i = block_count - 1; i >= 0; i--) { |
| 829 BlockEntryInstr* block = postorder_[i]; |
| 823 | 830 |
| 824 // For join entry predecessors create phi resolution moves if | 831 // For join entry predecessors create phi resolution moves if |
| 825 // necessary. They will be populated by the register allocator. | 832 // necessary. They will be populated by the register allocator. |
| 826 JoinEntryInstr* join = block->AsJoinEntry(); | 833 JoinEntryInstr* join = block->AsJoinEntry(); |
| 827 if ((join != NULL) && (join->phi_count() > 0)) { | 834 if ((join != NULL) && (join->phi_count() > 0)) { |
| 828 const intptr_t phi_count = join->phi_count(); | 835 const intptr_t phi_count = join->phi_count(); |
| 829 for (intptr_t i = 0; i < block->PredecessorCount(); i++) { | 836 for (intptr_t i = 0; i < block->PredecessorCount(); i++) { |
| 830 // Insert the move between the last two instructions of the | 837 // Insert the move between the last two instructions of the |
| 831 // predecessor block (all such blocks have at least two instructions: | 838 // predecessor block (all such blocks have at least two instructions: |
| 832 // the block entry and goto instructions.) | 839 // the block entry and goto instructions.) |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 | 1596 |
| 1590 if (FLAG_trace_ssa_allocator) { | 1597 if (FLAG_trace_ssa_allocator) { |
| 1591 OS::Print("-- ir after allocation -------------------------\n"); | 1598 OS::Print("-- ir after allocation -------------------------\n"); |
| 1592 FlowGraphPrinter printer(Function::Handle(), block_order_, true); | 1599 FlowGraphPrinter printer(Function::Handle(), block_order_, true); |
| 1593 printer.PrintBlocks(); | 1600 printer.PrintBlocks(); |
| 1594 } | 1601 } |
| 1595 } | 1602 } |
| 1596 | 1603 |
| 1597 | 1604 |
| 1598 } // namespace dart | 1605 } // namespace dart |
| OLD | NEW |