1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:57:45 +00:00

LibJS: Lazily collect stack trace information

The previous implementation was calling `backtrace()` for every
function call, which is quite slow.

Instead, this implementation provides VM::stack_trace() which unwinds
the native stack, maps it through NativeExecutable::get_source_range
and combines it with source ranges from interpreted call frames.
This commit is contained in:
Simon Wanner 2023-11-01 00:39:28 +01:00 committed by Andreas Kling
parent 77dc7c4d36
commit 68f4d21de2
11 changed files with 96 additions and 46 deletions

View file

@ -254,6 +254,8 @@ public:
// NOTE: This is meant as a temporary stopgap until everything is bytecode.
ThrowCompletionOr<Value> execute_ast_node(ASTNode const&);
Vector<StackTraceElement> stack_trace() const;
private:
using ErrorMessages = AK::Array<String, to_underlying(ErrorMessage::__Count)>;
@ -277,6 +279,8 @@ private:
void set_well_known_symbols(WellKnownSymbols well_known_symbols) { m_well_known_symbols = move(well_known_symbols); }
Vector<FlatPtr> get_native_stack_trace() const;
HashMap<String, GCPtr<PrimitiveString>> m_string_cache;
HashMap<DeprecatedString, GCPtr<PrimitiveString>> m_deprecated_string_cache;