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

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

Issue 23549020: Optimize conditional branches that have same true/false targets. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 7 years, 2 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/compiler.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/cha.h" 9 #include "vm/cha.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 bool FlowGraphCompiler::CanOptimizeFunction() const { 163 bool FlowGraphCompiler::CanOptimizeFunction() const {
164 return CanOptimize() && !parsed_function().function().HasBreakpoint(); 164 return CanOptimize() && !parsed_function().function().HasBreakpoint();
165 } 165 }
166 166
167 167
168 bool FlowGraphCompiler::CanOSRFunction() const { 168 bool FlowGraphCompiler::CanOSRFunction() const {
169 return FLAG_use_osr & CanOptimizeFunction() && !is_optimizing(); 169 return FLAG_use_osr & CanOptimizeFunction() && !is_optimizing();
170 } 170 }
171 171
172 172
173 static bool IsEmptyBlock(BlockEntryInstr* block) {
174 return !block->HasParallelMove() &&
175 block->next()->IsGoto() &&
176 !block->next()->AsGoto()->HasParallelMove();
177 }
178
179
180 void FlowGraphCompiler::CompactBlock(BlockEntryInstr* block) { 173 void FlowGraphCompiler::CompactBlock(BlockEntryInstr* block) {
181 BlockInfo* block_info = block_info_[block->postorder_number()]; 174 BlockInfo* block_info = block_info_[block->postorder_number()];
182 175
183 if (block_info->is_marked()) { 176 if (block_info->is_marked()) {
184 return; 177 return;
185 } 178 }
186 block_info->mark(); 179 block_info->mark();
187 180
188 if (IsEmptyBlock(block)) { 181 if (block->IsEmptyBlock()) {
189 BlockEntryInstr* target = block->next()->AsGoto()->successor(); 182 BlockEntryInstr* target = block->next()->AsGoto()->successor();
190 CompactBlock(target); 183 CompactBlock(target);
191 block_info->set_jump_label(GetJumpLabel(target)); 184 block_info->set_jump_label(GetJumpLabel(target));
192 } 185 }
193 } 186 }
194 187
195 188
196 void FlowGraphCompiler::CompactBlocks() { 189 void FlowGraphCompiler::CompactBlocks() {
197 Label* fallthrough_label = NULL; 190 Label* fallthrough_label = NULL;
198 for (intptr_t i = block_order().length() - 1; i >= 1; --i) { 191 for (intptr_t i = block_order().length() - 1; i >= 1; --i) {
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 1135
1143 for (int i = 0; i < len; i++) { 1136 for (int i = 0; i < len; i++) {
1144 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), 1137 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i),
1145 &Function::ZoneHandle(ic_data.GetTargetAt(i)), 1138 &Function::ZoneHandle(ic_data.GetTargetAt(i)),
1146 ic_data.GetCountAt(i))); 1139 ic_data.GetCountAt(i)));
1147 } 1140 }
1148 sorted->Sort(HighestCountFirst); 1141 sorted->Sort(HighestCountFirst);
1149 } 1142 }
1150 1143
1151 } // namespace dart 1144 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698