Permalink
Browse files

memory fix

  • Loading branch information...
1 parent 73906f9 commit bb111d325fa40bb817c8d05285f7c2a91589b2d0 @Nekotekina Nekotekina committed Feb 10, 2017
Showing with 15 additions and 8 deletions.
  1. +2 −2 Utilities/JIT.cpp
  2. +5 −5 Utilities/VirtualMemory.cpp
  3. +5 −0 rpcs3/Emu/Cell/PPUThread.cpp
  4. +2 −0 rpcs3/Emu/System.cpp
  5. +1 −1 rpcs3/Gui/InterpreterDisAsm.cpp
View
@@ -207,9 +207,9 @@ struct MemoryManager final : llvm::RTDyldMemoryManager
LOG_FATAL(GENERAL, "VirtualFree(%p) failed! Error %u", s_memory, GetLastError());
}
#else
- if (::mprotect(s_memory, s_memory_size, PROT_NONE))
+ if (!::mmap(s_memory, s_memory_size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0))
{
- LOG_FATAL(GENERAL, "mprotect(%p) failed! Error %d", s_memory, errno);
+ LOG_FATAL(GENERAL, "mmap(%p) failed! Error %d", s_memory, errno);
}
// TODO: unregister EH frames if necessary
@@ -13,7 +13,7 @@
namespace memory_helper
{
- void* reserve_memory(size_t size)
+ void* reserve_memory(std::size_t size)
{
#ifdef _WIN32
return verify("reserve_memory" HERE, VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS));
@@ -22,21 +22,21 @@ namespace memory_helper
#endif
}
- void commit_page_memory(void* pointer, size_t size)
+ void commit_page_memory(void* pointer, std::size_t size)
{
#ifdef _WIN32
verify(HERE), VirtualAlloc(pointer, size, MEM_COMMIT, PAGE_READWRITE);
#else
- verify(HERE), ::mprotect((void*)((u64)pointer & -4096), size, PROT_READ | PROT_WRITE) != -1;
+ verify(HERE), ::mprotect((void*)((u64)pointer & -4096), ::align(size, 4096), PROT_READ | PROT_WRITE) != -1;
#endif
}
- void free_reserved_memory(void* pointer, size_t size)
+ void free_reserved_memory(void* pointer, std::size_t size)
{
#ifdef _WIN32
verify(HERE), VirtualFree(pointer, 0, MEM_DECOMMIT);
#else
- verify(HERE), ::mprotect(pointer, size, PROT_NONE) != -1;
+ verify(HERE), ::mmap(pointer, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
#endif
}
}
@@ -73,6 +73,11 @@ extern void ppu_execute_function(ppu_thread& ppu, u32 index);
const auto s_ppu_compiled = static_cast<u32*>(memory_helper::reserve_memory(0x100000000));
+extern void ppu_finalize()
+{
+ memory_helper::free_reserved_memory(s_ppu_compiled, 0x100000000);
+}
+
// Get interpreter cache value
static u32 ppu_cache(u32 addr)
{
@@ -50,6 +50,7 @@ extern void ppu_load_exec(const ppu_exec_object&);
extern void spu_load_exec(const spu_exec_object&);
extern void arm_load_exec(const arm_exec_object&);
extern std::shared_ptr<struct lv2_prx> ppu_load_prx(const ppu_prx_object&);
+extern void ppu_finalize();
fs::file g_tty;
@@ -460,6 +461,7 @@ void Emulator::Stop()
RSXIOMem.Clear();
vm::close();
+ ppu_finalize();
if (g_cfg_autoexit)
{
@@ -424,7 +424,7 @@ void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event))
if (cpu && cpu->state.test_and_reset(cpu_flag::dbg_pause))
{
- if (!test(cpu->state, cpu_state_pause))
+ if (!test(cpu->state, cpu_flag::dbg_pause + cpu_flag::dbg_global_pause))
{
cpu->notify();
}

0 comments on commit bb111d3

Please sign in to comment.