Chromium Code Reviews| Index: dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart |
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart b/dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart |
| index d25c058fbc80ad2449528eb3a4cd616d56953a0c..8efe55851492336dc38467b2ead0cf14cc75f579 100644 |
| --- a/dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart |
| +++ b/dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart |
| @@ -12,7 +12,9 @@ import 'dart:_js_helper' show convertDartClosureToJS, |
| import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, |
| JS, |
| JS_CREATE_ISOLATE, |
| - JS_SET_CURRENT_ISOLATE; |
| + JS_CURRENT_ISOLATE, |
| + JS_SET_CURRENT_ISOLATE, |
| + IsolateContext; |
| ReceivePort lazyPort; |
| @@ -202,7 +204,7 @@ class _Manager { |
| } |
| /** Context information tracked for each isolate. */ |
| -class _IsolateContext { |
| +class _IsolateContext implements IsolateContext { |
| /** Current isolate id. */ |
| int id; |
| @@ -406,19 +408,21 @@ class IsolateNatives { |
| * JavaScript workers. |
| */ |
| static String computeThisScript() { |
| - // TODO(ahe): The following works in Firefox during loading of the |
| - // script, and is being considered for the standard. |
| - // if (JS('String', 'typeof document') == 'object') { |
| - // var currentScript = JS('', 'document.currentScript'); |
| - // if (JS('String', 'typeof #', currentScript) == 'object') { |
| - // return JS('String', '#.src', currentScript); |
| - // } |
| - // } |
| + var currentScript = |
| + JS('', r'#.$currentScript', JS_CURRENT_ISOLATE().isolateStatics); |
| + if (currentScript != null) { |
| + return JS('String', 'String(#.src)', currentScript); |
| + } |
| + |
| + // TODO(ahe): The following is for supporting command-line engines |
| + // such as d8 and jsshell. We should move this code to a helper |
| + // library that is only loaded when testing on those engines. |
| var stack = JS('String|Null', 'new Error().stack'); |
| if (stack == null) { |
| // According to Internet Explorer documentation, the stack |
| - // property is not set until the exception is thrown. |
| + // property is not set until the exception is thrown. The stack |
| + // property was not provided until IE10. |
|
ngeoffray
2013/02/19 15:22:26
But this code is just relevant to command line eng
ahe
2013/02/19 15:50:37
This comment is correct, and should help people un
ngeoffray
2013/02/19 16:00:02
Even if it's correct, it is confusing, because it'
ahe
2013/02/19 16:33:35
Now I have a problem. I certainly don't want to cr
|
| stack = JS('String', |
| '(function() {' |
| 'try { throw new Error() } catch(e) { return e.stack }' |