diff --git a/src/xenia/base/memory_posix.cc b/src/xenia/base/memory_posix.cc index bb14fc583..15a9ab858 100644 --- a/src/xenia/base/memory_posix.cc +++ b/src/xenia/base/memory_posix.cc @@ -171,7 +171,7 @@ bool DeallocFixed(void* base_address, size_t length, case DeallocationType::kDecommit: return Protect(base_address, length, PageAccess::kNoAccess); case DeallocationType::kRelease: - assert_always("Error: Tried to release mapped memory!"); + return false; default: assert_unhandled_case(deallocation_type); } diff --git a/src/xenia/cpu/backend/x64/x64_code_cache.cc b/src/xenia/cpu/backend/x64/x64_code_cache.cc index b63127c6f..c386d15ca 100644 --- a/src/xenia/cpu/backend/x64/x64_code_cache.cc +++ b/src/xenia/cpu/backend/x64/x64_code_cache.cc @@ -38,7 +38,7 @@ X64CodeCache::X64CodeCache() = default; X64CodeCache::~X64CodeCache() { if (indirection_table_base_) { - xe::memory::DeallocFixed(indirection_table_base_, 0, + xe::memory::DeallocFixed(indirection_table_base_, kIndirectionTableSize, xe::memory::DeallocationType::kRelease); } diff --git a/src/xenia/cpu/backend/x64/x64_emitter.cc b/src/xenia/cpu/backend/x64/x64_emitter.cc index 5262d0a4f..51e9847fd 100644 --- a/src/xenia/cpu/backend/x64/x64_emitter.cc +++ b/src/xenia/cpu/backend/x64/x64_emitter.cc @@ -1291,7 +1291,8 @@ uintptr_t X64Emitter::PlaceConstData() { } void X64Emitter::FreeConstData(uintptr_t data) { - memory::DeallocFixed(reinterpret_cast(data), 0, + memory::DeallocFixed(reinterpret_cast(data), + xe::round_up(kConstDataSize, memory::page_size()), memory::DeallocationType::kRelease); } diff --git a/src/xenia/cpu/thread_state.cc b/src/xenia/cpu/thread_state.cc index bc1315887..fc16b5a1c 100644 --- a/src/xenia/cpu/thread_state.cc +++ b/src/xenia/cpu/thread_state.cc @@ -56,9 +56,10 @@ static void* AllocateContext() { } static void FreeContext(void* ctx) { - char* true_start_of_ctx = &reinterpret_cast( - ctx)[-static_cast(xe::memory::allocation_granularity())]; - memory::DeallocFixed(true_start_of_ctx, 0, + size_t granularity = xe::memory::allocation_granularity(); + char* true_start_of_ctx = + &reinterpret_cast(ctx)[-static_cast(granularity)]; + memory::DeallocFixed(true_start_of_ctx, granularity + sizeof(ppc::PPCContext), memory::DeallocationType::kRelease); }