LibJS: Precompute the number of regs/constants/locals in Executable

Instead of doing it again on every call. Minor bump in call performance.
This commit is contained in:
Andreas Kling 2025-10-30 00:09:09 +01:00 committed by Andreas Kling
parent cdcbbcf48b
commit 6671cbef41
3 changed files with 5 additions and 1 deletions

View File

@ -92,6 +92,8 @@ public:
size_t number_of_registers { 0 };
bool is_strict_mode { false };
size_t registers_and_constants_and_locals_count { 0 };
struct ExceptionHandlers {
size_t start_offset;
size_t end_offset;

View File

@ -477,6 +477,8 @@ CodeGenerationErrorOr<GC::Ref<Executable>> Generator::compile(VM& vm, ASTNode co
executable->argument_index_base = number_of_registers + number_of_constants + number_of_locals;
executable->length_identifier = generator.m_length_identifier;
executable->registers_and_constants_and_locals_count = executable->number_of_registers + executable->constants.size() + executable->local_variable_names.size();
generator.m_finished = true;
return executable;

View File

@ -507,7 +507,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::get_stack_frame_size(size_t& r
executable = TRY(Bytecode::compile(vm(), *this));
}
}
registers_and_constants_and_locals_count = executable->number_of_registers + executable->constants.size() + executable->local_variable_names.size();
registers_and_constants_and_locals_count = executable->registers_and_constants_and_locals_count;
argument_count = max(argument_count, formal_parameters().size());
return {};
}