Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: runtime/vm/flow_graph_allocator.cc

Issue 10928232: Deoptimization support in inlined code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::ProcessEnvironmentUses(BlockEntryInstr* block,
739 Instruction* current) { 741 Instruction* current) {
740 ASSERT(current->env() != NULL); 742 ASSERT(current->env() != NULL);
743 Environment* env = current->env();
744 while (env != NULL) {
745 // Any value mentioned in the deoptimization environment should survive
746 // until the end of instruction but it does not need to be in the register.
747 // Expected shape of live range:
748 //
749 // i i'
750 // value -----*
751 //
741 752
742 Environment* env = current->env(); 753 if (env->Length() == 0) {
743 754 env = env->outer();
744 // 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.
746 // Expected shape of live range:
747 //
748 // i i'
749 // value -----*
750 //
751
752 if (env->Length() == 0) return;
753
754 const intptr_t block_start_pos = block->start_pos();
755 const intptr_t use_pos = current->lifetime_position() + 1;
756
757 Location* locations =
758 Isolate::Current()->current_zone()->Alloc<Location>(env->Length());
759
760 for (intptr_t i = 0; i < env->Length(); ++i) {
761 Value* value = env->ValueAt(i);
762 locations[i] = Location::Any();
763 Definition* def = value->definition();
764
765 if (def->IsPushArgument()) {
766 // Frame size is unknown until after allocation.
767 locations[i] = Location::NoLocation();
768 continue; 755 continue;
769 } 756 }
770 757
771 ConstantInstr* constant = def->AsConstant(); 758 const intptr_t block_start_pos = block->start_pos();
772 if (constant != NULL) { 759 const intptr_t use_pos = current->lifetime_position() + 1;
773 locations[i] = Location::Constant(constant->value()); 760
774 continue; 761 Location* locations =
762 Isolate::Current()->current_zone()->Alloc<Location>(env->Length());
763
764 for (intptr_t i = 0; i < env->Length(); ++i) {
765 Value* value = env->ValueAt(i);
766 locations[i] = Location::Any();
767 Definition* def = value->definition();
768
769 if (def->IsPushArgument()) {
770 // Frame size is unknown until after allocation.
771 locations[i] = Location::NoLocation();
772 continue;
773 }
774
775 ConstantInstr* constant = def->AsConstant();
776 if (constant != NULL) {
777 locations[i] = Location::Constant(constant->value());
778 continue;
779 }
780
781 const intptr_t vreg = def->ssa_temp_index();
782 LiveRange* range = GetLiveRange(vreg);
783 range->AddUseInterval(block_start_pos, use_pos);
784 range->AddUse(use_pos, &locations[i]);
775 } 785 }
776 786
777 const intptr_t vreg = def->ssa_temp_index(); 787 env->set_locations(locations);
778 LiveRange* range = GetLiveRange(vreg); 788 env = env->outer();
779 range->AddUseInterval(block_start_pos, use_pos);
780 range->AddUse(use_pos, &locations[i]);
781 } 789 }
782
783 env->set_locations(locations);
784 } 790 }
785 791
786 792
787 // Create and update live ranges corresponding to instruction's inputs, 793 // Create and update live ranges corresponding to instruction's inputs,
788 // temporaries and output. 794 // temporaries and output.
789 void FlowGraphAllocator::ProcessOneInstruction(BlockEntryInstr* block, 795 void FlowGraphAllocator::ProcessOneInstruction(BlockEntryInstr* block,
790 Instruction* current) { 796 Instruction* current) {
791 LocationSummary* locs = current->locs(); 797 LocationSummary* locs = current->locs();
792 798
793 Definition* def = current->AsDefinition(); 799 Definition* def = current->AsDefinition();
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", 2212 OS::Print("-- [after ssa allocator] ir [%s] -------------\n",
2207 function.ToFullyQualifiedCString()); 2213 function.ToFullyQualifiedCString());
2208 FlowGraphPrinter printer(flow_graph_, true); 2214 FlowGraphPrinter printer(flow_graph_, true);
2209 printer.PrintBlocks(); 2215 printer.PrintBlocks();
2210 OS::Print("----------------------------------------------\n"); 2216 OS::Print("----------------------------------------------\n");
2211 } 2217 }
2212 } 2218 }
2213 2219
2214 2220
2215 } // namespace dart 2221 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698