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

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. Fix setting of the handler in finallies... 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 getMakeController() {
1646 return findHelper("makeAsyncStarController");
1647 }
1648
1649 Element getStreamIteratorConstructor() {
1650 ClassElement classElement = find(compiler.asyncLibrary, "StreamIterator");
1651 classElement.ensureResolved(compiler);
1652 return classElement.lookupConstructor("");
1653 }
1654
1600 bool isNullImplementation(ClassElement cls) { 1655 bool isNullImplementation(ClassElement cls) {
1601 return cls == jsNullClass; 1656 return cls == jsNullClass;
1602 } 1657 }
1603 1658
1604 ClassElement get intImplementation => jsIntClass; 1659 ClassElement get intImplementation => jsIntClass;
1605 ClassElement get uint32Implementation => jsUInt32Class; 1660 ClassElement get uint32Implementation => jsUInt32Class;
1606 ClassElement get uint31Implementation => jsUInt31Class; 1661 ClassElement get uint31Implementation => jsUInt31Class;
1607 ClassElement get positiveIntImplementation => jsPositiveIntClass; 1662 ClassElement get positiveIntImplementation => jsPositiveIntClass;
1608 ClassElement get doubleImplementation => jsDoubleClass; 1663 ClassElement get doubleImplementation => jsDoubleClass;
1609 ClassElement get numImplementation => jsNumberClass; 1664 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. 2379 /// If [addExtension] is false, the ".part.js" suffix is left out.
2325 String deferredPartFileName(String name, {bool addExtension: true}) { 2380 String deferredPartFileName(String name, {bool addExtension: true}) {
2326 assert(name != ""); 2381 assert(name != "");
2327 String outPath = compiler.outputUri != null 2382 String outPath = compiler.outputUri != null
2328 ? compiler.outputUri.path 2383 ? compiler.outputUri.path
2329 : "out"; 2384 : "out";
2330 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); 2385 String outName = outPath.substring(outPath.lastIndexOf('/') + 1);
2331 String extension = addExtension ? ".part.js" : ""; 2386 String extension = addExtension ? ".part.js" : "";
2332 return "${outName}_$name$extension"; 2387 return "${outName}_$name$extension";
2333 } 2388 }
2389
2390 void registerAsyncMarker(FunctionElement element,
2391 Enqueuer enqueuer,
2392 Registry registry) {
2393 if (element.asyncMarker == AsyncMarker.ASYNC) {
2394 enqueue(enqueuer, getThenHelper(), registry);
2395 enqueue(enqueuer, getCompleterConstructor(), registry);
2396 enqueue(enqueuer, getStreamIteratorConstructor(), registry);
2397 } else if (element.asyncMarker == AsyncMarker.SYNC_STAR) {
2398 enqueuer.registerInstantiatedClass(getSyncStarIterable(), registry);
2399 enqueue(enqueuer, getSyncStarIterableConstructor(), registry);
2400 enqueue(enqueuer, getEndOfIteration(), registry);
2401 enqueue(enqueuer, getYieldStar(), registry);
2402 } else if (element.asyncMarker == AsyncMarker.ASYNC_STAR) {
2403 enqueue(enqueuer, getStreamHelper(), registry);
2404 enqueue(enqueuer, getYieldSingle(), registry);
2405 enqueue(enqueuer, getYieldStar(), registry);
2406 enqueue(enqueuer, getMakeController(), registry);
2407 enqueue(enqueuer, getStreamIteratorConstructor(), registry);
2408 }
2409 }
2334 } 2410 }
2335 2411
2336 class JavaScriptResolutionCallbacks extends ResolutionCallbacks { 2412 class JavaScriptResolutionCallbacks extends ResolutionCallbacks {
2337 final JavaScriptBackend backend; 2413 final JavaScriptBackend backend;
2338 2414
2339 JavaScriptResolutionCallbacks(this.backend); 2415 JavaScriptResolutionCallbacks(this.backend);
2340 2416
2341 void registerBackendStaticInvocation(Element element, Registry registry) { 2417 void registerBackendStaticInvocation(Element element, Registry registry) {
2342 registry.registerStaticInvocation(backend.registerBackendUse(element)); 2418 registry.registerStaticInvocation(backend.registerBackendUse(element));
2343 } 2419 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 } 2606 }
2531 } 2607 }
2532 2608
2533 /// Records that [constant] is used by the element behind [registry]. 2609 /// Records that [constant] is used by the element behind [registry].
2534 class Dependency { 2610 class Dependency {
2535 final ConstantValue constant; 2611 final ConstantValue constant;
2536 final Element annotatedElement; 2612 final Element annotatedElement;
2537 2613
2538 const Dependency(this.constant, this.annotatedElement); 2614 const Dependency(this.constant, this.annotatedElement);
2539 } 2615 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698