mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibJS/JIT: Compile the SetVariable bytecode instruction
This commit is contained in:
parent
393d90abe1
commit
6a16783c66
2 changed files with 31 additions and 0 deletions
|
@ -565,6 +565,33 @@ void Compiler::compile_typeof_variable(Bytecode::Op::TypeofVariable const& op)
|
||||||
check_exception();
|
check_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_set_variable(
|
||||||
|
VM& vm,
|
||||||
|
DeprecatedFlyString const& identifier,
|
||||||
|
Value value,
|
||||||
|
Bytecode::Op::EnvironmentMode environment_mode,
|
||||||
|
Bytecode::Op::SetVariable::InitializationMode initialization_mode)
|
||||||
|
{
|
||||||
|
TRY_OR_SET_EXCEPTION(Bytecode::set_variable(vm, identifier, value, environment_mode, initialization_mode));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_set_variable(Bytecode::Op::SetVariable const& op)
|
||||||
|
{
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(ARG1),
|
||||||
|
Assembler::Operand::Imm64(bit_cast<u64>(&m_bytecode_executable.get_identifier(op.identifier().value()))));
|
||||||
|
load_vm_register(ARG2, Bytecode::Register::accumulator());
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(ARG3),
|
||||||
|
Assembler::Operand::Imm64(to_underlying(op.mode())));
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(ARG4),
|
||||||
|
Assembler::Operand::Imm64(to_underlying(op.initialization_mode())));
|
||||||
|
m_assembler.native_call((void*)cxx_set_variable);
|
||||||
|
check_exception();
|
||||||
|
}
|
||||||
|
|
||||||
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_executable)
|
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_executable)
|
||||||
{
|
{
|
||||||
if (getenv("LIBJS_NO_JIT"))
|
if (getenv("LIBJS_NO_JIT"))
|
||||||
|
@ -659,6 +686,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
case Bytecode::Instruction::Type::TypeofVariable:
|
case Bytecode::Instruction::Type::TypeofVariable:
|
||||||
compiler.compile_typeof_variable(static_cast<Bytecode::Op::TypeofVariable const&>(op));
|
compiler.compile_typeof_variable(static_cast<Bytecode::Op::TypeofVariable const&>(op));
|
||||||
break;
|
break;
|
||||||
|
case Bytecode::Instruction::Type::SetVariable:
|
||||||
|
compiler.compile_set_variable(static_cast<Bytecode::Op::SetVariable const&>(op));
|
||||||
|
break;
|
||||||
|
|
||||||
#define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
#define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
||||||
case Bytecode::Instruction::Type::TitleCaseName: \
|
case Bytecode::Instruction::Type::TitleCaseName: \
|
||||||
|
|
|
@ -70,6 +70,7 @@ private:
|
||||||
|
|
||||||
void compile_call(Bytecode::Op::Call const&);
|
void compile_call(Bytecode::Op::Call const&);
|
||||||
void compile_typeof_variable(Bytecode::Op::TypeofVariable const&);
|
void compile_typeof_variable(Bytecode::Op::TypeofVariable const&);
|
||||||
|
void compile_set_variable(Bytecode::Op::SetVariable 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