diff options
author | Andreas Kling <kling@serenityos.org> | 2023-05-28 08:28:43 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-28 10:03:11 +0200 |
commit | 87ac906ee679043421f27617cc3822ebc9524622 (patch) | |
tree | 90fdcf14c778f51cda9a4a1a81a9ad6d9eb89d48 /Userland/Applications | |
parent | 6c81b90e5a06d6fb2164f6484c7e69b0492aa87f (diff) | |
download | serenity-87ac906ee679043421f27617cc3822ebc9524622.zip |
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. :^)
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/Spreadsheet.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetModel.cpp | 8 |
3 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp b/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp index 1126dcd51f..7a2e0f2cee 100644 --- a/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp +++ b/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp @@ -36,7 +36,7 @@ void CellSyntaxHighlighter::rehighlight(Palette const& palette) if (m_cell && m_cell->thrown_value().has_value()) { if (auto value = m_cell->thrown_value().value(); value.is_object() && is<JS::Error>(value.as_object())) { auto& error = static_cast<JS::Error const&>(value.as_object()); - auto& range = error.traceback().first().source_range; + auto& range = error.traceback().first().source_range(); spans.prepend({ GUI::TextRange { { range.start.line - 1, range.start.column }, { range.end.line - 1, range.end.column } }, diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index f365ce94e9..1142574d35 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -70,7 +70,7 @@ Sheet::Sheet(Workbook& workbook) warnln(" with message '{}'", error.get_without_side_effects(interpreter().vm().names.message)); for (auto& traceback_frame : error.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); } } else { diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp index f1ca5fdf9e..cad08a711e 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -122,13 +122,13 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) StringBuilder builder; builder.appendff("{}\n", error.get_without_side_effects(object.vm().names.message).to_string_without_side_effects().release_value_but_fixme_should_propagate_errors()); for (auto const& frame : trace.in_reverse()) { - if (frame.source_range.filename().contains("runtime.js"sv)) { + if (frame.source_range().filename().contains("runtime.js"sv)) { if (frame.function_name == "<unknown>") - builder.appendff(" in a builtin function at line {}, column {}\n", frame.source_range.start.line, frame.source_range.start.column); + builder.appendff(" in a builtin function at line {}, column {}\n", frame.source_range().start.line, frame.source_range().start.column); else builder.appendff(" while evaluating builtin '{}'\n", frame.function_name); - } else if (frame.source_range.filename().starts_with("cell "sv)) { - builder.appendff(" in cell '{}', at line {}, column {}\n", frame.source_range.filename().substring_view(5), frame.source_range.start.line, frame.source_range.start.column); + } else if (frame.source_range().filename().starts_with("cell "sv)) { + builder.appendff(" in cell '{}', at line {}, column {}\n", frame.source_range().filename().substring_view(5), frame.source_range().start.line, frame.source_range().start.column); } } return builder.to_deprecated_string(); |