| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 338 |
| 339 // Used to initialize the abstract value of definitions. | 339 // Used to initialize the abstract value of definitions. |
| 340 static RawObject* Unknown() { return Object::unknown_constant().raw(); } | 340 static RawObject* Unknown() { return Object::unknown_constant().raw(); } |
| 341 | 341 |
| 342 private: | 342 private: |
| 343 void Analyze(); | 343 void Analyze(); |
| 344 void Transform(); | 344 void Transform(); |
| 345 void EliminateRedundantBranches(); | 345 void EliminateRedundantBranches(); |
| 346 | 346 |
| 347 void SetReachable(BlockEntryInstr* block); | 347 void SetReachable(BlockEntryInstr* block); |
| 348 void SetValue(Definition* definition, const Object& value); | 348 bool SetValue(Definition* definition, const Object& value); |
| 349 |
| 350 Definition* UnwrapPhi(Definition* defn); |
| 351 void MarkPhi(Definition* defn); |
| 349 | 352 |
| 350 // Assign the join (least upper bound) of a pair of abstract values to the | 353 // Assign the join (least upper bound) of a pair of abstract values to the |
| 351 // first one. | 354 // first one. |
| 352 void Join(Object* left, const Object& right); | 355 void Join(Object* left, const Object& right); |
| 353 | 356 |
| 354 bool IsUnknown(const Object& value) { | 357 bool IsUnknown(const Object& value) { |
| 355 return value.raw() == unknown_.raw(); | 358 return value.raw() == unknown_.raw(); |
| 356 } | 359 } |
| 357 bool IsNonConstant(const Object& value) { | 360 bool IsNonConstant(const Object& value) { |
| 358 return value.raw() == non_constant_.raw(); | 361 return value.raw() == non_constant_.raw(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 374 FlowGraph* graph_; | 377 FlowGraph* graph_; |
| 375 | 378 |
| 376 // Sentinels for unknown constant and non-constant values. | 379 // Sentinels for unknown constant and non-constant values. |
| 377 const Object& unknown_; | 380 const Object& unknown_; |
| 378 const Object& non_constant_; | 381 const Object& non_constant_; |
| 379 | 382 |
| 380 // Analysis results. For each block, a reachability bit. Indexed by | 383 // Analysis results. For each block, a reachability bit. Indexed by |
| 381 // preorder number. | 384 // preorder number. |
| 382 BitVector* reachable_; | 385 BitVector* reachable_; |
| 383 | 386 |
| 384 // Definitions can move up the lattice twice, so we use a mark bit to | 387 BitVector* marked_phis_; |
| 385 // indicate that they are already on the worklist in order to avoid adding | |
| 386 // them again. Indexed by SSA temp index. | |
| 387 BitVector* definition_marks_; | |
| 388 | 388 |
| 389 // Worklists of blocks and definitions. | 389 // Worklists of blocks and definitions. |
| 390 GrowableArray<BlockEntryInstr*> block_worklist_; | 390 GrowableArray<BlockEntryInstr*> block_worklist_; |
| 391 GrowableArray<Definition*> definition_worklist_; | 391 DefinitionWorklist definition_worklist_; |
| 392 }; | 392 }; |
| 393 | 393 |
| 394 | 394 |
| 395 // Rewrite branches to eliminate materialization of boolean values after | 395 // Rewrite branches to eliminate materialization of boolean values after |
| 396 // inlining, and to expose other optimizations (e.g., constant folding of | 396 // inlining, and to expose other optimizations (e.g., constant folding of |
| 397 // branches, unreachable code elimination). | 397 // branches, unreachable code elimination). |
| 398 class BranchSimplifier : public AllStatic { | 398 class BranchSimplifier : public AllStatic { |
| 399 public: | 399 public: |
| 400 static void Simplify(FlowGraph* flow_graph); | 400 static void Simplify(FlowGraph* flow_graph); |
| 401 | 401 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 // Optimize spill stores inside try-blocks by identifying values that always | 503 // Optimize spill stores inside try-blocks by identifying values that always |
| 504 // contain a single known constant at catch block entry. | 504 // contain a single known constant at catch block entry. |
| 505 class TryCatchAnalyzer : public AllStatic { | 505 class TryCatchAnalyzer : public AllStatic { |
| 506 public: | 506 public: |
| 507 static void Optimize(FlowGraph* flow_graph); | 507 static void Optimize(FlowGraph* flow_graph); |
| 508 }; | 508 }; |
| 509 | 509 |
| 510 } // namespace dart | 510 } // namespace dart |
| 511 | 511 |
| 512 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 512 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |