summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Error.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-05-28 08:28:43 +0200
committerAndreas Kling <kling@serenityos.org>2023-05-28 10:03:11 +0200
commit87ac906ee679043421f27617cc3822ebc9524622 (patch)
tree90fdcf14c778f51cda9a4a1a81a9ad6d9eb89d48 /Userland/Libraries/LibJS/Runtime/Error.h
parent6c81b90e5a06d6fb2164f6484c7e69b0492aa87f (diff)
downloadserenity-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/Libraries/LibJS/Runtime/Error.h')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Error.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Error.h b/Userland/Libraries/LibJS/Runtime/Error.h
index 26be07495f..cf9315dfc8 100644
--- a/Userland/Libraries/LibJS/Runtime/Error.h
+++ b/Userland/Libraries/LibJS/Runtime/Error.h
@@ -17,7 +17,14 @@ namespace JS {
struct TracebackFrame {
DeprecatedFlyString function_name;
- SourceRange source_range;
+ [[nodiscard]] SourceRange const& source_range() const;
+
+ struct UnrealizedSourceRange {
+ u32 start_offset { 0 };
+ u32 end_offset { 0 };
+ RefPtr<JS::SourceCode const> source_code;
+ };
+ mutable Variant<SourceRange, UnrealizedSourceRange> source_range_storage;
};
class Error : public Object {