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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 12525007: Record dependency information to implement first version of dependency (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 years, 9 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 /** 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 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1602
1603 // Is it possible the primary function was inlined but the bailout was not? 1603 // Is it possible the primary function was inlined but the bailout was not?
1604 for (Element element in 1604 for (Element element in
1605 Elements.sortedByPosition(pendingElementsWithBailouts)) { 1605 Elements.sortedByPosition(pendingElementsWithBailouts)) {
1606 CodeBuffer buffer = bufferForElement(element, eagerBuffer); 1606 CodeBuffer buffer = bufferForElement(element, eagerBuffer);
1607 jsAst.Expression bailoutCode = backend.generatedBailoutCode[element]; 1607 jsAst.Expression bailoutCode = backend.generatedBailoutCode[element];
1608 emitStaticFunction(buffer, namer.getBailoutName(element), bailoutCode); 1608 emitStaticFunction(buffer, namer.getBailoutName(element), bailoutCode);
1609 } 1609 }
1610 } 1610 }
1611 1611
1612 void emitStaticFunctionGetters(CodeBuffer buffer) { 1612 void emitStaticFunctionGetters(CodeBuffer eagerBuffer) {
1613 Set<FunctionElement> functionsNeedingGetter = 1613 Set<FunctionElement> functionsNeedingGetter =
1614 compiler.codegenWorld.staticFunctionsNeedingGetter; 1614 compiler.codegenWorld.staticFunctionsNeedingGetter;
1615 for (FunctionElement element in 1615 for (FunctionElement element in
1616 Elements.sortedByPosition(functionsNeedingGetter)) { 1616 Elements.sortedByPosition(functionsNeedingGetter)) {
1617 // TODO(ahe): Defer loading of these getters. 1617 CodeBuffer buffer = bufferForElement(element, eagerBuffer);
1618 1618
1619 // The static function does not have the correct name. Since 1619 // The static function does not have the correct name. Since
1620 // [addParameterStubs] use the name to create its stubs we simply 1620 // [addParameterStubs] use the name to create its stubs we simply
1621 // create a fake element with the correct name. 1621 // create a fake element with the correct name.
1622 // Note: the callElement will not have any enclosingElement. 1622 // Note: the callElement will not have any enclosingElement.
1623 FunctionElement callElement = 1623 FunctionElement callElement =
1624 new ClosureInvocationElement(namer.closureInvocationSelectorName, 1624 new ClosureInvocationElement(namer.closureInvocationSelectorName,
1625 element); 1625 element);
1626 String staticName = namer.getName(element); 1626 String staticName = namer.getName(element);
1627 String invocationName = namer.instanceMethodName(callElement); 1627 String invocationName = namer.instanceMethodName(callElement);
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 2659
2660 deferredBuffer.add('$finishClassesName(\$\$,' 2660 deferredBuffer.add('$finishClassesName(\$\$,'
2661 '$_${namer.CURRENT_ISOLATE},' 2661 '$_${namer.CURRENT_ISOLATE},'
2662 '$_$isolatePropertiesName)$N'); 2662 '$_$isolatePropertiesName)$N');
2663 // Reset the map. 2663 // Reset the map.
2664 deferredBuffer.add("\$\$$_=${_}null$N$n"); 2664 deferredBuffer.add("\$\$$_=${_}null$N$n");
2665 } 2665 }
2666 2666
2667 emitClosureClassIfNeeded(mainBuffer); 2667 emitClosureClassIfNeeded(mainBuffer);
2668 2668
2669 addComment('Bound closures', mainBuffer);
2669 // Now that we have emitted all classes, we know all the bound 2670 // Now that we have emitted all classes, we know all the bound
2670 // closures that will be needed. 2671 // closures that will be needed.
2671 for (jsAst.Node node in boundClosures) { 2672 for (jsAst.Node node in boundClosures) {
2672 // TODO(ahe): Some of these can be deferred. 2673 // TODO(ahe): Some of these can be deferred.
2673 mainBuffer.add(jsAst.prettyPrint(node, compiler)); 2674 mainBuffer.add(jsAst.prettyPrint(node, compiler));
2674 mainBuffer.add("$N$n"); 2675 mainBuffer.add("$N$n");
2675 } 2676 }
2676 2677
2677 emitFinishClassesInvocationIfNecessary(mainBuffer); 2678 emitFinishClassesInvocationIfNecessary(mainBuffer);
2678 2679
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 """; 2784 """;
2784 const String HOOKS_API_USAGE = """ 2785 const String HOOKS_API_USAGE = """
2785 // The code supports the following hooks: 2786 // The code supports the following hooks:
2786 // dartPrint(message) - if this function is defined it is called 2787 // dartPrint(message) - if this function is defined it is called
2787 // instead of the Dart [print] method. 2788 // instead of the Dart [print] method.
2788 // dartMainRunner(main) - if this function is defined, the Dart [main] 2789 // dartMainRunner(main) - if this function is defined, the Dart [main]
2789 // method will not be invoked directly. 2790 // method will not be invoked directly.
2790 // Instead, a closure that will invoke [main] is 2791 // Instead, a closure that will invoke [main] is
2791 // passed to [dartMainRunner]. 2792 // passed to [dartMainRunner].
2792 """; 2793 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698