Przeglądaj źródła

LibJS/JIT: Compile the PutByValue bytecode instruction

Andreas Kling 1 rok temu
rodzic
commit
7097169967

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

@@ -772,6 +772,10 @@ public:
     ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
     DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
 
+    Register base() const { return m_base; }
+    Register property() const { return m_property; }
+    PropertyKind kind() const { return m_kind; }
+
 private:
     Register m_base;
     Register m_property;

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

@@ -567,6 +567,24 @@ void Compiler::compile_put_by_id(Bytecode::Op::PutById const& op)
     check_exception();
 }
 
+static Value cxx_put_by_value(VM& vm, Value base, Value property, Value value, Bytecode::Op::PropertyKind kind)
+{
+    TRY_OR_SET_EXCEPTION(Bytecode::put_by_value(vm, base, property, value, kind));
+    return {};
+}
+
+void Compiler::compile_put_by_value(Bytecode::Op::PutByValue const& op)
+{
+    load_vm_register(ARG1, op.base());
+    load_vm_register(ARG2, op.property());
+    load_vm_register(ARG3, Bytecode::Register::accumulator());
+    m_assembler.mov(
+        Assembler::Operand::Register(ARG4),
+        Assembler::Operand::Imm64(to_underlying(op.kind())));
+    m_assembler.native_call((void*)cxx_put_by_value);
+    check_exception();
+}
+
 static Value cxx_call(VM& vm, Value callee, u32 first_argument_index, u32 argument_count, Value this_value, Bytecode::Op::CallType call_type)
 {
     // FIXME: Uncomment this and deal with it.
@@ -728,6 +746,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
             case Bytecode::Instruction::Type::PutById:
                 compiler.compile_put_by_id(static_cast<Bytecode::Op::PutById const&>(op));
                 break;
+            case Bytecode::Instruction::Type::PutByValue:
+                compiler.compile_put_by_value(static_cast<Bytecode::Op::PutByValue const&>(op));
+                break;
             case Bytecode::Instruction::Type::ToNumeric:
                 compiler.compile_to_numeric(static_cast<Bytecode::Op::ToNumeric const&>(op));
                 break;

+ 1 - 0
Userland/Libraries/LibJS/JIT/Compiler.h

@@ -70,6 +70,7 @@ private:
     void compile_get_global(Bytecode::Op::GetGlobal const&);
 
     void compile_put_by_id(Bytecode::Op::PutById const&);
+    void compile_put_by_value(Bytecode::Op::PutByValue const&);
 
     void compile_call(Bytecode::Op::Call const&);
     void compile_typeof_variable(Bytecode::Op::TypeofVariable const&);