diff --git a/Source/Core/Common/Src/MemArena.cpp b/Source/Core/Common/Src/MemArena.cpp index 38e9f7ef50..6e37021989 100644 --- a/Source/Core/Common/Src/MemArena.cpp +++ b/Source/Core/Common/Src/MemArena.cpp @@ -58,19 +58,12 @@ void MemArena::ReleaseSpace() } -void* MemArena::CreateView(s64 offset, size_t size, bool ensure_low_mem) +void* MemArena::CreateView(s64 offset, size_t size) { #ifdef _WIN32 return MapViewOfFile(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size); #else - void* ptr = mmap(0, size, - PROT_READ | PROT_WRITE, - MAP_SHARED -#ifdef __x86_64__ - | (ensure_low_mem ? MAP_32BIT : 0) -#endif - , fd, offset); - return ptr; + return mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); #endif } diff --git a/Source/Core/Common/Src/MemArena.h b/Source/Core/Common/Src/MemArena.h index be0f86de75..4c4acbc2f8 100644 --- a/Source/Core/Common/Src/MemArena.h +++ b/Source/Core/Common/Src/MemArena.h @@ -27,14 +27,13 @@ // This class lets you create a block of anonymous RAM, and then arbitrarily map views into it. // Multiple views can mirror the same section of the block, which makes it very convient for emulating // memory mirrors. -// Pass ensure_low_mem = true to CreateView if you want arbitrarily positioned views to end up in the low 2GB. class MemArena { public: void GrabLowMemSpace(size_t size); void ReleaseSpace(); - void* CreateView(s64 offset, size_t size, bool ensure_low_mem = false); + void* CreateView(s64 offset, size_t size); void* CreateViewAt(s64 offset, size_t size, void* base); void ReleaseView(void* view, size_t size); diff --git a/Source/Core/Common/Src/MemoryUtil.cpp b/Source/Core/Common/Src/MemoryUtil.cpp index f231655971..a2e2308d82 100644 --- a/Source/Core/Common/Src/MemoryUtil.cpp +++ b/Source/Core/Common/Src/MemoryUtil.cpp @@ -34,59 +34,42 @@ void* AllocateExecutableMemory(size_t size, bool low) { #ifdef _WIN32 void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); +#else + void* ptr = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_ANON | MAP_PRIVATE +#if defined __linux__ && defined __x86_64__ + | (low ? MAP_32BIT : 0) +#endif + , -1, 0); +#endif + // printf("Mapped executable memory at %p (size %ld)\n", ptr, + // (unsigned long)size); + + if (ptr == NULL) + PanicAlert("Failed to allocate executable memory"); if ((u64)ptr >= 0x80000000) - { PanicAlert("Executable memory ended up above 2GB!"); - // If this happens, we have to implement a free ram search scheme. ector knows how. - } return ptr; - -#else - void* retval = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_ANON | MAP_PRIVATE -#ifdef __x86_64__ - | (low ? MAP_32BIT : 0) -#endif - , -1, 0); // | MAP_FIXED - // printf("Mapped executable memory at %p (size %i)\n", retval, size); - - if (!retval) - { - PanicAlert("Failed to allocate executable memory, errno=%i", errno); - } - - return retval; -#endif - } void* AllocateMemoryPages(size_t size) { #ifdef _WIN32 void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); - - if (!ptr) - { - PanicAlert("Failed to allocate raw memory"); - } - - return ptr; - #else - void* retval = mmap(0, size, PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, -1, 0); // | MAP_FIXED - // printf("Mapped memory at %p (size %i)\n", retval, size); - - if (!retval) - { - PanicAlert("Failed to allocate raw memory, errno=%i", errno); - } - - return retval; + void* ptr = mmap(0, size, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); #endif + // printf("Mapped memory at %p (size %ld)\n", ptr, + // (unsigned long)size); + + if (ptr == NULL) + PanicAlert("Failed to allocate raw memory"); + + return ptr; } void FreeMemoryPages(void* ptr, size_t size) @@ -125,27 +108,25 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute) #endif } - std::string MemUsage() { - #ifdef _WIN32 +#ifdef _WIN32 DWORD processID = GetCurrentProcessId(); - HANDLE hProcess; - PROCESS_MEMORY_COUNTERS pmc; + HANDLE hProcess; + PROCESS_MEMORY_COUNTERS pmc; std::string Ret; - // Print information about the memory usage of the process. + // Print information about the memory usage of the process. - hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID); - if (NULL == hProcess) return "MemUsage Error"; + hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID); + if (NULL == hProcess) return "MemUsage Error"; - if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) + if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); - CloseHandle(hProcess); + CloseHandle(hProcess); return Ret; - - #else +#else return ""; - #endif +#endif } diff --git a/Source/Core/Common/Src/MemoryUtil.h b/Source/Core/Common/Src/MemoryUtil.h index 5262898b35..3736a8c4bb 100644 --- a/Source/Core/Common/Src/MemoryUtil.h +++ b/Source/Core/Common/Src/MemoryUtil.h @@ -23,11 +23,6 @@ #endif #include -// Linux-specific mmap(2) flag -#ifndef MAP_32BIT -#define MAP_32BIT 0 -#endif - void* AllocateExecutableMemory(size_t size, bool low = true); void* AllocateMemoryPages(size_t size); void FreeMemoryPages(void* ptr, size_t size); diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index 3cf3f04341..5eaa0e1f68 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -91,27 +91,11 @@ void SCoreStartupParameter::LoadDefaults() bJITOff = false; // debugger only settings bJITLoadStoreOff = false; bJITLoadStoreFloatingOff = false; - bJITLoadStorePairedOff = false; + bJITLoadStorePairedOff = false; // XXX not 64-bit clean bJITFloatingPointOff = false; bJITIntegerOff = false; bJITPairedOff = false; bJITSystemRegistersOff = false; -#ifdef __APPLE__ - // These are required for the JIT cores to work in OSX - // Older revs (~4854) Only required LoadStorePaired to be turned off - // Newer revs (~4890) require both turned off - #ifdef _M_X64 - // These work fine in 32bit OSX - // Since the reason why 64bit OSX fails out is due to casting (u32)(u64) - // Since all 64bit applications are above the 32bit memory boundary - bJITLoadStorePairedOff = true; - #endif - //#elif defined(__linux__) - // Similar to OSX, something with LoadStorePaired seems to cause - // crashes on linux. Only Win32 seems to be forgiving enough to - // not do anything funny...(FIXME) - // bJITLoadStorePairedOff = true; -#endif m_strName = "NONE"; m_strUniqueID = "00000000"; diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/JitAsmCommon.cpp b/Source/Core/Core/Src/PowerPC/JitCommon/JitAsmCommon.cpp index 061ba36662..7001268253 100644 --- a/Source/Core/Core/Src/PowerPC/JitCommon/JitAsmCommon.cpp +++ b/Source/Core/Core/Src/PowerPC/JitCommon/JitAsmCommon.cpp @@ -35,63 +35,7 @@ using namespace Gen; -static int temp32; - -#if defined(__APPLE__) && _M_X64 -void CommonAsmRoutines::GenFifoWrite(int size) -{ - // Assume value in ABI_PARAM1 - PUSH(RSI); - if (size != 32) - PUSH(EDX); - BSWAP(size, ABI_PARAM1); - MOV(32, R(EAX), Imm32((u64)GPFifo::m_gatherPipe)); - MOV(64, R(RSI), M(&GPFifo::m_gatherPipeCount)); - if (size != 32) { - MOV(32, R(EDX), R(ABI_PARAM1)); - MOV(size, MComplex(RAX, RSI, 1, 0), R(EDX)); - } else { - MOV(size, MComplex(RAX, RSI, 1, 0), R(ABI_PARAM1)); - } - ADD(64, R(RSI), Imm8(size >> 3)); - MOV(64, M(&GPFifo::m_gatherPipeCount), R(RSI)); - if (size != 32) - POP(EDX); - POP(RSI); - RET(); -} -void CommonAsmRoutines::GenFifoFloatWrite() -{ - // Assume value in XMM0 - PUSH(RSI); - PUSH(EDX); - MOVSS(M(&temp32), XMM0); - MOV(32, R(EDX), M(&temp32)); - BSWAP(32, EDX); - MOV(64, R(RAX), Imm64((u64)GPFifo::m_gatherPipe)); - MOV(64, R(RSI), M(&GPFifo::m_gatherPipeCount)); - MOV(32, MComplex(RAX, RSI, 1, 0), R(EDX)); - ADD(64, R(RSI), Imm8(4)); - MOV(64, M(&GPFifo::m_gatherPipeCount), R(RSI)); - POP(EDX); - POP(RSI); - RET(); -} - -void CommonAsmRoutines::GenFifoXmm64Write() -{ - // Assume value in XMM0. Assume pre-byteswapped (unlike the others here!) - PUSH(RSI); - MOV(64, R(RAX), Imm32((u64)GPFifo::m_gatherPipe)); - MOV(64, R(RSI), M(&GPFifo::m_gatherPipeCount)); - MOVQ_xmm(MComplex(RAX, RSI, 1, 0), XMM0); - ADD(64, R(RSI), Imm8(8)); - MOV(64, M(&GPFifo::m_gatherPipeCount), R(RSI)); - POP(RSI); - RET(); -} -#else void CommonAsmRoutines::GenFifoWrite(int size) { // Assume value in ABI_PARAM1 @@ -116,6 +60,8 @@ void CommonAsmRoutines::GenFifoWrite(int size) } void CommonAsmRoutines::GenFifoFloatWrite() { + int temp32; + // Assume value in XMM0 PUSH(ESI); PUSH(EDX); @@ -143,8 +89,6 @@ void CommonAsmRoutines::GenFifoXmm64Write() POP(ESI); RET(); } -#endif - // Safe + Fast Quantizers, originally from JITIL by magumagu diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index 1838ed9c14..5b9e91a1b2 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -14,6 +14,10 @@ libs = [ 'inputcommon', 'common', 'lua', 'z', 'sfml-network', ] +wxlibs = [ ] + +ldflags = [ ] + if env['HAVE_WX']: files += [ 'AboutDolphin.cpp', @@ -46,7 +50,7 @@ if env['HAVE_WX']: 'WxUtils.cpp', ] - wxlibs = [ 'debwx', 'debugger_ui_util', 'inputuicommon' ] + wxlibs += [ 'debwx', 'debugger_ui_util', 'inputuicommon' ] else: files += [ 'MainNoGUI.cpp', @@ -57,14 +61,15 @@ if sys.platform == 'win32': files += [ "stdafx.cpp" ] elif sys.platform == 'darwin' and not env['HAVE_WX']: files += [ 'cocoaApp.m' ] + ldflags += [ '-Wl,-pagezero_size,0x1000' ] exeNoGUI = '#' + env['prefix'] + '/DolphinNoGUI' elif sys.platform == 'darwin' and env['HAVE_WX']: wxlibs += env['wxconfiglibs'] + ldflags += [ '-Wl,-pagezero_size,0x1000' ] exeGUI = '#' + env['prefix'] + '/Dolphin.app/Contents/MacOS/Dolphin' env.Install('#' + env['prefix'] + '/Dolphin.app/Contents/' + - 'Library/Frameworks/Cg.framework', - '#Externals/Cg/Cg.framework/Cg') + 'Library/Frameworks', '#Externals/Cg/Cg.framework') env.Install(env['data_dir'], '#Data/Sys') env.Install(env['data_dir'], '#Data/User') @@ -104,7 +109,10 @@ else: env.InstallAs(env['data_dir'] + '/sys', '#Data/Sys') env.InstallAs(env['data_dir'] + '/user', '#Data/User') +libs = wxlibs + libs + env['LIBS'] +linkflags = ldflags + env['LINKFLAGS'] + if env['HAVE_WX']: - env.Program(exeGUI, files, LIBS = wxlibs + libs + env['LIBS']) + env.Program(exeGUI, files, LIBS = libs, LINKFLAGS = linkflags) else: - env.Program(exeNoGUI, files, LIBS = libs + env['LIBS']) + env.Program(exeNoGUI, files, LIBS = libs, LINKFLAGS = linkflags) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript index b15c94c7cb..4e9508f31d 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript @@ -31,15 +31,17 @@ files = [ 'VertexFormatConverter.cpp', 'VertexLoader.cpp', 'VideoConfig.cpp', - 'VideoConfigDialog.cpp', 'XFMemLoader.cpp', ] -libs = [ 'videocommon', 'GLEW', 'SOIL', 'common' ] +if env['HAVE_WX']: + files += [ 'VideoConfigDialog.cpp' ] if sys.platform == 'darwin' and not env['HAVE_WX']: files += [ 'cocoaGL.m' ] elif sys.platform == 'win32': files += [ 'Win32.cpp' ] +libs = [ 'videocommon', 'GLEW', 'SOIL', 'common' ] + env.SharedLibrary(env['plugin_dir'] + name, files, LIBS = env['LIBS'] + libs)