mirror of
https://github.com/dart-lang/sdk
synced 2024-09-06 00:59:09 +00:00
[dart2wasm] Return JS string in StackTrace.current
Avoid copying JS string to Dart. The test co19/LibTest/convert/Latin1Codec_A01_t01 throws a lot of exceptions. Before this patch it runs in d8 in 4.1s, after it runs in 1.5s. Change-Id: I1b9bf06876d63e92c93a03cdbf14587e369978ad Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338400 Commit-Queue: Ömer Ağacan <omersa@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
f773c42087
commit
f67b219f0f
|
@ -16,14 +16,14 @@ class StackTrace {
|
|||
// Note: We remove the first two frames to prevent including
|
||||
// `getCurrentStackTrace` and `StackTrace.current`. On Chrome, the first
|
||||
// line is not a frame but a line with just "Error", which we also remove.
|
||||
return _StringStackTrace(JS<String>(r"""() => {
|
||||
return _StringStackTrace(JSStringImpl(JS<WasmExternRef?>(r"""() => {
|
||||
let stackString = new Error().stack.toString();
|
||||
let frames = stackString.split('\n');
|
||||
let drop = 2;
|
||||
if (frames[0] === 'Error') {
|
||||
drop += 1;
|
||||
}
|
||||
return stringToDartString(frames.slice(drop).join('\n'));
|
||||
}"""));
|
||||
return frames.slice(drop).join('\n');
|
||||
}""")));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue