OLD | NEW |
---|---|
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 150 |
151 String get finishIsolateConstructorName | 151 String get finishIsolateConstructorName |
152 => '${namer.isolateName}.\$finishIsolateConstructor'; | 152 => '${namer.isolateName}.\$finishIsolateConstructor'; |
153 String get isolatePropertiesName | 153 String get isolatePropertiesName |
154 => '${namer.isolateName}.${namer.isolatePropertiesName}'; | 154 => '${namer.isolateName}.${namer.isolatePropertiesName}'; |
155 String get lazyInitializerProperty | 155 String get lazyInitializerProperty |
156 => r'$lazy'; | 156 => r'$lazy'; |
157 String get lazyInitializerName | 157 String get lazyInitializerName |
158 => '${namer.isolateName}.${lazyInitializerProperty}'; | 158 => '${namer.isolateName}.${lazyInitializerProperty}'; |
159 String get initName => 'init'; | 159 String get initName => 'init'; |
160 String get deferredInitializedName => 'deferredInitialized'; | |
161 | |
160 String get makeConstListProperty | 162 String get makeConstListProperty |
161 => namer.getMappedInstanceName('makeConstantList'); | 163 => namer.getMappedInstanceName('makeConstantList'); |
162 | 164 |
163 /// The name of the property that contains all field names. | 165 /// The name of the property that contains all field names. |
164 /// | 166 /// |
165 /// This property is added to constructors when isolate support is enabled. | 167 /// This property is added to constructors when isolate support is enabled. |
166 static const String FIELD_NAMES_PROPERTY_NAME = r"$__fields__"; | 168 static const String FIELD_NAMES_PROPERTY_NAME = r"$__fields__"; |
167 | 169 |
168 /// For deferred loading we communicate the initializers via this global var. | 170 /// For deferred loading we communicate the initializers via this global var. |
169 final String deferredInitializers = r"$dart_deferred_initializers"; | 171 final String deferredInitializers = r"$dart_deferred_initializers"; |
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1820 } | 1822 } |
1821 return elementDescriptors.putIfAbsent( | 1823 return elementDescriptors.putIfAbsent( |
1822 owner, | 1824 owner, |
1823 () => new ClassBuilder(owner, namer)); | 1825 () => new ClassBuilder(owner, namer)); |
1824 } | 1826 } |
1825 | 1827 |
1826 /// Emits support-code for deferred loading into [buffer]. | 1828 /// Emits support-code for deferred loading into [buffer]. |
1827 void emitDeferredBoilerPlate(CodeBuffer buffer, | 1829 void emitDeferredBoilerPlate(CodeBuffer buffer, |
1828 Map<OutputUnit, String> deferredLoadHashes) { | 1830 Map<OutputUnit, String> deferredLoadHashes) { |
1829 // Function for checking if a hunk is loaded given its hash. | 1831 // Function for checking if a hunk is loaded given its hash. |
1830 buffer.write(jsAst.prettyPrint( | 1832 buffer.write(jsAst.prettyPrint( |
floitsch
2015/01/07 13:04:31
Put all these statements together into one string.
sigurdm
2015/01/07 13:37:13
Done.
| |
1831 js('# = function(hunkHash) {' | 1833 js.statement('# = function(hunkHash) {' |
1832 ' return !!$deferredInitializers[hunkHash];' | 1834 ' return !!$deferredInitializers[hunkHash];' |
1833 '}', generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_LOADED)), | 1835 '};', generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_LOADED)), |
1834 compiler, monitor: compiler.dumpInfoTask)); | 1836 compiler, monitor: compiler.dumpInfoTask)); |
1835 buffer.write('$N'); | 1837 buffer.write(jsAst.prettyPrint( |
1838 js.statement('$initName.$deferredInitializedName = new Object(null);'), | |
floitsch
2015/01/07 13:04:31
this looks like a bad "initName" of an embedded gl
sigurdm
2015/01/07 13:37:13
Changed it to an embedded global.
| |
1839 compiler, monitor: compiler.dumpInfoTask)); | |
1840 // Function for checking if a hunk is initialized given its hash. | |
1841 buffer.write(jsAst.prettyPrint( | |
1842 js.statement('# = function(hunkHash) {' | |
1843 'return $initName.$deferredInitializedName[hunkHash];' | |
1844 '};', | |
1845 generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_INITIALIZED)), | |
1846 compiler, monitor: compiler.dumpInfoTask)); | |
1836 // Function for initializing a loaded hunk, given its hash. | 1847 // Function for initializing a loaded hunk, given its hash. |
1837 buffer.write(jsAst.prettyPrint( | 1848 buffer.write(jsAst.prettyPrint( |
1838 js('# = function(hunkHash) {' | 1849 js.statement('# = function(hunkHash) {' |
1839 ' $deferredInitializers[hunkHash](' | 1850 '$deferredInitializers[hunkHash](' |
1840 '$globalsHolder, ${namer.currentIsolate})' | 1851 '$globalsHolder, ${namer.currentIsolate});' |
1841 '}', | 1852 '$initName.deferredInitialized[hunkHash] = true;' |
1853 '};', | |
1842 generateEmbeddedGlobalAccess( | 1854 generateEmbeddedGlobalAccess( |
1843 embeddedNames.INITIALIZE_LOADED_HUNK)), | 1855 embeddedNames.INITIALIZE_LOADED_HUNK)), |
1844 compiler, monitor: compiler.dumpInfoTask)); | 1856 compiler, monitor: compiler.dumpInfoTask)); |
1845 buffer.write('$N'); | |
1846 // Write a javascript mapping from Deferred import load ids (derrived | 1857 // Write a javascript mapping from Deferred import load ids (derrived |
1847 // from the import prefix.) to a list of lists of uris of hunks to load, | 1858 // from the import prefix.) to a list of lists of uris of hunks to load, |
1848 // and a corresponding mapping to a list of hashes used by | 1859 // and a corresponding mapping to a list of hashes used by |
1849 // INITIALIZE_LOADED_HUNK and IS_HUNK_LOADED. | 1860 // INITIALIZE_LOADED_HUNK and IS_HUNK_LOADED. |
1850 Map<String, List<String>> deferredLibraryUris = | 1861 Map<String, List<String>> deferredLibraryUris = |
1851 new Map<String, List<String>>(); | 1862 new Map<String, List<String>>(); |
1852 Map<String, List<String>> deferredLibraryHashes = | 1863 Map<String, List<String>> deferredLibraryHashes = |
1853 new Map<String, List<String>>(); | 1864 new Map<String, List<String>>(); |
1854 compiler.deferredLoadTask.hunksToLoad.forEach( | 1865 compiler.deferredLoadTask.hunksToLoad.forEach( |
1855 (String loadId, List<OutputUnit>outputUnits) { | 1866 (String loadId, List<OutputUnit>outputUnits) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2028 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2039 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
2029 if (element.isInstanceMember) { | 2040 if (element.isInstanceMember) { |
2030 cachedClassBuilders.remove(element.enclosingClass); | 2041 cachedClassBuilders.remove(element.enclosingClass); |
2031 | 2042 |
2032 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2043 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
2033 | 2044 |
2034 } | 2045 } |
2035 } | 2046 } |
2036 } | 2047 } |
2037 } | 2048 } |
OLD | NEW |