LibJS: Clear compile-only data from SharedFunctionInstanceData

After successful bytecode compilation, the m_functions_to_initialize
and m_var_names_to_initialize_binding vectors are no longer needed
as they are only consumed by emit_function_declaration_instantiation()
during code generation.

Add clear_compile_inputs() to release these vectors post-compile,
and call it from both ECMAScriptFunctionObject::get_stack_frame_size()
and NativeJavaScriptBackedFunction::bytecode_executable() after their
respective lazy compilation succeeds.

Also add a pre-compile assertion in Generator::generate_from_function()
to verify we never try to compile the same function data twice, and a
VERIFY in ECMAScriptFunctionObject::ecmascript_code() to guard against
null dereference.
This commit is contained in:
Andreas Kling
2026-02-10 22:21:23 +01:00
committed by Andreas Kling
parent dab742ed84
commit 658ba1d023
Notes: github-actions[bot] 2026-02-11 23:01:58 +00:00
7 changed files with 20 additions and 4 deletions

View File

@@ -60,7 +60,11 @@ public:
[[nodiscard]] bool is_module_wrapper() const { return shared_data().m_is_module_wrapper; }
void set_is_module_wrapper(bool b) { const_cast<SharedFunctionInstanceData&>(shared_data()).m_is_module_wrapper = b; }
Statement const& ecmascript_code() const { return *shared_data().m_ecmascript_code; }
Statement const& ecmascript_code() const
{
VERIFY(shared_data().m_ecmascript_code);
return *shared_data().m_ecmascript_code;
}
[[nodiscard]] virtual FunctionParameters const& formal_parameters() const override { return *shared_data().m_formal_parameters; }
virtual Utf16String name_for_call_stack() const override;