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

LibJS/JIT: Support the NewString bytecode op

This necessitated making the JIT::Compiler aware of the current
Bytecode::Executable, since that's where all the string literals are
held, but that seems like a good thing.
This commit is contained in:
Andreas Kling 2023-10-18 12:55:00 +02:00
parent efe58ebf2f
commit c2fe7af095
3 changed files with 30 additions and 3 deletions

View file

@ -15,7 +15,7 @@ namespace JS::JIT {
class Compiler {
public:
static OwnPtr<NativeExecutable> compile(Bytecode::Executable const&);
static OwnPtr<NativeExecutable> compile(Bytecode::Executable&);
private:
static constexpr auto GPR0 = Assembler::Reg::RAX;
@ -46,6 +46,7 @@ private:
void compile_mul(Bytecode::Op::Mul const&);
void compile_div(Bytecode::Op::Div const&);
void compile_return(Bytecode::Op::Return const&);
void compile_new_string(Bytecode::Op::NewString const&);
void store_vm_register(Bytecode::Register, Assembler::Reg);
void load_vm_register(Assembler::Reg, Bytecode::Register);
@ -60,8 +61,14 @@ private:
void push_unwind_context(bool valid, Optional<Bytecode::Label> const& handler, Optional<Bytecode::Label> const& finalizer);
void pop_unwind_context();
explicit Compiler(Bytecode::Executable& bytecode_executable)
: m_bytecode_executable(bytecode_executable)
{
}
Vector<u8> m_output;
Assembler m_assembler { m_output };
Bytecode::Executable& m_bytecode_executable;
};
}