[Android] Pre-allocate memory
This commit is contained in:
parent
9eaa9d77e6
commit
6cfd981b7d
|
@ -234,8 +234,8 @@ bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char
|
|||
|
||||
SetupTrace();
|
||||
FixDirectories();
|
||||
#ifdef _WIN32
|
||||
CMipsMemoryVM::ReserveMemory();
|
||||
#ifdef _WIN32
|
||||
IncreaseThreadPriority();
|
||||
#else
|
||||
if (!CMipsMemoryVM::SetupSegvHandler())
|
||||
|
|
|
@ -105,6 +105,8 @@ private:
|
|||
//Recompiler has access to manipulate and call functions
|
||||
friend CSystemTimer;
|
||||
|
||||
friend CMipsMemoryVM;
|
||||
|
||||
//Used for loading and potentially executing the CPU in its own thread.
|
||||
static void StartEmulationThread(CThread * thread);
|
||||
static bool EmulationStarting(CThread * thread);
|
||||
|
|
|
@ -465,6 +465,8 @@ void CN64Rom::NotificationCB(const char * Status, CN64Rom * /*_this*/)
|
|||
|
||||
bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Start (FileLoc: \"%s\" LoadBootCodeOnly: %s)", FileLoc, LoadBootCodeOnly ? "true" : "false");
|
||||
|
||||
UnallocateRomImage();
|
||||
m_ErrorMsg = EMPTY_STRING;
|
||||
|
||||
|
@ -482,6 +484,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
|
|||
{
|
||||
//Pop up a dialog and select file
|
||||
//allocate memory for sub name and copy selected file name to var
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (res: false)");
|
||||
return false; //remove once dialog is done
|
||||
}
|
||||
else
|
||||
|
@ -517,6 +520,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
|
|||
|
||||
if (!AllocateRomImage(RomFileSize))
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -525,12 +529,14 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
|
|||
if (!ZipFile.GetFile(i, m_ROMImage, RomFileSize))
|
||||
{
|
||||
SetError(MSG_FAIL_IMAGE);
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsValidRomImage(m_ROMImage))
|
||||
{
|
||||
SetError(MSG_FAIL_IMAGE);
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
g_Notify->DisplayMessage(5, MSG_BYTESWAP);
|
||||
|
@ -544,6 +550,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
|
|||
if (!Loaded7zFile)
|
||||
{
|
||||
SetError(MSG_7Z_FILE_NOT_FOUND);
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -556,10 +563,12 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
|
|||
{
|
||||
if (m_ErrorMsg != EMPTY_STRING)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
if (!AllocateAndLoadN64Image(FileLoc, LoadBootCodeOnly))
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -606,6 +615,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
|
|||
CalculateRomCrc();
|
||||
}
|
||||
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (res: true)");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,10 @@ CFunctionMap::~CFunctionMap()
|
|||
|
||||
bool CFunctionMap::AllocateMemory()
|
||||
{
|
||||
if (g_System->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable == NULL)
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "start");
|
||||
if (LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable == NULL)
|
||||
{
|
||||
m_FunctionTable = new PCCompiledFunc_TABLE[0x100000];
|
||||
m_FunctionTable = new (std::nothrow) PCCompiledFunc_TABLE[0x100000];
|
||||
if (m_FunctionTable == NULL)
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceError, "failed to allocate function table");
|
||||
|
@ -37,17 +38,18 @@ bool CFunctionMap::AllocateMemory()
|
|||
}
|
||||
memset(m_FunctionTable, 0, 0x100000 * sizeof(PCCompiledFunc_TABLE));
|
||||
}
|
||||
if (g_System->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable == NULL)
|
||||
if (LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable == NULL)
|
||||
{
|
||||
m_JumpTable = new PCCompiledFunc[g_MMU->RdramSize() >> 2];
|
||||
m_JumpTable = new (std::nothrow) PCCompiledFunc[RdramSize() >> 2];
|
||||
if (m_JumpTable == NULL)
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceError, "failed to allocate jump table");
|
||||
g_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
|
||||
return false;
|
||||
}
|
||||
memset(m_JumpTable, 0, (g_MMU->RdramSize() >> 2) * sizeof(PCCompiledFunc));
|
||||
memset(m_JumpTable, 0, (RdramSize() >> 2) * sizeof(PCCompiledFunc));
|
||||
}
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "Done");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -74,9 +76,11 @@ void CFunctionMap::CleanBuffers()
|
|||
|
||||
void CFunctionMap::Reset(bool bAllocate)
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "start (bAllocate: %s)", bAllocate ? "true" : "false");
|
||||
CleanBuffers();
|
||||
if (bAllocate && (g_System->LookUpMode() == FuncFind_VirtualLookup || g_System->LookUpMode() == FuncFind_PhysicalLookup))
|
||||
{
|
||||
AllocateMemory();
|
||||
}
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "Done");
|
||||
}
|
|
@ -11,7 +11,8 @@
|
|||
#pragma once
|
||||
#include <Project64-core/N64System/Recompiler/FunctionInfo.h>
|
||||
|
||||
class CFunctionMap
|
||||
class CFunctionMap :
|
||||
private CGameSettings
|
||||
{
|
||||
protected:
|
||||
typedef CCompiledFunc * PCCompiledFunc;
|
||||
|
|
|
@ -22,6 +22,7 @@ CRecompiler::CRecompiler(CRegisters & Registers, CProfiling & Profile, bool & En
|
|||
m_EndEmulation(EndEmulation),
|
||||
PROGRAM_COUNTER(Registers.m_PROGRAM_COUNTER)
|
||||
{
|
||||
CFunctionMap::AllocateMemory();
|
||||
if (g_MMU != NULL)
|
||||
{
|
||||
ResetMemoryStackPos();
|
||||
|
@ -718,12 +719,15 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB()
|
|||
|
||||
void CRecompiler::Reset()
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "start");
|
||||
ResetRecompCode(true);
|
||||
ResetMemoryStackPos();
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
void CRecompiler::ResetRecompCode(bool bAllocate)
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "start");
|
||||
CRecompMemory::Reset();
|
||||
CFunctionMap::Reset(bAllocate);
|
||||
|
||||
|
@ -739,6 +743,7 @@ void CRecompiler::ResetRecompCode(bool bAllocate)
|
|||
}
|
||||
}
|
||||
m_Functions.clear();
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
void CRecompiler::RecompilerMain_ChangeMemory()
|
||||
|
@ -1036,18 +1041,21 @@ void CRecompiler::ClearRecompCode_Phys(uint32_t Address, int length, REMOVE_REAS
|
|||
|
||||
void CRecompiler::ClearRecompCode_Virt(uint32_t Address, int length, REMOVE_REASON Reason)
|
||||
{
|
||||
uint32_t AddressIndex, WriteStart;
|
||||
int DataInBlock, DataToWrite, DataLeft;
|
||||
|
||||
switch (g_System->LookUpMode())
|
||||
{
|
||||
case FuncFind_VirtualLookup:
|
||||
{
|
||||
uint32_t AddressIndex = Address >> 0xC;
|
||||
uint32_t WriteStart = (Address & 0xFFC);
|
||||
AddressIndex = Address >> 0xC;
|
||||
WriteStart = (Address & 0xFFC);
|
||||
length = ((length + 3) & ~0x3);
|
||||
|
||||
int DataInBlock = 0x1000 - WriteStart;
|
||||
int DataToWrite = length < DataInBlock ? length : DataInBlock;
|
||||
int DataLeft = length - DataToWrite;
|
||||
DataInBlock = 0x1000 - WriteStart;
|
||||
DataToWrite = length < DataInBlock ? length : DataInBlock;
|
||||
DataLeft = length - DataToWrite;
|
||||
|
||||
{
|
||||
PCCompiledFunc_TABLE & table = FunctionTable()[AddressIndex];
|
||||
if (table)
|
||||
{
|
||||
|
|
|
@ -40,6 +40,7 @@ CPU_TYPE CGameSettings::m_CpuType = CPU_Recompiler;
|
|||
|
||||
void CGameSettings::RefreshGameSettings()
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "start");
|
||||
m_bSMM_StoreInstruc = false /*g_Settings->LoadBool(Game_SMM_StoreInstruc)*/;
|
||||
m_bSMM_Protect = g_Settings->LoadBool(Game_SMM_Protect);
|
||||
m_bSMM_ValidFunc = g_Settings->LoadBool(Game_SMM_ValidFunc);
|
||||
|
@ -73,6 +74,7 @@ void CGameSettings::RefreshGameSettings()
|
|||
{
|
||||
m_CountPerOp = 2;
|
||||
}
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
void CGameSettings::SpeedChanged(int SpeedLimit)
|
||||
|
|
|
@ -130,7 +130,7 @@ bool CSettingTypeApplication::Load(int /*Index*/, bool & Value) const
|
|||
{
|
||||
bool bRes = false;
|
||||
|
||||
uint32_t dwValue;
|
||||
uint32_t dwValue = 0;
|
||||
bRes = m_SettingsIniFile ? m_SettingsIniFile->GetNumber(SectionName(), m_KeyNameIdex.c_str(), Value, dwValue) : false;
|
||||
if (bRes)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue