1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

LibJS/JIT: Compile the TypeofVariable bytecode instruction

This commit is contained in:
Andreas Kling 2023-10-21 15:26:03 +02:00
parent d368dc5d25
commit e946440ed3
3 changed files with 21 additions and 0 deletions

View file

@ -1418,6 +1418,8 @@ public:
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
private: private:
IdentifierTableIndex m_identifier; IdentifierTableIndex m_identifier;
}; };

View file

@ -550,6 +550,21 @@ void Compiler::compile_call(Bytecode::Op::Call const& op)
check_exception(); check_exception();
} }
static Value cxx_typeof_variable(VM& vm, DeprecatedFlyString const& identifier)
{
return TRY_OR_SET_EXCEPTION(Bytecode::typeof_variable(vm, identifier));
}
void Compiler::compile_typeof_variable(Bytecode::Op::TypeofVariable const& op)
{
m_assembler.mov(
Assembler::Operand::Register(ARG1),
Assembler::Operand::Imm64(bit_cast<u64>(&m_bytecode_executable.get_identifier(op.identifier().value()))));
m_assembler.native_call((void*)cxx_typeof_variable);
store_vm_register(Bytecode::Register::accumulator(), RET);
check_exception();
}
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_executable) OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_executable)
{ {
if (getenv("LIBJS_NO_JIT")) if (getenv("LIBJS_NO_JIT"))
@ -641,6 +656,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
case Bytecode::Instruction::Type::Call: case Bytecode::Instruction::Type::Call:
compiler.compile_call(static_cast<Bytecode::Op::Call const&>(op)); compiler.compile_call(static_cast<Bytecode::Op::Call const&>(op));
break; break;
case Bytecode::Instruction::Type::TypeofVariable:
compiler.compile_typeof_variable(static_cast<Bytecode::Op::TypeofVariable const&>(op));
break;
#define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \ #define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
case Bytecode::Instruction::Type::TitleCaseName: \ case Bytecode::Instruction::Type::TitleCaseName: \

View file

@ -69,6 +69,7 @@ private:
void compile_put_by_id(Bytecode::Op::PutById const&); void compile_put_by_id(Bytecode::Op::PutById const&);
void compile_call(Bytecode::Op::Call const&); void compile_call(Bytecode::Op::Call const&);
void compile_typeof_variable(Bytecode::Op::TypeofVariable const&);
void store_vm_register(Bytecode::Register, Assembler::Reg); void store_vm_register(Bytecode::Register, Assembler::Reg);
void load_vm_register(Assembler::Reg, Bytecode::Register); void load_vm_register(Assembler::Reg, Bytecode::Register);