Browse Source

LibJS: Move Instruction::length() to the Op.h header

Make sure this gets inlined as well, as it's used by the bytecode
stream iterator and thus extremely hot.
Andreas Kling 4 years ago
parent
commit
a8ccc9580d

+ 0 - 18
Userland/Libraries/LibJS/Bytecode/Instruction.cpp

@@ -25,22 +25,4 @@ void Instruction::destroy(Instruction& instruction)
 #undef __BYTECODE_OP
 }
 
-size_t Instruction::length() const
-{
-    if (type() == Type::Call)
-        return static_cast<Op::Call const&>(*this).length();
-    else if (type() == Type::NewArray)
-        return static_cast<Op::NewArray const&>(*this).length();
-
-#define __BYTECODE_OP(op) \
-    case Type::op:        \
-        return sizeof(Op::op);
-
-    switch (type()) {
-        ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
-    default:
-        VERIFY_NOT_REACHED();
-    }
-}
-
 }

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

@@ -392,4 +392,23 @@ ALWAYS_INLINE void Instruction::execute(Bytecode::Interpreter& interpreter) cons
 #undef __BYTECODE_OP
 }
 
+ALWAYS_INLINE size_t Instruction::length() const
+{
+    if (type() == Type::Call)
+        return static_cast<Op::Call const&>(*this).length();
+    else if (type() == Type::NewArray)
+        return static_cast<Op::NewArray const&>(*this).length();
+
+#define __BYTECODE_OP(op) \
+    case Type::op:        \
+        return sizeof(Op::op);
+
+    switch (type()) {
+        ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
+    default:
+        VERIFY_NOT_REACHED();
+    }
+#undef __BYTECODE_OP
+}
+
 }