From 06488477a98e67f53197588cb5a3000f3baab03d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jan 2017 02:17:10 -0500 Subject: [PATCH] Interpreter_Tables: Ensure all instructions fit within m_allInstruction at compile-time --- .../PowerPC/Interpreter/Interpreter_Tables.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp index 798c4bcd8a..eb1c62c9f8 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp @@ -4,7 +4,6 @@ #include -#include "Common/MsgHandler.h" #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/Interpreter/Interpreter_Tables.h" @@ -358,6 +357,15 @@ static std::array table63_2 = namespace InterpreterTables { +constexpr size_t TotalInstructionFunctionCount() +{ + return primarytable.size() + table4_2.size() + table4_3.size() + table4.size() + table31.size() + + table19.size() + table59.size() + table63.size() + table63_2.size(); +} + +static_assert(TotalInstructionFunctionCount() < m_allInstructions.size(), + "m_allInstructions is too small"); + void InitTables() { // once initialized, tables are read-only @@ -484,11 +492,6 @@ void InitTables() for (auto& tpl : table63_2) m_allInstructions[m_numInstructions++] = &tpl.opinfo; - if (m_numInstructions >= 512) - { - PanicAlert("m_allInstructions underdimensioned"); - } - initialized = true; } }