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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 blocked_cpu_registers_[FPREG] = true; | 79 blocked_cpu_registers_[FPREG] = true; |
80 | 80 |
81 // XMM0 is used as scratch by optimized code and parallel move resolver. | 81 // XMM0 is used as scratch by optimized code and parallel move resolver. |
82 blocked_xmm_registers_[XMM0] = true; | 82 blocked_xmm_registers_[XMM0] = true; |
83 } | 83 } |
84 | 84 |
85 | 85 |
86 // Remove environments from the instructions which can't deoptimize. | 86 // Remove environments from the instructions which can't deoptimize. |
87 // Replace dead phis uses with null values in environments. | 87 // Replace dead phis uses with null values in environments. |
88 void FlowGraphAllocator::EliminateEnvironmentUses() { | 88 void FlowGraphAllocator::EliminateEnvironmentUses() { |
89 ConstantInstr* constant_null = | 89 Definition* constant_null = |
90 postorder_.Last()->AsGraphEntry()->constant_null(); | 90 postorder_.Last()->AsGraphEntry()->constant_null(); |
91 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 91 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
92 BlockEntryInstr* block = block_order_[i]; | 92 BlockEntryInstr* block = block_order_[i]; |
93 if (block->IsJoinEntry()) block->AsJoinEntry()->RemoveDeadPhis(); | 93 if (block->IsJoinEntry()) block->AsJoinEntry()->RemoveDeadPhis(); |
94 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { | 94 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
95 Instruction* current = it.Current(); | 95 Instruction* current = it.Current(); |
96 if (current->CanDeoptimize()) { | 96 if (current->CanDeoptimize()) { |
97 ASSERT(current->env() != NULL); | 97 ASSERT(current->env() != NULL); |
98 GrowableArray<Value*>* values = current->env()->values_ptr(); | 98 GrowableArray<Value*>* values = current->env()->values_ptr(); |
99 for (intptr_t i = 0; i < values->length(); i++) { | 99 for (intptr_t i = 0; i < values->length(); i++) { |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 // All incoming parameters are tagged. | 556 // All incoming parameters are tagged. |
557 CompleteRange(tail, Location::kRegister); | 557 CompleteRange(tail, Location::kRegister); |
558 } | 558 } |
559 ConvertAllUses(range); | 559 ConvertAllUses(range); |
560 if (flow_graph_.copied_parameter_count() > 0) { | 560 if (flow_graph_.copied_parameter_count() > 0) { |
561 MarkAsObjectAtSafepoints(range); | 561 MarkAsObjectAtSafepoints(range); |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 // Process global constants. | 565 // Process global constants. |
566 ConstantInstr* null_defn = graph_entry->constant_null(); | 566 BindInstr* null_defn = graph_entry->constant_null()->AsBind(); |
567 LiveRange* range = GetLiveRange(null_defn->ssa_temp_index()); | 567 LiveRange* range = GetLiveRange(null_defn->ssa_temp_index()); |
568 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); | 568 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); |
569 range->DefineAt(graph_entry->start_pos()); | 569 range->DefineAt(graph_entry->start_pos()); |
570 range->set_assigned_location(Location::Constant(null_defn->value())); | 570 range->set_assigned_location( |
571 range->set_spill_slot(Location::Constant(null_defn->value())); | 571 Location::Constant(null_defn->computation()->AsConstant()->value())); |
| 572 range->set_spill_slot( |
| 573 Location::Constant(null_defn->computation()->AsConstant()->value())); |
572 range->finger()->Initialize(range); | 574 range->finger()->Initialize(range); |
573 UsePosition* use = | 575 UsePosition* use = |
574 range->finger()->FirstRegisterBeneficialUse(graph_entry->start_pos()); | 576 range->finger()->FirstRegisterBeneficialUse(graph_entry->start_pos()); |
575 if (use != NULL) { | 577 if (use != NULL) { |
576 LiveRange* tail = SplitBetween(range, graph_entry->start_pos(), use->pos()); | 578 LiveRange* tail = SplitBetween(range, graph_entry->start_pos(), use->pos()); |
577 CompleteRange(tail, Location::kRegister); | 579 CompleteRange(tail, Location::kRegister); |
578 } | 580 } |
579 ConvertAllUses(range); | 581 ConvertAllUses(range); |
580 } | 582 } |
581 | 583 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 Value* value = values[i]; | 755 Value* value = values[i]; |
754 locations[i] = Location::Any(); | 756 locations[i] = Location::Any(); |
755 Definition* def = value->definition(); | 757 Definition* def = value->definition(); |
756 | 758 |
757 if (def->IsPushArgument()) { | 759 if (def->IsPushArgument()) { |
758 // Frame size is unknown until after allocation. | 760 // Frame size is unknown until after allocation. |
759 locations[i] = Location::NoLocation(); | 761 locations[i] = Location::NoLocation(); |
760 continue; | 762 continue; |
761 } | 763 } |
762 | 764 |
763 ConstantInstr* constant = def->AsConstant(); | 765 ConstantComp* constant = def->AsConstant(); |
764 if (constant != NULL) { | 766 if (constant != NULL) { |
765 locations[i] = Location::Constant(constant->value()); | 767 locations[i] = Location::Constant(constant->value()); |
766 continue; | 768 continue; |
767 } | 769 } |
768 | 770 |
769 const intptr_t vreg = def->ssa_temp_index(); | 771 const intptr_t vreg = def->ssa_temp_index(); |
770 LiveRange* range = GetLiveRange(vreg); | 772 LiveRange* range = GetLiveRange(vreg); |
771 range->AddUseInterval(block_start_pos, use_pos); | 773 range->AddUseInterval(block_start_pos, use_pos); |
772 range->AddUse(use_pos, &locations[i]); | 774 range->AddUse(use_pos, &locations[i]); |
773 } | 775 } |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 2174 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
2173 function.ToFullyQualifiedCString()); | 2175 function.ToFullyQualifiedCString()); |
2174 FlowGraphPrinter printer(flow_graph_, true); | 2176 FlowGraphPrinter printer(flow_graph_, true); |
2175 printer.PrintBlocks(); | 2177 printer.PrintBlocks(); |
2176 OS::Print("----------------------------------------------\n"); | 2178 OS::Print("----------------------------------------------\n"); |
2177 } | 2179 } |
2178 } | 2180 } |
2179 | 2181 |
2180 | 2182 |
2181 } // namespace dart | 2183 } // namespace dart |
OLD | NEW |