mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibJS/JIT: Add support for "throw" keyword
This commit is contained in:
parent
ed0d2bce83
commit
891b071654
2 changed files with 13 additions and 1 deletions
|
@ -313,6 +313,13 @@ void Compiler::compile_leave_unwind_context(Bytecode::Op::LeaveUnwindContext con
|
||||||
pop_unwind_context();
|
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<NativeExecutable> Compiler::compile(Bytecode::Executable const& bytecode_executable)
|
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable const& bytecode_executable)
|
||||||
{
|
{
|
||||||
if (getenv("LIBJS_NO_JIT"))
|
if (getenv("LIBJS_NO_JIT"))
|
||||||
|
@ -371,6 +378,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable const& bytecode_
|
||||||
case Bytecode::Instruction::Type::LeaveUnwindContext:
|
case Bytecode::Instruction::Type::LeaveUnwindContext:
|
||||||
compiler.compile_leave_unwind_context(static_cast<Bytecode::Op::LeaveUnwindContext const&>(op));
|
compiler.compile_leave_unwind_context(static_cast<Bytecode::Op::LeaveUnwindContext const&>(op));
|
||||||
break;
|
break;
|
||||||
|
case Bytecode::Instruction::Type::Throw:
|
||||||
|
compiler.compile_throw(static_cast<Bytecode::Op::Throw const&>(op));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
dbgln("JIT compilation failed: {}", bytecode_executable.name);
|
dbgln("JIT compilation failed: {}", bytecode_executable.name);
|
||||||
dbgln("Unsupported bytecode op: {}", op.to_deprecated_string(bytecode_executable));
|
dbgln("Unsupported bytecode op: {}", op.to_deprecated_string(bytecode_executable));
|
||||||
|
@ -413,7 +423,8 @@ OwnPtr<NativeExecutable> 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());
|
memcpy(executable_memory, compiler.m_output.data(), compiler.m_output.size());
|
||||||
mprotect(executable_memory, compiler.m_output.size(), PROT_READ | PROT_EXEC);
|
mprotect(executable_memory, compiler.m_output.size(), PROT_READ | PROT_EXEC);
|
||||||
|
|
|
@ -40,6 +40,7 @@ private:
|
||||||
void compile_increment(Bytecode::Op::Increment const&);
|
void compile_increment(Bytecode::Op::Increment const&);
|
||||||
void compile_enter_unwind_context(Bytecode::Op::EnterUnwindContext const&);
|
void compile_enter_unwind_context(Bytecode::Op::EnterUnwindContext const&);
|
||||||
void compile_leave_unwind_context(Bytecode::Op::LeaveUnwindContext 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 store_vm_register(Bytecode::Register, Assembler::Reg);
|
||||||
void load_vm_register(Assembler::Reg, Bytecode::Register);
|
void load_vm_register(Assembler::Reg, Bytecode::Register);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue