diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index f7c7a16141..5330751b11 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -313,6 +313,13 @@ void Compiler::compile_leave_unwind_context(Bytecode::Op::LeaveUnwindContext con pop_unwind_context(); } +void Compiler::compile_throw(Bytecode::Op::Throw const&) +{ + load_vm_register(GPR0, Bytecode::Register::accumulator()); + store_vm_register(Bytecode::Register::exception(), GPR0); + check_exception(); +} + OwnPtr Compiler::compile(Bytecode::Executable const& bytecode_executable) { if (getenv("LIBJS_NO_JIT")) @@ -371,6 +378,9 @@ OwnPtr Compiler::compile(Bytecode::Executable const& bytecode_ case Bytecode::Instruction::Type::LeaveUnwindContext: compiler.compile_leave_unwind_context(static_cast(op)); break; + case Bytecode::Instruction::Type::Throw: + compiler.compile_throw(static_cast(op)); + break; default: dbgln("JIT compilation failed: {}", bytecode_executable.name); dbgln("Unsupported bytecode op: {}", op.to_deprecated_string(bytecode_executable)); @@ -413,7 +423,8 @@ OwnPtr Compiler::compile(Bytecode::Executable const& bytecode_ } } - write(STDOUT_FILENO, compiler.m_output.data(), compiler.m_output.size()); + size_t res = write(STDOUT_FILENO, compiler.m_output.data(), compiler.m_output.size()); + if (!res) {} memcpy(executable_memory, compiler.m_output.data(), compiler.m_output.size()); mprotect(executable_memory, compiler.m_output.size(), PROT_READ | PROT_EXEC); diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index 368ca71480..5328edf72b 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -40,6 +40,7 @@ private: void compile_increment(Bytecode::Op::Increment const&); 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 store_vm_register(Bytecode::Register, Assembler::Reg); void load_vm_register(Assembler::Reg, Bytecode::Register);