| OLD | NEW |
| 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'; |
| 11 import '../js_backend/native_data.dart'; | 11 import '../js_backend/native_data.dart'; |
| 12 import '../js_backend/interceptor_data.dart'; | 12 import '../js_backend/interceptor_data.dart'; |
| 13 import '../js_model/closure.dart' show JRecordField, JClosureField; | 13 import '../js_model/closure.dart' show JRecordField, JClosureField; |
| 14 import '../js_model/locals.dart' show JLocal; |
| 14 import '../tree/tree.dart' as ast; | 15 import '../tree/tree.dart' as ast; |
| 15 import '../types/types.dart'; | 16 import '../types/types.dart'; |
| 16 import '../world.dart' show ClosedWorld; | 17 import '../world.dart' show ClosedWorld; |
| 17 | 18 |
| 18 import 'graph_builder.dart'; | 19 import 'graph_builder.dart'; |
| 19 import 'nodes.dart'; | 20 import 'nodes.dart'; |
| 20 import 'types.dart'; | 21 import 'types.dart'; |
| 21 | 22 |
| 22 /// Keeps track of locals (including parameters and phis) when building. The | 23 /// Keeps track of locals (including parameters and phis) when building. The |
| 23 /// 'this' reference is treated as parameter and hence handled by this class, | 24 /// 'this' reference is treated as parameter and hence handled by this class, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // The box is passed as a parameter to a generative | 149 // The box is passed as a parameter to a generative |
| 149 // constructor body. | 150 // constructor body. |
| 150 box = builder.addParameter(closureInfo.context, commonMasks.nonNullType); | 151 box = builder.addParameter(closureInfo.context, commonMasks.nonNullType); |
| 151 } else { | 152 } else { |
| 152 box = createBox(); | 153 box = createBox(); |
| 153 } | 154 } |
| 154 // Add the box to the known locals. | 155 // Add the box to the known locals. |
| 155 directLocals[closureInfo.context] = box; | 156 directLocals[closureInfo.context] = box; |
| 156 // Make sure that accesses to the boxed locals go into the box. We also | 157 // 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. | 158 // need to make sure that parameters are copied into the box if necessary. |
| 158 closureInfo.forEachBoxedVariable((_from, _to) { | 159 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 | 160 // The [from] can only be a parameter for function-scopes and not |
| 162 // loop scopes. | 161 // loop scopes. |
| 163 if (from.isRegularParameter && !forGenerativeConstructorBody) { | 162 bool isParameter; |
| 163 if (from is JLocal) { |
| 164 isParameter = from.isRegularParameter; |
| 165 } else if (from is LocalVariableElement) { |
| 166 isParameter = from.isRegularParameter; |
| 167 } |
| 168 assert(isParameter != null); |
| 169 if (isParameter && !forGenerativeConstructorBody) { |
| 164 // Now that the redirection is set up, the update to the local will | 170 // Now that the redirection is set up, the update to the local will |
| 165 // write the parameter value into the box. | 171 // write the parameter value into the box. |
| 166 // Store the captured parameter in the box. Get the current value | 172 // Store the captured parameter in the box. Get the current value |
| 167 // before we put the redirection in place. | 173 // before we put the redirection in place. |
| 168 // We don't need to update the local for a generative | 174 // We don't need to update the local for a generative |
| 169 // constructor body, because it receives a box that already | 175 // constructor body, because it receives a box that already |
| 170 // contains the updates as the last parameter. | 176 // contains the updates as the last parameter. |
| 171 HInstruction instruction = readLocal(from); | 177 HInstruction instruction = readLocal(from); |
| 172 redirectElement(from, to); | 178 redirectElement(from, to); |
| 173 updateLocal(from, instruction); | 179 updateLocal(from, instruction); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 final MemberEntity memberContext; | 699 final MemberEntity memberContext; |
| 694 | 700 |
| 695 // Avoid slow Object.hashCode. | 701 // Avoid slow Object.hashCode. |
| 696 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); | 702 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); |
| 697 static int _nextHashCode = 0; | 703 static int _nextHashCode = 0; |
| 698 | 704 |
| 699 SyntheticLocal(this.name, this.executableContext, this.memberContext); | 705 SyntheticLocal(this.name, this.executableContext, this.memberContext); |
| 700 | 706 |
| 701 toString() => 'SyntheticLocal($name)'; | 707 toString() => 'SyntheticLocal($name)'; |
| 702 } | 708 } |
| OLD | NEW |