Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 839323003: Implementation of async-await transformation on js ast. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments - add TODO for buggy error behaviour. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 // will instantiate those two classes. 934 // will instantiate those two classes.
935 addInterceptors(jsBoolClass, world, registry); 935 addInterceptors(jsBoolClass, world, registry);
936 addInterceptors(jsNullClass, world, registry); 936 addInterceptors(jsNullClass, world, registry);
937 if (compiler.enableTypeAssertions) { 937 if (compiler.enableTypeAssertions) {
938 // Unconditionally register the helper that checks if the 938 // Unconditionally register the helper that checks if the
939 // expression in an if/while/for is a boolean. 939 // expression in an if/while/for is a boolean.
940 // TODO(ngeoffray): Should we have the resolver register those instead? 940 // TODO(ngeoffray): Should we have the resolver register those instead?
941 Element e = findHelper('boolConversionCheck'); 941 Element e = findHelper('boolConversionCheck');
942 if (e != null) enqueue(world, e, registry); 942 if (e != null) enqueue(world, e, registry);
943 } 943 }
944
944 if (TRACE_CALLS) { 945 if (TRACE_CALLS) {
945 traceHelper = findHelper('traceHelper'); 946 traceHelper = findHelper('traceHelper');
946 assert(traceHelper != null); 947 assert(traceHelper != null);
947 enqueueInResolution(traceHelper, registry); 948 enqueueInResolution(traceHelper, registry);
948 } 949 }
949 registerCheckedModeHelpers(registry); 950 registerCheckedModeHelpers(registry);
950 } 951 }
951 952
952 onResolutionComplete() { 953 onResolutionComplete() {
953 super.onResolutionComplete(); 954 super.onResolutionComplete();
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 } 1591 }
1591 1592
1592 Element getCreateInvocationMirror() { 1593 Element getCreateInvocationMirror() {
1593 return findHelper(Compiler.CREATE_INVOCATION_MIRROR); 1594 return findHelper(Compiler.CREATE_INVOCATION_MIRROR);
1594 } 1595 }
1595 1596
1596 Element getCyclicThrowHelper() { 1597 Element getCyclicThrowHelper() {
1597 return findHelper("throwCyclicInit"); 1598 return findHelper("throwCyclicInit");
1598 } 1599 }
1599 1600
1601 Element getThenHelper() {
1602 return findHelper("thenHelper");
1603 }
1604
1605 Element getYieldStar() {
1606 ClassElement classElement = findHelper("IterationMarker");
1607 classElement.ensureResolved(compiler);
1608 return classElement.lookupLocalMember("yieldStar");
1609 }
1610
1611 Element getYieldSingle() {
1612 ClassElement classElement = findHelper("IterationMarker");
1613 classElement.ensureResolved(compiler);
1614 return classElement.lookupLocalMember("yieldSingle");
1615 }
1616
1617 Element getStreamHelper() {
1618 return findHelper("streamHelper");
1619 }
1620
1621 Element getEndOfIteration() {
1622 ClassElement classElement = findHelper("IterationMarker");
1623 classElement.ensureResolved(compiler);
1624 return classElement.lookupLocalMember("endOfIteration");
1625 }
1626
1627 Element getSyncStarIterable() {
1628 ClassElement classElement = findHelper("SyncStarIterable");
1629 classElement.ensureResolved(compiler);
1630 return classElement;
1631 }
1632
1633 Element getSyncStarIterableConstructor() {
1634 ClassElement classElement = getSyncStarIterable();
1635 classElement.ensureResolved(compiler);
1636 return classElement.lookupConstructor("");
1637 }
1638
1639 Element getCompleterConstructor() {
1640 ClassElement classElement = find(compiler.asyncLibrary, "Completer");
1641 classElement.ensureResolved(compiler);
1642 return classElement.lookupConstructor("");
1643 }
1644
1645 Element getASyncStarController() {
1646 ClassElement classElement = findHelper("AsyncStarStreamController");
1647 classElement.ensureResolved(compiler);
1648 return classElement;
1649 }
1650
1651 Element getASyncStarControllerConstructor() {
1652 ClassElement classElement = getASyncStarController();
1653 return classElement.lookupConstructor("");
1654 }
1655
1656 Element getStreamIteratorConstructor() {
1657 ClassElement classElement = find(compiler.asyncLibrary, "StreamIterator");
1658 classElement.ensureResolved(compiler);
1659 return classElement.lookupConstructor("");
1660 }
1661
1600 bool isNullImplementation(ClassElement cls) { 1662 bool isNullImplementation(ClassElement cls) {
1601 return cls == jsNullClass; 1663 return cls == jsNullClass;
1602 } 1664 }
1603 1665
1604 ClassElement get intImplementation => jsIntClass; 1666 ClassElement get intImplementation => jsIntClass;
1605 ClassElement get uint32Implementation => jsUInt32Class; 1667 ClassElement get uint32Implementation => jsUInt32Class;
1606 ClassElement get uint31Implementation => jsUInt31Class; 1668 ClassElement get uint31Implementation => jsUInt31Class;
1607 ClassElement get positiveIntImplementation => jsPositiveIntClass; 1669 ClassElement get positiveIntImplementation => jsPositiveIntClass;
1608 ClassElement get doubleImplementation => jsDoubleClass; 1670 ClassElement get doubleImplementation => jsDoubleClass;
1609 ClassElement get numImplementation => jsNumberClass; 1671 ClassElement get numImplementation => jsNumberClass;
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 /// If [addExtension] is false, the ".part.js" suffix is left out. 2386 /// If [addExtension] is false, the ".part.js" suffix is left out.
2325 String deferredPartFileName(String name, {bool addExtension: true}) { 2387 String deferredPartFileName(String name, {bool addExtension: true}) {
2326 assert(name != ""); 2388 assert(name != "");
2327 String outPath = compiler.outputUri != null 2389 String outPath = compiler.outputUri != null
2328 ? compiler.outputUri.path 2390 ? compiler.outputUri.path
2329 : "out"; 2391 : "out";
2330 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); 2392 String outName = outPath.substring(outPath.lastIndexOf('/') + 1);
2331 String extension = addExtension ? ".part.js" : ""; 2393 String extension = addExtension ? ".part.js" : "";
2332 return "${outName}_$name$extension"; 2394 return "${outName}_$name$extension";
2333 } 2395 }
2396
2397 void registerAsyncMarker(FunctionElement element,
2398 Enqueuer enqueuer,
2399 Registry registry) {
2400 if (element.asyncMarker == AsyncMarker.ASYNC) {
2401 enqueue(enqueuer, getThenHelper(), registry);
2402 enqueue(enqueuer, getCompleterConstructor(), registry);
2403 enqueue(enqueuer, getStreamIteratorConstructor(), registry);
2404 } else if (element.asyncMarker == AsyncMarker.SYNC_STAR) {
2405 enqueuer.registerInstantiatedClass(getSyncStarIterable(), registry);
2406 enqueue(enqueuer, getSyncStarIterableConstructor(), registry);
2407 enqueue(enqueuer, getEndOfIteration(), registry);
2408 enqueue(enqueuer, getYieldStar(), registry);
2409 } else if (element.asyncMarker == AsyncMarker.ASYNC_STAR) {
2410 enqueuer.registerInstantiatedClass(getASyncStarController(), registry);
2411 enqueue(enqueuer, getStreamHelper(), registry);
2412 enqueue(enqueuer, getYieldSingle(), registry);
2413 enqueue(enqueuer, getYieldStar(), registry);
2414 enqueue(enqueuer, getASyncStarControllerConstructor(), registry);
2415 enqueue(enqueuer, getStreamIteratorConstructor(), registry);
2416 }
2417 }
2334 } 2418 }
2335 2419
2336 class JavaScriptResolutionCallbacks extends ResolutionCallbacks { 2420 class JavaScriptResolutionCallbacks extends ResolutionCallbacks {
2337 final JavaScriptBackend backend; 2421 final JavaScriptBackend backend;
2338 2422
2339 JavaScriptResolutionCallbacks(this.backend); 2423 JavaScriptResolutionCallbacks(this.backend);
2340 2424
2341 void registerBackendStaticInvocation(Element element, Registry registry) { 2425 void registerBackendStaticInvocation(Element element, Registry registry) {
2342 registry.registerStaticInvocation(backend.registerBackendUse(element)); 2426 registry.registerStaticInvocation(backend.registerBackendUse(element));
2343 } 2427 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 } 2614 }
2531 } 2615 }
2532 2616
2533 /// Records that [constant] is used by the element behind [registry]. 2617 /// Records that [constant] is used by the element behind [registry].
2534 class Dependency { 2618 class Dependency {
2535 final ConstantValue constant; 2619 final ConstantValue constant;
2536 final Element annotatedElement; 2620 final Element annotatedElement;
2537 2621
2538 const Dependency(this.constant, this.annotatedElement); 2622 const Dependency(this.constant, this.annotatedElement);
2539 } 2623 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698