diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 269afc5f32..c9172bd4f6 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -410,6 +410,12 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + IdentifierTableIndex identifier() const { return m_identifier; } + EnvironmentMode mode() const { return m_mode; } + bool is_immutable() const { return m_is_immutable; } + bool is_global() const { return m_is_global; } + bool is_strict() const { return m_is_strict; } + private: IdentifierTableIndex m_identifier; EnvironmentMode m_mode; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 86fad4e6e3..10a9507982 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -960,6 +960,39 @@ void Compiler::compile_typeof_variable(Bytecode::Op::TypeofVariable const& op) check_exception(); } +static Value cxx_create_variable( + VM& vm, + DeprecatedFlyString const& name, + Bytecode::Op::EnvironmentMode mode, + bool is_global, + bool is_immutable, + bool is_strict) +{ + TRY_OR_SET_EXCEPTION(Bytecode::create_variable(vm, name, mode, is_global, is_immutable, is_strict)); + return {}; +} + +void Compiler::compile_create_variable(Bytecode::Op::CreateVariable const& op) +{ + m_assembler.mov( + Assembler::Operand::Register(ARG1), + Assembler::Operand::Imm(bit_cast(&m_bytecode_executable.get_identifier(op.identifier().value())))); + m_assembler.mov( + Assembler::Operand::Register(ARG2), + Assembler::Operand::Imm(to_underlying(op.mode()))); + m_assembler.mov( + Assembler::Operand::Register(ARG3), + Assembler::Operand::Imm(static_cast(op.is_global()))); + m_assembler.mov( + Assembler::Operand::Register(ARG4), + Assembler::Operand::Imm(static_cast(op.is_immutable()))); + m_assembler.mov( + Assembler::Operand::Register(ARG5), + Assembler::Operand::Imm(static_cast(op.is_strict()))); + native_call((void*)cxx_create_variable); + check_exception(); +} + static Value cxx_set_variable( VM& vm, DeprecatedFlyString const& identifier, @@ -1208,6 +1241,9 @@ OwnPtr Compiler::compile(Bytecode::Executable& bytecode_execut case Bytecode::Instruction::Type::ConcatString: compiler.compile_concat_string(static_cast(op)); break; + case Bytecode::Instruction::Type::CreateVariable: + compiler.compile_create_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 f60f55266f..c23eff3d08 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -101,6 +101,8 @@ private: void compile_new_regexp(Bytecode::Op::NewRegExp const&); void compile_new_bigint(Bytecode::Op::NewBigInt const&); + void compile_create_variable(Bytecode::Op::CreateVariable const&); + void compile_get_by_id(Bytecode::Op::GetById const&); void compile_get_by_value(Bytecode::Op::GetByValue const&); void compile_get_global(Bytecode::Op::GetGlobal const&);