diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index c52f4144a2..1fb3bd7a97 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -565,6 +565,33 @@ void Compiler::compile_typeof_variable(Bytecode::Op::TypeofVariable const& op) check_exception(); } +static Value cxx_set_variable( + VM& vm, + DeprecatedFlyString const& identifier, + Value value, + Bytecode::Op::EnvironmentMode environment_mode, + Bytecode::Op::SetVariable::InitializationMode initialization_mode) +{ + TRY_OR_SET_EXCEPTION(Bytecode::set_variable(vm, identifier, value, environment_mode, initialization_mode)); + return {}; +} + +void Compiler::compile_set_variable(Bytecode::Op::SetVariable const& op) +{ + m_assembler.mov( + Assembler::Operand::Register(ARG1), + Assembler::Operand::Imm64(bit_cast(&m_bytecode_executable.get_identifier(op.identifier().value())))); + load_vm_register(ARG2, Bytecode::Register::accumulator()); + m_assembler.mov( + Assembler::Operand::Register(ARG3), + Assembler::Operand::Imm64(to_underlying(op.mode()))); + m_assembler.mov( + Assembler::Operand::Register(ARG4), + Assembler::Operand::Imm64(to_underlying(op.initialization_mode()))); + m_assembler.native_call((void*)cxx_set_variable); + check_exception(); +} + OwnPtr Compiler::compile(Bytecode::Executable& bytecode_executable) { if (getenv("LIBJS_NO_JIT")) @@ -659,6 +686,9 @@ OwnPtr Compiler::compile(Bytecode::Executable& bytecode_execut case Bytecode::Instruction::Type::TypeofVariable: compiler.compile_typeof_variable(static_cast(op)); break; + case Bytecode::Instruction::Type::SetVariable: + compiler.compile_set_variable(static_cast(op)); + break; #define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \ case Bytecode::Instruction::Type::TitleCaseName: \ diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index eee4d6ec53..4ecbd53bd4 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -70,6 +70,7 @@ private: void compile_call(Bytecode::Op::Call const&); void compile_typeof_variable(Bytecode::Op::TypeofVariable const&); + void compile_set_variable(Bytecode::Op::SetVariable const&); void store_vm_register(Bytecode::Register, Assembler::Reg); void load_vm_register(Assembler::Reg, Bytecode::Register);