mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-13 00:08:39 +02:00
reduce arm codeisze, force 16x4 pages again
This commit is contained in:
parent
640d3d2894
commit
afad0f6a4e
3 changed files with 26 additions and 14 deletions
|
|
@ -105,21 +105,24 @@ struct Ucontext {
|
||||||
}
|
}
|
||||||
|
|
||||||
static boost::container::static_vector<std::pair<void*, size_t>, 16> swap_regions;
|
static boost::container::static_vector<std::pair<void*, size_t>, 16> swap_regions;
|
||||||
|
static std::mutex evil_swap_mutex;
|
||||||
extern "C" int sceKernelRemoveExceptionHandler(s32 sig_num);
|
extern "C" int sceKernelRemoveExceptionHandler(s32 sig_num);
|
||||||
static void SwapHandler(int sig, void* raw_context) {
|
static void SwapHandler(int sig, void* raw_context) {
|
||||||
|
std::unique_lock lk{evil_swap_mutex};
|
||||||
auto& mctx = ((Orbis::Ucontext*)raw_context)->uc_mcontext;
|
auto& mctx = ((Orbis::Ucontext*)raw_context)->uc_mcontext;
|
||||||
if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) {
|
if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) {
|
||||||
return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second;
|
return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second;
|
||||||
}); it != swap_regions.end()) {
|
}); it != swap_regions.end()) {
|
||||||
size_t const page_size = 4096 * 4; //16K
|
size_t const page_size = 4096 * 8; //16K
|
||||||
size_t const page_mask = ~(page_size - 1);
|
size_t const page_mask = ~(page_size - 1);
|
||||||
// should replace the existing mapping... ugh
|
// should replace the existing mapping... ugh
|
||||||
void* aligned_addr = reinterpret_cast<void*>(uintptr_t(mctx.mc_addr) & page_mask);
|
void* aligned_addr = reinterpret_cast<void*>(uintptr_t(mctx.mc_addr) & page_mask);
|
||||||
void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
|
void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
if (res == MAP_FAILED) {
|
if (res == MAP_FAILED) {
|
||||||
LOG_ERROR(HW_Memory, "{},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second);
|
LOG_ERROR(HW_Memory, "{:#x},{} @ {}:{:#x}", mctx.mc_addr, aligned_addr, it->first, it->second);
|
||||||
|
sceKernelRemoveExceptionHandler(SIGSEGV); // to not catch the next signal
|
||||||
} else {
|
} else {
|
||||||
LOG_TRACE(HW_Memory, "{},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second);
|
LOG_TRACE(HW_Memory, "{:#x},{} @ {}:{:#x}", mctx.mc_addr, aligned_addr, it->first, it->second);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address
|
LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address
|
||||||
|
|
@ -138,15 +141,17 @@ void* AllocateMemoryPages(std::size_t size) noexcept {
|
||||||
void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE);
|
void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
ASSERT(addr != nullptr);
|
ASSERT(addr != nullptr);
|
||||||
#elif defined(__OPENORBIS__)
|
#elif defined(__OPENORBIS__)
|
||||||
// void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
void* addr;
|
||||||
// if (addr == MAP_FAILED) {
|
if (size <= 8192 * 4096) {
|
||||||
LOG_WARNING(HW_Memory, "Using VoidMem for {}B area", size);
|
addr = malloc(size);
|
||||||
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0);
|
LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", size, addr);
|
||||||
ASSERT(addr != MAP_FAILED);
|
ASSERT(addr != nullptr);
|
||||||
swap_regions.emplace_back(addr, size);
|
} else {
|
||||||
// } else {
|
addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0);
|
||||||
// LOG_INFO(HW_Memory, "mmap {} bytes", size);
|
LOG_WARNING(HW_Memory, "Using VoidMem for {} bytes area @ {}", size, addr);
|
||||||
// }
|
ASSERT(addr != MAP_FAILED);
|
||||||
|
swap_regions.emplace_back(addr, size);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
ASSERT(addr != MAP_FAILED);
|
ASSERT(addr != MAP_FAILED);
|
||||||
|
|
@ -159,6 +164,13 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept {
|
||||||
return;
|
return;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
VirtualFree(addr, 0, MEM_RELEASE);
|
VirtualFree(addr, 0, MEM_RELEASE);
|
||||||
|
#elif defined(__OPENORBIS__)
|
||||||
|
if (size <= 8192 * 4096) {
|
||||||
|
free(addr);
|
||||||
|
} else {
|
||||||
|
int rc = munmap(addr, size);
|
||||||
|
ASSERT(rc == 0);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int rc = munmap(addr, size);
|
int rc = munmap(addr, size);
|
||||||
ASSERT(rc == 0);
|
ASSERT(rc == 0);
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ void ArmDynarmic32::MakeJit(Common::PageTable* page_table) {
|
||||||
|
|
||||||
// Code cache size
|
// Code cache size
|
||||||
#if defined(__OPENORBIS__)
|
#if defined(__OPENORBIS__)
|
||||||
config.code_cache_size = std::uint32_t(32_MiB);
|
config.code_cache_size = std::uint32_t(8_MiB);
|
||||||
#elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
|
#elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
|
||||||
config.code_cache_size = std::uint32_t(128_MiB);
|
config.code_cache_size = std::uint32_t(128_MiB);
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ void ArmDynarmic64::MakeJit(Common::PageTable* page_table, std::size_t address_s
|
||||||
|
|
||||||
// Code cache size
|
// Code cache size
|
||||||
#if defined(__OPENORBIS__)
|
#if defined(__OPENORBIS__)
|
||||||
config.code_cache_size = std::uint32_t(32_MiB);
|
config.code_cache_size = std::uint32_t(8_MiB);
|
||||||
#elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
|
#elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
|
||||||
config.code_cache_size = std::uint32_t(128_MiB);
|
config.code_cache_size = std::uint32_t(128_MiB);
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue