diff --git a/Common/ArmEmitter.cpp b/Common/ArmEmitter.cpp index 92c24b63c2..a27d6e82ad 100644 --- a/Common/ArmEmitter.cpp +++ b/Common/ArmEmitter.cpp @@ -157,15 +157,21 @@ const u8 *ARMXEmitter::AlignCodePage() void ARMXEmitter::FlushIcache() { -#ifdef __SYMBIAN32__ - User::IMB_Range( startcode, code ); -#elif defined(BLACKBERRY) - msync(startcode, code-startcode, MS_SYNC | MS_INVALIDATE_ICACHE); -#else - __builtin___clear_cache (startcode, code); -#endif - SLEEP(0); + FlushIcacheSection(lastCacheFlushEnd, code); + lastCacheFlushEnd = code; } + +void ARMXEmitter::FlushIcacheSection(u8 *start, u8 *end) +{ +#ifdef __SYMBIAN32__ + User::IMB_Range( start, end); +#elif defined(BLACKBERRY) + msync(start, end - start, MS_SYNC | MS_INVALIDATE_ICACHE); +#else + __builtin___clear_cache (start, end); +#endif +} + void ARMXEmitter::SetCC(CCFlags cond) { condition = cond << 28; diff --git a/Common/ArmEmitter.h b/Common/ArmEmitter.h index 87e17448f9..707d8b7717 100644 --- a/Common/ArmEmitter.h +++ b/Common/ArmEmitter.h @@ -331,6 +331,7 @@ class ARMXEmitter friend struct OpArg; // for Write8 etc private: u8 *code, *startcode; + u8 *lastCacheFlushEnd; u32 condition; void WriteStoreOp(u32 op, ARMReg dest, ARMReg src, Operand2 op2); @@ -346,8 +347,15 @@ protected: inline void Write32(u32 value) {*(u32*)code = value; code+=4;} public: - ARMXEmitter() { code = NULL; startcode = NULL; condition = CC_AL << 28;} - ARMXEmitter(u8 *code_ptr) { code = code_ptr; startcode = code_ptr; condition = CC_AL << 28;} + ARMXEmitter() : code(0), startcode(0), lastCacheFlushEnd(0) { + condition = CC_AL << 28; + } + ARMXEmitter(u8 *code_ptr) { + code = code_ptr; + lastCacheFlushEnd = code_ptr; + startcode = code_ptr; + condition = CC_AL << 28; + } virtual ~ARMXEmitter() {} void SetCodePtr(u8 *ptr); @@ -356,6 +364,7 @@ public: const u8 *AlignCodePage(); const u8 *GetCodePtr() const; void FlushIcache(); + void FlushIcacheSection(u8 *start, u8 *end); u8 *GetWritableCodePtr(); void SetCC(CCFlags cond = CC_AL); diff --git a/Core/MIPS/ARM/ArmJitCache.cpp b/Core/MIPS/ARM/ArmJitCache.cpp index 5f6769db04..c457e0c9c3 100644 --- a/Core/MIPS/ARM/ArmJitCache.cpp +++ b/Core/MIPS/ARM/ArmJitCache.cpp @@ -286,6 +286,7 @@ void ArmJitBlockCache::LinkBlockExits(int i) { ARMXEmitter emit(b.exitPtrs[e]); emit.B(blocks[destinationBlock].checkedEntry); + emit.FlushIcache(); b.linkStatus[e] = true; } } @@ -358,6 +359,7 @@ void ArmJitBlockCache::DestroyBlock(int block_num, bool invalidate) emit.ARMABI_MOVI2R(R0, b.originalAddress); emit.STR(R10, R0, offsetof(MIPSState, pc)); emit.B(MIPSComp::jit->dispatcher); + emit.FlushIcache(); } void ArmJitBlockCache::InvalidateICache(u32 address, const u32 length)