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 const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR"); | 9 const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR"); |
10 | 10 |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 // will instantiate those two classes. | 936 // will instantiate those two classes. |
937 addInterceptors(jsBoolClass, world, registry); | 937 addInterceptors(jsBoolClass, world, registry); |
938 addInterceptors(jsNullClass, world, registry); | 938 addInterceptors(jsNullClass, world, registry); |
939 if (compiler.enableTypeAssertions) { | 939 if (compiler.enableTypeAssertions) { |
940 // Unconditionally register the helper that checks if the | 940 // Unconditionally register the helper that checks if the |
941 // expression in an if/while/for is a boolean. | 941 // expression in an if/while/for is a boolean. |
942 // TODO(ngeoffray): Should we have the resolver register those instead? | 942 // TODO(ngeoffray): Should we have the resolver register those instead? |
943 Element e = findHelper('boolConversionCheck'); | 943 Element e = findHelper('boolConversionCheck'); |
944 if (e != null) enqueue(world, e, registry); | 944 if (e != null) enqueue(world, e, registry); |
945 } | 945 } |
| 946 |
946 if (TRACE_CALLS) { | 947 if (TRACE_CALLS) { |
947 traceHelper = findHelper('traceHelper'); | 948 traceHelper = findHelper('traceHelper'); |
948 assert(traceHelper != null); | 949 assert(traceHelper != null); |
949 enqueueInResolution(traceHelper, registry); | 950 enqueueInResolution(traceHelper, registry); |
950 } | 951 } |
951 registerCheckedModeHelpers(registry); | 952 registerCheckedModeHelpers(registry); |
952 } | 953 } |
953 | 954 |
954 onResolutionComplete() { | 955 onResolutionComplete() { |
955 super.onResolutionComplete(); | 956 super.onResolutionComplete(); |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 } | 1593 } |
1593 | 1594 |
1594 Element getCreateInvocationMirror() { | 1595 Element getCreateInvocationMirror() { |
1595 return findHelper(Compiler.CREATE_INVOCATION_MIRROR); | 1596 return findHelper(Compiler.CREATE_INVOCATION_MIRROR); |
1596 } | 1597 } |
1597 | 1598 |
1598 Element getCyclicThrowHelper() { | 1599 Element getCyclicThrowHelper() { |
1599 return findHelper("throwCyclicInit"); | 1600 return findHelper("throwCyclicInit"); |
1600 } | 1601 } |
1601 | 1602 |
| 1603 Element getThenHelper() { |
| 1604 return findHelper("thenHelper"); |
| 1605 } |
| 1606 |
| 1607 Element getYieldStar() { |
| 1608 ClassElement classElement = findHelper("IterationMarker"); |
| 1609 classElement.ensureResolved(compiler); |
| 1610 return classElement.lookupLocalMember("yieldStar"); |
| 1611 } |
| 1612 |
| 1613 Element getYieldSingle() { |
| 1614 ClassElement classElement = findHelper("IterationMarker"); |
| 1615 classElement.ensureResolved(compiler); |
| 1616 return classElement.lookupLocalMember("yieldSingle"); |
| 1617 } |
| 1618 |
| 1619 Element getStreamHelper() { |
| 1620 return findHelper("streamHelper"); |
| 1621 } |
| 1622 |
| 1623 Element getEndOfIteration() { |
| 1624 ClassElement classElement = findHelper("IterationMarker"); |
| 1625 classElement.ensureResolved(compiler); |
| 1626 return classElement.lookupLocalMember("endOfIteration"); |
| 1627 } |
| 1628 |
| 1629 Element getSyncStarIterable() { |
| 1630 ClassElement classElement = findHelper("SyncStarIterable"); |
| 1631 classElement.ensureResolved(compiler); |
| 1632 return classElement; |
| 1633 } |
| 1634 |
| 1635 Element getSyncStarIterableConstructor() { |
| 1636 ClassElement classElement = getSyncStarIterable(); |
| 1637 classElement.ensureResolved(compiler); |
| 1638 return classElement.lookupConstructor(""); |
| 1639 } |
| 1640 |
| 1641 Element getCompleterConstructor() { |
| 1642 ClassElement classElement = find(compiler.asyncLibrary, "Completer"); |
| 1643 classElement.ensureResolved(compiler); |
| 1644 return classElement.lookupConstructor(""); |
| 1645 } |
| 1646 |
| 1647 Element getASyncStarController() { |
| 1648 ClassElement classElement = findHelper("AsyncStarStreamController"); |
| 1649 classElement.ensureResolved(compiler); |
| 1650 return classElement; |
| 1651 } |
| 1652 |
| 1653 Element getASyncStarControllerConstructor() { |
| 1654 ClassElement classElement = getASyncStarController(); |
| 1655 return classElement.lookupConstructor(""); |
| 1656 } |
| 1657 |
| 1658 Element getStreamIteratorConstructor() { |
| 1659 ClassElement classElement = find(compiler.asyncLibrary, "StreamIterator"); |
| 1660 classElement.ensureResolved(compiler); |
| 1661 return classElement.lookupConstructor(""); |
| 1662 } |
| 1663 |
1602 bool isNullImplementation(ClassElement cls) { | 1664 bool isNullImplementation(ClassElement cls) { |
1603 return cls == jsNullClass; | 1665 return cls == jsNullClass; |
1604 } | 1666 } |
1605 | 1667 |
1606 ClassElement get intImplementation => jsIntClass; | 1668 ClassElement get intImplementation => jsIntClass; |
1607 ClassElement get uint32Implementation => jsUInt32Class; | 1669 ClassElement get uint32Implementation => jsUInt32Class; |
1608 ClassElement get uint31Implementation => jsUInt31Class; | 1670 ClassElement get uint31Implementation => jsUInt31Class; |
1609 ClassElement get positiveIntImplementation => jsPositiveIntClass; | 1671 ClassElement get positiveIntImplementation => jsPositiveIntClass; |
1610 ClassElement get doubleImplementation => jsDoubleClass; | 1672 ClassElement get doubleImplementation => jsDoubleClass; |
1611 ClassElement get numImplementation => jsNumberClass; | 1673 ClassElement get numImplementation => jsNumberClass; |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 /// If [addExtension] is false, the ".part.js" suffix is left out. | 2389 /// If [addExtension] is false, the ".part.js" suffix is left out. |
2328 String deferredPartFileName(String name, {bool addExtension: true}) { | 2390 String deferredPartFileName(String name, {bool addExtension: true}) { |
2329 assert(name != ""); | 2391 assert(name != ""); |
2330 String outPath = compiler.outputUri != null | 2392 String outPath = compiler.outputUri != null |
2331 ? compiler.outputUri.path | 2393 ? compiler.outputUri.path |
2332 : "out"; | 2394 : "out"; |
2333 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); | 2395 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); |
2334 String extension = addExtension ? ".part.js" : ""; | 2396 String extension = addExtension ? ".part.js" : ""; |
2335 return "${outName}_$name$extension"; | 2397 return "${outName}_$name$extension"; |
2336 } | 2398 } |
| 2399 |
| 2400 void registerAsyncMarker(FunctionElement element, |
| 2401 Enqueuer enqueuer, |
| 2402 Registry registry) { |
| 2403 if (element.asyncMarker == AsyncMarker.ASYNC) { |
| 2404 enqueue(enqueuer, getThenHelper(), registry); |
| 2405 enqueue(enqueuer, getCompleterConstructor(), registry); |
| 2406 enqueue(enqueuer, getStreamIteratorConstructor(), registry); |
| 2407 } else if (element.asyncMarker == AsyncMarker.SYNC_STAR) { |
| 2408 enqueuer.registerInstantiatedClass(getSyncStarIterable(), registry); |
| 2409 enqueue(enqueuer, getSyncStarIterableConstructor(), registry); |
| 2410 enqueue(enqueuer, getEndOfIteration(), registry); |
| 2411 enqueue(enqueuer, getYieldStar(), registry); |
| 2412 } else if (element.asyncMarker == AsyncMarker.ASYNC_STAR) { |
| 2413 enqueuer.registerInstantiatedClass(getASyncStarController(), registry); |
| 2414 enqueue(enqueuer, getStreamHelper(), registry); |
| 2415 enqueue(enqueuer, getYieldSingle(), registry); |
| 2416 enqueue(enqueuer, getYieldStar(), registry); |
| 2417 enqueue(enqueuer, getASyncStarControllerConstructor(), registry); |
| 2418 enqueue(enqueuer, getStreamIteratorConstructor(), registry); |
| 2419 } |
| 2420 } |
2337 } | 2421 } |
2338 | 2422 |
2339 /// Handling of special annotations for tests. | 2423 /// Handling of special annotations for tests. |
2340 class Annotations { | 2424 class Annotations { |
2341 static final Uri PACKAGE_EXPECT = | 2425 static final Uri PACKAGE_EXPECT = |
2342 new Uri(scheme: 'package', path: 'expect/expect.dart'); | 2426 new Uri(scheme: 'package', path: 'expect/expect.dart'); |
2343 | 2427 |
2344 ClassElement expectNoInliningClass; | 2428 ClassElement expectNoInliningClass; |
2345 ClassElement expectTrustTypeAnnotationsClass; | 2429 ClassElement expectTrustTypeAnnotationsClass; |
2346 ClassElement expectAssumeDynamicClass; | 2430 ClassElement expectAssumeDynamicClass; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 } | 2676 } |
2593 } | 2677 } |
2594 | 2678 |
2595 /// Records that [constant] is used by the element behind [registry]. | 2679 /// Records that [constant] is used by the element behind [registry]. |
2596 class Dependency { | 2680 class Dependency { |
2597 final ConstantValue constant; | 2681 final ConstantValue constant; |
2598 final Element annotatedElement; | 2682 final Element annotatedElement; |
2599 | 2683 |
2600 const Dependency(this.constant, this.annotatedElement); | 2684 const Dependency(this.constant, this.annotatedElement); |
2601 } | 2685 } |
OLD | NEW |