mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:17:35 +00:00
LibJS/JIT: Compile the TypeofLocal bytecode instruction
This commit is contained in:
parent
a645b9c6c3
commit
17b2c7d965
3 changed files with 18 additions and 0 deletions
|
@ -1447,6 +1447,8 @@ public:
|
||||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||||
|
|
||||||
|
size_t index() const { return m_index; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_index;
|
size_t m_index;
|
||||||
};
|
};
|
||||||
|
|
|
@ -100,6 +100,18 @@ void Compiler::compile_set_local(Bytecode::Op::SetLocal const& op)
|
||||||
store_vm_local(op.index(), GPR0);
|
store_vm_local(op.index(), GPR0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_typeof_local(VM& vm, Value value)
|
||||||
|
{
|
||||||
|
return PrimitiveString::create(vm, value.typeof());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_typeof_local(Bytecode::Op::TypeofLocal const& op)
|
||||||
|
{
|
||||||
|
load_vm_local(ARG1, op.index());
|
||||||
|
m_assembler.native_call((void*)cxx_typeof_local);
|
||||||
|
store_vm_register(Bytecode::Register::accumulator(), GPR0);
|
||||||
|
}
|
||||||
|
|
||||||
void Compiler::compile_jump(Bytecode::Op::Jump const& op)
|
void Compiler::compile_jump(Bytecode::Op::Jump const& op)
|
||||||
{
|
{
|
||||||
m_assembler.jump(label_for(op.true_target()->block()));
|
m_assembler.jump(label_for(op.true_target()->block()));
|
||||||
|
@ -937,6 +949,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
case Bytecode::Instruction::Type::SetLocal:
|
case Bytecode::Instruction::Type::SetLocal:
|
||||||
compiler.compile_set_local(static_cast<Bytecode::Op::SetLocal const&>(op));
|
compiler.compile_set_local(static_cast<Bytecode::Op::SetLocal const&>(op));
|
||||||
break;
|
break;
|
||||||
|
case Bytecode::Instruction::Type::TypeofLocal:
|
||||||
|
compiler.compile_typeof_local(static_cast<Bytecode::Op::TypeofLocal const&>(op));
|
||||||
|
break;
|
||||||
case Bytecode::Instruction::Type::Jump:
|
case Bytecode::Instruction::Type::Jump:
|
||||||
compiler.compile_jump(static_cast<Bytecode::Op::Jump const&>(op));
|
compiler.compile_jump(static_cast<Bytecode::Op::Jump const&>(op));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -42,6 +42,7 @@ private:
|
||||||
void compile_store(Bytecode::Op::Store const&);
|
void compile_store(Bytecode::Op::Store const&);
|
||||||
void compile_get_local(Bytecode::Op::GetLocal const&);
|
void compile_get_local(Bytecode::Op::GetLocal const&);
|
||||||
void compile_set_local(Bytecode::Op::SetLocal const&);
|
void compile_set_local(Bytecode::Op::SetLocal const&);
|
||||||
|
void compile_typeof_local(Bytecode::Op::TypeofLocal const&);
|
||||||
void compile_jump(Bytecode::Op::Jump const&);
|
void compile_jump(Bytecode::Op::Jump const&);
|
||||||
void compile_jump_conditional(Bytecode::Op::JumpConditional const&);
|
void compile_jump_conditional(Bytecode::Op::JumpConditional const&);
|
||||||
void compile_increment(Bytecode::Op::Increment const&);
|
void compile_increment(Bytecode::Op::Increment const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue