mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:08:10 +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:
parent
6c81b90e5a
commit
87ac906ee6
8 changed files with 51 additions and 20 deletions
|
@ -150,12 +150,12 @@ ErrorOr<void> MarkupGenerator::date_to_html(Object const& date, StringBuilder& h
|
|||
ErrorOr<void> MarkupGenerator::trace_to_html(TracebackFrame const& traceback_frame, StringBuilder& html_output)
|
||||
{
|
||||
auto function_name = escape_html_entities(traceback_frame.function_name);
|
||||
auto [line, column, _] = traceback_frame.source_range.start;
|
||||
auto [line, column, _] = traceback_frame.source_range().start;
|
||||
auto get_filename_from_path = [&](StringView filename) -> StringView {
|
||||
auto last_slash_index = filename.find_last('/');
|
||||
return last_slash_index.has_value() ? filename.substring_view(*last_slash_index + 1) : filename;
|
||||
};
|
||||
auto filename = escape_html_entities(get_filename_from_path(traceback_frame.source_range.filename()));
|
||||
auto filename = escape_html_entities(get_filename_from_path(traceback_frame.source_range().filename()));
|
||||
auto trace = TRY(String::formatted("at {} ({}:{}:{})", function_name, filename, line, column));
|
||||
|
||||
TRY(html_output.try_appendff(" {}<br>", trace));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue