mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Attempt at fixing JIT on iOS. Can only have PROT_WRITE or PROT_EXEC enabled. So toggle between them as needed.
This commit is contained in:
parent
529803e429
commit
f88bf8bbff
4 changed files with 20 additions and 4 deletions
|
@ -236,8 +236,7 @@ void ARMXEmitter::FlushIcacheSection(u8 *start, u8 *end)
|
|||
#elif defined(BLACKBERRY)
|
||||
msync(start, end - start, MS_SYNC | MS_INVALIDATE_ICACHE);
|
||||
#elif defined(IOS)
|
||||
if (start != NULL)
|
||||
sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start);
|
||||
sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start);
|
||||
#elif !defined(_WIN32)
|
||||
__builtin___clear_cache(start, end);
|
||||
#endif
|
||||
|
|
|
@ -611,7 +611,11 @@ public:
|
|||
// Start over if you need to change the code (call FreeCodeSpace(), AllocCodeSpace()).
|
||||
void WriteProtect()
|
||||
{
|
||||
WriteProtectMemory(region, region_size, true);
|
||||
WriteProtectMemory(region, region_size, true);
|
||||
}
|
||||
void UnWriteProtect()
|
||||
{
|
||||
UnWriteProtectMemory(region, region_size, false);
|
||||
}
|
||||
|
||||
void ResetCodePtr()
|
||||
|
|
|
@ -86,7 +86,7 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
|||
if (low && (!map_hint))
|
||||
map_hint = (char*)round_page(512*1024*1024); /* 0.5 GB rounded up to the next page */
|
||||
#endif
|
||||
void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_ANON | MAP_PRIVATE
|
||||
#if defined(__x86_64__) && defined(MAP_32BIT)
|
||||
| (low ? MAP_32BIT : 0)
|
||||
|
|
|
@ -62,7 +62,13 @@ Jit::Jit(MIPSState *mips) : blocks(mips), gpr(mips), fpr(mips), mips_(mips)
|
|||
gpr.SetEmitter(this);
|
||||
fpr.SetEmitter(this);
|
||||
AllocCodeSpace(1024 * 1024 * 16); // 32MB is the absolute max because that's what an ARM branch instruction can reach, backwards and forwards.
|
||||
#ifdef IOS
|
||||
UnWriteProtect();
|
||||
#endif
|
||||
GenerateFixedCode();
|
||||
#ifdef IOS
|
||||
WriteProtect();
|
||||
#endif
|
||||
|
||||
js.startDefaultPrefix = true;
|
||||
}
|
||||
|
@ -201,6 +207,10 @@ const u8 *Jit::DoJit(u32 em_address, ArmJitBlock *b)
|
|||
js.inDelaySlot = false;
|
||||
js.PrefixStart();
|
||||
|
||||
#ifdef IOS
|
||||
UnWriteProtect();
|
||||
#endif
|
||||
|
||||
// We add a check before the block, used when entering from a linked block.
|
||||
b->checkedEntry = GetCodePtr();
|
||||
// Downcount flag check. The last block decremented downcounter, and the flag should still be available.
|
||||
|
@ -255,6 +265,9 @@ const u8 *Jit::DoJit(u32 em_address, ArmJitBlock *b)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef IOS
|
||||
WriteProtect();
|
||||
#endif
|
||||
|
||||
b->codeSize = GetCodePtr() - b->normalEntry;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue