mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
LibJS: Make bytecode generation infallible
Remove CodeGenerationError and make all bytecode generation functions return their results directly instead of wrapping them in CodeGenerationErrorOr. For the few remaining sites where codegen encounters an unimplemented or unexpected AST node, we now use a new emit_todo() helper that emits a NewTypeError + Throw sequence at compile time (preserving the runtime behavior) and then switches to a dead basic block so subsequent codegen for the same function can continue without issue. This allows us to remove error handling from all callers of the bytecode compiler, simplifying the code significantly.
This commit is contained in:
parent
20f50d1f71
commit
7281091fdb
Notes:
github-actions[bot]
2026-02-12 10:39:25 +00:00
Author: https://github.com/awesomekling
Commit: 7281091fdb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7903
23 changed files with 469 additions and 556 deletions
|
|
@ -61,13 +61,12 @@ void NativeJavaScriptBackedFunction::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_shared_function_instance_data);
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> NativeJavaScriptBackedFunction::get_stack_frame_size(size_t& registers_and_locals_count, size_t& constants_count, size_t& argument_count)
|
||||
void NativeJavaScriptBackedFunction::get_stack_frame_size(size_t& registers_and_locals_count, size_t& constants_count, size_t& argument_count)
|
||||
{
|
||||
auto& bytecode_executable = this->bytecode_executable();
|
||||
registers_and_locals_count = bytecode_executable.registers_and_locals_count;
|
||||
constants_count = bytecode_executable.constants.size();
|
||||
argument_count = max(argument_count, m_shared_function_instance_data->m_function_length);
|
||||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> NativeJavaScriptBackedFunction::call()
|
||||
|
|
@ -99,7 +98,7 @@ Bytecode::Executable& NativeJavaScriptBackedFunction::bytecode_executable()
|
|||
{
|
||||
auto& executable = m_shared_function_instance_data->m_executable;
|
||||
if (!executable) {
|
||||
executable = MUST(Bytecode::compile(vm(), m_shared_function_instance_data, Bytecode::BuiltinAbstractOperationsEnabled::Yes));
|
||||
executable = Bytecode::compile(vm(), m_shared_function_instance_data, Bytecode::BuiltinAbstractOperationsEnabled::Yes);
|
||||
m_shared_function_instance_data->clear_compile_inputs();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue