mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibJS: Replace m_functions_to_initialize with pre-created data
Replace Vector<FunctionDeclaration const&> with a FunctionToInitialize struct that stores a pre-created SharedFunctionInstanceData, function name, and local index. The SharedFunctionInstanceData for each hoisted function is created eagerly during the parent's construction, removing the need to reference FunctionDeclaration AST nodes after construction.
This commit is contained in:
committed by
Andreas Kling
parent
7cc392551b
commit
d36521a698
Notes:
github-actions[bot]
2026-02-11 23:00:56 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/d36521a6987 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7896
@@ -123,8 +123,15 @@ SharedFunctionInstanceData::SharedFunctionInstanceData(
|
||||
scope_body->ensure_function_scope_data();
|
||||
auto const& function_scope_data = *scope_body->function_scope_data();
|
||||
|
||||
for (auto const& decl : function_scope_data.functions_to_initialize)
|
||||
m_functions_to_initialize.append(*decl);
|
||||
for (auto const& decl : function_scope_data.functions_to_initialize) {
|
||||
auto shared_data = decl->ensure_shared_data(vm);
|
||||
auto const& name_id = *decl->name_identifier();
|
||||
m_functions_to_initialize.append({
|
||||
.shared_data = shared_data,
|
||||
.name = decl->name(),
|
||||
.local = name_id.is_local() ? name_id.local_index() : Identifier::Local {},
|
||||
});
|
||||
}
|
||||
|
||||
if (!m_has_parameter_expressions && function_scope_data.has_function_named_arguments)
|
||||
m_arguments_object_needed = false;
|
||||
@@ -264,6 +271,8 @@ void SharedFunctionInstanceData::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_executable);
|
||||
for (auto& function : m_functions_to_initialize)
|
||||
visitor.visit(function.shared_data);
|
||||
m_class_field_initializer_name.visit([&](PropertyKey const& key) { key.visit_edges(visitor); }, [](auto&) {});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user