From 46ddcac3397da822618f271b8dda491d7c5ca10d Mon Sep 17 00:00:00 2001 From: invertego Date: Wed, 27 Sep 2023 02:08:47 -0700 Subject: [PATCH] recompiler: revert "avoid overallocation in code buffer" (#1241) Turns out the overallocation was masking some bugs in sljit. Will take this upstream and revert the ares change in the meantime. --- nall/bump-allocator.hpp | 4 ++-- nall/recompiler/generic/generic.hpp | 1 - thirdparty/sljitAllocator.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/nall/bump-allocator.hpp b/nall/bump-allocator.hpp index 4f20b2f6bc..dbf1e52adc 100644 --- a/nall/bump-allocator.hpp +++ b/nall/bump-allocator.hpp @@ -88,9 +88,9 @@ struct bump_allocator { _offset = nextOffset(size); //alignment } - auto tryAcquire(u32 size, bool reserve = true) -> u8* { + auto tryAcquire(u32 size) -> u8* { if((nextOffset(size)) > _capacity) return nullptr; - return reserve ? acquire(size) : acquire(); + return acquire(size); } private: diff --git a/nall/recompiler/generic/generic.hpp b/nall/recompiler/generic/generic.hpp index 748c735fe1..8872c460d2 100644 --- a/nall/recompiler/generic/generic.hpp +++ b/nall/recompiler/generic/generic.hpp @@ -31,7 +31,6 @@ namespace nall::recompiler { auto endFunction() -> u8* { u8* code = (u8*)sljit_generate_code(compiler); - allocator.reserve(sljit_get_generated_code_size(compiler)); resetCompiler(); return code; } diff --git a/thirdparty/sljitAllocator.cpp b/thirdparty/sljitAllocator.cpp index 0d8146d6f9..3e5b7e338c 100644 --- a/thirdparty/sljitAllocator.cpp +++ b/thirdparty/sljitAllocator.cpp @@ -5,5 +5,5 @@ auto sljit_nall_malloc_exec(sljit_uw size, void* exec_allocator_data) -> void* { auto allocator = (nall::bump_allocator*)exec_allocator_data; - return allocator->tryAcquire(size, false); + return allocator->acquire(size); }