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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 11778064: Cleanup the isolate library to pave the way for web worker support. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (revision 16903)
+++ sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (working copy)
@@ -1145,14 +1145,21 @@
if (closure == null) return null;
var function = JS('var', r'#.$identity', closure);
if (JS('bool', r'!!#', function)) return function;
+ // By fetching the current isolate before creating the JavaScript
+ // function, we prevent the compiler from inlining its use in
+ // the JavaScript function below (the compiler generates code for
+ // fetching the isolate before creating the JavaScript function).
+ // If it was inlined, the JavaScript function would not get the
+ // current isolate, but the one that is active when the callback
+ // executes.
+ var currentIsolate = JS_CURRENT_ISOLATE();
- function = JS("var", r"""function() {
- return #(#, #, #, arguments[0], arguments[1]);
- }""",
- DART_CLOSURE_TO_JS(invokeClosure),
- closure,
- JS_CURRENT_ISOLATE(),
- arity);
+ function = JS("var",
+ r"""function(a, b) { return #(#, #, #, a, b); }""",
+ DART_CLOSURE_TO_JS(invokeClosure),
+ closure,
+ JS_CURRENT_ISOLATE(),
+ arity);
JS('void', r'#.$identity = #', closure, function);
return function;

Powered by Google App Engine
This is Rietveld 408576698