mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:57:44 +00:00
LibJS/JIT: Compile the HasPrivateId instruction
This commit is contained in:
parent
712c89dacf
commit
a16082c6a5
3 changed files with 26 additions and 1 deletions
|
@ -645,6 +645,8 @@ public:
|
|||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
IdentifierTableIndex property() const { return m_property; }
|
||||
|
||||
private:
|
||||
IdentifierTableIndex m_property;
|
||||
};
|
||||
|
|
|
@ -1596,6 +1596,28 @@ void Compiler::compile_get_new_target(Bytecode::Op::GetNewTarget const&)
|
|||
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||
}
|
||||
|
||||
static Value cxx_has_private_id(VM& vm, Value object, DeprecatedFlyString const& identifier)
|
||||
{
|
||||
if (!object.is_object())
|
||||
TRY_OR_SET_EXCEPTION(vm.throw_completion<TypeError>(ErrorType::InOperatorWithObject));
|
||||
|
||||
auto private_environment = vm.running_execution_context().private_environment;
|
||||
VERIFY(private_environment);
|
||||
auto private_name = private_environment->resolve_private_identifier(identifier);
|
||||
return Value(object.as_object().private_element_find(private_name) != nullptr);
|
||||
}
|
||||
|
||||
void Compiler::compile_has_private_id(Bytecode::Op::HasPrivateId const& op)
|
||||
{
|
||||
load_vm_register(ARG1, Bytecode::Register::accumulator());
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG2),
|
||||
Assembler::Operand::Imm(bit_cast<u64>(&m_bytecode_executable.get_identifier(op.property()))));
|
||||
native_call((void*)cxx_has_private_id);
|
||||
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||
check_exception();
|
||||
}
|
||||
|
||||
void Compiler::jump_to_exit()
|
||||
{
|
||||
m_assembler.jump(m_exit_label);
|
||||
|
|
|
@ -131,7 +131,8 @@ private:
|
|||
O(GetImportMeta, get_import_meta) \
|
||||
O(DeleteVariable, delete_variable) \
|
||||
O(GetMethod, get_method) \
|
||||
O(GetNewTarget, get_new_target)
|
||||
O(GetNewTarget, get_new_target) \
|
||||
O(HasPrivateId, has_private_id)
|
||||
|
||||
# define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \
|
||||
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue