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

Side by Side Diff: pkg/compiler/lib/src/ssa/locals_handler.dart

Issue 3007743002: Add boxing for modified variables (Closed)
Patch Set: . Created 3 years, 3 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../elements/elements.dart'; 7 import '../elements/elements.dart';
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 import '../elements/types.dart'; 9 import '../elements/types.dart';
10 import '../io/source_information.dart'; 10 import '../io/source_information.dart';
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // The box is passed as a parameter to a generative 148 // The box is passed as a parameter to a generative
149 // constructor body. 149 // constructor body.
150 box = builder.addParameter(closureInfo.context, commonMasks.nonNullType); 150 box = builder.addParameter(closureInfo.context, commonMasks.nonNullType);
151 } else { 151 } else {
152 box = createBox(); 152 box = createBox();
153 } 153 }
154 // Add the box to the known locals. 154 // Add the box to the known locals.
155 directLocals[closureInfo.context] = box; 155 directLocals[closureInfo.context] = box;
156 // Make sure that accesses to the boxed locals go into the box. We also 156 // Make sure that accesses to the boxed locals go into the box. We also
157 // need to make sure that parameters are copied into the box if necessary. 157 // need to make sure that parameters are copied into the box if necessary.
158 closureInfo.forEachBoxedVariable((_from, _to) { 158 closureInfo.forEachBoxedVariable((Local from, FieldEntity to) {
159 LocalVariableElement from = _from;
160 BoxFieldElement to = _to;
161 // The [from] can only be a parameter for function-scopes and not 159 // The [from] can only be a parameter for function-scopes and not
162 // loop scopes. 160 // loop scopes.
163 if (from.isRegularParameter && !forGenerativeConstructorBody) { 161 if (from.isRegularParameter && !forGenerativeConstructorBody) {
164 // Now that the redirection is set up, the update to the local will 162 // Now that the redirection is set up, the update to the local will
165 // write the parameter value into the box. 163 // write the parameter value into the box.
166 // Store the captured parameter in the box. Get the current value 164 // Store the captured parameter in the box. Get the current value
167 // before we put the redirection in place. 165 // before we put the redirection in place.
168 // We don't need to update the local for a generative 166 // We don't need to update the local for a generative
169 // constructor body, because it receives a box that already 167 // constructor body, because it receives a box that already
170 // contains the updates as the last parameter. 168 // contains the updates as the last parameter.
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 final MemberEntity memberContext; 691 final MemberEntity memberContext;
694 692
695 // Avoid slow Object.hashCode. 693 // Avoid slow Object.hashCode.
696 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); 694 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30);
697 static int _nextHashCode = 0; 695 static int _nextHashCode = 0;
698 696
699 SyntheticLocal(this.name, this.executableContext, this.memberContext); 697 SyntheticLocal(this.name, this.executableContext, this.memberContext);
700 698
701 toString() => 'SyntheticLocal($name)'; 699 toString() => 'SyntheticLocal($name)';
702 } 700 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698