Browse Source

LibJS/Bytecode: Store Instruction length as u32

This makes every instruction 8 bytes smaller.
Andreas Kling 1 year ago
parent
commit
4cf4ea92a7

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

@@ -10,6 +10,13 @@
 
 namespace JS::Bytecode {
 
+Instruction::Instruction(Type type, size_t length)
+    : m_type(type)
+    , m_length(length)
+{
+    VERIFY(length <= NumericLimits<u32>::max());
+}
+
 void Instruction::destroy(Instruction& instruction)
 {
 #define __BYTECODE_OP(op)                        \

+ 2 - 6
Userland/Libraries/LibJS/Bytecode/Instruction.h

@@ -145,18 +145,14 @@ public:
     SourceRecord source_record() const { return m_source_record; }
 
 protected:
-    Instruction(Type type, size_t length)
-        : m_type(type)
-        , m_length(length)
-    {
-    }
+    Instruction(Type, size_t length);
 
     void visit_labels_impl(Function<void(Label&)>) { }
 
 private:
     SourceRecord m_source_record {};
     Type m_type {};
-    size_t m_length {};
+    u32 m_length {};
 };
 
 class InstructionStreamIterator {