| 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 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers); | 1804 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers); |
| 1805 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers); | 1805 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers); |
| 1806 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers); | 1806 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers); |
| 1807 } | 1807 } |
| 1808 | 1808 |
| 1809 String buildIsolateSetup(CodeBuffer buffer, | 1809 String buildIsolateSetup(CodeBuffer buffer, |
| 1810 Element appMain, | 1810 Element appMain, |
| 1811 Element isolateMain) { | 1811 Element isolateMain) { |
| 1812 String mainAccess = "${namer.isolateAccess(appMain)}"; | 1812 String mainAccess = "${namer.isolateAccess(appMain)}"; |
| 1813 String currentIsolate = "${namer.CURRENT_ISOLATE}"; | 1813 String currentIsolate = "${namer.CURRENT_ISOLATE}"; |
| 1814 String mainEnsureGetter = ''; | |
| 1815 // Since we pass the closurized version of the main method to | 1814 // Since we pass the closurized version of the main method to |
| 1816 // the isolate method, we must make sure that it exists. | 1815 // the isolate method, we must make sure that it exists. |
| 1817 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { | 1816 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { |
| 1818 Selector selector = new Selector.callClosure(0); | 1817 Selector selector = new Selector.callClosure(0); |
| 1819 String invocationName = "${namer.closureInvocationName(selector)}"; | 1818 String invocationName = "${namer.closureInvocationName(selector)}"; |
| 1820 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; | 1819 buffer.add("$mainAccess.$invocationName = $mainAccess"); |
| 1821 } | 1820 } |
| 1822 // TODO(ngeoffray): These globals are currently required by the isolate | 1821 return "${namer.isolateAccess(isolateMain)}($mainAccess)"; |
| 1823 // library. They should be removed. | |
| 1824 buffer.add(""" | |
| 1825 var \$globalThis = $currentIsolate; | |
| 1826 var \$globalState; | |
| 1827 var \$globals; | |
| 1828 var \$isWorker = false; | |
| 1829 var \$supportsWorkers = false; | |
| 1830 var \$thisScriptUrl; | |
| 1831 function \$static_init(){}; | |
| 1832 | |
| 1833 function \$initGlobals(context) { | |
| 1834 context.isolateStatics = new ${namer.isolateName}(); | |
| 1835 } | |
| 1836 function \$setGlobals(context) { | |
| 1837 $currentIsolate = context.isolateStatics; | |
| 1838 \$globalThis = $currentIsolate; | |
| 1839 } | |
| 1840 $mainEnsureGetter | |
| 1841 """); | |
| 1842 return "${namer.isolateAccess(isolateMain)}($mainAccess)"; | |
| 1843 } | 1822 } |
| 1844 | 1823 |
| 1845 emitMain(CodeBuffer buffer) { | 1824 emitMain(CodeBuffer buffer) { |
| 1846 if (compiler.isMockCompilation) return; | 1825 if (compiler.isMockCompilation) return; |
| 1847 Element main = compiler.mainApp.find(Compiler.MAIN); | 1826 Element main = compiler.mainApp.find(Compiler.MAIN); |
| 1848 String mainCall = null; | 1827 String mainCall = null; |
| 1849 if (compiler.isolateHelperLibrary != null) { | 1828 if (compiler.hasIsolateSupport()) { |
| 1850 Element isolateMain = | 1829 Element isolateMain = |
| 1851 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE); | 1830 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE); |
| 1852 mainCall = buildIsolateSetup(buffer, main, isolateMain); | 1831 mainCall = buildIsolateSetup(buffer, main, isolateMain); |
| 1853 } else { | 1832 } else { |
| 1854 mainCall = '${namer.isolateAccess(main)}()'; | 1833 mainCall = '${namer.isolateAccess(main)}()'; |
| 1855 } | 1834 } |
| 1856 if (!compiler.enableMinification) { | 1835 if (!compiler.enableMinification) { |
| 1857 buffer.add(""" | 1836 buffer.add(""" |
| 1858 | 1837 |
| 1859 // | 1838 // |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 """; | 1998 """; |
| 2020 const String HOOKS_API_USAGE = """ | 1999 const String HOOKS_API_USAGE = """ |
| 2021 // The code supports the following hooks: | 2000 // The code supports the following hooks: |
| 2022 // dartPrint(message) - if this function is defined it is called | 2001 // dartPrint(message) - if this function is defined it is called |
| 2023 // instead of the Dart [print] method. | 2002 // instead of the Dart [print] method. |
| 2024 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2003 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 2025 // method will not be invoked directly. | 2004 // method will not be invoked directly. |
| 2026 // Instead, a closure that will invoke [main] is | 2005 // Instead, a closure that will invoke [main] is |
| 2027 // passed to [dartMainRunner]. | 2006 // passed to [dartMainRunner]. |
| 2028 """; | 2007 """; |
| OLD | NEW |