Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
=================================================================== |
--- sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (revision 16793) |
+++ sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (working copy) |
@@ -1145,13 +1145,18 @@ |
if (closure == null) return null; |
var function = JS('var', r'#.$identity', closure); |
if (JS('bool', r'!!#', function)) return function; |
+ // Fetch the current isolate in a local variable to prevent the |
+ // compiler from inlining its use in the following JS expression: |
+ // the current isolate may have changed so if we read it from the JS |
+ // closure, it leads to the wrong isolate. |
+ var currentIsolate = JS_CURRENT_ISOLATE(); |
function = JS("var", r"""function() { |
return #(#, #, #, arguments[0], arguments[1]); |
}""", |
DART_CLOSURE_TO_JS(invokeClosure), |
closure, |
- JS_CURRENT_ISOLATE(), |
+ currentIsolate, |
arity); |
JS('void', r'#.$identity = #', closure, function); |