mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibJS: Put newly instantiated functions into locals more efficiently
- Don't allocate a separate register, store directly into the local. - Mark the local as initialized to avoid emitting TDZ checks.
This commit is contained in:
parent
6c70dc5f09
commit
904beef6d2
Notes:
github-actions[bot]
2025-03-27 19:51:28 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/904beef6d2d Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4122 Reviewed-by: https://github.com/LucasChollet
1 changed files with 7 additions and 4 deletions
|
@ -207,11 +207,14 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
|
|||
}
|
||||
|
||||
for (auto const& declaration : function.m_functions_to_initialize) {
|
||||
auto function = allocate_register();
|
||||
emit<Op::NewFunction>(function, declaration, OptionalNone {});
|
||||
if (declaration.name_identifier()->is_local()) {
|
||||
emit<Op::Mov>(local(declaration.name_identifier()->local_variable_index()), function);
|
||||
auto const& identifier = *declaration.name_identifier();
|
||||
if (identifier.is_local()) {
|
||||
auto local_index = identifier.local_variable_index();
|
||||
emit<Op::NewFunction>(local(local_index), declaration, OptionalNone {});
|
||||
set_local_initialized(local_index);
|
||||
} else {
|
||||
auto function = allocate_register();
|
||||
emit<Op::NewFunction>(function, declaration, OptionalNone {});
|
||||
emit<Op::SetVariableBinding>(intern_identifier(declaration.name()), function);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue