diff --git a/Source/Core/Common/Src/MemoryUtil.cpp b/Source/Core/Common/Src/MemoryUtil.cpp index d5681481d3..bd94eaf012 100644 --- a/Source/Core/Common/Src/MemoryUtil.cpp +++ b/Source/Core/Common/Src/MemoryUtil.cpp @@ -38,7 +38,7 @@ // This is purposedely not a full wrapper for virtualalloc/mmap, but it // provides exactly the primitive operations that Dolphin needs. -void* AllocateExecutableMemory(int size) +void* AllocateExecutableMemory(int size, bool low) { #ifdef _WIN32 void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); @@ -55,7 +55,7 @@ void* AllocateExecutableMemory(int size) void* retval = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE #ifdef __x86_64__ - | MAP_32BIT + | (low ? MAP_32BIT : 0) #endif , -1, 0); // | MAP_FIXED printf("mappah exe %p %i\n", retval, size); diff --git a/Source/Core/Common/Src/MemoryUtil.h b/Source/Core/Common/Src/MemoryUtil.h index 4fbfba28af..e3415a9e33 100644 --- a/Source/Core/Common/Src/MemoryUtil.h +++ b/Source/Core/Common/Src/MemoryUtil.h @@ -18,7 +18,7 @@ #ifndef _MEMORYUTIL_H #define _MEMORYUTIL_H -void* AllocateExecutableMemory(int size); +void* AllocateExecutableMemory(int size, bool low = true); void* AllocateMemoryPages(int size); void FreeMemoryPages(void* ptr, int size); void WriteProtectMemory(void* ptr, int size, bool executable = false); diff --git a/Source/Core/Common/Src/x64Emitter.cpp b/Source/Core/Common/Src/x64Emitter.cpp index f996e7bf7e..e4894a8068 100644 --- a/Source/Core/Common/Src/x64Emitter.cpp +++ b/Source/Core/Common/Src/x64Emitter.cpp @@ -313,7 +313,7 @@ namespace Gen s64 fn = (s64)fnptr; s64 c = (s64)code; if (myabs(fn - c) >= 0x80000000ULL) { - PanicAlert("CALL out of range, %p, %p", fn, c); + PanicAlert("CALL out of range (%p calls %p)", c, fn); } s32 distance = (s32)(fn - ((u64)code + 5)); Write8(0xE8); @@ -325,7 +325,8 @@ namespace Gen //TODO fix u64 jump = (code - (u8*)j8) - 1; - if (jump > 0x7f) _assert_msg_(DYNA_REC, 0, "j8 greater than 0x7f!!"); + if (jump > 0x7f) + _assert_msg_(DYNA_REC, 0, "j8 greater than 0x7f!!"); *j8 = (u8)jump; } @@ -1107,7 +1108,8 @@ namespace Gen else { // Simulate this instruction with SSE2 instructions - MOVAPD(regOp, arg); + if (!arg.IsSimpleReg(regOp)) + MOVAPD(regOp, arg); UNPCKLPD(regOp, R(regOp)); } } diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp index 4345f62898..5d4deb3a69 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp @@ -260,13 +260,17 @@ namespace Jit64 bool ImHereDebug = false; - std::map been_here; + std::map been_here; void ImHere() { - if (been_here.find(PC) != been_here.end()) - return; + if (been_here.find(PC) != been_here.end()) { + been_here.find(PC)->second++; + if ((been_here.find(PC)->second) & 1023) + return; + } LOG(DYNA_REC, "I'm here - PC = %08x , LR = %08x", PC, LR); - been_here[PC] = true; + printf("I'm here - PC = %08x , LR = %08x", PC, LR); + been_here[PC] = 1; } void FlushRegCaches() diff --git a/Source/Core/Core/Src/PowerPC/Jit64/JitBackpatch.cpp b/Source/Core/Core/Src/PowerPC/Jit64/JitBackpatch.cpp index b16d333b31..e3de9eb515 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/JitBackpatch.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/JitBackpatch.cpp @@ -23,11 +23,11 @@ void BackPatchError(const std::string &text, u8 *codePtr, u32 emAddress) { char disbuf[256]; memset(disbuf, 0, 256); #ifdef _M_IX86 - disasm.disasm32( + disasm.disasm32 #else - disasm.disasm64( + disasm.disasm64 #endif - 0, code_addr, codePtr, disbuf); + (0, code_addr, codePtr, disbuf); PanicAlert("%s\n\n" "Error encountered accessing emulated address %08x.\n" "Culprit instruction: \n%s\nat %08x%08x", @@ -82,9 +82,9 @@ void BackPatch(u8 *codePtr, int accessType, u32 emAddress) // * Set up stack frame. // * Call ReadMemory32 //LEA(32, ECX, MDisp((X64Reg)addrReg, info.displacement)); - MOV(32, R(ECX), R((X64Reg)addrReg)); + MOV(32, R(ABI_PARAM1), R((X64Reg)addrReg)); if (info.displacement) { - ADD(32, R(ECX), Imm32(info.displacement)); + ADD(32, R(ABI_PARAM1), Imm32(info.displacement)); } switch (info.operandSize) { //case 1: diff --git a/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp index a891d0cf14..ce7f59db70 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp @@ -198,6 +198,7 @@ namespace Jit64 bool GPRRegCache::IsXRegVolatile(X64Reg reg) const { +#ifdef _WIN32 switch (reg) { case RAX: case RCX: case RDX: case R8: case R9: case R10: case R11: @@ -208,6 +209,9 @@ namespace Jit64 default: return false; } +#else + return true; +#endif } void RegCache::DiscardRegContentsIfCached(int preg) @@ -252,7 +256,7 @@ namespace Jit64 #ifdef _WIN32 RSI, RDI, R12, R13, R14, R8, R9, RDX, R10, R11 //, RCX #else - R12, R13, R14, R8, R9, RDX, R10, R11, RSI, RDI //, RCX + R12, R13, R14, R8, R9, R10, R11, RSI, RDI //, RCX #endif #elif _M_IX86 ESI, EDI, EBX, EBP, EDX //, RCX diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp index 1c93d25c4c..8b34fa9e2e 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp @@ -188,9 +188,9 @@ namespace Jit64 #ifdef _M_X64 if (!jo.noAssumeFPLoadFromMem) { - MOV(32, R(EAX), MComplex(RBX, ECX, SCALE_1, offset)); + MOV(32, R(EAX), MComplex(RBX, ABI_PARAM1, SCALE_1, offset)); //#else -// MOV(32, R(EAX), MDisp(ECX, (u32)Memory::GetMainRAMPtr() + (u32)offset)); +// MOV(32, R(EAX), MDisp(ABI_PARAM1, (u32)Memory::GetMainRAMPtr() + (u32)offset)); //#endif BSWAP(32, EAX); } @@ -221,8 +221,8 @@ namespace Jit64 } s32 offset = (s32)(s16)inst.SIMM_16; gpr.Lock(a); - MOV(32, R(ECX), gpr.R(a)); - MOV(64, R(EAX), MComplex(RBX, ECX, SCALE_1, offset)); + MOV(32, R(ABI_PARAM1), gpr.R(a)); + MOV(64, R(EAX), MComplex(RBX, ABI_PARAM1, SCALE_1, offset)); BSWAP(64,EAX); MOV(64, M(&temp64), R(EAX)); fpr.Lock(d); @@ -249,10 +249,10 @@ namespace Jit64 fpr.Lock(s); fpr.LoadToX64(s, true, false); MOVSD(M(&temp64), fpr.RX(s)); - MOV(32, R(ECX), gpr.R(a)); + MOV(32, R(ABI_PARAM1), gpr.R(a)); MOV(64, R(EAX), M(&temp64)); BSWAP(64, EAX); - MOV(64, MComplex(RBX, ECX, SCALE_1, offset), R(EAX)); + MOV(64, MComplex(RBX, ABI_PARAM1, SCALE_1, offset), R(EAX)); gpr.UnlockAll(); fpr.UnlockAll(); } diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStorePaired.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStorePaired.cpp index 7bfd331e78..f036df152f 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStorePaired.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStorePaired.cpp @@ -52,8 +52,8 @@ static u32 GC_ALIGNED16(temp32); // TODO(ector): Improve 64-bit version void WriteDual32(u64 value, u32 address) { - Memory::Write_U32((u32)(value>>32), address); - Memory::Write_U32((u32)value, address+4); + Memory::Write_U32((u32)(value >> 32), address); + Memory::Write_U32((u32)value, address + 4); } const double m_quantizeTableD[] = @@ -171,7 +171,7 @@ void psq_st(UGeckoInstruction inst) MOVAPS(M(&temp64), XMM0); MOV(16, R(ABI_PARAM1), M(&temp64)); #ifdef _M_X64 - MOV(16, MComplex(RBX, RDX, SCALE_1, 0), R(ABI_PARAM1)); + MOV(16, MComplex(RBX, ABI_PARAM2, SCALE_1, 0), R(ABI_PARAM1)); #else BSWAP(32, ABI_PARAM1); SHR(32, R(ABI_PARAM1), Imm8(16)); @@ -201,7 +201,7 @@ void psq_st(UGeckoInstruction inst) MOV(32, R(ABI_PARAM1), M(&temp64)); #ifdef _M_X64 BSWAP(32, ABI_PARAM1); - MOV(32, MComplex(RBX, RDX, SCALE_1, 0), R(ABI_PARAM1)); + MOV(32, MComplex(RBX, ABI_PARAM2, SCALE_1, 0), R(ABI_PARAM1)); #else BSWAP(32, ABI_PARAM1); CALL(&Memory::Write_U32); @@ -321,4 +321,4 @@ void psq_l(UGeckoInstruction inst) //u32 EA = (m_GPR[_inst.RA] + _inst.SIMM_12) : _inst.SIMM_12; } -} // namespace \ No newline at end of file +} // namespace diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_SystemRegisters.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_SystemRegisters.cpp index 357d14d661..6b9cae7e0a 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_SystemRegisters.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_SystemRegisters.cpp @@ -58,7 +58,7 @@ namespace Jit64 // OK, this is easy. gpr.Lock(d); - gpr.LoadToX64(d,true); + gpr.LoadToX64(d, true); MOV(32, M(&PowerPC::ppcState.spr[iIndex]), gpr.R(d)); gpr.UnlockAll(); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp index 54294598e5..efb5b07049 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp @@ -145,7 +145,7 @@ VertexLoader::VertexLoader() m_AttrDirty = 2; VertexLoader_Normal::Init(); - m_compiledCode = (u8 *)AllocateExecutableMemory(COMPILED_CODE_SIZE); + m_compiledCode = (u8 *)AllocateExecutableMemory(COMPILED_CODE_SIZE, false); if (m_compiledCode) { memset(m_compiledCode, 0, COMPILED_CODE_SIZE); }