From d247744a3ef7b8220149e00538e46b21be96b4d7 Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Sun, 29 Oct 2023 15:34:01 +0100 Subject: [PATCH] LibJS/JIT: Compile the SuperCallWithArgumentArray instruction --- Userland/Libraries/LibJS/Bytecode/Op.h | 2 ++ Userland/Libraries/LibJS/JIT/Compiler.cpp | 17 +++++++++++++++++ Userland/Libraries/LibJS/JIT/Compiler.h | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 633febe80e..0a66d77dad 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -989,6 +989,8 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + bool is_synthetic() const { return m_is_synthetic; } + private: bool m_is_synthetic; }; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 6d704069a1..e7cd1d01aa 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1178,6 +1178,23 @@ void Compiler::compile_block_declaration_instantiation(Bytecode::Op::BlockDeclar native_call((void*)cxx_block_declaration_instantiation); } +static Value cxx_super_call_with_argument_array(VM& vm, Value argument_array, bool is_synthetic) +{ + TRY_OR_SET_EXCEPTION(Bytecode::super_call_with_argument_array(vm, argument_array, is_synthetic)); + return {}; +} + +void Compiler::compile_super_call_with_argument_array(Bytecode::Op::SuperCallWithArgumentArray const& op) +{ + load_vm_register(ARG1, Bytecode::Register::accumulator()); + m_assembler.mov( + Assembler::Operand::Register(ARG2), + Assembler::Operand::Imm(static_cast(op.is_synthetic()))); + native_call((void*)cxx_super_call_with_argument_array); + store_vm_register(Bytecode::Register::accumulator(), RET); + check_exception(); +} + void Compiler::jump_to_exit() { m_assembler.jump(m_exit_label); diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index bb6d1d17f3..2e4ff585c7 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -104,7 +104,8 @@ private: O(SetVariable, set_variable) \ O(ContinuePendingUnwind, continue_pending_unwind) \ O(ConcatString, concat_string) \ - O(BlockDeclarationInstantiation, block_declaration_instantiation) + O(BlockDeclarationInstantiation, block_declaration_instantiation) \ + O(SuperCallWithArgumentArray, super_call_with_argument_array) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);