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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/mutable_ssa.dart

Issue 1240263002: dart2js cps: Streamline expressions and primitives. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library dart2js.cps_ir.mutable_ssa; 5 library dart2js.cps_ir.mutable_ssa;
6 6
7 import 'cps_ir_nodes.dart'; 7 import 'cps_ir_nodes.dart';
8 import 'optimizers.dart'; 8 import 'optimizers.dart';
9 9
10 /// Determines which mutable variables should be rewritten to phi assignments 10 /// Determines which mutable variables should be rewritten to phi assignments
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Put the initial value into the environment. 148 // Put the initial value into the environment.
149 Primitive value = node.value.definition; 149 Primitive value = node.value.definition;
150 environment[node.variable] = value; 150 environment[node.variable] = value;
151 151
152 // Preserve variable names. 152 // Preserve variable names.
153 mergeHints(node.variable, value); 153 mergeHints(node.variable, value);
154 154
155 // Remove the mutable variable binding. 155 // Remove the mutable variable binding.
156 node.value.unlink(); 156 node.value.unlink();
157 removeNode(node); 157 removeNode(node);
158 } else if (node is SetMutableVariable && 158 } else if (node is LetPrim && node.primitive is SetMutableVariable) {
159 shouldRewrite(node.variable.definition)) { 159 SetMutableVariable setter = node.primitive;
160 // As above, update the environment, preserve variables and remove 160 MutableVariable variable = setter.variable.definition;
161 // the mutable variable assignment. 161 if (shouldRewrite(variable)) {
162 MutableVariable variable = node.variable.definition; 162 // As above, update the environment, preserve variables and remove
163 environment[variable] = node.value.definition; 163 // the mutable variable assignment.
164 mergeHints(variable, node.value.definition); 164 environment[variable] = setter.value.definition;
165 node.value.unlink(); 165 mergeHints(variable, setter.value.definition);
166 removeNode(node); 166 setter.value.unlink();
167 removeNode(node);
168 }
167 } else if (node is LetPrim && node.primitive is GetMutableVariable) { 169 } else if (node is LetPrim && node.primitive is GetMutableVariable) {
168 GetMutableVariable getter = node.primitive; 170 GetMutableVariable getter = node.primitive;
169 MutableVariable variable = getter.variable.definition; 171 MutableVariable variable = getter.variable.definition;
170 if (shouldRewrite(variable)) { 172 if (shouldRewrite(variable)) {
171 // Replace with the reaching definition from the environment. 173 // Replace with the reaching definition from the environment.
172 Primitive value = environment[variable]; 174 Primitive value = environment[variable];
173 value.substituteFor(getter); 175 value.substituteFor(getter);
174 mergeHints(variable, value); 176 mergeHints(variable, value);
175 removeNode(node); 177 removeNode(node);
176 } 178 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 class VariableItem extends StackItem {} 245 class VariableItem extends StackItem {}
244 246
245 /// Represents a yet unprocessed continuation together with the 247 /// Represents a yet unprocessed continuation together with the
246 /// environment in which to process it. 248 /// environment in which to process it.
247 class ContinuationItem extends StackItem { 249 class ContinuationItem extends StackItem {
248 final Continuation continuation; 250 final Continuation continuation;
249 final Map<MutableVariable, Primitive> environment; 251 final Map<MutableVariable, Primitive> environment;
250 252
251 ContinuationItem(this.continuation, this.environment); 253 ContinuationItem(this.continuation, this.environment);
252 } 254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698