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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/isolate_helper.dart

Issue 1130293002: dart2js: compute the currentScript in the preamble for d8 and jsshell. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/preambles/d8.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library _isolate_helper; 5 library _isolate_helper;
6 6
7 import 'dart:_js_embedded_names' show 7 import 'dart:_js_embedded_names' show
8 CLASS_ID_EXTRACTOR, 8 CLASS_ID_EXTRACTOR,
9 CLASS_FIELDS_EXTRACTOR, 9 CLASS_FIELDS_EXTRACTOR,
10 CREATE_NEW_ISOLATE, 10 CREATE_NEW_ISOLATE,
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 // TODO(herhut): Initialize this to false when able to track compile-time 746 // TODO(herhut): Initialize this to false when able to track compile-time
747 // constants. 747 // constants.
748 static var enableSpawnWorker; 748 static var enableSpawnWorker;
749 749
750 static String thisScript = computeThisScript(); 750 static String thisScript = computeThisScript();
751 751
752 /// Associates an ID with a native worker object. 752 /// Associates an ID with a native worker object.
753 static final Expando<int> workerIds = new Expando<int>(); 753 static final Expando<int> workerIds = new Expando<int>();
754 754
755 /** 755 /**
756 * The src url for the script tag that loaded this Used to create 756 * The src url for the script tag that loaded this function.
757 * JavaScript workers. 757 *
758 * Used to create JavaScript workers and load deferred libraries.
758 */ 759 */
759 static String computeThisScript() { 760 static String computeThisScript() {
760 var currentScript = JS_EMBEDDED_GLOBAL('', CURRENT_SCRIPT); 761 var currentScript = JS_EMBEDDED_GLOBAL('', CURRENT_SCRIPT);
floitsch 2015/05/07 21:09:51 The embedded global is set, if `document.currentSc
761 if (currentScript != null) { 762 if (currentScript != null) {
762 return JS('String', 'String(#.src)', currentScript); 763 return JS('String', 'String(#.src)', currentScript);
763 } 764 }
764 if (Primitives.isD8) return computeThisScriptD8();
herhut 2015/05/08 08:06:27 Do we still need the Primitives.isXX helpers? It w
floitsch 2015/05/09 01:07:54 Removed in https://codereview.chromium.org/1132923
765 if (Primitives.isJsshell) return computeThisScriptJsshell();
766 // A worker has no script tag - so get an url from a stack-trace. 765 // A worker has no script tag - so get an url from a stack-trace.
767 if (_globalState.isWorker) return computeThisScriptFromTrace(); 766 if (_globalState.isWorker) return computeThisScriptFromTrace();
768 return null; 767 return null;
769 } 768 }
770 769
771 static String computeThisScriptJsshell() {
772 return JS('String|Null', 'thisFilename()');
773 }
774
775 // TODO(ahe): The following is for supporting D8. We should move this code
776 // to a helper library that is only loaded when testing on D8.
777 static String computeThisScriptD8() => computeThisScriptFromTrace();
778
779 static String computeThisScriptFromTrace() { 770 static String computeThisScriptFromTrace() {
780 var stack = JS('String|Null', 'new Error().stack'); 771 var stack = JS('String|Null', 'new Error().stack');
781 if (stack == null) { 772 if (stack == null) {
782 // According to Internet Explorer documentation, the stack 773 // According to Internet Explorer documentation, the stack
783 // property is not set until the exception is thrown. The stack 774 // property is not set until the exception is thrown. The stack
784 // property was not provided until IE10. 775 // property was not provided until IE10.
785 stack = JS('String|Null', 776 stack = JS('String|Null',
786 '(function() {' 777 '(function() {'
787 'try { throw new Error() } catch(e) { return e.stack }' 778 'try { throw new Error() } catch(e) { return e.stack }'
788 '})()'); 779 '})()');
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 } 1442 }
1452 1443
1453 bool operator==(Object other) { 1444 bool operator==(Object other) {
1454 if (identical(other, this)) return true; 1445 if (identical(other, this)) return true;
1455 if (other is CapabilityImpl) { 1446 if (other is CapabilityImpl) {
1456 return identical(_id, other._id); 1447 return identical(_id, other._id);
1457 } 1448 }
1458 return false; 1449 return false;
1459 } 1450 }
1460 } 1451 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/preambles/d8.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698