From 714633f311c0cf029e65a07ad55386bb393a6b45 Mon Sep 17 00:00:00 2001 From: Jordan Cristiano Date: Thu, 14 Nov 2013 22:23:55 -0500 Subject: [PATCH] Fixed console commands not registering. Code cleanup. --- Source/Core/Core/Src/Console.cpp | 9 ++- Source/Core/Core/Src/PowerPC/PPCTables.cpp | 69 +++++++++++----------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Source/Core/Core/Src/Console.cpp b/Source/Core/Core/Src/Console.cpp index 15a19b4b74..2d48d0b5c6 100644 --- a/Source/Core/Core/Src/Console.cpp +++ b/Source/Core/Core/Src/Console.cpp @@ -17,8 +17,8 @@ #include "PowerPCDisasm.h" #include "Console.h" -#define CASE1(x) if (memcmp(cmd, x, 2*sizeof(TCHAR))==0) -#define CASE(x) else if (memcmp(cmd, x, 4*sizeof(TCHAR))==0) +#define CASE1(x) if (!strcmp(cmd, (x))) +#define CASE(x) else if (!strcmp(cmd, (x))) void Console_Submit(const char *cmd) { @@ -27,7 +27,7 @@ void Console_Submit(const char *cmd) Core::StartTrace(false); INFO_LOG(CONSOLE, "Read tracing started."); } - CASE1("w") + CASE("w") { Core::StartTrace(true); INFO_LOG(CONSOLE, "Write tracing started."); @@ -141,3 +141,6 @@ void Console_Submit(const char *cmd) ERROR_LOG(CONSOLE, "Invalid command"); } } + +#undef CASE1 +#undef CASE diff --git a/Source/Core/Core/Src/PowerPC/PPCTables.cpp b/Source/Core/Core/Src/PowerPC/PPCTables.cpp index 625e416299..5854f1f0da 100644 --- a/Source/Core/Core/Src/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/Src/PowerPC/PPCTables.cpp @@ -14,24 +14,15 @@ #include "Interpreter/Interpreter_Tables.h" #include "JitInterface.h" -struct op_inf -{ - const char *name; - int count; - bool operator < (const op_inf &o) const - { - return count > o.count; - } -}; - GekkoOPInfo *m_infoTable[64]; - GekkoOPInfo *m_infoTable4[1024]; - GekkoOPInfo *m_infoTable19[1024]; - GekkoOPInfo *m_infoTable31[1024]; - GekkoOPInfo *m_infoTable59[32]; - GekkoOPInfo *m_infoTable63[1024]; +GekkoOPInfo *m_infoTable[64]; +GekkoOPInfo *m_infoTable4[1024]; +GekkoOPInfo *m_infoTable19[1024]; +GekkoOPInfo *m_infoTable31[1024]; +GekkoOPInfo *m_infoTable59[32]; +GekkoOPInfo *m_infoTable63[1024]; - GekkoOPInfo *m_allInstructions[512]; - int m_numInstructions; +GekkoOPInfo *m_allInstructions[512]; +int m_numInstructions; GekkoOPInfo *GetOpInfo(UGeckoInstruction _inst) { @@ -182,26 +173,34 @@ void CountInstruction(UGeckoInstruction _inst) { GekkoOPInfo *info = GetOpInfo(_inst); if (info) + { info->runCount++; + } } void PrintInstructionRunCounts() { - std::vector temp; - for (int i = 0; i < m_numInstructions; i++) + typedef std::pair OpInfo; + std::vector temp; + temp.reserve(m_numInstructions); + for (int i = 0; i < m_numInstructions; ++i) { - op_inf x; - x.name = m_allInstructions[i]->opname; - x.count = (int)(m_allInstructions[i]->runCount); - temp.push_back(x); + GekkoOPInfo *pInst = m_allInstructions[i]; + temp.emplace_back(pInst->opname, pInst->runCount); } - std::sort(temp.begin(), temp.end()); - for (int i = 0; i < m_numInstructions; i++) + std::sort(temp.begin(), temp.end(), + [](const OpInfo &a, const OpInfo &b) + { + return a.second > b.second; + }); + + for (auto &inst : temp) { - if (temp[i].count == 0) + if (inst.second == 0) break; - DEBUG_LOG(POWERPC, "%s : %i", temp[i].name,temp[i].count); - //PanicAlert("%s : %i", temp[i].name,temp[i].count); + + DEBUG_LOG(POWERPC, "%s : %llu", inst.first, inst.second); + //PanicAlert("%s : %llu", inst.first, inst.second); } } @@ -212,20 +211,22 @@ void LogCompiledInstructions() File::IOFile f(StringFromFormat("%sinst_log%i.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time), "w"); for (int i = 0; i < m_numInstructions; i++) { - if (m_allInstructions[i]->compileCount > 0) + GekkoOPInfo *pInst = m_allInstructions[i]; + if (pInst->compileCount > 0) { - fprintf(f.GetHandle(), "%s\t%i\t%" PRId64 "\t%08x\n", m_allInstructions[i]->opname, - m_allInstructions[i]->compileCount, m_allInstructions[i]->runCount, m_allInstructions[i]->lastUse); + fprintf(f.GetHandle(), "%s\t%i\t%" PRId64 "\t%08x\n", pInst->opname, + pInst->compileCount, pInst->runCount, pInst->lastUse); } } f.Open(StringFromFormat("%sinst_not%i.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time), "w"); for (int i = 0; i < m_numInstructions; i++) { - if (m_allInstructions[i]->compileCount == 0) + GekkoOPInfo *pInst = m_allInstructions[i]; + if (pInst->compileCount == 0) { - fprintf(f.GetHandle(), "%s\t%i\t%" PRId64 "\n", m_allInstructions[i]->opname, - m_allInstructions[i]->compileCount, m_allInstructions[i]->runCount); + fprintf(f.GetHandle(), "%s\t%i\t%" PRId64 "\n", pInst->opname, + pInst->compileCount, pInst->runCount); } }