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

Unified Diff: runtime/vm/flow_graph_compiler.cc

Issue 10704119: Use the instruction iterator rather than an explicit loop in more places. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_compiler.cc
diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc
index 329204c6f984e1b1f8cdaf5cc49e370d5c54bb5d..ab31e943ccd049516ce48b17aa8bec12cbfc41d5 100644
--- a/runtime/vm/flow_graph_compiler.cc
+++ b/runtime/vm/flow_graph_compiler.cc
@@ -93,22 +93,23 @@ void FlowGraphCompiler::VisitBlocks() {
ASSERT(frame_register_allocator()->IsSpilled());
assembler()->Comment("B%d", i);
// Compile the block entry.
- set_current_block(block_order()[i]);
- current_block()->PrepareEntry(this);
- Instruction* instr = current_block()->next();
+ BlockEntryInstr* entry = block_order()[i];
+ set_current_block(entry);
+ entry->PrepareEntry(this);
// Compile all successors until an exit, branch, or a block entry.
- while ((instr != NULL) && !instr->IsBlockEntry()) {
+ Instruction* instr = entry;
+ for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
+ instr = it.Current();
if (FLAG_code_comments) EmitComment(instr);
ASSERT(instr->locs() != NULL);
EmitInstructionPrologue(instr);
instr->EmitNativeCode(this);
- instr = instr->next();
}
- BlockEntryInstr* successor =
- (instr == NULL) ? NULL : instr->AsBlockEntry();
- if (successor != NULL) {
+ if (instr->next() != NULL) {
+ BlockEntryInstr* successor = instr->next()->AsBlockEntry();
+ ASSERT(successor != NULL);
frame_register_allocator()->Spill();
- // Block ended with a "goto". We can fall through if it is the
+ // The block ended with a "goto". We can fall through if it is the
// next block in the list. Otherwise, we need a jump.
if ((i == block_order().length() - 1) ||
(block_order()[i + 1] != successor)) {
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698