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 Definition* constant_null = | 89 ConstantInstr* 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 BindInstr* null_defn = graph_entry->constant_null()->AsBind(); | 566 ConstantInstr* null_defn = graph_entry->constant_null(); |
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( | 570 range->set_assigned_location(Location::Constant(null_defn->value())); |
571 Location::Constant(null_defn->computation()->AsConstant()->value())); | 571 range->set_spill_slot(Location::Constant(null_defn->value())); |
572 range->set_spill_slot( | |
573 Location::Constant(null_defn->computation()->AsConstant()->value())); | |
574 range->finger()->Initialize(range); | 572 range->finger()->Initialize(range); |
575 UsePosition* use = | 573 UsePosition* use = |
576 range->finger()->FirstRegisterBeneficialUse(graph_entry->start_pos()); | 574 range->finger()->FirstRegisterBeneficialUse(graph_entry->start_pos()); |
577 if (use != NULL) { | 575 if (use != NULL) { |
578 LiveRange* tail = SplitBetween(range, graph_entry->start_pos(), use->pos()); | 576 LiveRange* tail = SplitBetween(range, graph_entry->start_pos(), use->pos()); |
579 CompleteRange(tail, Location::kRegister); | 577 CompleteRange(tail, Location::kRegister); |
580 } | 578 } |
581 ConvertAllUses(range); | 579 ConvertAllUses(range); |
582 } | 580 } |
583 | 581 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 Value* value = values[i]; | 753 Value* value = values[i]; |
756 locations[i] = Location::Any(); | 754 locations[i] = Location::Any(); |
757 Definition* def = value->definition(); | 755 Definition* def = value->definition(); |
758 | 756 |
759 if (def->IsPushArgument()) { | 757 if (def->IsPushArgument()) { |
760 // Frame size is unknown until after allocation. | 758 // Frame size is unknown until after allocation. |
761 locations[i] = Location::NoLocation(); | 759 locations[i] = Location::NoLocation(); |
762 continue; | 760 continue; |
763 } | 761 } |
764 | 762 |
765 ConstantComp* constant = def->AsConstant(); | 763 ConstantInstr* constant = def->AsConstant(); |
766 if (constant != NULL) { | 764 if (constant != NULL) { |
767 locations[i] = Location::Constant(constant->value()); | 765 locations[i] = Location::Constant(constant->value()); |
768 continue; | 766 continue; |
769 } | 767 } |
770 | 768 |
771 const intptr_t vreg = def->ssa_temp_index(); | 769 const intptr_t vreg = def->ssa_temp_index(); |
772 LiveRange* range = GetLiveRange(vreg); | 770 LiveRange* range = GetLiveRange(vreg); |
773 range->AddUseInterval(block_start_pos, use_pos); | 771 range->AddUseInterval(block_start_pos, use_pos); |
774 range->AddUse(use_pos, &locations[i]); | 772 range->AddUse(use_pos, &locations[i]); |
775 } | 773 } |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 2172 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
2175 function.ToFullyQualifiedCString()); | 2173 function.ToFullyQualifiedCString()); |
2176 FlowGraphPrinter printer(flow_graph_, true); | 2174 FlowGraphPrinter printer(flow_graph_, true); |
2177 printer.PrintBlocks(); | 2175 printer.PrintBlocks(); |
2178 OS::Print("----------------------------------------------\n"); | 2176 OS::Print("----------------------------------------------\n"); |
2179 } | 2177 } |
2180 } | 2178 } |
2181 | 2179 |
2182 | 2180 |
2183 } // namespace dart | 2181 } // namespace dart |
OLD | NEW |