1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Block parallel JIT allocation on macos

This commit is contained in:
kd-11 2024-08-29 03:28:04 +03:00 committed by kd-11
parent ce9024efc5
commit 4d193ecb6a
2 changed files with 6 additions and 7 deletions

View File

@ -253,6 +253,11 @@ uchar* jit_runtime::_alloc(usz size, usz align) noexcept
u8* jit_runtime::alloc(usz size, usz align, bool exec) noexcept u8* jit_runtime::alloc(usz size, usz align, bool exec) noexcept
{ {
#if defined(__APPLE__)
static std::mutex s_alloc_lock;
std::lock_guard lock(s_alloc_lock);
#endif
if (exec) if (exec)
{ {
return add_jit_memory<s_code_pos, 0x0, utils::protection::wx>(size, align); return add_jit_memory<s_code_pos, 0x0, utils::protection::wx>(size, align);

View File

@ -260,13 +260,7 @@ namespace utils
#ifdef __APPLE__ #ifdef __APPLE__
#ifdef ARCH_ARM64 #ifdef ARCH_ARM64
// NOTE: On MacOS, parallel calls to mmap can return the same address more than once. Trying to madvise the same address twice throws EPERM. auto ptr = ::mmap(use_addr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_JIT | c_map_noreserve, -1, 0);
static std::mutex mmap_lock;
void* ptr;
{
std::lock_guard lock(mmap_lock);
ptr = ::mmap(use_addr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_JIT | c_map_noreserve, -1, 0);
}
#else #else
auto ptr = ::mmap(use_addr, size, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_JIT | c_map_noreserve, -1, 0); auto ptr = ::mmap(use_addr, size, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_JIT | c_map_noreserve, -1, 0);
#endif #endif