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

Unified Diff: sdk/lib/_internal/js_runtime/lib/isolate_helper.dart

Issue 1264543004: dart2js: Make sure '_globalState' is set before calling `computeThisScript`. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add comment. Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/isolate_helper.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/isolate_helper.dart b/sdk/lib/_internal/js_runtime/lib/isolate_helper.dart
index 5ff44bbc5f881fbeb560191959cdd340fa67b2dc..d022bb84dadbbfe9aeaadc42e5e4bea5b4f9e7ca 100644
--- a/sdk/lib/_internal/js_runtime/lib/isolate_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/isolate_helper.dart
@@ -103,6 +103,7 @@ void startRootIsolate(entry, args) {
throw new ArgumentError("Arguments to main must be a List: $args");
}
_globalState = new _Manager(entry);
+ _globalState._initialize();
// Don't start the main loop again, if we are in a worker.
if (_globalState.isWorker) return;
@@ -220,7 +221,9 @@ class _Manager {
/** The entry point given by [startRootIsolate]. */
final Function entry;
- _Manager(this.entry) {
+ _Manager(this.entry);
+
+ _initialize() {
_nativeDetectEnvironment();
topEventLoop = new _EventLoop();
isolates = new Map<int, _IsolateContext>();
@@ -235,6 +238,8 @@ class _Manager {
bool isWindowDefined = globalWindow != null;
bool isWorkerDefined = globalWorker != null;
+ // `isWorker` must be initialized now, since `IsolateNatives.thisScript`
+ // may access it.
isWorker = !isWindowDefined && globalPostMessageDefined;
supportsWorkers = isWorker
|| (isWorkerDefined && IsolateNatives.thisScript != null);
@@ -764,6 +769,8 @@ class IsolateNatives {
}
// A worker has no script tag - so get an url from a stack-trace.
if (_globalState.isWorker) return computeThisScriptFromTrace();
+ // An isolate that doesn't support workers, but doesn't have a
+ // currentScript either. This is most likely a Chrome extension.
return null;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698