From e7157e7c5285e668cef909409c319597336beda2 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 2 Sep 2013 04:10:21 -0500 Subject: [PATCH] [Android] Fix fastmem and enable. --- Source/Core/Common/Src/MemArena.cpp | 14 ++--- .../Src/PowerPC/JitArm32/JitArm_LoadStore.cpp | 58 ++++++++++--------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/Source/Core/Common/Src/MemArena.cpp b/Source/Core/Common/Src/MemArena.cpp index b7400a978e..c8267c4411 100644 --- a/Source/Core/Common/Src/MemArena.cpp +++ b/Source/Core/Common/Src/MemArena.cpp @@ -143,20 +143,20 @@ u8* MemArena::Find4GBBase() return base; #else #ifdef ANDROID - const u32 MemSize = 0x04000000; + // Android 4.3 changed how mmap works. + // if we map it private and then munmap it, we can't use the base returned. + // This may be due to changes in them support a full SELinux implementation. + const int flags = MAP_ANON; #else - const u32 MemSize = 0x31000000; + const int flags = MAP_ANON | MAP_PRIVATE; #endif - void* base = mmap(0, MemSize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0); + const u32 MemSize = 0x31000000; + void* base = mmap(0, MemSize, PROT_NONE, flags, -1, 0); if (base == MAP_FAILED) { PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno)); return 0; } -#ifndef ANDROID - // Android 4.3 changes how munmap works which causes crashes. - // Keep the memory space after allocating it... munmap(base, MemSize); -#endif return static_cast(base); #endif #endif diff --git a/Source/Core/Core/Src/PowerPC/JitArm32/JitArm_LoadStore.cpp b/Source/Core/Core/Src/PowerPC/JitArm32/JitArm_LoadStore.cpp index c9d6394873..505b7a2044 100644 --- a/Source/Core/Core/Src/PowerPC/JitArm32/JitArm_LoadStore.cpp +++ b/Source/Core/Core/Src/PowerPC/JitArm32/JitArm_LoadStore.cpp @@ -32,7 +32,7 @@ #include "JitAsm.h" #ifdef ANDROID -#define FASTMEM 0 +#define FASTMEM 1 #else #define FASTMEM 1 #endif @@ -455,36 +455,40 @@ void JitArm::lhz(UGeckoInstruction inst) // Backpatch route // Gets loaded in to RD // Address is in R10 - gpr.Unlock(rA, rB); - if (inst.RA) + if (Core::g_CoreStartupParameter.bFastmem) { - ARMReg RA = gpr.R(inst.RA); - MOV(R10, RA); // - 4 + if (inst.RA) + { + ARMReg RA = gpr.R(inst.RA); + MOV(R10, RA); // - 4 + } + else + MOV(R10, 0); // - 4 + + LoadToReg(RD, R10, 16, (u32)inst.SIMM_16); } else - MOV(R10, 0); // - 4 - - LoadToReg(RD, R10, 16, (u32)inst.SIMM_16); -#else - - if (inst.RA) - { - MOVI2R(rB, inst.SIMM_16); - ARMReg RA = gpr.R(inst.RA); - ADD(rB, rB, RA); - } - else - MOVI2R(rB, (u32)inst.SIMM_16); - - MOVI2R(rA, (u32)&Memory::Read_U16); - PUSH(4, R0, R1, R2, R3); - MOV(R0, rB); - BL(rA); - MOV(rA, R0); - POP(4, R0, R1, R2, R3); - MOV(RD, rA); - gpr.Unlock(rA, rB); #endif + { + if (inst.RA) + { + MOVI2R(rB, inst.SIMM_16); + ARMReg RA = gpr.R(inst.RA); + ADD(rB, rB, RA); + } + else + MOVI2R(rB, (u32)inst.SIMM_16); + + MOVI2R(rA, (u32)&Memory::Read_U16); + PUSH(4, R0, R1, R2, R3); + MOV(R0, rB); + BL(rA); + MOV(rA, R0); + POP(4, R0, R1, R2, R3); + MOV(RD, rA); + } + + gpr.Unlock(rA, rB); SetJumpTarget(DoNotLoad); } void JitArm::lha(UGeckoInstruction inst)