Skip to content

Commit b29f46f

Browse files
committed
Merge pull request hrydgard#8363 from unknownbrackets/jit-alloc
Jit: Properly re-allocate when jit is freed a lot
2 parents 5bd72ea + f3a616d commit b29f46f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Common/MemoryUtil.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ void *AllocateExecutableMemory(size_t size, bool exec) {
177177
else if (exec && (uintptr_t)map_hint <= 0xFFFFFFFF) {
178178
// Round up if we're below 32-bit mark, probably allocating sequentially.
179179
map_hint += round_page(size);
180+
181+
// If we moved ahead too far, skip backwards and recalculate.
182+
// When we free, we keep moving forward and eventually move too far.
183+
if ((uintptr_t)map_hint - (uintptr_t) &hint_location >= 0x70000000) {
184+
map_hint = 0;
185+
}
180186
}
181187
#endif
182188

0 commit comments

Comments
 (0)