Various linux stuff - JIT does not work yet :(

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@109 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-07-30 22:17:52 +00:00
parent fb7a7f9001
commit 5698cbde2f
8 changed files with 76 additions and 72 deletions

View File

@ -1,7 +1,11 @@
import os
import sys
ccflags = '-g -O3 -fno-strict-aliasing -fPIC -msse2 -Wall -DLOGGING -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE'
warnings = ' -Wall -Wwrite-strings -Wfloat-equal -Wshadow -Wpointer-arith -Wcast-qual -Wpacked'
nonactive_warnings = '-Wunreachable-code'
ccflags = '-g -O3 -fno-strict-aliasing -fPIC -msse2 -DLOGGING -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE' + warnings
if sys.platform == 'darwin':
ccflags += ' -I/opt/local/include'
@ -25,15 +29,15 @@ if sys.platform == 'darwin':
"Externals/Bochs_disasm",
"Source/Core/Core/Src",
"Source/Core/DiscIO/Src",
"Source/Core/DebuggerWX/src",
"Source/Core/VideoCommon/Src",
# "Source/Plugins/Plugin_VideoOGL/Src",
"Source/Plugins/Plugin_DSP_NULL/Src",
# "Source/Plugins/Plugin_DSP_LLE/Src",
"Source/Plugins/Plugin_PadSimple/Src",
"Source/Plugins/Plugin_nJoy_SDL/Src",
"Source/Core/DolphinWX/src",
]
"Source/Core/DebuggerWX/src",
"Source/Core/VideoCommon/Src",
# "Source/Plugins/Plugin_VideoOGL/Src",
"Source/Plugins/Plugin_DSP_NULL/Src",
# "Source/Plugins/Plugin_DSP_LLE/Src",
"Source/Plugins/Plugin_PadSimple/Src",
"Source/Plugins/Plugin_nJoy_SDL/Src",
"Source/Core/DolphinWX/src",
]
else:
dirs = ["Source/Core/Common/Src",
"Externals/Bochs_disasm",

View File

@ -112,12 +112,12 @@ u64 MemArena::Find4GBBase()
VirtualFree(base, 0, MEM_RELEASE);
return((u64)base);
#else
// Very precarious - mmap cannot return an error when trying to map already used pages.
// This makes the Windows approach above unusable on Linux, so we will simply pray...
// TODO(ector): Do correctly (yeah i know how to do it now :P)
return(0x2300000000ULL);
#endif
#else
// This is the one that will be tricky on Unix, if I want to be nice.
// 32 bit
// The highest thing in any 1GB section of memory space is the locked cache. We only need to fit it.
u8* base = (u8*)VirtualAlloc(0, 0x31000000, MEM_RESERVE, PAGE_READWRITE);

View File

@ -124,4 +124,3 @@ void UnWriteProtectMemory(void* ptr, int size, bool allowExecute)
#endif
}

View File

@ -233,18 +233,18 @@ namespace Jit64
if (js.isLastInstruction)
{
MOV(32, M(&PC), Imm32(js.compilerPC));
MOV(32, M(&NPC), Imm32(js.compilerPC+4));
MOV(32, M(&NPC), Imm32(js.compilerPC + 4));
}
#ifdef _M_X64
MOV(32,R(RCX), Imm32(_inst.hex));
MOV(32, R(XR_PARAM1), Imm32(_inst.hex));
CInterpreter::_interpreterInstruction instr = GetInterpreterOp(_inst);
CALL((void*)instr);
#elif _M_IX86
MOV(32,R(ECX), Imm32(_inst.hex));
MOV(32, R(ECX), Imm32(_inst.hex));
PUSH(ECX);
CInterpreter::_interpreterInstruction instr = GetInterpreterOp(_inst);
CALL((void*)instr);
ADD(32,R(ESP), Imm8(4));
ADD(32, R(ESP), Imm8(4));
#endif
}
@ -257,8 +257,8 @@ namespace Jit64
{
FlushRegCaches();
#ifdef _M_X64
MOV(32, R(ECX), Imm32(js.compilerPC));
MOV(32, R(EDX), Imm32(_inst.hex));
MOV(32, R(XR_PARAM1), Imm32(js.compilerPC));
MOV(32, R(XR_PARAM2), Imm32(_inst.hex));
#elif _M_IX86
PUSH(32, Imm32(_inst.hex));
PUSH(32, Imm32(js.compilerPC));
@ -361,13 +361,14 @@ namespace Jit64
SetJumpTarget(skip);
const u8 *normalEntry = GetCodePtr();
if (ImHereDebug) CALL((void *)&ImHere); //Used to get a trace of the last few blocks before a crash, sometimes VERY useful
if (ImHereDebug)
CALL((void *)&ImHere); //Used to get a trace of the last few blocks before a crash, sometimes VERY useful
if (js.fpa.any)
{
//This block uses FPU - needs to add FP exception bailout
// TODO(ector): change to large J_CC(CC_Z) when verified that it still works
TEST(32, M(&PowerPC::ppcState.msr), Imm32(1<<13)); //Test FP bit
TEST(32, M(&PowerPC::ppcState.msr), Imm32(1 << 13)); //Test FP bit
FixupBranch b1 = J_CC(CC_NZ);
MOV(32, M(&PC), Imm32(js.blockStart));
JMP(Asm::fpException, true);
@ -391,7 +392,8 @@ namespace Jit64
js.compilerPC = ops[i].address;
js.op = &ops[i];
js.instructionNumber = i;
if (i == (int)size - 1) js.isLastInstruction = true;
if (i == (int)size - 1)
js.isLastInstruction = true;
PPCTables::CompileInstruction(ops[i].inst);
gpr.SanityCheck();
fpr.SanityCheck();

View File

@ -25,6 +25,16 @@
#include "../PPCAnalyst.h"
#include "JitCache.h"
#ifdef _WIN32
#define XR_PARAM1 ECX
#define XR_PARAM2 EDX
#else
#define XR_PARAM1 RDI
#define XR_PARAM2 RSI
#define XR_PARAM3 RDX
#define XR_PARAM4 RCX
#endif
namespace Jit64
{
struct JitStats

View File

@ -188,6 +188,7 @@ void Generate()
{
enterCode = AlignCode16();
//we only want to do this once
#ifdef _WIN32
PUSH(RBX);
PUSH(RSI);
PUSH(RDI);
@ -197,7 +198,14 @@ void Generate()
PUSH(R15);
//TODO: Also preserve XMM0-3?
SUB(64, R(RSP), Imm8(0x20));
//INT3();
#else
PUSH(RBP);
PUSH(RBX);
PUSH(R12);
PUSH(R13);
PUSH(R14);
PUSH(R15);
#endif
MOV(64, R(RBX), Imm64((u64)Memory::base));
if ((u64)GetCodePointers() > 0x80000000ULL) {
@ -233,11 +241,11 @@ void Generate()
ADD(32, M(&PowerPC::ppcState.DebugCount), Imm8(1));
}
//grab from list and jump to it
JMPptr(MComplex(R15,RAX,8,0));
JMPptr(MComplex(R15, RAX, 8, 0));
SetJumpTarget(notfound);
//Ok, no block, let's jit
MOV(32, R(ECX), M(&PowerPC::ppcState.pc));
MOV(32, R(XR_PARAM1), M(&PowerPC::ppcState.pc));
CALL((void *)&Jit);
JMP(dispatcherNoCheck); // no point in special casing this, not the "fast path"
@ -260,7 +268,7 @@ void Generate()
CALL((void *)&CoreTiming::Advance);
testExceptions = GetCodePtr();
TEST(32,M(&PowerPC::ppcState.Exceptions), Imm32(0xFFFFFFFF));
TEST(32, M(&PowerPC::ppcState.Exceptions), Imm32(0xFFFFFFFF));
FixupBranch skipExceptions = J_CC(CC_Z);
MOV(32, R(EAX), M(&PC));
MOV(32, M(&NPC), R(EAX));
@ -271,7 +279,7 @@ void Generate()
TEST(32, M((void*)&PowerPC::state), Imm32(0xFFFFFFFF));
J_CC(CC_Z, outerLoop, true);
#ifdef _WIN32
//Landing pad for drec space
ADD(64, R(RSP), Imm8(0x20));
POP(R15);
@ -281,6 +289,14 @@ void Generate()
POP(RDI);
POP(RSI);
POP(RBX);
#else
PUSH(R15);
PUSH(R14);
PUSH(R13);
PUSH(R12);
PUSH(RBX);
PUSH(RBP);
#endif
RET();
computeRc = AlignCode16();
@ -321,43 +337,6 @@ void Generate()
}
MessageBox(0,(char*)xDis,"yo",0);
delete [] xDis; */
/*
RUNTIME_FUNCTION func;
func.BeginAddress = 0;
func.EndAddress = (u32)(GetCodePtr() - enterCode);
func.UnwindData = 0;
RtlAddFunctionTable(&func, 1, (ULONGLONG)enterCode);*/
/*
//we only want to do this once
PUSH(RBX);
PUSH(RSI);
PUSH(RDI);
PUSH(R12);
PUSH(R13);
PUSH(R14);
PUSH(R15);
//TODO: Also preserve XMM0-3?
SUB(64, R(RSP), Imm8(0x20));
MOV(32, R(R15), M(&Memory::base));
MOV(32, M(&PowerPC::ppcState.pc), R(R14));
//Landing pad for drec space
ADD(64, R(RSP), Imm8(0x20));
POP(R15);
POP(R14);
POP(R13);
POP(R12);
POP(RDI);
POP(RSI);
POP(RBX);
RET();*/
}
#endif
}

View File

@ -104,8 +104,7 @@ namespace Jit64
{
int aCount;
const int *aOrder = GetAllocationOrder(aCount);
int i;
for (i = 0; i < aCount; i++)
for (int i = 0; i < aCount; i++)
{
X64Reg xr = (X64Reg)aOrder[i];
if (!xlocks[xr] && xregs[xr].free)
@ -201,11 +200,16 @@ namespace Jit64
{
switch (reg)
{
#ifdef _WIN32
case RAX: case RCX: case RDX: case R8: case R9: case R10: case R11:
#ifdef _M_IX86
case RBX:
#endif
#else
// linux64
case RAX: case RCX: case RDX: case RSI: case RDI: case R9: case R10: case R11:
return true;
#endif
default:
return false;
}
@ -250,10 +254,14 @@ namespace Jit64
{
static const int allocationOrder[] =
{
#ifdef _WIN32
#ifdef _M_X64
RSI, RDI, R12, R13, R14, R8, R9, RDX, R10, R11 //, RCX
#elif _M_IX86
ESI, EDI, EBX, EBP, EDX //, RCX
#endif
#else
R12, R13, R14, R15, RDX,
#endif
};
count = sizeof(allocationOrder) / sizeof(const int);
@ -266,10 +274,14 @@ namespace Jit64
{
static const int allocationOrder[] =
{
#ifdef _WIN32
#ifdef _M_X64
XMM6, XMM7, XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, XMM2, XMM3, XMM4, XMM5
#elif _M_IX86
XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
#endif
#else
XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15,
#endif
};
count = sizeof(allocationOrder) / sizeof(int);

View File

@ -57,9 +57,6 @@ bool BootCore(const std::string& _rFilename)
// StartUp.bUseDualCore = false;
StartUp.bUseDynarec = true;
}
#ifndef _WIN32
StartUp.bUseDynarec = false;//Never use Dynarec in Linux, crashes
#endif
StartUp.m_BootType = SCoreStartupParameter::BOOT_ISO;
StartUp.m_strFilename = _rFilename;
StartUp.bRunCompareClient = false;
@ -68,8 +65,9 @@ bool BootCore(const std::string& _rFilename)
std::string BaseDataPath;
#ifdef _WIN32
StartUp.hInstance = wxGetInstance();
#endif
#else
StartUp.bUseDynarec = false;
#endif
StartUp.AutoSetup(SCoreStartupParameter::BOOT_DEFAULT);
// Load overrides