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 /** | 7 /** |
8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
9 * from the given element. | 9 * from the given element. |
10 */ | 10 */ |
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 | 1600 |
1601 // Is it possible the primary function was inlined but the bailout was not? | 1601 // Is it possible the primary function was inlined but the bailout was not? |
1602 for (Element element in | 1602 for (Element element in |
1603 Elements.sortedByPosition(pendingElementsWithBailouts)) { | 1603 Elements.sortedByPosition(pendingElementsWithBailouts)) { |
1604 CodeBuffer buffer = bufferForElement(element, eagerBuffer); | 1604 CodeBuffer buffer = bufferForElement(element, eagerBuffer); |
1605 jsAst.Expression bailoutCode = backend.generatedBailoutCode[element]; | 1605 jsAst.Expression bailoutCode = backend.generatedBailoutCode[element]; |
1606 emitStaticFunction(buffer, namer.getBailoutName(element), bailoutCode); | 1606 emitStaticFunction(buffer, namer.getBailoutName(element), bailoutCode); |
1607 } | 1607 } |
1608 } | 1608 } |
1609 | 1609 |
1610 void emitStaticFunctionGetters(CodeBuffer buffer) { | 1610 void emitStaticFunctionGetters(CodeBuffer eagerBuffer) { |
1611 Set<FunctionElement> functionsNeedingGetter = | 1611 Set<FunctionElement> functionsNeedingGetter = |
1612 compiler.codegenWorld.staticFunctionsNeedingGetter; | 1612 compiler.codegenWorld.staticFunctionsNeedingGetter; |
1613 for (FunctionElement element in | 1613 for (FunctionElement element in |
1614 Elements.sortedByPosition(functionsNeedingGetter)) { | 1614 Elements.sortedByPosition(functionsNeedingGetter)) { |
1615 // TODO(ahe): Defer loading of these getters. | 1615 CodeBuffer buffer = bufferForElement(element, eagerBuffer); |
1616 | 1616 |
1617 // The static function does not have the correct name. Since | 1617 // The static function does not have the correct name. Since |
1618 // [addParameterStubs] use the name to create its stubs we simply | 1618 // [addParameterStubs] use the name to create its stubs we simply |
1619 // create a fake element with the correct name. | 1619 // create a fake element with the correct name. |
1620 // Note: the callElement will not have any enclosingElement. | 1620 // Note: the callElement will not have any enclosingElement. |
1621 FunctionElement callElement = | 1621 FunctionElement callElement = |
1622 new ClosureInvocationElement(namer.closureInvocationSelectorName, | 1622 new ClosureInvocationElement(namer.closureInvocationSelectorName, |
1623 element); | 1623 element); |
1624 String staticName = namer.getName(element); | 1624 String staticName = namer.getName(element); |
1625 String invocationName = namer.instanceMethodName(callElement); | 1625 String invocationName = namer.instanceMethodName(callElement); |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2641 | 2641 |
2642 deferredBuffer.add('$finishClassesName(\$\$,' | 2642 deferredBuffer.add('$finishClassesName(\$\$,' |
2643 '$_${namer.CURRENT_ISOLATE},' | 2643 '$_${namer.CURRENT_ISOLATE},' |
2644 '$_$isolatePropertiesName)$N'); | 2644 '$_$isolatePropertiesName)$N'); |
2645 // Reset the map. | 2645 // Reset the map. |
2646 deferredBuffer.add("\$\$$_=${_}null$N$n"); | 2646 deferredBuffer.add("\$\$$_=${_}null$N$n"); |
2647 } | 2647 } |
2648 | 2648 |
2649 emitClosureClassIfNeeded(mainBuffer); | 2649 emitClosureClassIfNeeded(mainBuffer); |
2650 | 2650 |
| 2651 addComment('Bound closures', mainBuffer); |
2651 // Now that we have emitted all classes, we know all the bound | 2652 // Now that we have emitted all classes, we know all the bound |
2652 // closures that will be needed. | 2653 // closures that will be needed. |
2653 for (jsAst.Node node in boundClosures) { | 2654 for (jsAst.Node node in boundClosures) { |
2654 // TODO(ahe): Some of these can be deferred. | 2655 // TODO(ahe): Some of these can be deferred. |
2655 mainBuffer.add(jsAst.prettyPrint(node, compiler)); | 2656 mainBuffer.add(jsAst.prettyPrint(node, compiler)); |
2656 mainBuffer.add("$N$n"); | 2657 mainBuffer.add("$N$n"); |
2657 } | 2658 } |
2658 | 2659 |
2659 emitFinishClassesInvocationIfNecessary(mainBuffer); | 2660 emitFinishClassesInvocationIfNecessary(mainBuffer); |
2660 | 2661 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2765 """; | 2766 """; |
2766 const String HOOKS_API_USAGE = """ | 2767 const String HOOKS_API_USAGE = """ |
2767 // The code supports the following hooks: | 2768 // The code supports the following hooks: |
2768 // dartPrint(message) - if this function is defined it is called | 2769 // dartPrint(message) - if this function is defined it is called |
2769 // instead of the Dart [print] method. | 2770 // instead of the Dart [print] method. |
2770 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2771 // dartMainRunner(main) - if this function is defined, the Dart [main] |
2771 // method will not be invoked directly. | 2772 // method will not be invoked directly. |
2772 // Instead, a closure that will invoke [main] is | 2773 // Instead, a closure that will invoke [main] is |
2773 // passed to [dartMainRunner]. | 2774 // passed to [dartMainRunner]. |
2774 """; | 2775 """; |
OLD | NEW |