| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
| 8 | 8 |
| 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
| 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 FunctionElement disableTreeShakingMarker; | 266 FunctionElement disableTreeShakingMarker; |
| 267 | 267 |
| 268 /// Holds the method "preserveNames" in js_mirrors when | 268 /// Holds the method "preserveNames" in js_mirrors when |
| 269 /// dart:mirrors has been loaded. | 269 /// dart:mirrors has been loaded. |
| 270 FunctionElement preserveNamesMarker; | 270 FunctionElement preserveNamesMarker; |
| 271 | 271 |
| 272 /// Holds the method "preserveMetadata" in js_mirrors when | 272 /// Holds the method "preserveMetadata" in js_mirrors when |
| 273 /// dart:mirrors has been loaded. | 273 /// dart:mirrors has been loaded. |
| 274 FunctionElement preserveMetadataMarker; | 274 FunctionElement preserveMetadataMarker; |
| 275 | 275 |
| 276 /// Holds the method "preserveUris" in js_mirrors when |
| 277 /// dart:mirrors has been loaded. |
| 278 FunctionElement preserveUrisMarker; |
| 279 |
| 280 /// Holds the method "preserveLibraryNames" in js_mirrors when |
| 281 /// dart:mirrors has been loaded. |
| 282 FunctionElement preserveLibraryNamesMarker; |
| 283 |
| 276 /// Holds the method "requiresPreamble" in _js_helper. | 284 /// Holds the method "requiresPreamble" in _js_helper. |
| 277 FunctionElement requiresPreambleMarker; | 285 FunctionElement requiresPreambleMarker; |
| 278 | 286 |
| 279 /// True if a call to preserveMetadataMarker has been seen. This means that | 287 /// True if a call to preserveMetadataMarker has been seen. This means that |
| 280 /// metadata must be retained for dart:mirrors to work correctly. | 288 /// metadata must be retained for dart:mirrors to work correctly. |
| 281 bool mustRetainMetadata = false; | 289 bool mustRetainMetadata = false; |
| 282 | 290 |
| 283 /// True if any metadata has been retained. This is slightly different from | 291 /// True if any metadata has been retained. This is slightly different from |
| 284 /// [mustRetainMetadata] and tells us if any metadata was retained. For | 292 /// [mustRetainMetadata] and tells us if any metadata was retained. For |
| 285 /// example, if [mustRetainMetadata] is true but there is no metadata in the | 293 /// example, if [mustRetainMetadata] is true but there is no metadata in the |
| 286 /// program, this variable will stil be false. | 294 /// program, this variable will stil be false. |
| 287 bool hasRetainedMetadata = false; | 295 bool hasRetainedMetadata = false; |
| 288 | 296 |
| 297 /// True if a call to preserveUris has been seen. |
| 298 bool mustRetainUris = false; |
| 299 |
| 300 /// True if a call to preserveLibraryNames has been seen. |
| 301 bool mustRetainLibraryNames = false; |
| 302 |
| 289 /// True if a call to preserveNames has been seen. | 303 /// True if a call to preserveNames has been seen. |
| 290 bool mustPreserveNames = false; | 304 bool mustPreserveNames = false; |
| 291 | 305 |
| 292 /// True if a call to disableTreeShaking has been seen. | 306 /// True if a call to disableTreeShaking has been seen. |
| 293 bool isTreeShakingDisabled = false; | 307 bool isTreeShakingDisabled = false; |
| 294 | 308 |
| 295 /// True if there isn't sufficient @MirrorsUsed data. | 309 /// True if there isn't sufficient @MirrorsUsed data. |
| 296 bool hasInsufficientMirrorsUsed = false; | 310 bool hasInsufficientMirrorsUsed = false; |
| 297 | 311 |
| 298 /// True if a core-library function requires the preamble file to function. | 312 /// True if a core-library function requires the preamble file to function. |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1458 |
| 1445 void registerStaticUse(Element element, Enqueuer enqueuer) { | 1459 void registerStaticUse(Element element, Enqueuer enqueuer) { |
| 1446 if (element == disableTreeShakingMarker) { | 1460 if (element == disableTreeShakingMarker) { |
| 1447 compiler.disableTypeInferenceForMirrors = true; | 1461 compiler.disableTypeInferenceForMirrors = true; |
| 1448 isTreeShakingDisabled = true; | 1462 isTreeShakingDisabled = true; |
| 1449 typeVariableHandler.onTreeShakingDisabled(enqueuer); | 1463 typeVariableHandler.onTreeShakingDisabled(enqueuer); |
| 1450 } else if (element == preserveNamesMarker) { | 1464 } else if (element == preserveNamesMarker) { |
| 1451 mustPreserveNames = true; | 1465 mustPreserveNames = true; |
| 1452 } else if (element == preserveMetadataMarker) { | 1466 } else if (element == preserveMetadataMarker) { |
| 1453 mustRetainMetadata = true; | 1467 mustRetainMetadata = true; |
| 1468 } else if (element == preserveUrisMarker) { |
| 1469 mustRetainUris = true; |
| 1470 } else if (element == preserveLibraryNamesMarker) { |
| 1471 mustRetainLibraryNames = true; |
| 1454 } else if (element == getIsolateAffinityTagMarker) { | 1472 } else if (element == getIsolateAffinityTagMarker) { |
| 1455 needToInitializeIsolateAffinityTag = true; | 1473 needToInitializeIsolateAffinityTag = true; |
| 1456 } else if (element.isDeferredLoaderGetter) { | 1474 } else if (element.isDeferredLoaderGetter) { |
| 1457 // TODO(sigurdm): Create a function registerLoadLibraryAccess. | 1475 // TODO(sigurdm): Create a function registerLoadLibraryAccess. |
| 1458 if (compiler.loadLibraryFunction == null) { | 1476 if (compiler.loadLibraryFunction == null) { |
| 1459 compiler.loadLibraryFunction = | 1477 compiler.loadLibraryFunction = |
| 1460 findHelper("_loadLibraryWrapper"); | 1478 findHelper("_loadLibraryWrapper"); |
| 1461 enqueueInResolution(compiler.loadLibraryFunction, | 1479 enqueueInResolution(compiler.loadLibraryFunction, |
| 1462 compiler.globalDependencies); | 1480 compiler.globalDependencies); |
| 1463 } | 1481 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 noThrowsClass = findClass('NoThrows'); | 1622 noThrowsClass = findClass('NoThrows'); |
| 1605 noInlineClass = findClass('NoInline'); | 1623 noInlineClass = findClass('NoInline'); |
| 1606 irRepresentationClass = findClass('IrRepresentation'); | 1624 irRepresentationClass = findClass('IrRepresentation'); |
| 1607 | 1625 |
| 1608 getIsolateAffinityTagMarker = findMethod('getIsolateAffinityTag'); | 1626 getIsolateAffinityTagMarker = findMethod('getIsolateAffinityTag'); |
| 1609 | 1627 |
| 1610 requiresPreambleMarker = findMethod('requiresPreamble'); | 1628 requiresPreambleMarker = findMethod('requiresPreamble'); |
| 1611 } else if (uri == DART_JS_MIRRORS) { | 1629 } else if (uri == DART_JS_MIRRORS) { |
| 1612 disableTreeShakingMarker = find(library, 'disableTreeShaking'); | 1630 disableTreeShakingMarker = find(library, 'disableTreeShaking'); |
| 1613 preserveMetadataMarker = find(library, 'preserveMetadata'); | 1631 preserveMetadataMarker = find(library, 'preserveMetadata'); |
| 1632 preserveUrisMarker = find(library, 'preserveUris'); |
| 1633 preserveLibraryNamesMarker = find(library, 'preserveLibraryNames'); |
| 1614 } else if (uri == DART_JS_NAMES) { | 1634 } else if (uri == DART_JS_NAMES) { |
| 1615 preserveNamesMarker = find(library, 'preserveNames'); | 1635 preserveNamesMarker = find(library, 'preserveNames'); |
| 1616 } else if (uri == DART_HTML) { | 1636 } else if (uri == DART_HTML) { |
| 1617 htmlLibraryIsLoaded = true; | 1637 htmlLibraryIsLoaded = true; |
| 1618 } | 1638 } |
| 1619 }); | 1639 }); |
| 1620 } | 1640 } |
| 1621 | 1641 |
| 1622 Future onLibrariesLoaded(Map<Uri, LibraryElement> loadedLibraries) { | 1642 Future onLibrariesLoaded(Map<Uri, LibraryElement> loadedLibraries) { |
| 1623 if (!loadedLibraries.containsKey(Compiler.DART_CORE)) { | 1643 if (!loadedLibraries.containsKey(Compiler.DART_CORE)) { |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2281 } | 2301 } |
| 2282 | 2302 |
| 2283 /// Records that [constant] is used by the element behind [registry]. | 2303 /// Records that [constant] is used by the element behind [registry]. |
| 2284 class Dependency { | 2304 class Dependency { |
| 2285 final Constant constant; | 2305 final Constant constant; |
| 2286 // TODO(johnniwinther): Change to [Element] when dependency nodes are added. | 2306 // TODO(johnniwinther): Change to [Element] when dependency nodes are added. |
| 2287 final Registry registry; | 2307 final Registry registry; |
| 2288 | 2308 |
| 2289 const Dependency(this.constant, this.registry); | 2309 const Dependency(this.constant, this.registry); |
| 2290 } | 2310 } |
| OLD | NEW |