Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class SsaTypePropagator extends HGraphVisitor implements OptimizationPhase { | 5 class SsaTypePropagator extends HGraphVisitor implements OptimizationPhase { |
| 6 | 6 |
| 7 final Map<int, HInstruction> workmap; | 7 final Map<int, HInstruction> workmap; |
| 8 final List<int> worklist; | 8 final List<int> worklist; |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 String get name() => 'type propagator'; | 10 String get name() => 'type propagator'; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 worklist.add(id); | 79 worklist.add(id); |
| 80 workmap[id] = instruction; | 80 workmap[id] = instruction; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 class SsaSpeculativeTypePropagator extends SsaTypePropagator { | 85 class SsaSpeculativeTypePropagator extends SsaTypePropagator { |
| 86 final String name = 'speculative type propagator'; | 86 final String name = 'speculative type propagator'; |
| 87 SsaSpeculativeTypePropagator(Compiler compiler) : super(compiler); | 87 SsaSpeculativeTypePropagator(Compiler compiler) : super(compiler); |
| 88 | 88 |
| 89 HType computeDesiredType(HInstruction instruction) { | |
| 90 HType desiredType = HType.UNKNOWN; | |
| 91 for (final user in instruction.usedBy) { | |
| 92 desiredType = | |
| 93 desiredType.combine(user.computeDesiredInputType(instruction)); | |
| 94 // No need to continue if two users disagree on the type. | |
| 95 if (desiredType.isConflicting()) break; | |
| 96 } | |
| 97 return desiredType; | |
| 98 } | |
| 99 | |
| 89 HType computeType(HInstruction instruction) { | 100 HType computeType(HInstruction instruction) { |
| 90 HType newType = super.computeType(instruction); | 101 HType newType = super.computeType(instruction); |
| 91 HType desiredType = instruction.computeDesiredType(); | 102 HType desiredType = computeDesiredType(instruction); |
|
floitsch
2012/03/30 23:16:00
No need to compute the desired type if the 'newTyp
| |
| 92 HType combined = newType.combine(desiredType); | 103 // If the desired type is conflicting just return the computed |
| 93 // If the propagated type [newType] does not conflict with the | 104 // type. |
| 94 // speculated type [desiredType], use it. | 105 if (desiredType.isConflicting()) return newType; |
| 95 if (combined.isKnown()) return combined; | 106 return newType.combine(desiredType); |
| 96 return newType; | |
| 97 } | 107 } |
| 98 } | 108 } |
| OLD | NEW |