mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibJS/JIT: Compile the AsyncIteratorClose instruction
This commit is contained in:
parent
ac59e982a9
commit
a2b0154661
3 changed files with 28 additions and 1 deletions
|
@ -1411,6 +1411,9 @@ 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;
|
||||||
|
|
||||||
|
Completion::Type completion_type() const { return m_completion_type; }
|
||||||
|
Optional<Value> const& completion_value() const { return m_completion_value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Completion::Type m_completion_type { Completion::Type::Normal };
|
Completion::Type m_completion_type { Completion::Type::Normal };
|
||||||
Optional<Value> m_completion_value;
|
Optional<Value> m_completion_value;
|
||||||
|
|
|
@ -1717,6 +1717,29 @@ void Compiler::compile_copy_object_excluding_properties(Bytecode::Op::CopyObject
|
||||||
check_exception();
|
check_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_async_iterator_close(VM& vm, Value iterator, Completion::Type completion_type, Optional<Value> const& completion_value)
|
||||||
|
{
|
||||||
|
auto iterator_object = TRY_OR_SET_EXCEPTION(iterator.to_object(vm));
|
||||||
|
auto iterator_record = Bytecode::object_to_iterator(vm, iterator_object);
|
||||||
|
|
||||||
|
// FIXME: Return the value of the resulting completion. (Note that completion_value can be empty!)
|
||||||
|
TRY_OR_SET_EXCEPTION(async_iterator_close(vm, iterator_record, Completion { completion_type, completion_value, {} }));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_async_iterator_close(Bytecode::Op::AsyncIteratorClose const& op)
|
||||||
|
{
|
||||||
|
load_vm_register(ARG1, Bytecode::Register::accumulator());
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(ARG2),
|
||||||
|
Assembler::Operand::Imm(to_underlying(op.completion_type())));
|
||||||
|
m_assembler.mov(
|
||||||
|
Assembler::Operand::Register(ARG3),
|
||||||
|
Assembler::Operand::Imm(bit_cast<u64>(&op.completion_value())));
|
||||||
|
native_call((void*)cxx_async_iterator_close);
|
||||||
|
check_exception();
|
||||||
|
}
|
||||||
|
|
||||||
void Compiler::jump_to_exit()
|
void Compiler::jump_to_exit()
|
||||||
{
|
{
|
||||||
m_assembler.jump(m_exit_label);
|
m_assembler.jump(m_exit_label);
|
||||||
|
|
|
@ -139,7 +139,8 @@ private:
|
||||||
O(GetNewTarget, get_new_target) \
|
O(GetNewTarget, get_new_target) \
|
||||||
O(HasPrivateId, has_private_id) \
|
O(HasPrivateId, has_private_id) \
|
||||||
O(PutByValueWithThis, put_by_value_with_this) \
|
O(PutByValueWithThis, put_by_value_with_this) \
|
||||||
O(CopyObjectExcludingProperties, copy_object_excluding_properties)
|
O(CopyObjectExcludingProperties, copy_object_excluding_properties) \
|
||||||
|
O(AsyncIteratorClose, async_iterator_close)
|
||||||
|
|
||||||
# define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case, ...) \
|
# define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case, ...) \
|
||||||
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue