From c0c40110c10ed70655ca225ac84e6ab1166b2bf0 Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Sun, 29 Oct 2023 23:41:33 +0100 Subject: [PATCH] LibJS/JIT: Compile the ImportCall instruction --- Userland/Libraries/LibJS/Bytecode/Op.h | 3 +++ Userland/Libraries/LibJS/JIT/Compiler.cpp | 14 ++++++++++++++ Userland/Libraries/LibJS/JIT/Compiler.h | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 752595abe0..8bbe462fbd 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -338,6 +338,9 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + Register specifier() const { return m_specifier; } + Register options() const { return m_options; } + private: Register m_specifier; Register m_options; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 53f29264b8..24ca3d7aeb 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1527,6 +1527,20 @@ void Compiler::compile_put_private_by_id(Bytecode::Op::PutPrivateById const& op) check_exception(); } +static Value cxx_import_call(VM& vm, Value specifier, Value options) +{ + return TRY_OR_SET_EXCEPTION(perform_import_call(vm, specifier, options)); +} + +void Compiler::compile_import_call(Bytecode::Op::ImportCall const& op) +{ + load_vm_register(ARG1, op.specifier()); + load_vm_register(ARG2, op.options()); + native_call((void*)cxx_import_call); + 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 39e8fb84be..0db7cffc54 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -126,7 +126,8 @@ private: O(GetByValueWithThis, get_by_value_with_this) \ O(DeleteByIdWithThis, delete_by_id_with_this) \ O(PutByIdWithThis, put_by_id_with_this) \ - O(PutPrivateById, put_private_by_id) + O(PutPrivateById, put_private_by_id) \ + O(ImportCall, import_call) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);