Selaa lähdekoodia

LibX86: Don't build_opcode_table_if_needed() every instruction decode

Instead, just do this once at startup. :^)
Andreas Kling 5 vuotta sitten
vanhempi
commit
7ea36f5ed0
2 muutettua tiedostoa jossa 1 lisäystä ja 10 poistoa
  1. 1 7
      Libraries/LibX86/Instruction.cpp
  2. 0 3
      Libraries/LibX86/Instruction.h

+ 1 - 7
Libraries/LibX86/Instruction.cpp

@@ -257,12 +257,8 @@ static void build_0f_slash(u8 op, u8 slash, const char* mnemonic, InstructionFor
     build_slash(s_0f_table32, op, slash, mnemonic, format, impl, lock_prefix_allowed);
 }
 
-void Instruction::build_opcode_tables_if_needed()
+[[gnu::constructor]] static void build_opcode_tables()
 {
-    static bool has_built_tables = false;
-    if (has_built_tables)
-        return;
-
     build(0x00, "ADD", OP_RM8_reg8, &Interpreter::ADD_RM8_reg8, LockPrefixAllowed);
     build(0x01, "ADD", OP_RM16_reg16, &Interpreter::ADD_RM16_reg16, OP_RM32_reg32, &Interpreter::ADD_RM32_reg32, LockPrefixAllowed);
     build(0x02, "ADD", OP_reg8_RM8, &Interpreter::ADD_reg8_RM8, LockPrefixAllowed);
@@ -706,8 +702,6 @@ void Instruction::build_opcode_tables_if_needed()
     build_0f(0xFD, "PADDW", OP_mm1_mm2m64, &Interpreter::PADDW_mm1_mm2m64);
     build_0f(0xFE, "PADDD", OP_mm1_mm2m64, &Interpreter::PADDD_mm1_mm2m64);
     build_0f(0xFF, "UD0", OP, &Interpreter::UD0);
-
-    has_built_tables = true;
 }
 
 static const char* register_name(RegisterIndex8);

+ 0 - 3
Libraries/LibX86/Instruction.h

@@ -505,8 +505,6 @@ public:
 private:
     Instruction(InstructionStream&, bool o32, bool a32);
 
-    static void build_opcode_tables_if_needed();
-
     String to_string_internal(u32 origin, const SymbolProvider*, bool x32) const;
 
     const char* reg8_name() const;
@@ -788,7 +786,6 @@ ALWAYS_INLINE u32 MemoryOrRegisterReference::read32(CPU& cpu, const Instruction&
 
 ALWAYS_INLINE Instruction Instruction::from_stream(InstructionStream& stream, bool o32, bool a32)
 {
-    build_opcode_tables_if_needed();
     return Instruction(stream, o32, a32);
 }