LibJS: Keep parsed function parameters in a shared data structure

Instead of making a copy of the Vector<FunctionParameter> from the AST
every time we instantiate an ECMAScriptFunctionObject, we now keep the
parameters in a ref-counted FunctionParameters object.

This reduces memory usage, and also allows us to cache the bytecode
executables for default parameter expressions without recompiling them
for every instantiation. :^)
This commit is contained in:
Andreas Kling 2025-03-27 12:59:50 +00:00 committed by Jelle Raaijmakers
commit 7477002e46
Notes: github-actions[bot] 2025-03-27 15:02:02 +00:00
11 changed files with 68 additions and 38 deletions

View file

@ -68,8 +68,8 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
}
auto const& formal_parameters = function.formal_parameters();
for (u32 param_index = 0; param_index < formal_parameters.size(); ++param_index) {
auto const& parameter = formal_parameters[param_index];
for (u32 param_index = 0; param_index < formal_parameters->size(); ++param_index) {
auto const& parameter = formal_parameters->parameters()[param_index];
if (parameter.is_rest) {
auto argument_reg = allocate_register();