mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
vm: Fix memory mirror performance regression
This commit is contained in:
parent
c35d0d16e7
commit
46abe0f315
1 changed files with 4 additions and 5 deletions
|
@ -107,18 +107,17 @@ namespace utils
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
for (u64 addr = (u64)pointer, end = addr + size; addr < end;)
|
for (u64 addr = (u64)pointer, end = addr + size; addr < end;)
|
||||||
{
|
{
|
||||||
// Query current region
|
const u64 boundary = (addr + 0x10000) & -0x10000;
|
||||||
::MEMORY_BASIC_INFORMATION mem;
|
const u64 block_size = std::min(boundary, end) - addr;
|
||||||
verify(HERE), ::VirtualQuery((void*)addr, &mem, sizeof(mem));
|
|
||||||
|
|
||||||
DWORD old;
|
DWORD old;
|
||||||
if (!::VirtualProtect(mem.BaseAddress, std::min<u64>(end - (u64)mem.BaseAddress, mem.RegionSize), +prot, &old))
|
if (!::VirtualProtect((LPVOID)addr, block_size, +prot, &old))
|
||||||
{
|
{
|
||||||
fmt::throw_exception("VirtualProtect failed (%p, 0x%x, addr=0x%x, error=%#x)", pointer, size, addr, GetLastError());
|
fmt::throw_exception("VirtualProtect failed (%p, 0x%x, addr=0x%x, error=%#x)", pointer, size, addr, GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next region
|
// Next region
|
||||||
addr = (u64)mem.BaseAddress + mem.RegionSize;
|
addr += block_size;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
verify(HERE), ::mprotect((void*)((u64)pointer & -4096), ::align(size, 4096), +prot) != -1;
|
verify(HERE), ::mprotect((void*)((u64)pointer & -4096), ::align(size, 4096), +prot) != -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue