mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 09:28:13 +00:00
LibJS/JIT: Compile the CreateVariable bytecode instruction
This commit is contained in:
parent
54f1f7a51b
commit
224f92f6e4
3 changed files with 44 additions and 0 deletions
|
@ -410,6 +410,12 @@ public:
|
|||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
IdentifierTableIndex identifier() const { return m_identifier; }
|
||||
EnvironmentMode mode() const { return m_mode; }
|
||||
bool is_immutable() const { return m_is_immutable; }
|
||||
bool is_global() const { return m_is_global; }
|
||||
bool is_strict() const { return m_is_strict; }
|
||||
|
||||
private:
|
||||
IdentifierTableIndex m_identifier;
|
||||
EnvironmentMode m_mode;
|
||||
|
|
|
@ -960,6 +960,39 @@ void Compiler::compile_typeof_variable(Bytecode::Op::TypeofVariable const& op)
|
|||
check_exception();
|
||||
}
|
||||
|
||||
static Value cxx_create_variable(
|
||||
VM& vm,
|
||||
DeprecatedFlyString const& name,
|
||||
Bytecode::Op::EnvironmentMode mode,
|
||||
bool is_global,
|
||||
bool is_immutable,
|
||||
bool is_strict)
|
||||
{
|
||||
TRY_OR_SET_EXCEPTION(Bytecode::create_variable(vm, name, mode, is_global, is_immutable, is_strict));
|
||||
return {};
|
||||
}
|
||||
|
||||
void Compiler::compile_create_variable(Bytecode::Op::CreateVariable const& op)
|
||||
{
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG1),
|
||||
Assembler::Operand::Imm(bit_cast<u64>(&m_bytecode_executable.get_identifier(op.identifier().value()))));
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG2),
|
||||
Assembler::Operand::Imm(to_underlying(op.mode())));
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG3),
|
||||
Assembler::Operand::Imm(static_cast<u64>(op.is_global())));
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG4),
|
||||
Assembler::Operand::Imm(static_cast<u64>(op.is_immutable())));
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG5),
|
||||
Assembler::Operand::Imm(static_cast<u64>(op.is_strict())));
|
||||
native_call((void*)cxx_create_variable);
|
||||
check_exception();
|
||||
}
|
||||
|
||||
static Value cxx_set_variable(
|
||||
VM& vm,
|
||||
DeprecatedFlyString const& identifier,
|
||||
|
@ -1208,6 +1241,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
|||
case Bytecode::Instruction::Type::ConcatString:
|
||||
compiler.compile_concat_string(static_cast<Bytecode::Op::ConcatString const&>(op));
|
||||
break;
|
||||
case Bytecode::Instruction::Type::CreateVariable:
|
||||
compiler.compile_create_variable(static_cast<Bytecode::Op::CreateVariable const&>(op));
|
||||
break;
|
||||
|
||||
# define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \
|
||||
case Bytecode::Instruction::Type::TitleCaseName: \
|
||||
|
|
|
@ -101,6 +101,8 @@ private:
|
|||
void compile_new_regexp(Bytecode::Op::NewRegExp const&);
|
||||
void compile_new_bigint(Bytecode::Op::NewBigInt const&);
|
||||
|
||||
void compile_create_variable(Bytecode::Op::CreateVariable const&);
|
||||
|
||||
void compile_get_by_id(Bytecode::Op::GetById const&);
|
||||
void compile_get_by_value(Bytecode::Op::GetByValue const&);
|
||||
void compile_get_global(Bytecode::Op::GetGlobal const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue