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 part of ssa; | 5 part of ssa; |
6 | 6 |
7 class SsaTypePropagator extends HGraphVisitor implements OptimizationPhase { | 7 class SsaTypePropagator extends HGraphVisitor implements OptimizationPhase { |
8 | 8 |
9 final Map<int, HInstruction> workmap; | 9 final Map<int, HInstruction> workmap; |
10 final List<int> worklist; | 10 final List<int> worklist; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 void visitGraph(HGraph graph) { | 63 void visitGraph(HGraph graph) { |
64 visitDominatorTree(graph); | 64 visitDominatorTree(graph); |
65 processWorklist(); | 65 processWorklist(); |
66 } | 66 } |
67 | 67 |
68 visitBasicBlock(HBasicBlock block) { | 68 visitBasicBlock(HBasicBlock block) { |
69 if (block.isLoopHeader()) { | 69 if (block.isLoopHeader()) { |
70 block.forEachPhi((HPhi phi) { | 70 block.forEachPhi((HPhi phi) { |
71 HType propagatedType = types[phi]; | 71 // Set the initial type for the phi. We're not using the type |
72 // Once the propagation has run once, the propagated type can already | 72 // the phi thinks it has because new optimizations may imply |
73 // be set. In this case we use that one for the first iteration of the | 73 // changing it. |
74 // loop. | 74 // In theory we would need to mark |
75 if (propagatedType.isUnknown()) { | 75 // the type of all other incoming edges as "unitialized" and take this |
76 // Set the initial type for the phi. In theory we would need to mark | 76 // into account when doing the propagation inside the phis. Just |
77 // the type of all other incoming edges as "unitialized" and take this | 77 // setting the propagated type is however easier. |
78 // into account when doing the propagation inside the phis. Just | 78 types[phi] = types[phi.inputs[0]]; |
79 // setting the propagated type is however easier. | |
80 types[phi] = types[phi.inputs[0]]; | |
81 } | |
82 addToWorkList(phi); | 79 addToWorkList(phi); |
83 }); | 80 }); |
84 } else { | 81 } else { |
85 block.forEachPhi((HPhi phi) { | 82 block.forEachPhi((HPhi phi) { |
86 if (updateType(phi)) { | 83 if (updateType(phi)) { |
87 addDependentInstructionsToWorkList(phi); | 84 addDependentInstructionsToWorkList(phi); |
88 } | 85 } |
89 }); | 86 }); |
90 } | 87 } |
91 | 88 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // TODO(ngeoffray): Allow speculative optimizations on | 200 // TODO(ngeoffray): Allow speculative optimizations on |
204 // non-primitive types? | 201 // non-primitive types? |
205 if (!desiredType.isPrimitive()) return newType; | 202 if (!desiredType.isPrimitive()) return newType; |
206 return newType.intersection(desiredType, compiler); | 203 return newType.intersection(desiredType, compiler); |
207 } | 204 } |
208 | 205 |
209 // Do not use speculative argument type optimization for now. | 206 // Do not use speculative argument type optimization for now. |
210 void considerForArgumentTypeOptimization(HInstruction instruction) { } | 207 void considerForArgumentTypeOptimization(HInstruction instruction) { } |
211 | 208 |
212 } | 209 } |
OLD | NEW |