1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:38:10 +00:00

LibJS: Keep cached this value in a call frame register

Just moving more things to call frame registers..
This commit is contained in:
Andreas Kling 2023-09-26 14:42:30 +02:00
parent 3887b840a3
commit c833885fb5
5 changed files with 13 additions and 9 deletions

View file

@ -767,13 +767,14 @@ ThrowCompletionOr<void> Jump::execute_impl(Bytecode::Interpreter& interpreter) c
ThrowCompletionOr<void> ResolveThisBinding::execute_impl(Bytecode::Interpreter& interpreter) const
{
if (!interpreter.this_value().has_value()) {
auto& cached_this_value = interpreter.reg(Register::this_value());
if (cached_this_value.is_empty()) {
// OPTIMIZATION: Because the value of 'this' cannot be reassigned during a function execution, it's
// resolved once and then saved for subsequent use.
auto& vm = interpreter.vm();
interpreter.this_value() = TRY(vm.resolve_this_binding());
cached_this_value = TRY(vm.resolve_this_binding());
}
interpreter.accumulator() = interpreter.this_value().value();
interpreter.accumulator() = cached_this_value;
return {};
}