Index: lib/isolate/frog/compiler_hooks.dart |
diff --git a/lib/isolate/frog/compiler_hooks.dart b/lib/isolate/frog/compiler_hooks.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..31f4d80eb61739f3b71a5ea92790c0e0c0ed2518 |
--- /dev/null |
+++ b/lib/isolate/frog/compiler_hooks.dart |
@@ -0,0 +1,31 @@ |
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+// This file contains functions that are used in the code generated by the frog |
+// compiler. |
+ |
+/** |
+ * Wrapper that takes the dart entry point and runs it within an isolate. The |
+ * frog compiler will inject a call of the form [: startRootIsolate(main); :] |
+ * when it determines that this wrapping is needed. For single-isolate |
+ * applications (e.g. hello world), this call is not emitted. |
+ */ |
+void startRootIsolate(entry) { |
+ globalState = new GlobalState(); |
+ |
+ // Don't start the main loop again, if we are in a worker. |
+ if (globalState.isWorker) return; |
+ final rootContext = new IsolateContext(); |
+ globalState.rootContext = rootContext; |
+ fillStatics(rootContext); |
+ |
+ // BUG(5151491): Setting currentContext should not be necessary, but |
+ // because closures passed to the DOM as event handlers do not bind their |
+ // isolate automatically we try to give them a reasonable context to live in |
+ // by having a "default" isolate (the first one created). |
+ globalState.currentContext = rootContext; |
+ |
+ rootContext.eval(entry); |
+ globalState.topEventLoop.run(); |
+} |