| 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 class IfConverter : public AllStatic { | 422 class IfConverter : public AllStatic { |
| 423 public: | 423 public: |
| 424 static void Simplify(FlowGraph* flow_graph); | 424 static void Simplify(FlowGraph* flow_graph); |
| 425 }; | 425 }; |
| 426 | 426 |
| 427 | 427 |
| 428 class AllocationSinking : public ZoneAllocated { | 428 class AllocationSinking : public ZoneAllocated { |
| 429 public: | 429 public: |
| 430 explicit AllocationSinking(FlowGraph* flow_graph) | 430 explicit AllocationSinking(FlowGraph* flow_graph) |
| 431 : flow_graph_(flow_graph), | 431 : flow_graph_(flow_graph), |
| 432 candidates_(5), |
| 432 materializations_(5) { } | 433 materializations_(5) { } |
| 433 | 434 |
| 435 const GrowableArray<AllocateObjectInstr*>& candidates() const { |
| 436 return candidates_; |
| 437 } |
| 438 |
| 439 // Find the materialization insterted for the given allocation |
| 440 // at the given exit. |
| 441 MaterializeObjectInstr* MaterializationFor(Definition* alloc, |
| 442 Instruction* exit); |
| 443 |
| 434 void Optimize(); | 444 void Optimize(); |
| 435 | 445 |
| 436 void DetachMaterializations(); | 446 void DetachMaterializations(); |
| 437 | 447 |
| 438 private: | 448 private: |
| 449 void CollectCandidates(); |
| 450 |
| 451 void DiscoverFailedCandidates(); |
| 452 |
| 439 void InsertMaterializations(AllocateObjectInstr* alloc); | 453 void InsertMaterializations(AllocateObjectInstr* alloc); |
| 440 | 454 |
| 441 void CreateMaterializationAt( | 455 void CreateMaterializationAt( |
| 442 Instruction* exit, | 456 Instruction* exit, |
| 443 AllocateObjectInstr* alloc, | 457 AllocateObjectInstr* alloc, |
| 444 const Class& cls, | 458 const Class& cls, |
| 445 const ZoneGrowableArray<const Object*>& fields); | 459 const ZoneGrowableArray<const Object*>& fields); |
| 446 | 460 |
| 461 void EliminateAllocation(AllocateObjectInstr* alloc); |
| 462 |
| 447 Isolate* isolate() const { return flow_graph_->isolate(); } | 463 Isolate* isolate() const { return flow_graph_->isolate(); } |
| 448 | 464 |
| 449 FlowGraph* flow_graph_; | 465 FlowGraph* flow_graph_; |
| 450 | 466 |
| 467 GrowableArray<AllocateObjectInstr*> candidates_; |
| 451 GrowableArray<MaterializeObjectInstr*> materializations_; | 468 GrowableArray<MaterializeObjectInstr*> materializations_; |
| 452 }; | 469 }; |
| 453 | 470 |
| 454 | 471 |
| 455 // Optimize spill stores inside try-blocks by identifying values that always | 472 // Optimize spill stores inside try-blocks by identifying values that always |
| 456 // contain a single known constant at catch block entry. | 473 // contain a single known constant at catch block entry. |
| 457 class TryCatchAnalyzer : public AllStatic { | 474 class TryCatchAnalyzer : public AllStatic { |
| 458 public: | 475 public: |
| 459 static void Optimize(FlowGraph* flow_graph); | 476 static void Optimize(FlowGraph* flow_graph); |
| 460 }; | 477 }; |
| 461 | 478 |
| 462 } // namespace dart | 479 } // namespace dart |
| 463 | 480 |
| 464 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 481 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |