More linux...

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@122 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-08-01 13:59:37 +00:00
parent 814af6c7b9
commit 9a4c66e066
10 changed files with 39 additions and 29 deletions

View File

@ -38,7 +38,7 @@
// This is purposedely not a full wrapper for virtualalloc/mmap, but it // This is purposedely not a full wrapper for virtualalloc/mmap, but it
// provides exactly the primitive operations that Dolphin needs. // provides exactly the primitive operations that Dolphin needs.
void* AllocateExecutableMemory(int size) void* AllocateExecutableMemory(int size, bool low)
{ {
#ifdef _WIN32 #ifdef _WIN32
void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 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, void* retval = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_ANONYMOUS | MAP_PRIVATE MAP_ANONYMOUS | MAP_PRIVATE
#ifdef __x86_64__ #ifdef __x86_64__
| MAP_32BIT | (low ? MAP_32BIT : 0)
#endif #endif
, -1, 0); // | MAP_FIXED , -1, 0); // | MAP_FIXED
printf("mappah exe %p %i\n", retval, size); printf("mappah exe %p %i\n", retval, size);

View File

@ -18,7 +18,7 @@
#ifndef _MEMORYUTIL_H #ifndef _MEMORYUTIL_H
#define _MEMORYUTIL_H #define _MEMORYUTIL_H
void* AllocateExecutableMemory(int size); void* AllocateExecutableMemory(int size, bool low = true);
void* AllocateMemoryPages(int size); void* AllocateMemoryPages(int size);
void FreeMemoryPages(void* ptr, int size); void FreeMemoryPages(void* ptr, int size);
void WriteProtectMemory(void* ptr, int size, bool executable = false); void WriteProtectMemory(void* ptr, int size, bool executable = false);

View File

@ -313,7 +313,7 @@ namespace Gen
s64 fn = (s64)fnptr; s64 fn = (s64)fnptr;
s64 c = (s64)code; s64 c = (s64)code;
if (myabs(fn - c) >= 0x80000000ULL) { 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)); s32 distance = (s32)(fn - ((u64)code + 5));
Write8(0xE8); Write8(0xE8);
@ -325,7 +325,8 @@ namespace Gen
//TODO fix //TODO fix
u64 jump = (code - (u8*)j8) - 1; 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; *j8 = (u8)jump;
} }
@ -1107,6 +1108,7 @@ namespace Gen
else else
{ {
// Simulate this instruction with SSE2 instructions // Simulate this instruction with SSE2 instructions
if (!arg.IsSimpleReg(regOp))
MOVAPD(regOp, arg); MOVAPD(regOp, arg);
UNPCKLPD(regOp, R(regOp)); UNPCKLPD(regOp, R(regOp));
} }

View File

@ -260,13 +260,17 @@ namespace Jit64
bool ImHereDebug = false; bool ImHereDebug = false;
std::map<u32, bool> been_here; std::map<u32, int> been_here;
void ImHere() void ImHere()
{ {
if (been_here.find(PC) != been_here.end()) if (been_here.find(PC) != been_here.end()) {
been_here.find(PC)->second++;
if ((been_here.find(PC)->second) & 1023)
return; return;
}
LOG(DYNA_REC, "I'm here - PC = %08x , LR = %08x", PC, LR); 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() void FlushRegCaches()

View File

@ -23,11 +23,11 @@ void BackPatchError(const std::string &text, u8 *codePtr, u32 emAddress) {
char disbuf[256]; char disbuf[256];
memset(disbuf, 0, 256); memset(disbuf, 0, 256);
#ifdef _M_IX86 #ifdef _M_IX86
disasm.disasm32( disasm.disasm32
#else #else
disasm.disasm64( disasm.disasm64
#endif #endif
0, code_addr, codePtr, disbuf); (0, code_addr, codePtr, disbuf);
PanicAlert("%s\n\n" PanicAlert("%s\n\n"
"Error encountered accessing emulated address %08x.\n" "Error encountered accessing emulated address %08x.\n"
"Culprit instruction: \n%s\nat %08x%08x", "Culprit instruction: \n%s\nat %08x%08x",
@ -82,9 +82,9 @@ void BackPatch(u8 *codePtr, int accessType, u32 emAddress)
// * Set up stack frame. // * Set up stack frame.
// * Call ReadMemory32 // * Call ReadMemory32
//LEA(32, ECX, MDisp((X64Reg)addrReg, info.displacement)); //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) { if (info.displacement) {
ADD(32, R(ECX), Imm32(info.displacement)); ADD(32, R(ABI_PARAM1), Imm32(info.displacement));
} }
switch (info.operandSize) { switch (info.operandSize) {
//case 1: //case 1:

View File

@ -198,6 +198,7 @@ namespace Jit64
bool GPRRegCache::IsXRegVolatile(X64Reg reg) const bool GPRRegCache::IsXRegVolatile(X64Reg reg) const
{ {
#ifdef _WIN32
switch (reg) switch (reg)
{ {
case RAX: case RCX: case RDX: case R8: case R9: case R10: case R11: case RAX: case RCX: case RDX: case R8: case R9: case R10: case R11:
@ -208,6 +209,9 @@ namespace Jit64
default: default:
return false; return false;
} }
#else
return true;
#endif
} }
void RegCache::DiscardRegContentsIfCached(int preg) void RegCache::DiscardRegContentsIfCached(int preg)
@ -252,7 +256,7 @@ namespace Jit64
#ifdef _WIN32 #ifdef _WIN32
RSI, RDI, R12, R13, R14, R8, R9, RDX, R10, R11 //, RCX RSI, RDI, R12, R13, R14, R8, R9, RDX, R10, R11 //, RCX
#else #else
R12, R13, R14, R8, R9, RDX, R10, R11, RSI, RDI //, RCX R12, R13, R14, R8, R9, R10, R11, RSI, RDI //, RCX
#endif #endif
#elif _M_IX86 #elif _M_IX86
ESI, EDI, EBX, EBP, EDX //, RCX ESI, EDI, EBX, EBP, EDX //, RCX

View File

@ -188,9 +188,9 @@ namespace Jit64
#ifdef _M_X64 #ifdef _M_X64
if (!jo.noAssumeFPLoadFromMem) 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 //#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 //#endif
BSWAP(32, EAX); BSWAP(32, EAX);
} }
@ -221,8 +221,8 @@ namespace Jit64
} }
s32 offset = (s32)(s16)inst.SIMM_16; s32 offset = (s32)(s16)inst.SIMM_16;
gpr.Lock(a); gpr.Lock(a);
MOV(32, R(ECX), gpr.R(a)); MOV(32, R(ABI_PARAM1), gpr.R(a));
MOV(64, R(EAX), MComplex(RBX, ECX, SCALE_1, offset)); MOV(64, R(EAX), MComplex(RBX, ABI_PARAM1, SCALE_1, offset));
BSWAP(64,EAX); BSWAP(64,EAX);
MOV(64, M(&temp64), R(EAX)); MOV(64, M(&temp64), R(EAX));
fpr.Lock(d); fpr.Lock(d);
@ -249,10 +249,10 @@ namespace Jit64
fpr.Lock(s); fpr.Lock(s);
fpr.LoadToX64(s, true, false); fpr.LoadToX64(s, true, false);
MOVSD(M(&temp64), fpr.RX(s)); 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)); MOV(64, R(EAX), M(&temp64));
BSWAP(64, EAX); 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(); gpr.UnlockAll();
fpr.UnlockAll(); fpr.UnlockAll();
} }

View File

@ -171,7 +171,7 @@ void psq_st(UGeckoInstruction inst)
MOVAPS(M(&temp64), XMM0); MOVAPS(M(&temp64), XMM0);
MOV(16, R(ABI_PARAM1), M(&temp64)); MOV(16, R(ABI_PARAM1), M(&temp64));
#ifdef _M_X64 #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 #else
BSWAP(32, ABI_PARAM1); BSWAP(32, ABI_PARAM1);
SHR(32, R(ABI_PARAM1), Imm8(16)); SHR(32, R(ABI_PARAM1), Imm8(16));
@ -201,7 +201,7 @@ void psq_st(UGeckoInstruction inst)
MOV(32, R(ABI_PARAM1), M(&temp64)); MOV(32, R(ABI_PARAM1), M(&temp64));
#ifdef _M_X64 #ifdef _M_X64
BSWAP(32, ABI_PARAM1); 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 #else
BSWAP(32, ABI_PARAM1); BSWAP(32, ABI_PARAM1);
CALL(&Memory::Write_U32); CALL(&Memory::Write_U32);

View File

@ -145,7 +145,7 @@ VertexLoader::VertexLoader()
m_AttrDirty = 2; m_AttrDirty = 2;
VertexLoader_Normal::Init(); VertexLoader_Normal::Init();
m_compiledCode = (u8 *)AllocateExecutableMemory(COMPILED_CODE_SIZE); m_compiledCode = (u8 *)AllocateExecutableMemory(COMPILED_CODE_SIZE, false);
if (m_compiledCode) { if (m_compiledCode) {
memset(m_compiledCode, 0, COMPILED_CODE_SIZE); memset(m_compiledCode, 0, COMPILED_CODE_SIZE);
} }