Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1115)

Side by Side Diff: lib/compiler/implementation/ssa/types.dart

Issue 10139012: Refactor types in ssa nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and remove isIntegerOrDouble. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 for (int i = 0, length = instruction.inputs.length; i < length; i++) { 105 for (int i = 0, length = instruction.inputs.length; i < length; i++) {
106 addToWorkList(instruction.inputs[i]); 106 addToWorkList(instruction.inputs[i]);
107 } 107 }
108 } 108 }
109 109
110 HType computeDesiredType(HInstruction instruction) { 110 HType computeDesiredType(HInstruction instruction) {
111 HType desiredType = HType.UNKNOWN; 111 HType desiredType = HType.UNKNOWN;
112 for (final user in instruction.usedBy) { 112 for (final user in instruction.usedBy) {
113 desiredType = 113 desiredType =
114 desiredType.combine(user.computeDesiredTypeForInput(instruction)); 114 desiredType.intersect(user.computeDesiredTypeForInput(instruction));
115 // No need to continue if two users disagree on the type. 115 // No need to continue if two users disagree on the type.
116 if (desiredType.isConflicting()) break; 116 if (desiredType.isConflicting()) break;
117 } 117 }
118 return desiredType; 118 return desiredType;
119 } 119 }
120 120
121 HType computeType(HInstruction instruction) { 121 HType computeType(HInstruction instruction) {
122 // Once we are in a conflicting state don't update the type anymore. 122 // Once we are in a conflicting state don't update the type anymore.
123 HType oldType = instruction.propagatedType; 123 HType oldType = instruction.propagatedType;
124 if (oldType.isConflicting()) return oldType; 124 if (oldType.isConflicting()) return oldType;
125 125
126 HType newType = super.computeType(instruction); 126 HType newType = super.computeType(instruction);
127 // [computeDesiredType] goes to all usedBys and lets them compute their 127 // [computeDesiredType] goes to all usedBys and lets them compute their
128 // desired type. By setting the [newType] here we give them more context to 128 // desired type. By setting the [newType] here we give them more context to
129 // work with. 129 // work with.
130 instruction.propagatedType = newType; 130 instruction.propagatedType = newType;
131 HType desiredType = computeDesiredType(instruction); 131 HType desiredType = computeDesiredType(instruction);
132 // If the desired type is conflicting just return the computed type. 132 // If the desired type is conflicting just return the computed type.
133 if (desiredType.isConflicting()) return newType; 133 if (desiredType.isConflicting()) return newType;
134 // TODO(ngeoffray): Allow speculative optimizations on 134 // TODO(ngeoffray): Allow speculative optimizations on
135 // non-primitive types? 135 // non-primitive types?
136 if (desiredType.isNonPrimitive()) return newType; 136 if (desiredType.isNonPrimitive()) return newType;
137 return newType.combine(desiredType); 137 return newType.intersect(desiredType);
138 } 138 }
139 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698