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

LibJS/JIT: Compile the ToNumeric bytecode instruction

This commit is contained in:
Andreas Kling 2023-10-20 12:27:31 +02:00
parent 0f735b3502
commit b2602a4bae
2 changed files with 17 additions and 0 deletions

View file

@ -386,6 +386,19 @@ void Compiler::compile_get_by_id(Bytecode::Op::GetById const& op)
check_exception();
}
static Value cxx_to_numeric(VM& vm, Value value)
{
return TRY_OR_SET_EXCEPTION(value.to_numeric(vm));
}
void Compiler::compile_to_numeric(Bytecode::Op::ToNumeric const&)
{
load_vm_register(ARG1, Bytecode::Register::accumulator());
m_assembler.native_call((void*)cxx_to_numeric);
store_vm_register(Bytecode::Register::accumulator(), RET);
check_exception();
}
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_executable)
{
if (getenv("LIBJS_NO_JIT"))
@ -453,6 +466,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
case Bytecode::Instruction::Type::GetById:
compiler.compile_get_by_id(static_cast<Bytecode::Op::GetById const&>(op));
break;
case Bytecode::Instruction::Type::ToNumeric:
compiler.compile_to_numeric(static_cast<Bytecode::Op::ToNumeric const&>(op));
break;
#define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
case Bytecode::Instruction::Type::TitleCaseName: \

View file

@ -41,6 +41,7 @@ private:
void compile_enter_unwind_context(Bytecode::Op::EnterUnwindContext const&);
void compile_leave_unwind_context(Bytecode::Op::LeaveUnwindContext const&);
void compile_throw(Bytecode::Op::Throw const&);
void compile_to_numeric(Bytecode::Op::ToNumeric const&);
#define DO_COMPILE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);