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