[Project64] update Function Info to use standard types
This commit is contained in:
parent
23210e759a
commit
8f694e157f
|
@ -486,11 +486,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
{
|
||||
if (JumpInfo[i]->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -503,11 +503,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) { continue; }
|
||||
if (JumpInfo[i]->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -540,11 +540,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
JumpInfo[i]->FallThrough = false;
|
||||
if (JumpInfo[i]->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -649,11 +649,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
if (TargetSection[i] == NULL)
|
||||
{
|
||||
CPU_Message("ExitBlock (from %d):", m_SectionID);
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->ExitReason, true, NULL);
|
||||
|
@ -672,11 +672,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
stdstr_f Label("Section_%d (from %d):", TargetSection[i]->m_SectionID, m_SectionID);
|
||||
|
||||
CPU_Message(Label.c_str());
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
m_RegWorkingSet = JumpInfo[i]->RegSet;
|
||||
|
@ -1790,10 +1790,10 @@ bool CCodeSection::InheritParentInfo()
|
|||
if (JumpInfo->LinkLocation != NULL)
|
||||
{
|
||||
CPU_Message(" Section_%d:", m_SectionID);
|
||||
SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
if (JumpInfo->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
}
|
||||
}
|
||||
m_RegWorkingSet = m_RegEnter;
|
||||
|
@ -1883,11 +1883,11 @@ bool CCodeSection::InheritParentInfo()
|
|||
if (JumpInfo->LinkLocation != NULL)
|
||||
{
|
||||
CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID);
|
||||
SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
JumpInfo->LinkLocation = NULL;
|
||||
if (JumpInfo->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
JumpInfo->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2150,11 +2150,11 @@ bool CCodeSection::InheritParentInfo()
|
|||
CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID);
|
||||
if (JumpInfo->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
JumpInfo->LinkLocation = NULL;
|
||||
if (JumpInfo->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
JumpInfo->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2184,11 +2184,11 @@ bool CCodeSection::InheritParentInfo()
|
|||
|
||||
if (JumpInfo->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
JumpInfo->LinkLocation = NULL;
|
||||
if (JumpInfo->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
JumpInfo->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,15 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
CCompiledFunc::CCompiledFunc( const CCodeBlock & CodeBlock ) :
|
||||
m_EnterPC(CodeBlock.VAddrEnter()),
|
||||
m_MinPC(CodeBlock.VAddrFirst()),
|
||||
m_MaxPC(CodeBlock.VAddrLast()),
|
||||
m_Hash(CodeBlock.Hash()),
|
||||
m_Function((Func)CodeBlock.CompiledLocation()),
|
||||
m_Next(NULL)
|
||||
m_EnterPC(CodeBlock.VAddrEnter()),
|
||||
m_MinPC(CodeBlock.VAddrFirst()),
|
||||
m_MaxPC(CodeBlock.VAddrLast()),
|
||||
m_Hash(CodeBlock.Hash()),
|
||||
m_Function((Func)CodeBlock.CompiledLocation()),
|
||||
m_Next(NULL)
|
||||
{
|
||||
m_MemContents[0] = CodeBlock.MemContents(0);
|
||||
m_MemContents[1] = CodeBlock.MemContents(1);
|
||||
m_MemLocation[0] = CodeBlock.MemLocation(0);
|
||||
m_MemLocation[1] = CodeBlock.MemLocation(1);
|
||||
m_MemContents[0] = CodeBlock.MemContents(0);
|
||||
m_MemContents[1] = CodeBlock.MemContents(1);
|
||||
m_MemLocation[0] = CodeBlock.MemLocation(0);
|
||||
m_MemLocation[1] = CodeBlock.MemLocation(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,41 +12,42 @@
|
|||
|
||||
class CCompiledFunc
|
||||
{
|
||||
//constructor
|
||||
CCompiledFunc(); // not implemented
|
||||
|
||||
public:
|
||||
CCompiledFunc(const CCodeBlock & CodeBlock);
|
||||
CCompiledFunc(const CCodeBlock & CodeBlock);
|
||||
|
||||
typedef void (*Func)();
|
||||
typedef void (*Func)();
|
||||
|
||||
//Get Private Information
|
||||
const DWORD EnterPC () const { return m_EnterPC; }
|
||||
const DWORD MinPC () const { return m_MinPC; }
|
||||
const DWORD MaxPC () const { return m_MaxPC; }
|
||||
const Func Function () const { return m_Function; }
|
||||
const MD5Digest& Hash () const { return m_Hash; }
|
||||
//Get Private Information
|
||||
const uint32_t EnterPC () const { return m_EnterPC; }
|
||||
const uint32_t MinPC () const { return m_MinPC; }
|
||||
const uint32_t MaxPC () const { return m_MaxPC; }
|
||||
const Func Function () const { return m_Function; }
|
||||
const MD5Digest& Hash () const { return m_Hash; }
|
||||
|
||||
CCompiledFunc* Next () const { return m_Next; }
|
||||
void SetNext(CCompiledFunc* Next) { m_Next = Next; }
|
||||
CCompiledFunc* Next () const { return m_Next; }
|
||||
void SetNext(CCompiledFunc* Next) { m_Next = Next; }
|
||||
|
||||
QWORD MemContents(int i) { return m_MemContents[i]; }
|
||||
QWORD* MemLocation(int i) { return m_MemLocation[i]; }
|
||||
uint64_t MemContents(int32_t i) { return m_MemContents[i]; }
|
||||
uint64_t* MemLocation(int32_t i) { return m_MemLocation[i]; }
|
||||
|
||||
private:
|
||||
//Information
|
||||
DWORD m_EnterPC; // The Entry PC
|
||||
DWORD m_MinPC; // The Lowest PC in the function
|
||||
DWORD m_MaxPC; // The Highest PC in the function
|
||||
CCompiledFunc(void); // Disable default constructor
|
||||
CCompiledFunc(const CCompiledFunc&); // Disable copy constructor
|
||||
CCompiledFunc& operator=(const CCompiledFunc&); // Disable assignment
|
||||
|
||||
MD5Digest m_Hash;
|
||||
//From querying the recompiler get information about the function
|
||||
Func m_Function;
|
||||
//Information
|
||||
uint32_t m_EnterPC; // The Entry PC
|
||||
uint32_t m_MinPC; // The Lowest PC in the function
|
||||
uint32_t m_MaxPC; // The Highest PC in the function
|
||||
|
||||
CCompiledFunc* m_Next;
|
||||
|
||||
//Validation
|
||||
QWORD m_MemContents[2], * m_MemLocation[2];
|
||||
MD5Digest m_Hash;
|
||||
//From querying the recompiler get information about the function
|
||||
Func m_Function;
|
||||
|
||||
CCompiledFunc* m_Next;
|
||||
|
||||
//Validation
|
||||
uint64_t m_MemContents[2], * m_MemLocation[2];
|
||||
};
|
||||
|
||||
typedef std::map<DWORD, CCompiledFunc *> CCompiledFuncList;
|
||||
typedef std::map<uint32_t, CCompiledFunc *> CCompiledFuncList;
|
||||
|
|
|
@ -11,68 +11,69 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
CFunctionMap::CFunctionMap() :
|
||||
m_JumpTable(NULL),
|
||||
m_FunctionTable(NULL)
|
||||
m_JumpTable(NULL),
|
||||
m_FunctionTable(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CFunctionMap::~CFunctionMap()
|
||||
{
|
||||
CleanBuffers();
|
||||
CleanBuffers();
|
||||
}
|
||||
|
||||
bool CFunctionMap::AllocateMemory()
|
||||
{
|
||||
if (g_System->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable == NULL)
|
||||
{
|
||||
m_FunctionTable = (PCCompiledFunc_TABLE *)VirtualAlloc(NULL,0xFFFFF * sizeof(CCompiledFunc *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
|
||||
if (m_FunctionTable == NULL) {
|
||||
WriteTrace(TraceError,__FUNCTION__ ": failed to allocate function table");
|
||||
g_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
|
||||
return false;
|
||||
}
|
||||
memset(m_FunctionTable,0,0xFFFFF * sizeof(CCompiledFunc *));
|
||||
}
|
||||
if (g_System->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable == NULL)
|
||||
{
|
||||
m_JumpTable = new PCCompiledFunc[g_MMU->RdramSize() >> 2];
|
||||
if (m_JumpTable == NULL)
|
||||
{
|
||||
WriteTrace(TraceError,__FUNCTION__ ": failed to allocate jump table");
|
||||
g_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
|
||||
return false;
|
||||
}
|
||||
memset(m_JumpTable,0,(g_MMU->RdramSize() >> 2) * sizeof(PCCompiledFunc));
|
||||
}
|
||||
return true;
|
||||
if (g_System->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable == NULL)
|
||||
{
|
||||
m_FunctionTable = (PCCompiledFunc_TABLE *)VirtualAlloc(NULL, 0xFFFFF * sizeof(CCompiledFunc *), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
||||
if (m_FunctionTable == NULL)
|
||||
{
|
||||
WriteTrace(TraceError, __FUNCTION__ ": failed to allocate function table");
|
||||
g_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
|
||||
return false;
|
||||
}
|
||||
memset(m_FunctionTable, 0, 0xFFFFF * sizeof(CCompiledFunc *));
|
||||
}
|
||||
if (g_System->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable == NULL)
|
||||
{
|
||||
m_JumpTable = new PCCompiledFunc[g_MMU->RdramSize() >> 2];
|
||||
if (m_JumpTable == NULL)
|
||||
{
|
||||
WriteTrace(TraceError, __FUNCTION__ ": failed to allocate jump table");
|
||||
g_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
|
||||
return false;
|
||||
}
|
||||
memset(m_JumpTable, 0, (g_MMU->RdramSize() >> 2) * sizeof(PCCompiledFunc));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CFunctionMap::CleanBuffers()
|
||||
{
|
||||
if (m_FunctionTable)
|
||||
{
|
||||
for (int i = 0, n = 0x100000; i < n; i++)
|
||||
{
|
||||
if (m_FunctionTable[i] != NULL)
|
||||
{
|
||||
delete m_FunctionTable[i];
|
||||
}
|
||||
}
|
||||
VirtualFree( m_FunctionTable, 0 , MEM_RELEASE);
|
||||
m_FunctionTable = NULL;
|
||||
}
|
||||
if (m_JumpTable)
|
||||
{
|
||||
delete [] m_JumpTable;
|
||||
m_JumpTable = NULL;
|
||||
}
|
||||
if (m_FunctionTable)
|
||||
{
|
||||
for (int i = 0, n = 0x100000; i < n; i++)
|
||||
{
|
||||
if (m_FunctionTable[i] != NULL)
|
||||
{
|
||||
delete m_FunctionTable[i];
|
||||
}
|
||||
}
|
||||
VirtualFree(m_FunctionTable, 0, MEM_RELEASE);
|
||||
m_FunctionTable = NULL;
|
||||
}
|
||||
if (m_JumpTable)
|
||||
{
|
||||
delete[] m_JumpTable;
|
||||
m_JumpTable = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CFunctionMap::Reset ( bool bAllocate )
|
||||
void CFunctionMap::Reset(bool bAllocate)
|
||||
{
|
||||
CleanBuffers();
|
||||
if (bAllocate && (g_System->LookUpMode() == FuncFind_VirtualLookup || g_System->LookUpMode() == FuncFind_PhysicalLookup))
|
||||
{
|
||||
AllocateMemory();
|
||||
}
|
||||
CleanBuffers();
|
||||
if (bAllocate && (g_System->LookUpMode() == FuncFind_VirtualLookup || g_System->LookUpMode() == FuncFind_PhysicalLookup))
|
||||
{
|
||||
AllocateMemory();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,22 +13,22 @@
|
|||
class CFunctionMap
|
||||
{
|
||||
protected:
|
||||
typedef CCompiledFunc * PCCompiledFunc;
|
||||
typedef PCCompiledFunc * PCCompiledFunc_TABLE;
|
||||
typedef CCompiledFunc * PCCompiledFunc;
|
||||
typedef PCCompiledFunc * PCCompiledFunc_TABLE;
|
||||
|
||||
CFunctionMap();
|
||||
~CFunctionMap();
|
||||
CFunctionMap();
|
||||
~CFunctionMap();
|
||||
|
||||
bool AllocateMemory();
|
||||
void Reset(bool bAllocate);
|
||||
bool AllocateMemory();
|
||||
void Reset(bool bAllocate);
|
||||
|
||||
public:
|
||||
PCCompiledFunc_TABLE * FunctionTable() const { return m_FunctionTable; }
|
||||
PCCompiledFunc * JumpTable() const { return m_JumpTable; }
|
||||
PCCompiledFunc_TABLE * FunctionTable() const { return m_FunctionTable; }
|
||||
PCCompiledFunc * JumpTable() const { return m_JumpTable; }
|
||||
|
||||
private:
|
||||
void CleanBuffers();
|
||||
void CleanBuffers();
|
||||
|
||||
PCCompiledFunc * m_JumpTable;
|
||||
PCCompiledFunc_TABLE * m_FunctionTable;
|
||||
PCCompiledFunc * m_JumpTable;
|
||||
PCCompiledFunc_TABLE * m_FunctionTable;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue