| OLD | NEW |
| 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.js_helpers.impact; | 5 library dart2js.js_helpers.impact; |
| 6 | 6 |
| 7 import '../common/names.dart'; | 7 import '../common/names.dart'; |
| 8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
| 9 import '../core_types.dart' show CommonElements; | 9 import '../core_types.dart' show CommonElements; |
| 10 import '../dart_types.dart' show InterfaceType; | 10 import '../dart_types.dart' show InterfaceType; |
| 11 import '../elements/elements.dart' show ClassElement, Element; | 11 import '../elements/elements.dart' show ClassElement, Element; |
| 12 import '../universe/selector.dart'; | 12 import '../universe/selector.dart'; |
| 13 import '../util/enumset.dart'; | 13 import '../util/enumset.dart'; |
| 14 import 'backend_helpers.dart'; | 14 import 'backend_helpers.dart'; |
| 15 import 'constant_system_javascript.dart'; | 15 import 'constant_system_javascript.dart'; |
| 16 import 'js_backend.dart'; | 16 import 'js_backend.dart'; |
| 17 | 17 |
| 18 /// Backend specific features required by a backend impact. | 18 /// Backend specific features required by a backend impact. |
| 19 enum BackendFeature { | 19 enum BackendFeature { |
| 20 needToInitializeIsolateAffinityTag, | 20 needToInitializeIsolateAffinityTag, |
| 21 needToInitializeDispatchProperty, | 21 needToInitializeDispatchProperty, |
| 22 } | 22 } |
| 23 | 23 |
| 24 /// A set of JavaScript backend dependencies. | 24 /// A set of JavaScript backend dependencies. |
| 25 class BackendImpact { | 25 class BackendImpact { |
| 26 final List<Element> staticUses; | 26 final List<Element> staticUses; |
| 27 final List<Element> globalUses; |
| 27 final List<Selector> dynamicUses; | 28 final List<Selector> dynamicUses; |
| 28 final List<InterfaceType> instantiatedTypes; | 29 final List<InterfaceType> instantiatedTypes; |
| 29 final List<ClassElement> instantiatedClasses; | 30 final List<ClassElement> instantiatedClasses; |
| 31 final List<ClassElement> globalClasses; |
| 30 final List<BackendImpact> otherImpacts; | 32 final List<BackendImpact> otherImpacts; |
| 31 final EnumSet<BackendFeature> _features; | 33 final EnumSet<BackendFeature> _features; |
| 32 | 34 |
| 33 const BackendImpact( | 35 const BackendImpact( |
| 34 {this.staticUses: const <Element>[], | 36 {this.staticUses: const <Element>[], |
| 37 this.globalUses: const <Element>[], |
| 35 this.dynamicUses: const <Selector>[], | 38 this.dynamicUses: const <Selector>[], |
| 36 this.instantiatedTypes: const <InterfaceType>[], | 39 this.instantiatedTypes: const <InterfaceType>[], |
| 37 this.instantiatedClasses: const <ClassElement>[], | 40 this.instantiatedClasses: const <ClassElement>[], |
| 41 this.globalClasses: const <ClassElement>[], |
| 38 this.otherImpacts: const <BackendImpact>[], | 42 this.otherImpacts: const <BackendImpact>[], |
| 39 EnumSet<BackendFeature> features: const EnumSet<BackendFeature>.fixed(0)}) | 43 EnumSet<BackendFeature> features: const EnumSet<BackendFeature>.fixed(0)}) |
| 40 : this._features = features; | 44 : this._features = features; |
| 41 | 45 |
| 42 Iterable<BackendFeature> get features => | 46 Iterable<BackendFeature> get features => |
| 43 _features.iterable(BackendFeature.values); | 47 _features.iterable(BackendFeature.values); |
| 44 } | 48 } |
| 45 | 49 |
| 46 /// The JavaScript backend dependencies for various features. | 50 /// The JavaScript backend dependencies for various features. |
| 47 class BackendImpacts { | 51 class BackendImpacts { |
| 48 final Compiler compiler; | 52 final Compiler compiler; |
| 49 | 53 |
| 50 BackendImpacts(this.compiler); | 54 BackendImpacts(this.compiler); |
| 51 | 55 |
| 52 JavaScriptBackend get backend => compiler.backend; | 56 JavaScriptBackend get backend => compiler.backend; |
| 53 | 57 |
| 54 BackendHelpers get helpers => backend.helpers; | 58 BackendHelpers get helpers => backend.helpers; |
| 55 | 59 |
| 56 CommonElements get commonElements => compiler.commonElements; | 60 CommonElements get commonElements => compiler.commonElements; |
| 57 | 61 |
| 58 BackendImpact _getRuntimeTypeArgument; | 62 BackendImpact _getRuntimeTypeArgument; |
| 59 | 63 |
| 60 BackendImpact get getRuntimeTypeArgument { | 64 BackendImpact get getRuntimeTypeArgument { |
| 61 if (_getRuntimeTypeArgument == null) { | 65 return _getRuntimeTypeArgument ??= new BackendImpact(globalUses: [ |
| 62 _getRuntimeTypeArgument = new BackendImpact(staticUses: [ | 66 helpers.getRuntimeTypeArgument, |
| 63 helpers.getRuntimeTypeArgument, | 67 helpers.getTypeArgumentByIndex, |
| 64 helpers.getTypeArgumentByIndex, | 68 ]); |
| 65 ]); | |
| 66 } | |
| 67 return _getRuntimeTypeArgument; | |
| 68 } | 69 } |
| 69 | 70 |
| 70 BackendImpact _computeSignature; | 71 BackendImpact _computeSignature; |
| 71 | 72 |
| 72 BackendImpact get computeSignature { | 73 BackendImpact get computeSignature { |
| 73 if (_computeSignature == null) { | 74 return _computeSignature ??= new BackendImpact(globalUses: [ |
| 74 _computeSignature = new BackendImpact(staticUses: [ | 75 helpers.setRuntimeTypeInfo, |
| 75 helpers.setRuntimeTypeInfo, | 76 helpers.getRuntimeTypeInfo, |
| 76 helpers.getRuntimeTypeInfo, | 77 helpers.computeSignature, |
| 77 helpers.computeSignature, | 78 helpers.getRuntimeTypeArguments |
| 78 helpers.getRuntimeTypeArguments | 79 ], otherImpacts: [ |
| 79 ], otherImpacts: [ | 80 listValues |
| 80 listValues | 81 ]); |
| 81 ]); | |
| 82 } | |
| 83 return _computeSignature; | |
| 84 } | 82 } |
| 85 | 83 |
| 86 BackendImpact _mainWithArguments; | 84 BackendImpact _mainWithArguments; |
| 87 | 85 |
| 88 BackendImpact get mainWithArguments { | 86 BackendImpact get mainWithArguments { |
| 89 if (_mainWithArguments == null) { | 87 return _mainWithArguments ??= new BackendImpact( |
| 90 _mainWithArguments = new BackendImpact( | 88 instantiatedClasses: [helpers.jsArrayClass, helpers.jsStringClass]); |
| 91 instantiatedClasses: [ | |
| 92 helpers.jsArrayClass, | |
| 93 helpers.jsStringClass]); | |
| 94 } | |
| 95 return _mainWithArguments; | |
| 96 } | 89 } |
| 97 | 90 |
| 98 BackendImpact _asyncBody; | 91 BackendImpact _asyncBody; |
| 99 | 92 |
| 100 BackendImpact get asyncBody { | 93 BackendImpact get asyncBody { |
| 101 if (_asyncBody == null) { | 94 return _asyncBody ??= new BackendImpact(staticUses: [ |
| 102 _asyncBody = new BackendImpact(staticUses: [ | 95 helpers.asyncHelper, |
| 103 helpers.asyncHelper, | 96 helpers.syncCompleterConstructor, |
| 104 helpers.syncCompleterConstructor, | 97 helpers.streamIteratorConstructor, |
| 105 helpers.streamIteratorConstructor, | 98 helpers.wrapBody |
| 106 helpers.wrapBody | 99 ]); |
| 107 ]); | |
| 108 } | |
| 109 return _asyncBody; | |
| 110 } | 100 } |
| 111 | 101 |
| 112 BackendImpact _syncStarBody; | 102 BackendImpact _syncStarBody; |
| 113 | 103 |
| 114 BackendImpact get syncStarBody { | 104 BackendImpact get syncStarBody { |
| 115 if (_syncStarBody == null) { | 105 return _syncStarBody ??= new BackendImpact(staticUses: [ |
| 116 _syncStarBody = new BackendImpact(staticUses: [ | 106 helpers.syncStarIterableConstructor, |
| 117 helpers.syncStarIterableConstructor, | 107 helpers.endOfIteration, |
| 118 helpers.endOfIteration, | 108 helpers.yieldStar, |
| 119 helpers.yieldStar, | 109 helpers.syncStarUncaughtError |
| 120 helpers.syncStarUncaughtError | 110 ], instantiatedClasses: [ |
| 121 ], instantiatedClasses: [ | 111 helpers.syncStarIterable |
| 122 helpers.syncStarIterable | 112 ]); |
| 123 ]); | |
| 124 } | |
| 125 return _syncStarBody; | |
| 126 } | 113 } |
| 127 | 114 |
| 128 BackendImpact _asyncStarBody; | 115 BackendImpact _asyncStarBody; |
| 129 | 116 |
| 130 BackendImpact get asyncStarBody { | 117 BackendImpact get asyncStarBody { |
| 131 if (_asyncStarBody == null) { | 118 return _asyncStarBody ??= new BackendImpact(staticUses: [ |
| 132 _asyncStarBody = new BackendImpact(staticUses: [ | 119 helpers.asyncStarHelper, |
| 133 helpers.asyncStarHelper, | 120 helpers.streamOfController, |
| 134 helpers.streamOfController, | 121 helpers.yieldSingle, |
| 135 helpers.yieldSingle, | 122 helpers.yieldStar, |
| 136 helpers.yieldStar, | 123 helpers.asyncStarControllerConstructor, |
| 137 helpers.asyncStarControllerConstructor, | 124 helpers.streamIteratorConstructor, |
| 138 helpers.streamIteratorConstructor, | 125 helpers.wrapBody |
| 139 helpers.wrapBody | 126 ], instantiatedClasses: [ |
| 140 ], instantiatedClasses: [ | 127 helpers.asyncStarController |
| 141 helpers.asyncStarController | 128 ]); |
| 142 ]); | |
| 143 } | |
| 144 return _asyncStarBody; | |
| 145 } | 129 } |
| 146 | 130 |
| 147 BackendImpact _typeVariableBoundCheck; | 131 BackendImpact _typeVariableBoundCheck; |
| 148 | 132 |
| 149 BackendImpact get typeVariableBoundCheck { | 133 BackendImpact get typeVariableBoundCheck { |
| 150 if (_typeVariableBoundCheck == null) { | 134 return _typeVariableBoundCheck ??= new BackendImpact( |
| 151 _typeVariableBoundCheck = new BackendImpact( | 135 staticUses: [helpers.throwTypeError, helpers.assertIsSubtype]); |
| 152 staticUses: [helpers.throwTypeError, helpers.assertIsSubtype]); | |
| 153 } | |
| 154 return _typeVariableBoundCheck; | |
| 155 } | 136 } |
| 156 | 137 |
| 157 BackendImpact _abstractClassInstantiation; | 138 BackendImpact _abstractClassInstantiation; |
| 158 | 139 |
| 159 BackendImpact get abstractClassInstantiation { | 140 BackendImpact get abstractClassInstantiation { |
| 160 if (_abstractClassInstantiation == null) { | 141 return _abstractClassInstantiation ??= new BackendImpact( |
| 161 _abstractClassInstantiation = new BackendImpact( | 142 staticUses: [helpers.throwAbstractClassInstantiationError], |
| 162 staticUses: [helpers.throwAbstractClassInstantiationError], | 143 otherImpacts: [_needsString('Needed to encode the message.')]); |
| 163 otherImpacts: [_needsString('Needed to encode the message.')]); | |
| 164 } | |
| 165 return _abstractClassInstantiation; | |
| 166 } | 144 } |
| 167 | 145 |
| 168 BackendImpact _fallThroughError; | 146 BackendImpact _fallThroughError; |
| 169 | 147 |
| 170 BackendImpact get fallThroughError { | 148 BackendImpact get fallThroughError { |
| 171 if (_fallThroughError == null) { | 149 return _fallThroughError ??= |
| 172 _fallThroughError = | 150 new BackendImpact(staticUses: [helpers.fallThroughError]); |
| 173 new BackendImpact(staticUses: [helpers.fallThroughError]); | |
| 174 } | |
| 175 return _fallThroughError; | |
| 176 } | 151 } |
| 177 | 152 |
| 178 BackendImpact _asCheck; | 153 BackendImpact _asCheck; |
| 179 | 154 |
| 180 BackendImpact get asCheck { | 155 BackendImpact get asCheck { |
| 181 if (_asCheck == null) { | 156 return _asCheck ??= |
| 182 _asCheck = new BackendImpact(staticUses: [helpers.throwRuntimeError]); | 157 new BackendImpact(staticUses: [helpers.throwRuntimeError]); |
| 183 } | |
| 184 return _asCheck; | |
| 185 } | 158 } |
| 186 | 159 |
| 187 BackendImpact _throwNoSuchMethod; | 160 BackendImpact _throwNoSuchMethod; |
| 188 | 161 |
| 189 BackendImpact get throwNoSuchMethod { | 162 BackendImpact get throwNoSuchMethod { |
| 190 if (_throwNoSuchMethod == null) { | 163 return _throwNoSuchMethod ??= new BackendImpact(staticUses: [ |
| 191 _throwNoSuchMethod = new BackendImpact(staticUses: [ | 164 helpers.throwNoSuchMethod |
| 192 helpers.throwNoSuchMethod | 165 ], otherImpacts: [ |
| 193 ], otherImpacts: [ | 166 // Also register the types of the arguments passed to this method. |
| 194 // Also register the types of the arguments passed to this method. | 167 _needsList('Needed to encode the arguments for throw NoSuchMethodError.'), |
| 195 _needsList( | 168 _needsString('Needed to encode the name for throw NoSuchMethodError.') |
| 196 'Needed to encode the arguments for throw NoSuchMethodError.'), | 169 ]); |
| 197 _needsString('Needed to encode the name for throw NoSuchMethodError.') | |
| 198 ]); | |
| 199 } | |
| 200 return _throwNoSuchMethod; | |
| 201 } | 170 } |
| 202 | 171 |
| 203 BackendImpact _stringValues; | 172 BackendImpact _stringValues; |
| 204 | 173 |
| 205 BackendImpact get stringValues { | 174 BackendImpact get stringValues { |
| 206 if (_stringValues == null) { | 175 return _stringValues ??= |
| 207 _stringValues = | 176 new BackendImpact(instantiatedClasses: [helpers.jsStringClass]); |
| 208 new BackendImpact(instantiatedClasses: [helpers.jsStringClass]); | |
| 209 } | |
| 210 return _stringValues; | |
| 211 } | 177 } |
| 212 | 178 |
| 213 BackendImpact _numValues; | 179 BackendImpact _numValues; |
| 214 | 180 |
| 215 BackendImpact get numValues { | 181 BackendImpact get numValues { |
| 216 if (_numValues == null) { | 182 return _numValues ??= new BackendImpact(instantiatedClasses: [ |
| 217 _numValues = new BackendImpact(instantiatedClasses: [ | 183 helpers.jsIntClass, |
| 218 helpers.jsIntClass, | 184 helpers.jsPositiveIntClass, |
| 219 helpers.jsPositiveIntClass, | 185 helpers.jsUInt32Class, |
| 220 helpers.jsUInt32Class, | 186 helpers.jsUInt31Class, |
| 221 helpers.jsUInt31Class, | 187 helpers.jsNumberClass, |
| 222 helpers.jsNumberClass, | 188 helpers.jsDoubleClass |
| 223 helpers.jsDoubleClass | 189 ]); |
| 224 ]); | |
| 225 } | |
| 226 return _numValues; | |
| 227 } | 190 } |
| 228 | 191 |
| 229 BackendImpact get intValues => numValues; | 192 BackendImpact get intValues => numValues; |
| 230 | 193 |
| 231 BackendImpact get doubleValues => numValues; | 194 BackendImpact get doubleValues => numValues; |
| 232 | 195 |
| 233 BackendImpact _boolValues; | 196 BackendImpact _boolValues; |
| 234 | 197 |
| 235 BackendImpact get boolValues { | 198 BackendImpact get boolValues { |
| 236 if (_boolValues == null) { | 199 return _boolValues ??= |
| 237 _boolValues = | 200 new BackendImpact(instantiatedClasses: [helpers.jsBoolClass]); |
| 238 new BackendImpact(instantiatedClasses: [helpers.jsBoolClass]); | |
| 239 } | |
| 240 return _boolValues; | |
| 241 } | 201 } |
| 242 | 202 |
| 243 BackendImpact _nullValue; | 203 BackendImpact _nullValue; |
| 244 | 204 |
| 245 BackendImpact get nullValue { | 205 BackendImpact get nullValue { |
| 246 if (_nullValue == null) { | 206 return _nullValue ??= |
| 247 _nullValue = | 207 new BackendImpact(instantiatedClasses: [helpers.jsNullClass]); |
| 248 new BackendImpact(instantiatedClasses: [helpers.jsNullClass]); | |
| 249 } | |
| 250 return _nullValue; | |
| 251 } | 208 } |
| 252 | 209 |
| 253 BackendImpact _listValues; | 210 BackendImpact _listValues; |
| 254 | 211 |
| 255 BackendImpact get listValues { | 212 BackendImpact get listValues { |
| 256 if (_listValues == null) { | 213 return _listValues ??= new BackendImpact(globalClasses: [ |
| 257 _listValues = new BackendImpact(instantiatedClasses: [ | 214 helpers.jsArrayClass, |
| 258 helpers.jsArrayClass, | 215 helpers.jsMutableArrayClass, |
| 259 helpers.jsMutableArrayClass, | 216 helpers.jsFixedArrayClass, |
| 260 helpers.jsFixedArrayClass, | 217 helpers.jsExtendableArrayClass, |
| 261 helpers.jsExtendableArrayClass, | 218 helpers.jsUnmodifiableArrayClass |
| 262 helpers.jsUnmodifiableArrayClass | 219 ]); |
| 263 ]); | |
| 264 } | |
| 265 return _listValues; | |
| 266 } | 220 } |
| 267 | 221 |
| 268 BackendImpact _throwRuntimeError; | 222 BackendImpact _throwRuntimeError; |
| 269 | 223 |
| 270 BackendImpact get throwRuntimeError { | 224 BackendImpact get throwRuntimeError { |
| 271 if (_throwRuntimeError == null) { | 225 return _throwRuntimeError ??= new BackendImpact(staticUses: [ |
| 272 _throwRuntimeError = new BackendImpact(staticUses: [ | 226 helpers.throwRuntimeError |
| 273 helpers.throwRuntimeError | 227 ], otherImpacts: [ |
| 274 ], otherImpacts: [ | 228 // Also register the types of the arguments passed to this method. |
| 275 // Also register the types of the arguments passed to this method. | 229 stringValues |
| 276 stringValues | 230 ]); |
| 277 ]); | |
| 278 } | |
| 279 return _throwRuntimeError; | |
| 280 } | 231 } |
| 281 | 232 |
| 282 BackendImpact _superNoSuchMethod; | 233 BackendImpact _superNoSuchMethod; |
| 283 | 234 |
| 284 BackendImpact get superNoSuchMethod { | 235 BackendImpact get superNoSuchMethod { |
| 285 if (_superNoSuchMethod == null) { | 236 return _superNoSuchMethod ??= new BackendImpact(staticUses: [ |
| 286 _superNoSuchMethod = new BackendImpact(staticUses: [ | 237 helpers.createInvocationMirror, |
| 287 helpers.createInvocationMirror, | 238 helpers.objectNoSuchMethod |
| 288 helpers.objectNoSuchMethod | 239 ], otherImpacts: [ |
| 289 ], otherImpacts: [ | 240 _needsInt('Needed to encode the invocation kind of super.noSuchMethod.'), |
| 290 _needsInt( | 241 _needsList('Needed to encode the arguments of super.noSuchMethod.'), |
| 291 'Needed to encode the invocation kind of super.noSuchMethod.'), | 242 _needsString('Needed to encode the name of super.noSuchMethod.') |
| 292 _needsList('Needed to encode the arguments of super.noSuchMethod.'), | 243 ]); |
| 293 _needsString('Needed to encode the name of super.noSuchMethod.') | |
| 294 ]); | |
| 295 } | |
| 296 return _superNoSuchMethod; | |
| 297 } | 244 } |
| 298 | 245 |
| 299 BackendImpact _constantMapLiteral; | 246 BackendImpact _constantMapLiteral; |
| 300 | 247 |
| 301 BackendImpact get constantMapLiteral { | 248 BackendImpact get constantMapLiteral { |
| 302 if (_constantMapLiteral == null) { | 249 if (_constantMapLiteral == null) { |
| 303 ClassElement find(String name) { | 250 ClassElement find(String name) { |
| 304 return helpers.find(helpers.jsHelperLibrary, name); | 251 return helpers.find(helpers.jsHelperLibrary, name); |
| 305 } | 252 } |
| 306 | 253 |
| 307 _constantMapLiteral = new BackendImpact(instantiatedClasses: [ | 254 _constantMapLiteral = new BackendImpact(instantiatedClasses: [ |
| 308 find(JavaScriptMapConstant.DART_CLASS), | 255 find(JavaScriptMapConstant.DART_CLASS), |
| 309 find(JavaScriptMapConstant.DART_PROTO_CLASS), | 256 find(JavaScriptMapConstant.DART_PROTO_CLASS), |
| 310 find(JavaScriptMapConstant.DART_STRING_CLASS), | 257 find(JavaScriptMapConstant.DART_STRING_CLASS), |
| 311 find(JavaScriptMapConstant.DART_GENERAL_CLASS) | 258 find(JavaScriptMapConstant.DART_GENERAL_CLASS) |
| 312 ]); | 259 ]); |
| 313 } | 260 } |
| 314 return _constantMapLiteral; | 261 return _constantMapLiteral; |
| 315 } | 262 } |
| 316 | 263 |
| 317 BackendImpact _symbolConstructor; | 264 BackendImpact _symbolConstructor; |
| 318 | 265 |
| 319 BackendImpact get symbolConstructor { | 266 BackendImpact get symbolConstructor { |
| 320 if (_symbolConstructor == null) { | 267 return _symbolConstructor ??= |
| 321 _symbolConstructor = | 268 new BackendImpact(staticUses: [helpers.symbolValidatedConstructor]); |
| 322 new BackendImpact(staticUses: [helpers.symbolValidatedConstructor]); | |
| 323 } | |
| 324 return _symbolConstructor; | |
| 325 } | 269 } |
| 326 | 270 |
| 327 BackendImpact _constSymbol; | 271 BackendImpact _constSymbol; |
| 328 | 272 |
| 329 BackendImpact get constSymbol { | 273 BackendImpact get constSymbol { |
| 330 if (_constSymbol == null) { | 274 return _constSymbol ??= new BackendImpact( |
| 331 _constSymbol = new BackendImpact( | 275 instantiatedClasses: [commonElements.symbolClass], |
| 332 instantiatedClasses: [commonElements.symbolClass], | 276 staticUses: [commonElements.symbolConstructor.declaration]); |
| 333 staticUses: [commonElements.symbolConstructor.declaration]); | |
| 334 } | |
| 335 return _constSymbol; | |
| 336 } | 277 } |
| 337 | 278 |
| 338 /// Helper for registering that `int` is needed. | 279 /// Helper for registering that `int` is needed. |
| 339 BackendImpact _needsInt(String reason) { | 280 BackendImpact _needsInt(String reason) { |
| 340 // TODO(johnniwinther): Register [reason] for use in dump-info. | 281 // TODO(johnniwinther): Register [reason] for use in dump-info. |
| 341 return intValues; | 282 return intValues; |
| 342 } | 283 } |
| 343 | 284 |
| 344 /// Helper for registering that `List` is needed. | 285 /// Helper for registering that `List` is needed. |
| 345 BackendImpact _needsList(String reason) { | 286 BackendImpact _needsList(String reason) { |
| 346 // TODO(johnniwinther): Register [reason] for use in dump-info. | 287 // TODO(johnniwinther): Register [reason] for use in dump-info. |
| 347 return listValues; | 288 return listValues; |
| 348 } | 289 } |
| 349 | 290 |
| 350 /// Helper for registering that `String` is needed. | 291 /// Helper for registering that `String` is needed. |
| 351 BackendImpact _needsString(String reason) { | 292 BackendImpact _needsString(String reason) { |
| 352 // TODO(johnniwinther): Register [reason] for use in dump-info. | 293 // TODO(johnniwinther): Register [reason] for use in dump-info. |
| 353 return stringValues; | 294 return stringValues; |
| 354 } | 295 } |
| 355 | 296 |
| 356 BackendImpact _assertWithoutMessage; | 297 BackendImpact _assertWithoutMessage; |
| 357 | 298 |
| 358 BackendImpact get assertWithoutMessage { | 299 BackendImpact get assertWithoutMessage { |
| 359 if (_assertWithoutMessage == null) { | 300 return _assertWithoutMessage ??= |
| 360 _assertWithoutMessage = | 301 new BackendImpact(staticUses: [helpers.assertHelper]); |
| 361 new BackendImpact(staticUses: [helpers.assertHelper]); | |
| 362 } | |
| 363 return _assertWithoutMessage; | |
| 364 } | 302 } |
| 365 | 303 |
| 366 BackendImpact _assertWithMessage; | 304 BackendImpact _assertWithMessage; |
| 367 | 305 |
| 368 BackendImpact get assertWithMessage { | 306 BackendImpact get assertWithMessage { |
| 369 if (_assertWithMessage == null) { | 307 return _assertWithMessage ??= new BackendImpact( |
| 370 _assertWithMessage = new BackendImpact( | 308 staticUses: [helpers.assertTest, helpers.assertThrow]); |
| 371 staticUses: [helpers.assertTest, helpers.assertThrow]); | |
| 372 } | |
| 373 return _assertWithMessage; | |
| 374 } | 309 } |
| 375 | 310 |
| 376 BackendImpact _asyncForIn; | 311 BackendImpact _asyncForIn; |
| 377 | 312 |
| 378 BackendImpact get asyncForIn { | 313 BackendImpact get asyncForIn { |
| 379 if (_asyncForIn == null) { | 314 return _asyncForIn ??= |
| 380 _asyncForIn = | 315 new BackendImpact(staticUses: [helpers.streamIteratorConstructor]); |
| 381 new BackendImpact(staticUses: [helpers.streamIteratorConstructor]); | |
| 382 } | |
| 383 return _asyncForIn; | |
| 384 } | 316 } |
| 385 | 317 |
| 386 BackendImpact _stringInterpolation; | 318 BackendImpact _stringInterpolation; |
| 387 | 319 |
| 388 BackendImpact get stringInterpolation { | 320 BackendImpact get stringInterpolation { |
| 389 if (_stringInterpolation == null) { | 321 return _stringInterpolation ??= new BackendImpact( |
| 390 _stringInterpolation = new BackendImpact( | 322 dynamicUses: [Selectors.toString_], |
| 391 dynamicUses: [Selectors.toString_], | 323 staticUses: [helpers.stringInterpolationHelper], |
| 392 staticUses: [helpers.stringInterpolationHelper], | 324 otherImpacts: [_needsString('Strings are created.')]); |
| 393 otherImpacts: [_needsString('Strings are created.')]); | |
| 394 } | |
| 395 return _stringInterpolation; | |
| 396 } | 325 } |
| 397 | 326 |
| 398 BackendImpact _stringJuxtaposition; | 327 BackendImpact _stringJuxtaposition; |
| 399 | 328 |
| 400 BackendImpact get stringJuxtaposition { | 329 BackendImpact get stringJuxtaposition { |
| 401 if (_stringJuxtaposition == null) { | 330 return _stringJuxtaposition ??= _needsString('String.concat is used.'); |
| 402 _stringJuxtaposition = _needsString('String.concat is used.'); | |
| 403 } | |
| 404 return _stringJuxtaposition; | |
| 405 } | 331 } |
| 406 | 332 |
| 407 BackendImpact get nullLiteral => nullValue; | 333 BackendImpact get nullLiteral => nullValue; |
| 408 | 334 |
| 409 BackendImpact get boolLiteral => boolValues; | 335 BackendImpact get boolLiteral => boolValues; |
| 410 | 336 |
| 411 BackendImpact get intLiteral => intValues; | 337 BackendImpact get intLiteral => intValues; |
| 412 | 338 |
| 413 BackendImpact get doubleLiteral => doubleValues; | 339 BackendImpact get doubleLiteral => doubleValues; |
| 414 | 340 |
| 415 BackendImpact get stringLiteral => stringValues; | 341 BackendImpact get stringLiteral => stringValues; |
| 416 | 342 |
| 417 BackendImpact _catchStatement; | 343 BackendImpact _catchStatement; |
| 418 | 344 |
| 419 BackendImpact get catchStatement { | 345 BackendImpact get catchStatement { |
| 420 if (_catchStatement == null) { | 346 return _catchStatement ??= new BackendImpact(staticUses: [ |
| 421 _catchStatement = new BackendImpact(staticUses: [ | 347 helpers.exceptionUnwrapper |
| 422 helpers.exceptionUnwrapper | 348 ], instantiatedClasses: [ |
| 423 ], instantiatedClasses: [ | 349 helpers.jsPlainJavaScriptObjectClass, |
| 424 helpers.jsPlainJavaScriptObjectClass, | 350 helpers.jsUnknownJavaScriptObjectClass |
| 425 helpers.jsUnknownJavaScriptObjectClass | 351 ]); |
| 426 ]); | |
| 427 } | |
| 428 return _catchStatement; | |
| 429 } | 352 } |
| 430 | 353 |
| 431 BackendImpact _throwExpression; | 354 BackendImpact _throwExpression; |
| 432 | 355 |
| 433 BackendImpact get throwExpression { | 356 BackendImpact get throwExpression { |
| 434 if (_throwExpression == null) { | 357 return _throwExpression ??= new BackendImpact( |
| 435 _throwExpression = new BackendImpact( | 358 // We don't know ahead of time whether we will need the throw in a |
| 436 // We don't know ahead of time whether we will need the throw in a | 359 // statement context or an expression context, so we register both |
| 437 // statement context or an expression context, so we register both | 360 // here, even though we may not need the throwExpression helper. |
| 438 // here, even though we may not need the throwExpression helper. | 361 staticUses: [ |
| 439 staticUses: [ | 362 helpers.wrapExceptionHelper, |
| 440 helpers.wrapExceptionHelper, | 363 helpers.throwExpressionHelper |
| 441 helpers.throwExpressionHelper | 364 ]); |
| 442 ]); | |
| 443 } | |
| 444 return _throwExpression; | |
| 445 } | 365 } |
| 446 | 366 |
| 447 BackendImpact _lazyField; | 367 BackendImpact _lazyField; |
| 448 | 368 |
| 449 BackendImpact get lazyField { | 369 BackendImpact get lazyField { |
| 450 if (_lazyField == null) { | 370 return _lazyField ??= |
| 451 _lazyField = new BackendImpact(staticUses: [helpers.cyclicThrowHelper]); | 371 new BackendImpact(staticUses: [helpers.cyclicThrowHelper]); |
| 452 } | |
| 453 return _lazyField; | |
| 454 } | 372 } |
| 455 | 373 |
| 456 BackendImpact _typeLiteral; | 374 BackendImpact _typeLiteral; |
| 457 | 375 |
| 458 BackendImpact get typeLiteral { | 376 BackendImpact get typeLiteral { |
| 459 if (_typeLiteral == null) { | 377 return _typeLiteral ??= new BackendImpact( |
| 460 _typeLiteral = new BackendImpact( | 378 instantiatedClasses: [backend.backendClasses.typeImplementation], |
| 461 instantiatedClasses: [backend.backendClasses.typeImplementation], | 379 staticUses: [helpers.createRuntimeType]); |
| 462 staticUses: [helpers.createRuntimeType]); | |
| 463 } | |
| 464 return _typeLiteral; | |
| 465 } | 380 } |
| 466 | 381 |
| 467 BackendImpact _stackTraceInCatch; | 382 BackendImpact _stackTraceInCatch; |
| 468 | 383 |
| 469 BackendImpact get stackTraceInCatch { | 384 BackendImpact get stackTraceInCatch { |
| 470 if (_stackTraceInCatch == null) { | 385 return _stackTraceInCatch ??= new BackendImpact( |
| 471 _stackTraceInCatch = new BackendImpact( | 386 instantiatedClasses: [helpers.stackTraceClass], |
| 472 instantiatedClasses: [helpers.stackTraceClass], | 387 staticUses: [helpers.traceFromException]); |
| 473 staticUses: [helpers.traceFromException]); | |
| 474 } | |
| 475 return _stackTraceInCatch; | |
| 476 } | 388 } |
| 477 | 389 |
| 478 BackendImpact _syncForIn; | 390 BackendImpact _syncForIn; |
| 479 | 391 |
| 480 BackendImpact get syncForIn { | 392 BackendImpact get syncForIn { |
| 481 if (_syncForIn == null) { | 393 return _syncForIn ??= new BackendImpact( |
| 482 _syncForIn = new BackendImpact( | 394 // The SSA builder recognizes certain for-in loops and can generate |
| 483 // The SSA builder recognizes certain for-in loops and can generate | 395 // calls to throwConcurrentModificationError. |
| 484 // calls to throwConcurrentModificationError. | 396 staticUses: [helpers.checkConcurrentModificationError]); |
| 485 staticUses: [helpers.checkConcurrentModificationError]); | |
| 486 } | |
| 487 return _syncForIn; | |
| 488 } | 397 } |
| 489 | 398 |
| 490 BackendImpact _typeVariableExpression; | 399 BackendImpact _typeVariableExpression; |
| 491 | 400 |
| 492 BackendImpact get typeVariableExpression { | 401 BackendImpact get typeVariableExpression { |
| 493 if (_typeVariableExpression == null) { | 402 return _typeVariableExpression ??= new BackendImpact(staticUses: [ |
| 494 _typeVariableExpression = new BackendImpact(staticUses: [ | 403 helpers.setRuntimeTypeInfo, |
| 495 helpers.setRuntimeTypeInfo, | 404 helpers.getRuntimeTypeInfo, |
| 496 helpers.getRuntimeTypeInfo, | 405 helpers.runtimeTypeToString, |
| 497 helpers.runtimeTypeToString, | 406 helpers.createRuntimeType |
| 498 helpers.createRuntimeType | 407 ], otherImpacts: [ |
| 499 ], otherImpacts: [ | 408 listValues, |
| 500 listValues, | 409 getRuntimeTypeArgument, |
| 501 getRuntimeTypeArgument, | 410 _needsInt('Needed for accessing a type variable literal on this.') |
| 502 _needsInt('Needed for accessing a type variable literal on this.') | 411 ]); |
| 503 ]); | |
| 504 } | |
| 505 return _typeVariableExpression; | |
| 506 } | 412 } |
| 507 | 413 |
| 508 BackendImpact _typeCheck; | 414 BackendImpact _typeCheck; |
| 509 | 415 |
| 510 BackendImpact get typeCheck { | 416 BackendImpact get typeCheck { |
| 511 if (_typeCheck == null) { | 417 return _typeCheck ??= new BackendImpact(otherImpacts: [boolValues]); |
| 512 _typeCheck = new BackendImpact(otherImpacts: [boolValues]); | |
| 513 } | |
| 514 return _typeCheck; | |
| 515 } | 418 } |
| 516 | 419 |
| 517 BackendImpact _checkedModeTypeCheck; | 420 BackendImpact _checkedModeTypeCheck; |
| 518 | 421 |
| 519 BackendImpact get checkedModeTypeCheck { | 422 BackendImpact get checkedModeTypeCheck { |
| 520 if (_checkedModeTypeCheck == null) { | 423 return _checkedModeTypeCheck ??= |
| 521 _checkedModeTypeCheck = | 424 new BackendImpact(staticUses: [helpers.throwRuntimeError]); |
| 522 new BackendImpact(staticUses: [helpers.throwRuntimeError]); | |
| 523 } | |
| 524 return _checkedModeTypeCheck; | |
| 525 } | 425 } |
| 526 | 426 |
| 527 BackendImpact _malformedTypeCheck; | 427 BackendImpact _malformedTypeCheck; |
| 528 | 428 |
| 529 BackendImpact get malformedTypeCheck { | 429 BackendImpact get malformedTypeCheck { |
| 530 if (_malformedTypeCheck == null) { | 430 return _malformedTypeCheck ??= |
| 531 _malformedTypeCheck = | 431 new BackendImpact(staticUses: [helpers.throwTypeError]); |
| 532 new BackendImpact(staticUses: [helpers.throwTypeError]); | |
| 533 } | |
| 534 return _malformedTypeCheck; | |
| 535 } | 432 } |
| 536 | 433 |
| 537 BackendImpact _genericTypeCheck; | 434 BackendImpact _genericTypeCheck; |
| 538 | 435 |
| 539 BackendImpact get genericTypeCheck { | 436 BackendImpact get genericTypeCheck { |
| 540 if (_genericTypeCheck == null) { | 437 return _genericTypeCheck ??= new BackendImpact(staticUses: [ |
| 541 _genericTypeCheck = new BackendImpact(staticUses: [ | 438 helpers.checkSubtype, |
| 542 helpers.checkSubtype, | 439 // TODO(johnniwinther): Investigate why this is needed. |
| 543 // TODO(johnniwinther): Investigate why this is needed. | 440 helpers.setRuntimeTypeInfo, |
| 544 helpers.setRuntimeTypeInfo, | 441 helpers.getRuntimeTypeInfo |
| 545 helpers.getRuntimeTypeInfo | 442 ], otherImpacts: [ |
| 546 ], otherImpacts: [ | 443 listValues, |
| 547 listValues, | 444 getRuntimeTypeArgument |
| 548 getRuntimeTypeArgument | 445 ]); |
| 549 ]); | |
| 550 } | |
| 551 return _genericTypeCheck; | |
| 552 } | 446 } |
| 553 | 447 |
| 554 BackendImpact _genericIsCheck; | 448 BackendImpact _genericIsCheck; |
| 555 | 449 |
| 556 BackendImpact get genericIsCheck { | 450 BackendImpact get genericIsCheck { |
| 557 if (_genericIsCheck == null) { | 451 return _genericIsCheck ??= new BackendImpact(otherImpacts: [intValues]); |
| 558 _genericIsCheck = new BackendImpact(otherImpacts: [intValues]); | |
| 559 } | |
| 560 return _genericIsCheck; | |
| 561 } | 452 } |
| 562 | 453 |
| 563 BackendImpact _genericCheckedModeTypeCheck; | 454 BackendImpact _genericCheckedModeTypeCheck; |
| 564 | 455 |
| 565 BackendImpact get genericCheckedModeTypeCheck { | 456 BackendImpact get genericCheckedModeTypeCheck { |
| 566 if (_genericCheckedModeTypeCheck == null) { | 457 return _genericCheckedModeTypeCheck ??= |
| 567 _genericCheckedModeTypeCheck = | 458 new BackendImpact(staticUses: [helpers.assertSubtype]); |
| 568 new BackendImpact(staticUses: [helpers.assertSubtype]); | |
| 569 } | |
| 570 return _genericCheckedModeTypeCheck; | |
| 571 } | 459 } |
| 572 | 460 |
| 573 BackendImpact _typeVariableTypeCheck; | 461 BackendImpact _typeVariableTypeCheck; |
| 574 | 462 |
| 575 BackendImpact get typeVariableTypeCheck { | 463 BackendImpact get typeVariableTypeCheck { |
| 576 if (_typeVariableTypeCheck == null) { | 464 return _typeVariableTypeCheck ??= |
| 577 _typeVariableTypeCheck = | 465 new BackendImpact(staticUses: [helpers.checkSubtypeOfRuntimeType]); |
| 578 new BackendImpact(staticUses: [helpers.checkSubtypeOfRuntimeType]); | |
| 579 } | |
| 580 return _typeVariableTypeCheck; | |
| 581 } | 466 } |
| 582 | 467 |
| 583 BackendImpact _typeVariableCheckedModeTypeCheck; | 468 BackendImpact _typeVariableCheckedModeTypeCheck; |
| 584 | 469 |
| 585 BackendImpact get typeVariableCheckedModeTypeCheck { | 470 BackendImpact get typeVariableCheckedModeTypeCheck { |
| 586 if (_typeVariableCheckedModeTypeCheck == null) { | 471 return _typeVariableCheckedModeTypeCheck ??= |
| 587 _typeVariableCheckedModeTypeCheck = | 472 new BackendImpact(staticUses: [helpers.assertSubtypeOfRuntimeType]); |
| 588 new BackendImpact(staticUses: [helpers.assertSubtypeOfRuntimeType]); | |
| 589 } | |
| 590 return _typeVariableCheckedModeTypeCheck; | |
| 591 } | 473 } |
| 592 | 474 |
| 593 BackendImpact _functionTypeCheck; | 475 BackendImpact _functionTypeCheck; |
| 594 | 476 |
| 595 BackendImpact get functionTypeCheck { | 477 BackendImpact get functionTypeCheck { |
| 596 if (_functionTypeCheck == null) { | 478 return _functionTypeCheck ??= |
| 597 _functionTypeCheck = | 479 new BackendImpact(staticUses: [helpers.functionTypeTestMetaHelper]); |
| 598 new BackendImpact(staticUses: [helpers.functionTypeTestMetaHelper]); | |
| 599 } | |
| 600 return _functionTypeCheck; | |
| 601 } | 480 } |
| 602 | 481 |
| 603 BackendImpact _nativeTypeCheck; | 482 BackendImpact _nativeTypeCheck; |
| 604 | 483 |
| 605 BackendImpact get nativeTypeCheck { | 484 BackendImpact get nativeTypeCheck { |
| 606 if (_nativeTypeCheck == null) { | 485 return _nativeTypeCheck ??= new BackendImpact(staticUses: [ |
| 607 _nativeTypeCheck = new BackendImpact(staticUses: [ | 486 // We will neeed to add the "$is" and "$as" properties on the |
| 608 // We will neeed to add the "$is" and "$as" properties on the | 487 // JavaScript object prototype, so we make sure |
| 609 // JavaScript object prototype, so we make sure | 488 // [:defineProperty:] is compiled. |
| 610 // [:defineProperty:] is compiled. | 489 helpers.defineProperty |
| 611 helpers.defineProperty | 490 ]); |
| 612 ]); | |
| 613 } | |
| 614 return _nativeTypeCheck; | |
| 615 } | 491 } |
| 616 | 492 |
| 617 BackendImpact _closure; | 493 BackendImpact _closure; |
| 618 | 494 |
| 619 BackendImpact get closure { | 495 BackendImpact get closure { |
| 620 if (_closure == null) { | 496 return _closure ??= |
| 621 _closure = new BackendImpact( | 497 new BackendImpact(instantiatedClasses: [commonElements.functionClass]); |
| 622 instantiatedClasses: [commonElements.functionClass]); | |
| 623 } | |
| 624 return _closure; | |
| 625 } | 498 } |
| 626 | 499 |
| 627 BackendImpact _interceptorUse; | 500 BackendImpact _interceptorUse; |
| 628 | 501 |
| 629 BackendImpact get interceptorUse { | 502 BackendImpact get interceptorUse { |
| 630 if (_interceptorUse == null) { | 503 return _interceptorUse ??= new BackendImpact( |
| 631 _interceptorUse = new BackendImpact( | 504 staticUses: [ |
| 632 staticUses: [ | 505 helpers.getNativeInterceptorMethod |
| 633 helpers.getNativeInterceptorMethod | 506 ], |
| 634 ], | 507 instantiatedClasses: [ |
| 635 instantiatedClasses: [ | 508 helpers.jsJavaScriptObjectClass, |
| 636 helpers.jsJavaScriptObjectClass, | 509 helpers.jsPlainJavaScriptObjectClass, |
| 637 helpers.jsPlainJavaScriptObjectClass, | 510 helpers.jsJavaScriptFunctionClass |
| 638 helpers.jsJavaScriptFunctionClass | 511 ], |
| 639 ], | 512 features: new EnumSet<BackendFeature>.fromValues([ |
| 640 features: new EnumSet<BackendFeature>.fromValues([ | 513 BackendFeature.needToInitializeDispatchProperty, |
| 641 BackendFeature.needToInitializeDispatchProperty, | 514 BackendFeature.needToInitializeIsolateAffinityTag |
| 642 BackendFeature.needToInitializeIsolateAffinityTag | 515 ], fixed: true)); |
| 643 ], fixed: true)); | 516 } |
| 644 } | 517 |
| 645 return _interceptorUse; | 518 BackendImpact _numClasses; |
| 519 |
| 520 BackendImpact get numClasses { |
| 521 return _numClasses ??= new BackendImpact( |
| 522 // The backend will try to optimize number operations and use the |
| 523 // `iae` helper directly. |
| 524 globalUses: [helpers.throwIllegalArgumentException]); |
| 525 } |
| 526 |
| 527 BackendImpact _listOrStringClasses; |
| 528 |
| 529 BackendImpact get listOrStringClasses { |
| 530 return _listOrStringClasses ??= new BackendImpact( |
| 531 // The backend will try to optimize array and string access and use the |
| 532 // `ioore` and `iae` helpers directly. |
| 533 globalUses: [ |
| 534 helpers.throwIndexOutOfRangeException, |
| 535 helpers.throwIllegalArgumentException |
| 536 ]); |
| 537 } |
| 538 |
| 539 BackendImpact _functionClass; |
| 540 |
| 541 BackendImpact get functionClass { |
| 542 return _functionClass ??= |
| 543 new BackendImpact(globalClasses: [helpers.closureClass]); |
| 544 } |
| 545 |
| 546 BackendImpact _mapClass; |
| 547 |
| 548 BackendImpact get mapClass { |
| 549 return _mapClass ??= new BackendImpact( |
| 550 // The backend will use a literal list to initialize the entries |
| 551 // of the map. |
| 552 globalClasses: [ |
| 553 helpers.coreClasses.listClass, |
| 554 helpers.mapLiteralClass |
| 555 ]); |
| 556 } |
| 557 |
| 558 BackendImpact _boundClosureClass; |
| 559 |
| 560 BackendImpact get boundClosureClass { |
| 561 return _boundClosureClass ??= |
| 562 new BackendImpact(globalClasses: [helpers.boundClosureClass]); |
| 563 } |
| 564 |
| 565 BackendImpact _nativeOrExtendsClass; |
| 566 |
| 567 BackendImpact get nativeOrExtendsClass { |
| 568 return _nativeOrExtendsClass ??= new BackendImpact(globalUses: [ |
| 569 helpers.getNativeInterceptorMethod |
| 570 ], globalClasses: [ |
| 571 helpers.jsInterceptorClass, |
| 572 helpers.jsJavaScriptObjectClass, |
| 573 helpers.jsPlainJavaScriptObjectClass, |
| 574 helpers.jsJavaScriptFunctionClass |
| 575 ]); |
| 576 } |
| 577 |
| 578 BackendImpact _mapLiteralClass; |
| 579 |
| 580 BackendImpact get mapLiteralClass { |
| 581 return _mapLiteralClass ??= new BackendImpact(globalUses: [ |
| 582 helpers.mapLiteralConstructor, |
| 583 helpers.mapLiteralConstructorEmpty, |
| 584 helpers.mapLiteralUntypedMaker, |
| 585 helpers.mapLiteralUntypedEmptyMaker |
| 586 ]); |
| 587 } |
| 588 |
| 589 BackendImpact _closureClass; |
| 590 |
| 591 BackendImpact get closureClass { |
| 592 return _closureClass ??= |
| 593 new BackendImpact(globalUses: [helpers.closureFromTearOff]); |
| 594 } |
| 595 |
| 596 BackendImpact _listClasses; |
| 597 |
| 598 BackendImpact get listClasses { |
| 599 return _listClasses ??= new BackendImpact( |
| 600 // Literal lists can be translated into calls to these functions: |
| 601 globalUses: [ |
| 602 helpers.jsArrayTypedConstructor, |
| 603 helpers.setRuntimeTypeInfo, |
| 604 helpers.getTypeArgumentByIndex |
| 605 ]); |
| 606 } |
| 607 |
| 608 BackendImpact _jsIndexingBehavior; |
| 609 |
| 610 BackendImpact get jsIndexingBehavior { |
| 611 return _jsIndexingBehavior ??= new BackendImpact( |
| 612 // These two helpers are used by the emitter and the codegen. |
| 613 // Because we cannot enqueue elements at the time of emission, |
| 614 // we make sure they are always generated. |
| 615 globalUses: [helpers.isJsIndexable]); |
| 616 } |
| 617 |
| 618 BackendImpact _enableTypeAssertions; |
| 619 |
| 620 BackendImpact get enableTypeAssertions { |
| 621 return _enableTypeAssertions ??= new BackendImpact( |
| 622 // Register the helper that checks if the expression in an if/while/for |
| 623 // is a boolean. |
| 624 // TODO(johnniwinther): Should this be registered through a [Feature] |
| 625 // instead? |
| 626 globalUses: [helpers.boolConversionCheck]); |
| 627 } |
| 628 |
| 629 BackendImpact _traceHelper; |
| 630 |
| 631 BackendImpact get traceHelper { |
| 632 return _traceHelper ??= |
| 633 new BackendImpact(globalUses: [helpers.traceHelper]); |
| 634 } |
| 635 |
| 636 BackendImpact _assertUnreachable; |
| 637 |
| 638 BackendImpact get assertUnreachable { |
| 639 return _assertUnreachable ??= |
| 640 new BackendImpact(globalUses: [helpers.assertUnreachableMethod]); |
| 641 } |
| 642 |
| 643 BackendImpact _runtimeTypeSupport; |
| 644 |
| 645 BackendImpact get runtimeTypeSupport { |
| 646 return _runtimeTypeSupport ??= new BackendImpact( |
| 647 globalClasses: [helpers.coreClasses.listClass], |
| 648 globalUses: [helpers.setRuntimeTypeInfo, helpers.getRuntimeTypeInfo], |
| 649 otherImpacts: [getRuntimeTypeArgument, computeSignature]); |
| 650 } |
| 651 |
| 652 BackendImpact _deferredLoading; |
| 653 |
| 654 BackendImpact get deferredLoading { |
| 655 return _deferredLoading ??= |
| 656 new BackendImpact(globalUses: [helpers.checkDeferredIsLoaded], |
| 657 // Also register the types of the arguments passed to this method. |
| 658 globalClasses: [helpers.coreClasses.stringClass]); |
| 659 } |
| 660 |
| 661 BackendImpact _noSuchMethodSupport; |
| 662 |
| 663 BackendImpact get noSuchMethodSupport { |
| 664 return _noSuchMethodSupport ??= new BackendImpact( |
| 665 staticUses: [helpers.createInvocationMirror], |
| 666 dynamicUses: [Selectors.noSuchMethod_]); |
| 667 } |
| 668 |
| 669 BackendImpact _isolateSupport; |
| 670 |
| 671 /// Backend impact for isolate support. |
| 672 BackendImpact get isolateSupport { |
| 673 return _isolateSupport ??= |
| 674 new BackendImpact(globalUses: [helpers.startRootIsolate]); |
| 675 } |
| 676 |
| 677 BackendImpact _isolateSupportForResolution; |
| 678 |
| 679 /// Additional backend impact for isolate support in resolution. |
| 680 BackendImpact get isolateSupportForResolution { |
| 681 return _isolateSupportForResolution ??= new BackendImpact( |
| 682 globalUses: [helpers.currentIsolate, helpers.callInIsolate]); |
| 683 } |
| 684 |
| 685 BackendImpact _loadLibrary; |
| 686 |
| 687 /// Backend impact for accessing a `loadLibrary` function on a deferred |
| 688 /// prefix. |
| 689 BackendImpact get loadLibrary { |
| 690 return _loadLibrary ??= |
| 691 new BackendImpact(globalUses: [helpers.loadLibraryWrapper]); |
| 692 } |
| 693 |
| 694 BackendImpact _memberClosure; |
| 695 |
| 696 /// Backend impact for performing member closurization. |
| 697 BackendImpact get memberClosure { |
| 698 return _memberClosure ??= |
| 699 new BackendImpact(globalClasses: [helpers.boundClosureClass]); |
| 700 } |
| 701 |
| 702 BackendImpact _staticClosure; |
| 703 |
| 704 /// Backend impact for performing closurization of a top-level or static |
| 705 /// function. |
| 706 BackendImpact get staticClosure { |
| 707 return _staticClosure ??= |
| 708 new BackendImpact(globalClasses: [helpers.closureClass]); |
| 646 } | 709 } |
| 647 } | 710 } |
| OLD | NEW |