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

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

Issue 557413002: Merge chains of straight-line blocks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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.h ('k') | runtime/vm/flow_graph_optimizer.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.h" 5 #include "vm/flow_graph.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 reverse_postorder_.Add(postorder_[block_count - i - 1]); 168 reverse_postorder_.Add(postorder_[block_count - i - 1]);
169 } 169 }
170 170
171 // Block effects are using postorder numbering. Discard computed information. 171 // Block effects are using postorder numbering. Discard computed information.
172 block_effects_ = NULL; 172 block_effects_ = NULL;
173 loop_headers_ = NULL; 173 loop_headers_ = NULL;
174 loop_invariant_loads_ = NULL; 174 loop_invariant_loads_ = NULL;
175 } 175 }
176 176
177 177
178 void FlowGraph::MergeBlocks() {
179 bool changed = false;
180 BitVector* merged = new(isolate()) BitVector(postorder().length());
zerny-google 2014/11/19 11:32:34 BitVector takes a isolate as first argument after
Florian Schneider 2014/11/19 12:19:35 Done.
181 for (BlockIterator block_it = reverse_postorder_iterator();
182 !block_it.Done();
183 block_it.Advance()) {
184 BlockEntryInstr* block = block_it.Current();
185 if (block->IsGraphEntry()) continue;
186 if (merged->Contains(block->postorder_number())) continue;
187
188 Instruction* last = block->last_instruction();
189 BlockEntryInstr* successor = NULL;
190 while ((last->SuccessorCount() == 1) &&
191 (last->SuccessorAt(0)->PredecessorCount() == 1) &&
192 (block->try_index() == last->SuccessorAt(0)->try_index())) {
193 successor = last->SuccessorAt(0);
194 ASSERT(last->IsGoto());
195
196 // Remove environment uses and unlink goto and block entry.
197 successor->UnuseAllInputs();
198 last->previous()->LinkTo(successor->next());
199 last->UnuseAllInputs();
200
201 last = successor->last_instruction();
202 merged->Add(successor->postorder_number());
203 changed = true;
204 if (FLAG_trace_optimization) {
205 OS::Print("Merged blocks B%" Pd " and B%" Pd "\n",
206 block->block_id(),
207 successor->block_id());
208 }
209 }
210 // The new block inherits the block id of the last successor to maintain
211 // the order of phi inputs at its successors consistent with block ids.
212 if (successor != NULL) {
213 block->set_block_id(successor->block_id());
214 }
215 }
216 // Recompute block order after changes were made.
217 if (changed) DiscoverBlocks();
218 }
219
220
178 // Debugging code to verify the construction of use lists. 221 // Debugging code to verify the construction of use lists.
179 static intptr_t MembershipCount(Value* use, Value* list) { 222 static intptr_t MembershipCount(Value* use, Value* list) {
180 intptr_t count = 0; 223 intptr_t count = 0;
181 while (list != NULL) { 224 while (list != NULL) {
182 if (list == use) ++count; 225 if (list == use) ++count;
183 list = list->next_use(); 226 list = list->next_use();
184 } 227 }
185 return count; 228 return count;
186 } 229 }
187 230
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 } 1297 }
1255 1298
1256 1299
1257 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, 1300 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from,
1258 BlockEntryInstr* to) const { 1301 BlockEntryInstr* to) const {
1259 return available_at_[to->postorder_number()]->Contains( 1302 return available_at_[to->postorder_number()]->Contains(
1260 from->postorder_number()); 1303 from->postorder_number());
1261 } 1304 }
1262 1305
1263 } // namespace dart 1306 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698