1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:35:07 +00:00

LibJS: Make Error stack traces lazier

Instead of eagerly populating the stack trace with a textual
representation of every call frame, just store the raw source code range
(code, start offset, end offset). From that, we can generate the full
rich backtrace when requested, and save ourselves the trouble otherwise.

This makes test-wasm take ~7 seconds on my machine instead of ~60. :^)
This commit is contained in:
Andreas Kling 2023-05-28 08:28:43 +02:00
parent 6c81b90e5a
commit 87ac906ee6
8 changed files with 51 additions and 20 deletions

View file

@ -33,7 +33,7 @@ void report_exception_to_console(JS::Value value, JS::Realm& realm, ErrorInPromi
auto const& error_value = static_cast<JS::Error const&>(object);
for (auto& traceback_frame : error_value.traceback()) {
auto& function_name = traceback_frame.function_name;
auto& source_range = traceback_frame.source_range;
auto& source_range = traceback_frame.source_range();
dbgln(" {} at {}:{}:{}", function_name, source_range.filename(), source_range.start.line, source_range.start.column);
}
console.report_exception(error_value, error_in_promise == ErrorInPromise::Yes);