summaryrefslogtreecommitdiff
path: root/Source/Core/Common/MemoryUtil.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2017-04-14 12:53:32 +0200
committerJosJuice <josjuice@gmail.com>2017-05-20 09:35:53 +0200
commit4b4cf509f8746a8c4afb73a2a2de165179201db6 (patch)
treee85c7ac4504b2b13d165121ffe15884c180dc11f /Source/Core/Common/MemoryUtil.cpp
parent89535468eb178af2a0dcfafff7b47bbbc3c0e2e1 (diff)
Remove code for only allocating low memory
This is unnecessary when we have position-independent code.
Diffstat (limited to 'Source/Core/Common/MemoryUtil.cpp')
-rw-r--r--Source/Core/Common/MemoryUtil.cpp59
1 files changed, 5 insertions, 54 deletions
diff --git a/Source/Core/Common/MemoryUtil.cpp b/Source/Core/Common/MemoryUtil.cpp
index 4eb2e1f2d3..db8201f84e 100644
--- a/Source/Core/Common/MemoryUtil.cpp
+++ b/Source/Core/Common/MemoryUtil.cpp
@@ -29,74 +29,25 @@
#endif
#endif
-// Valgrind doesn't support MAP_32BIT.
-// Uncomment the following line to be able to run Dolphin in Valgrind.
-//#undef MAP_32BIT
-
namespace Common
{
-#if !defined(_WIN32) && defined(_M_X86_64) && !defined(MAP_32BIT)
-#include <unistd.h>
-static uintptr_t RoundPage(uintptr_t addr)
-{
- uintptr_t mask = getpagesize() - 1;
- return (addr + mask) & ~mask;
-}
-#endif
-
// This is purposely not a full wrapper for virtualalloc/mmap, but it
// provides exactly the primitive operations that Dolphin needs.
-void* AllocateExecutableMemory(size_t size, bool low)
+void* AllocateExecutableMemory(size_t size)
{
#if defined(_WIN32)
void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else
- static char* map_hint = nullptr;
-#if defined(_M_X86_64) && !defined(MAP_32BIT)
- // This OS has no flag to enforce allocation below the 4 GB boundary,
- // but if we hint that we want a low address it is very likely we will
- // get one.
- // An older version of this code used MAP_FIXED, but that has the side
- // effect of discarding already mapped pages that happen to be in the
- // requested virtual memory range (such as the emulated RAM, sometimes).
- if (low && (!map_hint))
- map_hint = (char*)RoundPage(512 * 1024 * 1024); /* 0.5 GB rounded up to the next page */
-#endif
- void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE
-#if defined(_M_X86_64) && defined(MAP_32BIT)
- | (low ? MAP_32BIT : 0)
-#endif
- ,
- -1, 0);
-#endif /* defined(_WIN32) */
+ void* ptr =
+ mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
-#ifdef _WIN32
- if (ptr == nullptr)
- {
-#else
if (ptr == MAP_FAILED)
- {
ptr = nullptr;
#endif
- PanicAlert("Failed to allocate executable memory. If you are running Dolphin in Valgrind, try "
- "'#undef MAP_32BIT'.");
- }
-#if !defined(_WIN32) && defined(_M_X86_64) && !defined(MAP_32BIT)
- else
- {
- if (low)
- {
- map_hint += size;
- map_hint = (char*)RoundPage((uintptr_t)map_hint); /* round up to the next page */
- }
- }
-#endif
-#if _M_X86_64
- if ((u64)ptr >= 0x80000000 && low == true)
- PanicAlert("Executable memory ended up above 2GB!");
-#endif
+ if (ptr == nullptr)
+ PanicAlert("Failed to allocate executable memory");
return ptr;
}