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

Side by Side Diff: runtime/vm/flow_graph_optimizer.h

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/flow_graph_compiler.cc ('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 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_ 5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_
6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ 6 #define VM_FLOW_GRAPH_OPTIMIZER_H_
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 #include "vm/flow_graph.h" 9 #include "vm/flow_graph.h"
10 10
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 // Sparse conditional constant propagation and unreachable code elimination. 236 // Sparse conditional constant propagation and unreachable code elimination.
237 // Assumes that use lists are computed and preserves them. 237 // Assumes that use lists are computed and preserves them.
238 class ConstantPropagator : public FlowGraphVisitor { 238 class ConstantPropagator : public FlowGraphVisitor {
239 public: 239 public:
240 ConstantPropagator(FlowGraph* graph, 240 ConstantPropagator(FlowGraph* graph,
241 const GrowableArray<BlockEntryInstr*>& ignored); 241 const GrowableArray<BlockEntryInstr*>& ignored);
242 242
243 static void Optimize(FlowGraph* graph); 243 static void Optimize(FlowGraph* graph);
244 244
245 // Only visit branches to optimize away unreachable blocks discovered 245 // (1) Visit branches to optimize away unreachable blocks discovered by range
246 // by range analysis. 246 // analysis.
247 // (2) Eliminate branches that have the same true- and false-target: For
248 // example, this occurs after expressions like
249 //
250 // if (a == null || b == null) {
251 // ...
252 // }
253 //
254 // where b is known to be null.
247 static void OptimizeBranches(FlowGraph* graph); 255 static void OptimizeBranches(FlowGraph* graph);
248 256
249 // Used to initialize the abstract value of definitions. 257 // Used to initialize the abstract value of definitions.
250 static RawObject* Unknown() { return Object::unknown_constant().raw(); } 258 static RawObject* Unknown() { return Object::unknown_constant().raw(); }
251 259
252 private: 260 private:
253 void Analyze(); 261 void Analyze();
254 void VisitBranches(); 262 void VisitBranches();
255 void Transform(); 263 void Transform();
264 void EliminateRedundantBranches();
256 265
257 void SetReachable(BlockEntryInstr* block); 266 void SetReachable(BlockEntryInstr* block);
258 void SetValue(Definition* definition, const Object& value); 267 void SetValue(Definition* definition, const Object& value);
259 268
260 // Assign the join (least upper bound) of a pair of abstract values to the 269 // Assign the join (least upper bound) of a pair of abstract values to the
261 // first one. 270 // first one.
262 void Join(Object* left, const Object& right); 271 void Join(Object* left, const Object& right);
263 272
264 bool IsUnknown(const Object& value) { 273 bool IsUnknown(const Object& value) {
265 return value.raw() == unknown_.raw(); 274 return value.raw() == unknown_.raw();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // Optimize spill stores inside try-blocks by identifying values that always 374 // Optimize spill stores inside try-blocks by identifying values that always
366 // contain a single known constant at catch block entry. 375 // contain a single known constant at catch block entry.
367 class TryCatchAnalyzer : public AllStatic { 376 class TryCatchAnalyzer : public AllStatic {
368 public: 377 public:
369 static void Optimize(FlowGraph* flow_graph); 378 static void Optimize(FlowGraph* flow_graph);
370 }; 379 };
371 380
372 } // namespace dart 381 } // namespace dart
373 382
374 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ 383 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698