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

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

Issue 2667813002: Optimize StackTrace.current Eliminate redundant call to captureStackTrace and compute the stack tra… (Closed)
Patch Set: for discussion Created 3 years, 10 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 | sdk/lib/convert/line_splitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/core_patch.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/core_patch.dart b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
index af96764c5665553988c70778e3e1b16191570c6b..e5e76bfa6478fc459621dd449463ed15e6fbaab9 100644
--- a/sdk/lib/_internal/js_runtime/lib/core_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
@@ -687,17 +687,18 @@ Uri _resolvePackageUri(Uri packageUri) {
return resolved;
}
+bool _hasErrorStackProperty = JS('bool', 'new Error().stack != void 0');
+
@patch
class StackTrace {
@patch
@NoInline()
static StackTrace get current {
- if (JS('', 'Error.captureStackTrace') != null) {
- var error = JS('', 'new Error()');
- JS('void', 'Error.captureStackTrace(#)', error);
- return getTraceFromException(error);
+ if (_hasErrorStackProperty) {
+ return getTraceFromException(JS('', 'new Error()'));
}
- // Fallback if Error.captureStackTrace does not exist.
+ // Fallback if new Error().stack does not exist.
+ // Currently only required for IE 11.
try {
throw '';
} catch (_, stackTrace) {
« no previous file with comments | « no previous file | sdk/lib/convert/line_splitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698