mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 17:02:56 +00:00
LibJS: Add file & line number to bytecode VM stack traces :^)
This works by adding source start/end offset to every bytecode instruction. In the future we can make this more efficient by keeping a map of bytecode ranges to source ranges in the Executable instead, but let's just get traces working first. Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
This commit is contained in:
parent
0b66656ca9
commit
1c06111cbd
Notes:
sideshowbarker
2024-07-16 21:39:23 +09:00
Author: https://github.com/awesomekling
Commit: 1c06111cbd
Pull-request: https://github.com/SerenityOS/serenity/pull/20905
16 changed files with 157 additions and 26 deletions
|
@ -24,6 +24,7 @@ CodeGenerationErrorOr<NonnullOwnPtr<Executable>> Generator::generate(ASTNode con
|
|||
{
|
||||
Generator generator;
|
||||
generator.switch_to_basic_block(generator.make_block());
|
||||
SourceLocationScope scope(generator, node);
|
||||
generator.m_enclosing_function_kind = enclosing_function_kind;
|
||||
if (generator.is_in_generator_or_async_function()) {
|
||||
// Immediately yield with no value.
|
||||
|
@ -69,6 +70,7 @@ CodeGenerationErrorOr<NonnullOwnPtr<Executable>> Generator::generate(ASTNode con
|
|||
.string_table = move(generator.m_string_table),
|
||||
.identifier_table = move(generator.m_identifier_table),
|
||||
.regex_table = move(generator.m_regex_table),
|
||||
.source_code = node.source_code(),
|
||||
.number_of_registers = generator.m_next_register,
|
||||
.is_strict_mode = is_strict_mode,
|
||||
});
|
||||
|
@ -92,6 +94,18 @@ Register Generator::allocate_register()
|
|||
return Register { m_next_register++ };
|
||||
}
|
||||
|
||||
Generator::SourceLocationScope::SourceLocationScope(Generator& generator, ASTNode const& node)
|
||||
: m_generator(generator)
|
||||
, m_previous_node(m_generator.m_current_ast_node)
|
||||
{
|
||||
m_generator.m_current_ast_node = &node;
|
||||
}
|
||||
|
||||
Generator::SourceLocationScope::~SourceLocationScope()
|
||||
{
|
||||
m_generator.m_current_ast_node = m_previous_node;
|
||||
}
|
||||
|
||||
Label Generator::nearest_continuable_scope() const
|
||||
{
|
||||
return m_continuable_scopes.last().bytecode_target;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue