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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 859843002: dart2js: use model in native emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert debug code. Created 5 years, 11 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 var \$desc; 716 var \$desc;
717 #; 717 #;
718 return #; 718 return #;
719 }''', 719 }''',
720 [cspPrecompiledFunctionFor(outputUnit), 720 [cspPrecompiledFunctionFor(outputUnit),
721 new jsAst.ArrayInitializer( 721 new jsAst.ArrayInitializer(
722 cspPrecompiledConstructorNamesFor(outputUnit))]); 722 cspPrecompiledConstructorNamesFor(outputUnit))]);
723 } 723 }
724 724
725 void emitClass(Class cls, ClassBuilder enclosingBuilder) { 725 void emitClass(Class cls, ClassBuilder enclosingBuilder) {
726 // Native classes are handled by the native emitter.
727 assert(!cls.isNative || cls.onlyForRti);
728
726 ClassElement classElement = cls.element; 729 ClassElement classElement = cls.element;
727 compiler.withCurrentElement(classElement, () { 730 compiler.withCurrentElement(classElement, () {
728 if (compiler.hasIncrementalSupport) { 731 if (compiler.hasIncrementalSupport) {
729 ClassBuilder cachedBuilder = 732 ClassBuilder cachedBuilder =
730 cachedClassBuilders.putIfAbsent(classElement, () { 733 cachedClassBuilders.putIfAbsent(classElement, () {
731 ClassBuilder builder = new ClassBuilder(classElement, namer); 734 ClassBuilder builder = new ClassBuilder(classElement, namer);
732 classEmitter.emitClass( 735 classEmitter.emitClass(
733 cls, builder, additionalProperties[classElement]); 736 cls, builder, additionalProperties[classElement]);
734 return builder; 737 return builder;
735 }); 738 });
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 for (LibraryElement library in Elements.sortedByPosition(libraries)) { 1752 for (LibraryElement library in Elements.sortedByPosition(libraries)) {
1750 writeLibraryDescriptors(buffer, library); 1753 writeLibraryDescriptors(buffer, library);
1751 elementDescriptors.remove(library); 1754 elementDescriptors.remove(library);
1752 } 1755 }
1753 } 1756 }
1754 } 1757 }
1755 1758
1756 return emitDeferredCode(program, outputBuffers); 1759 return emitDeferredCode(program, outputBuffers);
1757 } 1760 }
1758 1761
1759 CodeBuffer buildNativesBuffer() { 1762 CodeBuffer buildNativesBuffer(Program program) {
1760 // Emit native classes on [nativeBuffer]. 1763 // Emit native classes on [nativeBuffer].
1761 // TODO(johnniwinther): Avoid creating a [CodeBuffer]. 1764 // TODO(johnniwinther): Avoid creating a [CodeBuffer].
1762 final CodeBuffer nativeBuffer = new CodeBuffer(); 1765 final CodeBuffer nativeBuffer = new CodeBuffer();
1763 1766
1764 if (nativeClasses.isEmpty) return nativeBuffer; 1767 if (program.nativeClasses.isEmpty) return nativeBuffer;
1765 1768
1766 1769
1767 addComment('Native classes', nativeBuffer); 1770 addComment('Native classes', nativeBuffer);
1768 1771
1769 nativeEmitter.generateNativeClasses(nativeClasses, additionalProperties); 1772 nativeEmitter.generateNativeClasses(program.nativeClasses,
1773 additionalProperties);
1770 1774
1771 nativeEmitter.finishGenerateNativeClasses(); 1775 nativeEmitter.finishGenerateNativeClasses();
1772 nativeEmitter.assembleCode(nativeBuffer); 1776 nativeEmitter.assembleCode(nativeBuffer);
1773 1777
1774 return nativeBuffer; 1778 return nativeBuffer;
1775 } 1779 }
1776 1780
1777 int emitProgram(Program program) { 1781 int emitProgram(Program program) {
1778 // Shorten the code by using [namer.currentIsolate] as temporary. 1782 // Shorten the code by using [namer.currentIsolate] as temporary.
1779 isolateProperties = namer.currentIsolate; 1783 isolateProperties = namer.currentIsolate;
1780 1784
1781 // Emit deferred units first, so we have their hashes. 1785 // Emit deferred units first, so we have their hashes.
1782 // Map from OutputUnit to a hash of its content. The hash uniquely 1786 // Map from OutputUnit to a hash of its content. The hash uniquely
1783 // identifies the code of the output-unit. It does not include 1787 // identifies the code of the output-unit. It does not include
1784 // boilerplate JS code, like the sourcemap directives or the hash 1788 // boilerplate JS code, like the sourcemap directives or the hash
1785 // itself. 1789 // itself.
1786 Map<OutputUnit, String> deferredLoadHashes = 1790 Map<OutputUnit, String> deferredLoadHashes =
1787 emitDeferredOutputUnits(program); 1791 emitDeferredOutputUnits(program);
1788 CodeBuffer nativeBuffer = buildNativesBuffer(); 1792 CodeBuffer nativeBuffer = buildNativesBuffer(program);
1789 emitMainOutputUnit(program, deferredLoadHashes, nativeBuffer); 1793 emitMainOutputUnit(program, deferredLoadHashes, nativeBuffer);
1790 1794
1791 if (backend.requiresPreamble && 1795 if (backend.requiresPreamble &&
1792 !backend.htmlLibraryIsLoaded) { 1796 !backend.htmlLibraryIsLoaded) {
1793 compiler.reportHint(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); 1797 compiler.reportHint(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE);
1794 } 1798 }
1795 // Return the total program size. 1799 // Return the total program size.
1796 return outputBuffers.values.fold(0, (a, b) => a + b.length); 1800 return outputBuffers.values.fold(0, (a, b) => a + b.length);
1797 } 1801 }
1798 1802
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2083 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2080 if (element.isInstanceMember) { 2084 if (element.isInstanceMember) {
2081 cachedClassBuilders.remove(element.enclosingClass); 2085 cachedClassBuilders.remove(element.enclosingClass);
2082 2086
2083 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2087 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2084 2088
2085 } 2089 }
2086 } 2090 }
2087 } 2091 }
2088 } 2092 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698