From f3a616df24cf9bf95d012f53f50fae391af8c172 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 2 Jan 2016 13:24:58 -0800 Subject: [PATCH] Jit: Properly re-allocate when jit is freed a lot. Fixes #8334. --- Common/MemoryUtil.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Common/MemoryUtil.cpp b/Common/MemoryUtil.cpp index 6096e176c4..9b6261faac 100644 --- a/Common/MemoryUtil.cpp +++ b/Common/MemoryUtil.cpp @@ -177,6 +177,12 @@ void *AllocateExecutableMemory(size_t size, bool exec) { else if (exec && (uintptr_t)map_hint <= 0xFFFFFFFF) { // Round up if we're below 32-bit mark, probably allocating sequentially. map_hint += round_page(size); + + // If we moved ahead too far, skip backwards and recalculate. + // When we free, we keep moving forward and eventually move too far. + if ((uintptr_t)map_hint - (uintptr_t) &hint_location >= 0x70000000) { + map_hint = 0; + } } #endif