mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 07:22:21 +00:00
LibJS: Cache arguments span in ExecutionContext
Allows us to avoid doing math in ExecutionContext::argument()
This commit is contained in:
parent
ff751173ac
commit
e48645c83f
Notes:
github-actions[bot]
2025-04-24 08:31:57 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: e48645c83f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4434
Reviewed-by: https://github.com/alimpfard
13 changed files with 24 additions and 31 deletions
|
@ -106,6 +106,7 @@ ExecutionContext::ExecutionContext(u32 registers_and_constants_and_locals_count,
|
|||
auto* registers_and_constants_and_locals_and_arguments = this->registers_and_constants_and_locals_and_arguments();
|
||||
for (size_t i = 0; i < registers_and_constants_and_locals_count; ++i)
|
||||
registers_and_constants_and_locals_and_arguments[i] = js_special_empty_value();
|
||||
arguments = { registers_and_constants_and_locals_and_arguments + arguments_offset, registers_and_constants_and_locals_and_arguments_count - arguments_offset };
|
||||
}
|
||||
|
||||
ExecutionContext::~ExecutionContext()
|
||||
|
@ -114,7 +115,7 @@ ExecutionContext::~ExecutionContext()
|
|||
|
||||
NonnullOwnPtr<ExecutionContext> ExecutionContext::copy() const
|
||||
{
|
||||
auto copy = create(registers_and_constants_and_locals_and_arguments_count, arguments().size());
|
||||
auto copy = create(registers_and_constants_and_locals_and_arguments_count, arguments.size());
|
||||
copy->function = function;
|
||||
copy->realm = realm;
|
||||
copy->script_or_module = script_or_module;
|
||||
|
@ -134,6 +135,7 @@ NonnullOwnPtr<ExecutionContext> ExecutionContext::copy() const
|
|||
copy->registers_and_constants_and_locals_and_arguments_count = registers_and_constants_and_locals_and_arguments_count;
|
||||
for (size_t i = 0; i < registers_and_constants_and_locals_and_arguments_count; ++i)
|
||||
copy->registers_and_constants_and_locals_and_arguments()[i] = registers_and_constants_and_locals_and_arguments()[i];
|
||||
copy->arguments = { copy->registers_and_constants_and_locals_and_arguments() + copy->arguments_offset, arguments.size() };
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue