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

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

Issue 261823005: Optimize conditional branches that have same true/false targets. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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.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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 // Sparse conditional constant propagation and unreachable code elimination. 291 // Sparse conditional constant propagation and unreachable code elimination.
292 // Assumes that use lists are computed and preserves them. 292 // Assumes that use lists are computed and preserves them.
293 class ConstantPropagator : public FlowGraphVisitor { 293 class ConstantPropagator : public FlowGraphVisitor {
294 public: 294 public:
295 ConstantPropagator(FlowGraph* graph, 295 ConstantPropagator(FlowGraph* graph,
296 const GrowableArray<BlockEntryInstr*>& ignored); 296 const GrowableArray<BlockEntryInstr*>& ignored);
297 297
298 static void Optimize(FlowGraph* graph); 298 static void Optimize(FlowGraph* graph);
299 299
300 // Only visit branches to optimize away unreachable blocks discovered 300 // (1) Visit branches to optimize away unreachable blocks discovered by range
301 // by range analysis. 301 // analysis.
302 // (2) Eliminate branches that have the same true- and false-target: For
303 // example, this occurs after expressions like
304 //
305 // if (a == null || b == null) {
306 // ...
307 // }
308 //
309 // where b is known to be null.
302 static void OptimizeBranches(FlowGraph* graph); 310 static void OptimizeBranches(FlowGraph* graph);
303 311
304 // Used to initialize the abstract value of definitions. 312 // Used to initialize the abstract value of definitions.
305 static RawObject* Unknown() { return Object::unknown_constant().raw(); } 313 static RawObject* Unknown() { return Object::unknown_constant().raw(); }
306 314
307 private: 315 private:
308 void Analyze(); 316 void Analyze();
309 void VisitBranches(); 317 void VisitBranches();
310 void Transform(); 318 void Transform();
319 void EliminateRedundantBranches();
311 320
312 void SetReachable(BlockEntryInstr* block); 321 void SetReachable(BlockEntryInstr* block);
313 void SetValue(Definition* definition, const Object& value); 322 void SetValue(Definition* definition, const Object& value);
314 323
315 // Assign the join (least upper bound) of a pair of abstract values to the 324 // Assign the join (least upper bound) of a pair of abstract values to the
316 // first one. 325 // first one.
317 void Join(Object* left, const Object& right); 326 void Join(Object* left, const Object& right);
318 327
319 bool IsUnknown(const Object& value) { 328 bool IsUnknown(const Object& value) {
320 return value.raw() == unknown_.raw(); 329 return value.raw() == unknown_.raw();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // Optimize spill stores inside try-blocks by identifying values that always 429 // Optimize spill stores inside try-blocks by identifying values that always
421 // contain a single known constant at catch block entry. 430 // contain a single known constant at catch block entry.
422 class TryCatchAnalyzer : public AllStatic { 431 class TryCatchAnalyzer : public AllStatic {
423 public: 432 public:
424 static void Optimize(FlowGraph* flow_graph); 433 static void Optimize(FlowGraph* flow_graph);
425 }; 434 };
426 435
427 } // namespace dart 436 } // namespace dart
428 437
429 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ 438 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698