| OLD | NEW |
| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 static void Optimize(FlowGraph* graph); | 328 static void Optimize(FlowGraph* graph); |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 | 331 |
| 332 class DeadCodeElimination : public AllStatic { | 332 class DeadCodeElimination : public AllStatic { |
| 333 public: | 333 public: |
| 334 static void EliminateDeadPhis(FlowGraph* graph); | 334 static void EliminateDeadPhis(FlowGraph* graph); |
| 335 }; | 335 }; |
| 336 | 336 |
| 337 | 337 |
| 338 // Rewrite branches to eliminate materialization of boolean values after | |
| 339 // inlining, and to expose other optimizations (e.g., constant folding of | |
| 340 // branches, unreachable code elimination). | |
| 341 class BranchSimplifier : public AllStatic { | |
| 342 public: | |
| 343 static void Simplify(FlowGraph* flow_graph); | |
| 344 | |
| 345 // Replace a target entry instruction with a join entry instruction. Does | |
| 346 // not update the original target's predecessors to point to the new block | |
| 347 // and does not replace the target in already computed block order lists. | |
| 348 static JoinEntryInstr* ToJoinEntry(Zone* zone, | |
| 349 TargetEntryInstr* target); | |
| 350 | |
| 351 private: | |
| 352 // Match an instance of the pattern to rewrite. See the implementation | |
| 353 // for the patterns that are handled by this pass. | |
| 354 static bool Match(JoinEntryInstr* block); | |
| 355 | |
| 356 // Duplicate a branch while replacing its comparison's left and right | |
| 357 // inputs. | |
| 358 static BranchInstr* CloneBranch(Zone* zone, | |
| 359 BranchInstr* branch, | |
| 360 Value* new_left, | |
| 361 Value* new_right); | |
| 362 }; | |
| 363 | |
| 364 | |
| 365 // Rewrite diamond control flow patterns that materialize values to use more | |
| 366 // efficient branchless code patterns if such are supported on the current | |
| 367 // platform. | |
| 368 class IfConverter : public AllStatic { | |
| 369 public: | |
| 370 static void Simplify(FlowGraph* flow_graph); | |
| 371 }; | |
| 372 | |
| 373 | |
| 374 class AllocationSinking : public ZoneAllocated { | 338 class AllocationSinking : public ZoneAllocated { |
| 375 public: | 339 public: |
| 376 explicit AllocationSinking(FlowGraph* flow_graph) | 340 explicit AllocationSinking(FlowGraph* flow_graph) |
| 377 : flow_graph_(flow_graph), | 341 : flow_graph_(flow_graph), |
| 378 candidates_(5), | 342 candidates_(5), |
| 379 materializations_(5) { } | 343 materializations_(5) { } |
| 380 | 344 |
| 381 const GrowableArray<Definition*>& candidates() const { | 345 const GrowableArray<Definition*>& candidates() const { |
| 382 return candidates_; | 346 return candidates_; |
| 383 } | 347 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 // Optimize spill stores inside try-blocks by identifying values that always | 411 // Optimize spill stores inside try-blocks by identifying values that always |
| 448 // contain a single known constant at catch block entry. | 412 // contain a single known constant at catch block entry. |
| 449 class TryCatchAnalyzer : public AllStatic { | 413 class TryCatchAnalyzer : public AllStatic { |
| 450 public: | 414 public: |
| 451 static void Optimize(FlowGraph* flow_graph); | 415 static void Optimize(FlowGraph* flow_graph); |
| 452 }; | 416 }; |
| 453 | 417 |
| 454 } // namespace dart | 418 } // namespace dart |
| 455 | 419 |
| 456 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 420 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |