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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 11574032: Make unit testing of the compiler work with the new isolate helper library. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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) 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 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers); 1849 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers);
1850 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers); 1850 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers);
1851 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers); 1851 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers);
1852 } 1852 }
1853 1853
1854 String buildIsolateSetup(CodeBuffer buffer, 1854 String buildIsolateSetup(CodeBuffer buffer,
1855 Element appMain, 1855 Element appMain,
1856 Element isolateMain) { 1856 Element isolateMain) {
1857 String mainAccess = "${namer.isolateAccess(appMain)}"; 1857 String mainAccess = "${namer.isolateAccess(appMain)}";
1858 String currentIsolate = "${namer.CURRENT_ISOLATE}"; 1858 String currentIsolate = "${namer.CURRENT_ISOLATE}";
1859 String mainEnsureGetter = '';
1860 // Since we pass the closurized version of the main method to 1859 // Since we pass the closurized version of the main method to
1861 // the isolate method, we must make sure that it exists. 1860 // the isolate method, we must make sure that it exists.
1862 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { 1861 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) {
1863 Selector selector = new Selector.callClosure(0); 1862 Selector selector = new Selector.callClosure(0);
1864 String invocationName = "${namer.closureInvocationName(selector)}"; 1863 String invocationName = "${namer.closureInvocationName(selector)}";
1865 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; 1864 buffer.add("$mainAccess.$invocationName = $mainAccess");
1866 } 1865 }
1867 // TODO(ngeoffray): These globals are currently required by the isolate 1866 return "${namer.isolateAccess(isolateMain)}($mainAccess)";
1868 // library. They should be removed.
1869 buffer.add("""
1870 var \$globalThis = $currentIsolate;
1871 var \$globalState;
1872 var \$globals;
1873 var \$isWorker = false;
1874 var \$supportsWorkers = false;
1875 var \$thisScriptUrl;
1876 function \$static_init(){};
1877
1878 function \$initGlobals(context) {
1879 context.isolateStatics = new ${namer.isolateName}();
1880 }
1881 function \$setGlobals(context) {
1882 $currentIsolate = context.isolateStatics;
1883 \$globalThis = $currentIsolate;
1884 }
1885 $mainEnsureGetter
1886 """);
1887 return "${namer.isolateAccess(isolateMain)}($mainAccess)";
1888 } 1867 }
1889 1868
1890 emitMain(CodeBuffer buffer) { 1869 emitMain(CodeBuffer buffer) {
1891 if (compiler.isMockCompilation) return; 1870 if (compiler.isMockCompilation) return;
1892 Element main = compiler.mainApp.find(Compiler.MAIN); 1871 Element main = compiler.mainApp.find(Compiler.MAIN);
1893 String mainCall = null; 1872 String mainCall = null;
1894 if (compiler.isolateHelperLibrary != null) { 1873 if (compiler.hasIsolateSupport()) {
1895 Element isolateMain = 1874 Element isolateMain =
1896 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE); 1875 compiler.isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE);
1897 mainCall = buildIsolateSetup(buffer, main, isolateMain); 1876 mainCall = buildIsolateSetup(buffer, main, isolateMain);
1898 } else { 1877 } else {
1899 mainCall = '${namer.isolateAccess(main)}()'; 1878 mainCall = '${namer.isolateAccess(main)}()';
1900 } 1879 }
1901 if (!compiler.enableMinification) { 1880 if (!compiler.enableMinification) {
1902 buffer.add(""" 1881 buffer.add("""
1903 1882
1904 // 1883 //
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 """; 2060 """;
2082 const String HOOKS_API_USAGE = """ 2061 const String HOOKS_API_USAGE = """
2083 // The code supports the following hooks: 2062 // The code supports the following hooks:
2084 // dartPrint(message) - if this function is defined it is called 2063 // dartPrint(message) - if this function is defined it is called
2085 // instead of the Dart [print] method. 2064 // instead of the Dart [print] method.
2086 // dartMainRunner(main) - if this function is defined, the Dart [main] 2065 // dartMainRunner(main) - if this function is defined, the Dart [main]
2087 // method will not be invoked directly. 2066 // method will not be invoked directly.
2088 // Instead, a closure that will invoke [main] is 2067 // Instead, a closure that will invoke [main] is
2089 // passed to [dartMainRunner]. 2068 // passed to [dartMainRunner].
2090 """; 2069 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698