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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // Returns true if any instructions were canonicalized away. | 38 // Returns true if any instructions were canonicalized away. |
39 bool Canonicalize(); | 39 bool Canonicalize(); |
40 | 40 |
41 void EliminateDeadPhis(); | 41 void EliminateDeadPhis(); |
42 | 42 |
43 void SelectRepresentations(); | 43 void SelectRepresentations(); |
44 | 44 |
45 void InferSmiRanges(); | 45 void InferSmiRanges(); |
46 | 46 |
| 47 // Remove environments from the instructions which do not deoptimize. |
| 48 void EliminateEnvironments(); |
| 49 |
47 virtual void VisitStaticCall(StaticCallInstr* instr); | 50 virtual void VisitStaticCall(StaticCallInstr* instr); |
48 virtual void VisitInstanceCall(InstanceCallInstr* instr); | 51 virtual void VisitInstanceCall(InstanceCallInstr* instr); |
49 virtual void VisitRelationalOp(RelationalOpInstr* instr); | 52 virtual void VisitRelationalOp(RelationalOpInstr* instr); |
50 virtual void VisitEqualityCompare(EqualityCompareInstr* instr); | 53 virtual void VisitEqualityCompare(EqualityCompareInstr* instr); |
51 virtual void VisitBranch(BranchInstr* instr); | 54 virtual void VisitBranch(BranchInstr* instr); |
52 virtual void VisitStrictCompare(StrictCompareInstr* instr); | 55 virtual void VisitStrictCompare(StrictCompareInstr* instr); |
53 | 56 |
54 void InsertBefore(Instruction* next, | 57 void InsertBefore(Instruction* next, |
55 Instruction* instr, | 58 Instruction* instr, |
56 Environment* env, | 59 Environment* env, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 314 |
312 // Rewrite diamond control flow patterns that materialize values to use more | 315 // Rewrite diamond control flow patterns that materialize values to use more |
313 // efficient branchless code patterns if such are supported on the current | 316 // efficient branchless code patterns if such are supported on the current |
314 // platform. | 317 // platform. |
315 class IfConverter : public AllStatic { | 318 class IfConverter : public AllStatic { |
316 public: | 319 public: |
317 static void Simplify(FlowGraph* flow_graph); | 320 static void Simplify(FlowGraph* flow_graph); |
318 }; | 321 }; |
319 | 322 |
320 | 323 |
| 324 class AllocationSinking : public ZoneAllocated { |
| 325 public: |
| 326 explicit AllocationSinking(FlowGraph* flow_graph) |
| 327 : flow_graph_(flow_graph), |
| 328 materializations_(5) { } |
| 329 |
| 330 void Optimize(); |
| 331 |
| 332 void DetachMaterializations(); |
| 333 |
| 334 private: |
| 335 void InsertMaterializations(AllocateObjectInstr* alloc); |
| 336 |
| 337 void CreateMaterializationAt( |
| 338 Instruction* exit, |
| 339 AllocateObjectInstr* alloc, |
| 340 const Class& cls, |
| 341 const ZoneGrowableArray<const Field*>& fields); |
| 342 |
| 343 FlowGraph* flow_graph_; |
| 344 |
| 345 GrowableArray<MaterializeObjectInstr*> materializations_; |
| 346 }; |
| 347 |
321 } // namespace dart | 348 } // namespace dart |
322 | 349 |
323 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 350 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |