1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

LibJS: Use correct this value when callee is a with binding

If we're inside of a `with` statement scope, we have to take care to
extract the correct `this` value for use in calls when calling a method
on the binding object via an Identifier instead of a MemberExpression.

This makes Vue.js work way better in the bytecode VM. :^)

Also, 1 new pass on test262.
This commit is contained in:
Andreas Kling 2023-08-01 14:33:58 +02:00
parent e61fdd1dc6
commit e91bdedc93
4 changed files with 186 additions and 104 deletions

View file

@ -441,6 +441,29 @@ private:
size_t m_index;
};
class GetCalleeAndThisFromEnvironment final : public Instruction {
public:
explicit GetCalleeAndThisFromEnvironment(IdentifierTableIndex identifier, Register callee_reg, Register this_reg)
: Instruction(Type::GetCalleeAndThisFromEnvironment)
, m_identifier(identifier)
, m_callee_reg(callee_reg)
, m_this_reg(this_reg)
{
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
private:
IdentifierTableIndex m_identifier;
Register m_callee_reg;
Register m_this_reg;
Optional<EnvironmentCoordinate> mutable m_cached_environment_coordinate;
};
class GetVariable final : public Instruction {
public:
explicit GetVariable(IdentifierTableIndex identifier)