| 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 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers); | 1866 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers); |
| 1867 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers); | 1867 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers); |
| 1868 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers); | 1868 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers); |
| 1869 } | 1869 } |
| 1870 | 1870 |
| 1871 String buildIsolateSetup(CodeBuffer buffer, | 1871 String buildIsolateSetup(CodeBuffer buffer, |
| 1872 Element appMain, | 1872 Element appMain, |
| 1873 Element isolateMain) { | 1873 Element isolateMain) { |
| 1874 String mainAccess = "${namer.isolateAccess(appMain)}"; | 1874 String mainAccess = "${namer.isolateAccess(appMain)}"; |
| 1875 String currentIsolate = "${namer.CURRENT_ISOLATE}"; | 1875 String currentIsolate = "${namer.CURRENT_ISOLATE}"; |
| 1876 String mainEnsureGetter = ''; | |
| 1877 // Since we pass the closurized version of the main method to | 1876 // Since we pass the closurized version of the main method to |
| 1878 // the isolate method, we must make sure that it exists. | 1877 // the isolate method, we must make sure that it exists. |
| 1879 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { | 1878 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { |
| 1880 Selector selector = new Selector.callClosure(0); | 1879 Selector selector = new Selector.callClosure(0); |
| 1881 String invocationName = "${namer.closureInvocationName(selector)}"; | 1880 String invocationName = "${namer.closureInvocationName(selector)}"; |
| 1882 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; | 1881 buffer.add("$mainAccess.$invocationName = $mainAccess"); |
| 1883 } | 1882 } |
| 1884 // TODO(ngeoffray): These globals are currently required by the isolate | 1883 return "${namer.isolateAccess(isolateMain)}($mainAccess)"; |
| 1885 // library. They should be removed. | |
| 1886 buffer.add(""" | |
| 1887 var \$globalThis = $currentIsolate; | |
| 1888 var \$globalState; | |
| 1889 var \$globals; | |
| 1890 var \$isWorker = false; | |
| 1891 var \$supportsWorkers = false; | |
| 1892 var \$thisScriptUrl; | |
| 1893 function \$static_init(){}; | |
| 1894 | |
| 1895 function \$initGlobals(context) { | |
| 1896 context.isolateStatics = new ${namer.isolateName}(); | |
| 1897 } | |
| 1898 function \$setGlobals(context) { | |
| 1899 $currentIsolate = context.isolateStatics; | |
| 1900 \$globalThis = $currentIsolate; | |
| 1901 } | |
| 1902 $mainEnsureGetter | |
| 1903 """); | |
| 1904 return "${namer.isolateAccess(isolateMain)}($mainAccess)"; | |
| 1905 } | 1884 } |
| 1906 | 1885 |
| 1907 emitMain(CodeBuffer buffer) { | 1886 emitMain(CodeBuffer buffer) { |
| 1908 if (compiler.isMockCompilation) return; | 1887 if (compiler.isMockCompilation) return; |
| 1909 Element main = compiler.mainApp.find(Compiler.MAIN); | 1888 Element main = compiler.mainApp.find(Compiler.MAIN); |
| 1910 String mainCall = null; | 1889 String mainCall = null; |
| 1911 if (compiler.hasIsolateSupport()) { | 1890 if (compiler.hasIsolateSupport()) { |
| 1912 Element isolateMain = | 1891 Element isolateMain = |
| 1913 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE); | 1892 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE); |
| 1914 mainCall = buildIsolateSetup(buffer, main, isolateMain); | 1893 mainCall = buildIsolateSetup(buffer, main, isolateMain); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 """; | 2166 """; |
| 2188 const String HOOKS_API_USAGE = """ | 2167 const String HOOKS_API_USAGE = """ |
| 2189 // The code supports the following hooks: | 2168 // The code supports the following hooks: |
| 2190 // dartPrint(message) - if this function is defined it is called | 2169 // dartPrint(message) - if this function is defined it is called |
| 2191 // instead of the Dart [print] method. | 2170 // instead of the Dart [print] method. |
| 2192 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2171 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 2193 // method will not be invoked directly. | 2172 // method will not be invoked directly. |
| 2194 // Instead, a closure that will invoke [main] is | 2173 // Instead, a closure that will invoke [main] is |
| 2195 // passed to [dartMainRunner]. | 2174 // passed to [dartMainRunner]. |
| 2196 """; | 2175 """; |
| OLD | NEW |