فهرست منبع

LibJS/JIT: Compile the GetByValueWithThis instruction

Simon Wanner 1 سال پیش
والد
کامیت
b53277110e
3فایلهای تغییر یافته به همراه22 افزوده شده و 1 حذف شده
  1. 3 0
      Userland/Libraries/LibJS/Bytecode/Op.h
  2. 17 0
      Userland/Libraries/LibJS/JIT/Compiler.cpp
  3. 2 1
      Userland/Libraries/LibJS/JIT/Compiler.h

+ 3 - 0
Userland/Libraries/LibJS/Bytecode/Op.h

@@ -781,6 +781,9 @@ public:
     ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
     DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
 
+    Register base() const { return m_base; }
+    Register this_value() const { return m_this_value; }
+
 private:
     Register m_base;
     Register m_this_value;

+ 17 - 0
Userland/Libraries/LibJS/JIT/Compiler.cpp

@@ -1452,6 +1452,23 @@ void Compiler::compile_get_by_id_with_this(Bytecode::Op::GetByIdWithThis const&
     check_exception();
 }
 
+static Value cxx_get_by_value_with_this(VM& vm, Value property_key_value, Value base, Value this_value)
+{
+    auto object = TRY_OR_SET_EXCEPTION(base.to_object(vm));
+    auto property_key = TRY_OR_SET_EXCEPTION(property_key_value.to_property_key(vm));
+    return TRY_OR_SET_EXCEPTION(object->internal_get(property_key, this_value));
+}
+
+void Compiler::compile_get_by_value_with_this(Bytecode::Op::GetByValueWithThis const& op)
+{
+    load_vm_register(ARG1, Bytecode::Register::accumulator());
+    load_vm_register(ARG2, op.base());
+    load_vm_register(ARG3, op.this_value());
+    native_call((void*)cxx_get_by_value_with_this);
+    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

@@ -122,7 +122,8 @@ private:
         O(GetObjectPropertyIterator, get_object_property_iterator)               \
         O(GetPrivateById, get_private_by_id)                                     \
         O(ResolveSuperBase, resolve_super_base)                                  \
-        O(GetByIdWithThis, get_by_id_with_this)
+        O(GetByIdWithThis, get_by_id_with_this)                                  \
+        O(GetByValueWithThis, get_by_value_with_this)
 
 #    define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \
         void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);