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

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: Created 7 years, 3 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
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Only visit branches to optimize away unreachable blocks discovered
246 // by range analysis. 246 // by range analysis.
247 static void OptimizeBranches(FlowGraph* graph); 247 static void OptimizeBranches(FlowGraph* graph);
248 248
249 // Eliminate branches that have the same true- and false-target: For example,
250 // this occurs after expressions like
251 //
252 // if (a == null) || (b == null) {
Kevin Millikin (Google) 2013/09/27 11:03:43 You need more parentheses in the comment :)
Florian Schneider 2013/09/30 12:19:23 Less is more :) Done.
253 // ...
254 // }
255 //
256 // where b is known to be null.
257 static void RemoveRedundantBranches(FlowGraph* graph);
258
249 // Used to initialize the abstract value of definitions. 259 // Used to initialize the abstract value of definitions.
250 static RawObject* Unknown() { return Object::unknown_constant().raw(); } 260 static RawObject* Unknown() { return Object::unknown_constant().raw(); }
251 261
252 private: 262 private:
253 void Analyze(); 263 void Analyze();
254 void VisitBranches(); 264 void VisitBranches();
255 void Transform(); 265 void Transform();
266 void EliminateRedundantBranches();
256 267
257 void SetReachable(BlockEntryInstr* block); 268 void SetReachable(BlockEntryInstr* block);
258 void SetValue(Definition* definition, const Object& value); 269 void SetValue(Definition* definition, const Object& value);
259 270
260 // Assign the join (least upper bound) of a pair of abstract values to the 271 // Assign the join (least upper bound) of a pair of abstract values to the
261 // first one. 272 // first one.
262 void Join(Object* left, const Object& right); 273 void Join(Object* left, const Object& right);
263 274
264 bool IsUnknown(const Object& value) { 275 bool IsUnknown(const Object& value) {
265 return value.raw() == unknown_.raw(); 276 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 376 // Optimize spill stores inside try-blocks by identifying values that always
366 // contain a single known constant at catch block entry. 377 // contain a single known constant at catch block entry.
367 class TryCatchAnalyzer : public AllStatic { 378 class TryCatchAnalyzer : public AllStatic {
368 public: 379 public:
369 static void Optimize(FlowGraph* flow_graph); 380 static void Optimize(FlowGraph* flow_graph);
370 }; 381 };
371 382
372 } // namespace dart 383 } // namespace dart
373 384
374 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ 385 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698