mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
LibJS/JIT: Compile the IteratorClose instruction
This commit is contained in:
parent
233502a10c
commit
c697ff61f6
3 changed files with 28 additions and 1 deletions
|
@ -1283,6 +1283,29 @@ void Compiler::compile_iterator_result_value(Bytecode::Op::IteratorResultValue c
|
|||
check_exception();
|
||||
}
|
||||
|
||||
static Value cxx_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 m_completion_value can be empty!)
|
||||
TRY_OR_SET_EXCEPTION(iterator_close(vm, iterator_record, Completion { completion_type, completion_value, {} }));
|
||||
return {};
|
||||
}
|
||||
|
||||
void Compiler::compile_iterator_close(Bytecode::Op::IteratorClose 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_iterator_close);
|
||||
check_exception();
|
||||
}
|
||||
|
||||
void Compiler::jump_to_exit()
|
||||
{
|
||||
m_assembler.jump(m_exit_label);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue