Browse Source

LibJS/JIT: Compile the ResolveSuperBase instruction

Simon Wanner 1 year ago
parent
commit
ad81f49b02
2 changed files with 21 additions and 1 deletions
  1. 19 0
      Userland/Libraries/LibJS/JIT/Compiler.cpp
  2. 2 1
      Userland/Libraries/LibJS/JIT/Compiler.h

+ 19 - 0
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<FunctionEnvironment>(*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);

+ 2 - 1
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&);