mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Keep only a single active stack trace, enables traces for thrown non-exceptions
BUG= R=jmesserly@google.com Review URL: https://codereview.chromium.org/2545923002 .
This commit is contained in:
parent
4d7c536c2f
commit
1ff09b431f
|
@ -1899,14 +1899,12 @@ define([], function() {
|
|||
if (!condition) dart.throwAssertionError();
|
||||
};
|
||||
dart.throw = function(obj) {
|
||||
if (obj != null && (typeof obj == 'object' || typeof obj == 'function')) {
|
||||
dart._stack.set(obj, new Error());
|
||||
}
|
||||
dart._stack = new Error();
|
||||
throw obj;
|
||||
};
|
||||
dart.getError = function(exception) {
|
||||
var stack = dart._stack.get(exception);
|
||||
return stack !== void 0 ? stack : exception;
|
||||
var stack = dart._stack;
|
||||
return stack !== null ? stack : exception;
|
||||
};
|
||||
dart.stackPrint = function(exception) {
|
||||
var error = dart.getError(exception);
|
||||
|
@ -2664,7 +2662,7 @@ define([], function() {
|
|||
return false;
|
||||
});
|
||||
})();
|
||||
dart._stack = new WeakMap();
|
||||
dart._stack = null;
|
||||
dart._value = Symbol("_value");
|
||||
dart.constants = new Map();
|
||||
dart.constantLists = new Map();
|
||||
|
|
|
@ -1899,14 +1899,12 @@
|
|||
if (!condition) dart.throwAssertionError();
|
||||
};
|
||||
dart.throw = function(obj) {
|
||||
if (obj != null && (typeof obj == 'object' || typeof obj == 'function')) {
|
||||
dart._stack.set(obj, new Error());
|
||||
}
|
||||
dart._stack = new Error();
|
||||
throw obj;
|
||||
};
|
||||
dart.getError = function(exception) {
|
||||
var stack = dart._stack.get(exception);
|
||||
return stack !== void 0 ? stack : exception;
|
||||
var stack = dart._stack;
|
||||
return stack !== null ? stack : exception;
|
||||
};
|
||||
dart.stackPrint = function(exception) {
|
||||
var error = dart.getError(exception);
|
||||
|
@ -2664,7 +2662,7 @@
|
|||
return false;
|
||||
});
|
||||
})();
|
||||
dart._stack = new WeakMap();
|
||||
dart._stack = null;
|
||||
dart._value = Symbol("_value");
|
||||
dart.constants = new Map();
|
||||
dart.constantLists = new Map();
|
||||
|
|
|
@ -1897,14 +1897,12 @@ dart.assert = function(condition) {
|
|||
if (!condition) dart.throwAssertionError();
|
||||
};
|
||||
dart.throw = function(obj) {
|
||||
if (obj != null && (typeof obj == 'object' || typeof obj == 'function')) {
|
||||
dart._stack.set(obj, new Error());
|
||||
}
|
||||
dart._stack = new Error();
|
||||
throw obj;
|
||||
};
|
||||
dart.getError = function(exception) {
|
||||
var stack = dart._stack.get(exception);
|
||||
return stack !== void 0 ? stack : exception;
|
||||
var stack = dart._stack;
|
||||
return stack !== null ? stack : exception;
|
||||
};
|
||||
dart.stackPrint = function(exception) {
|
||||
var error = dart.getError(exception);
|
||||
|
@ -2662,7 +2660,7 @@ dart._ignoreTypeFailure = (() => {
|
|||
return false;
|
||||
});
|
||||
})();
|
||||
dart._stack = new WeakMap();
|
||||
dart._stack = null;
|
||||
dart._value = Symbol("_value");
|
||||
dart.constants = new Map();
|
||||
dart.constantLists = new Map();
|
||||
|
|
|
@ -1900,14 +1900,12 @@ dart_library.library('dart_sdk', null, /* Imports */[
|
|||
if (!condition) dart.throwAssertionError();
|
||||
};
|
||||
dart.throw = function(obj) {
|
||||
if (obj != null && (typeof obj == 'object' || typeof obj == 'function')) {
|
||||
dart._stack.set(obj, new Error());
|
||||
}
|
||||
dart._stack = new Error();
|
||||
throw obj;
|
||||
};
|
||||
dart.getError = function(exception) {
|
||||
var stack = dart._stack.get(exception);
|
||||
return stack !== void 0 ? stack : exception;
|
||||
var stack = dart._stack;
|
||||
return stack !== null ? stack : exception;
|
||||
};
|
||||
dart.stackPrint = function(exception) {
|
||||
var error = dart.getError(exception);
|
||||
|
@ -2665,7 +2663,7 @@ dart_library.library('dart_sdk', null, /* Imports */[
|
|||
return false;
|
||||
});
|
||||
})();
|
||||
dart._stack = new WeakMap();
|
||||
dart._stack = null;
|
||||
dart._value = Symbol("_value");
|
||||
dart.constants = new Map();
|
||||
dart.constantLists = new Map();
|
||||
|
|
Binary file not shown.
|
@ -275,8 +275,6 @@ define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'is', 'require'],
|
|||
'setter_no_getter_test_01_multi': skip_fail,
|
||||
'stack_overflow_stacktrace_test': skip_fail,
|
||||
'stack_overflow_test': skip_fail,
|
||||
'stack_trace_test': skip_fail,
|
||||
'stacktrace_rethrow_nonerror_test': skip_fail, // mismatch from Karma's file hash
|
||||
'stacktrace_rethrow_error_test_none_multi': skip_fail,
|
||||
'stacktrace_rethrow_error_test_withtraceparameter_multi': skip_fail,
|
||||
'stacktrace_test': skip_fail,
|
||||
|
@ -377,7 +375,6 @@ define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'is', 'require'],
|
|||
'regress_r21715_test': fail,
|
||||
'throw_half_surrogate_pair_test_02_multi': fail,
|
||||
'splay_tree_from_iterable_test': firefox_fail,
|
||||
'stacktrace_current_test': chrome_fail,
|
||||
'string_case_test_01_multi': firefox_fail,
|
||||
'string_fromcharcodes_test': skip_timeout,
|
||||
'string_operations_with_null_test': fail,
|
||||
|
|
|
@ -552,25 +552,20 @@ assert_(condition) => JS(
|
|||
if (!$condition) $throwAssertionError();
|
||||
})()''');
|
||||
|
||||
final _stack = JS('', 'new WeakMap()');
|
||||
var _stack = null;
|
||||
@JSExportName('throw')
|
||||
throw_(obj) => JS(
|
||||
'',
|
||||
'''(() => {
|
||||
if ($obj != null && (typeof $obj == 'object' || typeof $obj == 'function')) {
|
||||
// TODO(jmesserly): couldn't we store the most recent stack in a single
|
||||
// variable? There should only be one active stack trace. That would
|
||||
// allow it to work for things like strings and numbers.
|
||||
$_stack.set($obj, new Error());
|
||||
}
|
||||
$_stack = new Error();
|
||||
throw $obj;
|
||||
})()''');
|
||||
|
||||
getError(exception) => JS(
|
||||
'',
|
||||
'''(() => {
|
||||
var stack = $_stack.get($exception);
|
||||
return stack !== void 0 ? stack : $exception;
|
||||
var stack = $_stack;
|
||||
return stack !== null ? stack : $exception;
|
||||
})()''');
|
||||
|
||||
// This is a utility function: it is only intended to be called from dev
|
||||
|
|
Loading…
Reference in a new issue