Chromium Code Reviews| 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 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1741 // Function for checking if a hunk is loaded given its hash. | 1741 // Function for checking if a hunk is loaded given its hash. |
| 1742 buffer.write(jsAst.prettyPrint( | 1742 buffer.write(jsAst.prettyPrint( |
| 1743 js('# = function(hunkHash) {' | 1743 js('# = function(hunkHash) {' |
| 1744 ' return !!$deferredInitializers[hunkHash];' | 1744 ' return !!$deferredInitializers[hunkHash];' |
| 1745 '}', generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_LOADED)), | 1745 '}', generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_LOADED)), |
| 1746 compiler, monitor: compiler.dumpInfoTask)); | 1746 compiler, monitor: compiler.dumpInfoTask)); |
| 1747 buffer.write('$N'); | 1747 buffer.write('$N'); |
| 1748 // Function for initializing a loaded hunk, given its hash. | 1748 // Function for initializing a loaded hunk, given its hash. |
| 1749 buffer.write(jsAst.prettyPrint( | 1749 buffer.write(jsAst.prettyPrint( |
| 1750 js('# = function(hunkHash) {' | 1750 js('# = function(hunkHash) {' |
| 1751 ' $deferredInitializers[hunkHash]($globalsHolder)' | 1751 ' $deferredInitializers[hunkHash](' |
| 1752 '$globalsHolder, ${namer.currentIsolate})' | |
| 1752 '}', | 1753 '}', |
| 1753 generateEmbeddedGlobalAccess( | 1754 generateEmbeddedGlobalAccess( |
| 1754 embeddedNames.INITIALIZE_LOADED_HUNK)), | 1755 embeddedNames.INITIALIZE_LOADED_HUNK)), |
| 1755 compiler, monitor: compiler.dumpInfoTask)); | 1756 compiler, monitor: compiler.dumpInfoTask)); |
| 1756 buffer.write('$N'); | 1757 buffer.write('$N'); |
| 1757 // Write a javascript mapping from Deferred import load ids (derrived | 1758 // Write a javascript mapping from Deferred import load ids (derrived |
| 1758 // from the import prefix.) to a list of lists of uris of hunks to load, | 1759 // from the import prefix.) to a list of lists of uris of hunks to load, |
| 1759 // and a corresponding mapping to a list of hashes used by | 1760 // and a corresponding mapping to a list of hashes used by |
| 1760 // INITIALIZE_LOADED_HUNK and IS_HUNK_LOADED. | 1761 // INITIALIZE_LOADED_HUNK and IS_HUNK_LOADED. |
| 1761 Map<String, List<String>> deferredLibraryUris = | 1762 Map<String, List<String>> deferredLibraryUris = |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1828 outputBuffer | 1829 outputBuffer |
| 1829 ..write('var init$_=$_${globalsHolder}.init$N') | 1830 ..write('var init$_=$_${globalsHolder}.init$N') |
| 1830 ..write('var ${namer.isolateName}$_=$_' | 1831 ..write('var ${namer.isolateName}$_=$_' |
| 1831 '${globalsHolder}.${namer.isolateName}$N'); | 1832 '${globalsHolder}.${namer.isolateName}$N'); |
| 1832 if (libraryDescriptorBuffer != null) { | 1833 if (libraryDescriptorBuffer != null) { |
| 1833 // TODO(ahe): This defines a lot of properties on the | 1834 // TODO(ahe): This defines a lot of properties on the |
| 1834 // Isolate.prototype object. We know this will turn it into a | 1835 // Isolate.prototype object. We know this will turn it into a |
| 1835 // slow object in V8, so instead we should do something similar | 1836 // slow object in V8, so instead we should do something similar |
| 1836 // to Isolate.$finishIsolateConstructor. | 1837 // to Isolate.$finishIsolateConstructor. |
| 1837 outputBuffer | 1838 outputBuffer |
| 1838 ..write('var ${namer.currentIsolate}$_=$_$isolatePropertiesName$N') | 1839 ..write('var ${namer.currentIsolate}$_=$_$isolatePropertiesName$N') |
|
floitsch
2014/10/10 22:12:21
This is, where we set the namer.currentIsolate var
| |
| 1839 // The classesCollector object ($$). | 1840 // The classesCollector object ($$). |
| 1840 ..write('$classesCollector$_=${_}Object.create(null);$n') | 1841 ..write('$classesCollector$_=${_}Object.create(null);$n') |
| 1841 ..write('(') | 1842 ..write('(') |
| 1842 ..write( | 1843 ..write( |
| 1843 jsAst.prettyPrint( | 1844 jsAst.prettyPrint( |
| 1844 getReflectionDataParser(classesCollector, backend), | 1845 getReflectionDataParser(classesCollector, backend), |
| 1845 compiler, monitor: compiler.dumpInfoTask)) | 1846 compiler, monitor: compiler.dumpInfoTask)) |
| 1846 ..write(')') | 1847 ..write(')') |
| 1847 ..write('([$n') | 1848 ..write('([$n') |
| 1848 ..addBuffer(libraryDescriptorBuffer) | 1849 ..addBuffer(libraryDescriptorBuffer) |
| 1849 ..write('])$N'); | 1850 ..write('])$N'); |
| 1850 | 1851 |
| 1851 if (outputClassLists.containsKey(outputUnit)) { | 1852 if (outputClassLists.containsKey(outputUnit)) { |
| 1852 outputBuffer.write( | 1853 outputBuffer.write( |
| 1853 '$finishClassesName($classesCollector,$_${namer.currentIsolate},' | 1854 '$finishClassesName($classesCollector,$_${namer.currentIsolate},' |
| 1854 '$_$isolatePropertiesName)$N'); | 1855 '$_$isolatePropertiesName)$N'); |
| 1855 } | 1856 } |
| 1856 | 1857 |
| 1857 } | 1858 } |
| 1858 | 1859 |
| 1859 classesCollector = oldClassesCollector; | 1860 classesCollector = oldClassesCollector; |
| 1860 | 1861 |
| 1862 // Set the currentIsolate variable to the current isolate (which is | |
| 1863 // provided as second argument). | |
| 1864 // We need to do this, because we use the same variable for setting up | |
| 1865 // the isolate-properties and for storing the current isolate. During | |
| 1866 // the setup (the code above this lines) we must set the variable to | |
| 1867 // the isolate-properties. | |
| 1868 // After we have done the setup (finishing with `finishClasses`) it must | |
| 1869 // point to the current Isolate. Otherwise all methods/functions | |
| 1870 // accessing isolate variables will access the wrong object. | |
| 1871 outputBuffer.write("${namer.currentIsolate}$_=${_}arguments[1]$N"); | |
| 1861 typeTestEmitter.emitRuntimeTypeSupport(outputBuffer, outputUnit); | 1872 typeTestEmitter.emitRuntimeTypeSupport(outputBuffer, outputUnit); |
| 1862 | 1873 |
| 1863 emitCompileTimeConstants(outputBuffer, outputUnit); | 1874 emitCompileTimeConstants(outputBuffer, outputUnit); |
| 1864 outputBuffer.write('}$N'); | 1875 outputBuffer.write('}$N'); |
| 1865 | 1876 |
| 1866 if (compiler.useContentSecurityPolicy) { | 1877 if (compiler.useContentSecurityPolicy) { |
| 1867 jsAst.FunctionDeclaration precompiledFunctionAst = | 1878 jsAst.FunctionDeclaration precompiledFunctionAst = |
| 1868 buildCspPrecompiledFunctionFor(outputUnit); | 1879 buildCspPrecompiledFunctionFor(outputUnit); |
| 1869 | 1880 |
| 1870 outputBuffer.write( | 1881 outputBuffer.write( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1922 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 1933 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 1923 if (element.isInstanceMember) { | 1934 if (element.isInstanceMember) { |
| 1924 cachedClassBuilders.remove(element.enclosingClass); | 1935 cachedClassBuilders.remove(element.enclosingClass); |
| 1925 | 1936 |
| 1926 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 1937 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 1927 | 1938 |
| 1928 } | 1939 } |
| 1929 } | 1940 } |
| 1930 } | 1941 } |
| 1931 } | 1942 } |
| OLD | NEW |