Chromium Code Reviews| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 // Handle uses. | 142 // Handle uses. |
| 143 for (intptr_t j = 0; j < current->InputCount(); j++) { | 143 for (intptr_t j = 0; j < current->InputCount(); j++) { |
| 144 Value* input = current->InputAt(j); | 144 Value* input = current->InputAt(j); |
| 145 const intptr_t use = input->definition()->ssa_temp_index(); | 145 const intptr_t use = input->definition()->ssa_temp_index(); |
| 146 live_in->Add(use); | 146 live_in->Add(use); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Add non-argument uses from the deoptimization environment (pushed | 149 // Add non-argument uses from the deoptimization environment (pushed |
| 150 // arguments are not allocated by the register allocator). | 150 // arguments are not allocated by the register allocator). |
| 151 if (current->env() != NULL) { | 151 if (current->env() != NULL) { |
| 152 for (intptr_t i = 0; i < current->env()->Length(); ++i) { | 152 for (Environment::DeepIterator env_it(current->env()); |
| 153 Value* value = current->env()->ValueAt(i); | 153 !env_it.Done(); |
| 154 env_it.Advance()) { | |
| 155 Value* value = env_it.CurrentValue(); | |
| 154 if (!value->definition()->IsPushArgument()) { | 156 if (!value->definition()->IsPushArgument()) { |
| 155 live_in->Add(value->definition()->ssa_temp_index()); | 157 live_in->Add(value->definition()->ssa_temp_index()); |
| 156 } | 158 } |
| 157 } | 159 } |
| 158 } | 160 } |
| 159 } | 161 } |
| 160 | 162 |
| 161 // Handle phis. | 163 // Handle phis. |
| 162 if (block->IsJoinEntry()) { | 164 if (block->IsJoinEntry()) { |
| 163 JoinEntryInstr* join = block->AsJoinEntry(); | 165 JoinEntryInstr* join = block->AsJoinEntry(); |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 AssignSafepoints(range); | 730 AssignSafepoints(range); |
| 729 | 731 |
| 730 CompleteRange(range, RegisterKindForResult(phi)); | 732 CompleteRange(range, RegisterKindForResult(phi)); |
| 731 | 733 |
| 732 move_idx++; | 734 move_idx++; |
| 733 } | 735 } |
| 734 } | 736 } |
| 735 } | 737 } |
| 736 | 738 |
| 737 | 739 |
| 738 void FlowGraphAllocator::ProcessEnvironmentUses(BlockEntryInstr* block, | 740 void FlowGraphAllocator::ProcessEnvironmentUsesRecursive(BlockEntryInstr* block, |
| 739 Instruction* current) { | 741 Instruction* current, |
| 740 ASSERT(current->env() != NULL); | 742 Environment* env) { |
| 743 if (env == NULL) return; | |
| 741 | 744 |
| 742 Environment* env = current->env(); | 745 if (env->outer() != NULL) { |
|
Kevin Millikin (Google)
2012/09/18 11:01:55
The base of the recursion handles env == NULL, so
zerny-google
2012/09/18 11:53:07
Done.
| |
| 746 ProcessEnvironmentUsesRecursive(block, current, env->outer()); | |
| 747 } | |
| 743 | 748 |
| 744 // Any value mentioned in the deoptimization environment should survive | 749 // Any value mentioned in the deoptimization environment should survive |
| 745 // until the end of instruction but it does not need to be in the register. | 750 // until the end of instruction but it does not need to be in the register. |
| 746 // Expected shape of live range: | 751 // Expected shape of live range: |
| 747 // | 752 // |
| 748 // i i' | 753 // i i' |
| 749 // value -----* | 754 // value -----* |
| 750 // | 755 // |
| 751 | 756 |
| 752 if (env->Length() == 0) return; | 757 if (env->Length() == 0) return; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 777 const intptr_t vreg = def->ssa_temp_index(); | 782 const intptr_t vreg = def->ssa_temp_index(); |
| 778 LiveRange* range = GetLiveRange(vreg); | 783 LiveRange* range = GetLiveRange(vreg); |
| 779 range->AddUseInterval(block_start_pos, use_pos); | 784 range->AddUseInterval(block_start_pos, use_pos); |
| 780 range->AddUse(use_pos, &locations[i]); | 785 range->AddUse(use_pos, &locations[i]); |
| 781 } | 786 } |
| 782 | 787 |
| 783 env->set_locations(locations); | 788 env->set_locations(locations); |
| 784 } | 789 } |
| 785 | 790 |
| 786 | 791 |
| 792 void FlowGraphAllocator::ProcessEnvironmentUses(BlockEntryInstr* block, | |
| 793 Instruction* current) { | |
| 794 ASSERT(current->env() != NULL); | |
| 795 ProcessEnvironmentUsesRecursive(block, current, current->env()); | |
| 796 } | |
| 797 | |
| 798 | |
| 787 // Create and update live ranges corresponding to instruction's inputs, | 799 // Create and update live ranges corresponding to instruction's inputs, |
| 788 // temporaries and output. | 800 // temporaries and output. |
| 789 void FlowGraphAllocator::ProcessOneInstruction(BlockEntryInstr* block, | 801 void FlowGraphAllocator::ProcessOneInstruction(BlockEntryInstr* block, |
| 790 Instruction* current) { | 802 Instruction* current) { |
| 791 LocationSummary* locs = current->locs(); | 803 LocationSummary* locs = current->locs(); |
| 792 | 804 |
| 793 Definition* def = current->AsDefinition(); | 805 Definition* def = current->AsDefinition(); |
| 794 if ((def != NULL) && | 806 if ((def != NULL) && |
| 795 (def->AsConstant() != NULL) && | 807 (def->AsConstant() != NULL) && |
| 796 (GetLiveRange(def->ssa_temp_index())->first_use() == NULL)) { | 808 (GetLiveRange(def->ssa_temp_index())->first_use() == NULL)) { |
| (...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2206 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 2218 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
| 2207 function.ToFullyQualifiedCString()); | 2219 function.ToFullyQualifiedCString()); |
| 2208 FlowGraphPrinter printer(flow_graph_, true); | 2220 FlowGraphPrinter printer(flow_graph_, true); |
| 2209 printer.PrintBlocks(); | 2221 printer.PrintBlocks(); |
| 2210 OS::Print("----------------------------------------------\n"); | 2222 OS::Print("----------------------------------------------\n"); |
| 2211 } | 2223 } |
| 2212 } | 2224 } |
| 2213 | 2225 |
| 2214 | 2226 |
| 2215 } // namespace dart | 2227 } // namespace dart |
| OLD | NEW |