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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/flow_graph_optimizer.h » ('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/globals.h" // Needed here to get TARGET_ARCH_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 (FLAG_optimization_counter_threshold >= 0) && 86 (FLAG_optimization_counter_threshold >= 0) &&
87 !Isolate::Current()->debugger()->IsActive(); 87 !Isolate::Current()->debugger()->IsActive();
88 } 88 }
89 89
90 90
91 void FlowGraphCompiler::VisitBlocks() { 91 void FlowGraphCompiler::VisitBlocks() {
92 for (intptr_t i = 0; i < block_order().length(); ++i) { 92 for (intptr_t i = 0; i < block_order().length(); ++i) {
93 ASSERT(frame_register_allocator()->IsSpilled()); 93 ASSERT(frame_register_allocator()->IsSpilled());
94 assembler()->Comment("B%d", i); 94 assembler()->Comment("B%d", i);
95 // Compile the block entry. 95 // Compile the block entry.
96 set_current_block(block_order()[i]); 96 BlockEntryInstr* entry = block_order()[i];
97 current_block()->PrepareEntry(this); 97 set_current_block(entry);
98 Instruction* instr = current_block()->next(); 98 entry->PrepareEntry(this);
99 // Compile all successors until an exit, branch, or a block entry. 99 // Compile all successors until an exit, branch, or a block entry.
100 while ((instr != NULL) && !instr->IsBlockEntry()) { 100 Instruction* instr = entry;
101 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
102 instr = it.Current();
101 if (FLAG_code_comments) EmitComment(instr); 103 if (FLAG_code_comments) EmitComment(instr);
102 ASSERT(instr->locs() != NULL); 104 ASSERT(instr->locs() != NULL);
103 EmitInstructionPrologue(instr); 105 EmitInstructionPrologue(instr);
104 instr->EmitNativeCode(this); 106 instr->EmitNativeCode(this);
105 instr = instr->next();
106 } 107 }
107 BlockEntryInstr* successor = 108 if (instr->next() != NULL) {
108 (instr == NULL) ? NULL : instr->AsBlockEntry(); 109 BlockEntryInstr* successor = instr->next()->AsBlockEntry();
109 if (successor != NULL) { 110 ASSERT(successor != NULL);
110 frame_register_allocator()->Spill(); 111 frame_register_allocator()->Spill();
111 // Block ended with a "goto". We can fall through if it is the 112 // The block ended with a "goto". We can fall through if it is the
112 // next block in the list. Otherwise, we need a jump. 113 // next block in the list. Otherwise, we need a jump.
113 if ((i == block_order().length() - 1) || 114 if ((i == block_order().length() - 1) ||
114 (block_order()[i + 1] != successor)) { 115 (block_order()[i + 1] != successor)) {
115 assembler()->jmp(GetBlockLabel(successor)); 116 assembler()->jmp(GetBlockLabel(successor));
116 } 117 }
117 } 118 }
118 } 119 }
119 } 120 }
120 121
121 122
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 623
623 624
624 void FrameRegisterAllocator::SpillInDeoptStub(DeoptimizationStub* stub) { 625 void FrameRegisterAllocator::SpillInDeoptStub(DeoptimizationStub* stub) {
625 for (int i = 0; i < stack_.length(); i++) { 626 for (int i = 0; i < stack_.length(); i++) {
626 stub->Push(stack_[i]); 627 stub->Push(stack_[i]);
627 } 628 }
628 } 629 }
629 630
630 631
631 } // namespace dart 632 } // namespace dart
OLDNEW
« 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