diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 48979164e6..6a3f9df860 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -376,6 +376,13 @@ void Compiler::compile_div(Bytecode::Op::Div const& op) check_exception(); } +void Compiler::compile_return(Bytecode::Op::Return const&) +{ + load_vm_register(GPR0, Bytecode::Register::accumulator()); + store_vm_register(Bytecode::Register::return_value(), GPR0); + m_assembler.exit(); +} + OwnPtr Compiler::compile(Bytecode::Executable const& bytecode_executable) { if (getenv("LIBJS_NO_JIT")) @@ -449,6 +456,9 @@ OwnPtr Compiler::compile(Bytecode::Executable const& bytecode_ case Bytecode::Instruction::Type::Div: compiler.compile_div(static_cast(op)); break; + case Bytecode::Instruction::Type::Return: + compiler.compile_return(static_cast(op)); + break; default: dbgln("JIT compilation failed: {}", bytecode_executable.name); dbgln("Unsupported bytecode op: {}", op.to_deprecated_string(bytecode_executable)); diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index 597e4fac5b..88b9910db7 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -45,6 +45,7 @@ private: void compile_sub(Bytecode::Op::Sub const&); void compile_mul(Bytecode::Op::Mul const&); void compile_div(Bytecode::Op::Div const&); + void compile_return(Bytecode::Op::Return const&); void store_vm_register(Bytecode::Register, Assembler::Reg); void load_vm_register(Assembler::Reg, Bytecode::Register);