mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:07:35 +00:00
LibJS/JIT: Compile the Append instruction
This commit is contained in:
parent
516bb01082
commit
40064d872f
3 changed files with 22 additions and 1 deletions
|
@ -318,6 +318,9 @@ public:
|
|||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
Register lhs() const { return m_lhs; }
|
||||
bool is_spread() const { return m_is_spread; }
|
||||
|
||||
private:
|
||||
Register m_lhs;
|
||||
bool m_is_spread = false;
|
||||
|
|
|
@ -1319,6 +1319,23 @@ void Compiler::compile_iterator_to_array(Bytecode::Op::IteratorToArray const&)
|
|||
check_exception();
|
||||
}
|
||||
|
||||
static Value cxx_append(VM& vm, Value lhs, Value rhs, bool is_spread)
|
||||
{
|
||||
TRY_OR_SET_EXCEPTION(Bytecode::append(vm, lhs, rhs, is_spread));
|
||||
return {};
|
||||
}
|
||||
|
||||
void Compiler::compile_append(Bytecode::Op::Append const& op)
|
||||
{
|
||||
load_vm_register(ARG1, op.lhs());
|
||||
load_vm_register(ARG2, Bytecode::Register::accumulator());
|
||||
m_assembler.mov(
|
||||
Assembler::Operand::Register(ARG3),
|
||||
Assembler::Operand::Imm(static_cast<u64>(op.is_spread())));
|
||||
native_call((void*)cxx_append);
|
||||
check_exception();
|
||||
}
|
||||
|
||||
void Compiler::jump_to_exit()
|
||||
{
|
||||
m_assembler.jump(m_exit_label);
|
||||
|
|
|
@ -113,7 +113,8 @@ private:
|
|||
O(ThrowIfNullish, throw_if_nullish) \
|
||||
O(IteratorResultValue, iterator_result_value) \
|
||||
O(IteratorClose, iterator_close) \
|
||||
O(IteratorToArray, iterator_to_array)
|
||||
O(IteratorToArray, iterator_to_array) \
|
||||
O(Append, append)
|
||||
|
||||
# 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