From ad81f49b026fe188151bcce11fe5aa3453d24b81 Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Sun, 29 Oct 2023 21:32:33 +0100 Subject: [PATCH] LibJS/JIT: Compile the ResolveSuperBase instruction --- Userland/Libraries/LibJS/JIT/Compiler.cpp | 19 +++++++++++++++++++ Userland/Libraries/LibJS/JIT/Compiler.h | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index d12fbf92b3..959edf2ac5 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1412,6 +1412,25 @@ void Compiler::compile_get_private_by_id(Bytecode::Op::GetPrivateById const& op) check_exception(); } +static Value cxx_resolve_super_base(VM& vm) +{ + // 1. Let env be GetThisEnvironment(). + auto& env = verify_cast(*get_this_environment(vm)); + + // 2. Assert: env.HasSuperBinding() is true. + VERIFY(env.has_super_binding()); + + // 3. Let baseValue be ? env.GetSuperBase(). + return TRY_OR_SET_EXCEPTION(env.get_super_base()); +} + +void Compiler::compile_resolve_super_base(Bytecode::Op::ResolveSuperBase const&) +{ + native_call((void*)cxx_resolve_super_base); + 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 41f6cb21de..f5ace1a888 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -120,7 +120,8 @@ private: O(DeleteByValue, delete_by_value) \ O(DeleteByValueWithThis, delete_by_value_with_this) \ O(GetObjectPropertyIterator, get_object_property_iterator) \ - O(GetPrivateById, get_private_by_id) + O(GetPrivateById, get_private_by_id) \ + O(ResolveSuperBase, resolve_super_base) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);