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

Side by Side Diff: vm/flow_graph_allocator.cc

Issue 10692107: Add forward iterator to iterate instructions inside a basic block. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | « no previous file | 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/flow_graph_compiler.h" 9 #include "vm/flow_graph_compiler.h"
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const intptr_t use = ToVirtualRegister(val->AsUse()->definition()); 59 const intptr_t use = ToVirtualRegister(val->AsUse()->definition());
60 if (use >= 0) { 60 if (use >= 0) {
61 BlockEntryInstr* pred = block->PredecessorAt(k); 61 BlockEntryInstr* pred = block->PredecessorAt(k);
62 live_out_[pred->postorder_number()]->Add(use); 62 live_out_[pred->postorder_number()]->Add(use);
63 } 63 }
64 } 64 }
65 } 65 }
66 } 66 }
67 } 67 }
68 68
69 Instruction* current = block->successor();
70 // TODO(vegorov): iterate backwards. 69 // TODO(vegorov): iterate backwards.
71 while ((current != NULL) && !current->IsBlockEntry()) { 70 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
71 Instruction* current = it.Current();
72 for (intptr_t j = 0; j < current->InputCount(); j++) { 72 for (intptr_t j = 0; j < current->InputCount(); j++) {
73 Value* input = current->InputAt(j); 73 Value* input = current->InputAt(j);
74 if (!input->IsUse()) continue; 74 if (!input->IsUse()) continue;
75 const intptr_t use = ToVirtualRegister(input->AsUse()->definition()); 75 const intptr_t use = ToVirtualRegister(input->AsUse()->definition());
76 if ((use >= 0) && !kill->Contains(use)) live_in->Add(use); 76 if ((use >= 0) && !kill->Contains(use)) live_in->Add(use);
77 } 77 }
78 78
79 const intptr_t def = ToVirtualRegister(current); 79 const intptr_t def = ToVirtualRegister(current);
80 if (def >= 0) kill->Add(def); 80 if (def >= 0) kill->Add(def);
81
82 current = current->successor();
83 } 81 }
84 } 82 }
85 83
86 // Update initial live_in sets to match live_out sets. Has to be 84 // Update initial live_in sets to match live_out sets. Has to be
87 // done in a separate path because of backwards branches. 85 // done in a separate path because of backwards branches.
88 for (intptr_t i = 0; i < block_count; i++) { 86 for (intptr_t i = 0; i < block_count; i++) {
89 UpdateLiveIn(postorder_[i]); 87 UpdateLiveIn(postorder_[i]);
90 } 88 }
91 } 89 }
92 90
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 OS::Print("\n"); 174 OS::Print("\n");
177 175
178 PrintBitVector(" live out", live_out_[i]); 176 PrintBitVector(" live out", live_out_[i]);
179 PrintBitVector(" kill", kill_[i]); 177 PrintBitVector(" kill", kill_[i]);
180 PrintBitVector(" live in", live_in_[i]); 178 PrintBitVector(" live in", live_in_[i]);
181 } 179 }
182 } 180 }
183 181
184 182
185 } // namespace dart 183 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698