skip exception handler register on PS4 and use xbyak::inner:getpagesize

This commit is contained in:
lizzie 2026-04-01 00:48:24 +00:00
parent 24bc0012ee
commit 1280feec35
3 changed files with 12 additions and 9 deletions

View file

@ -7,6 +7,7 @@
*/
#include "dynarmic/backend/x64/block_of_code.h"
#include "xbyak/xbyak.h"
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
@ -83,13 +84,12 @@ public:
bool useProtect() const override { return false; }
#else
static constexpr size_t DYNARMIC_PAGE_SIZE = 4096;
// Can't subclass Xbyak::MmapAllocator because it is not a pure interface
// and doesn't expose its construtor
uint8_t* alloc(size_t size) override {
auto const page_size = Xbyak::inner::getPageSize();
// Waste a page to store the size
size += DYNARMIC_PAGE_SIZE;
size += page_size;
int mode = MAP_PRIVATE;
#if defined(MAP_ANONYMOUS)
@ -118,13 +118,14 @@ public:
#endif
}
std::memcpy(p, &size, sizeof(size_t));
return static_cast<uint8_t*>(p) + DYNARMIC_PAGE_SIZE;
return static_cast<uint8_t*>(p) + page_size;
}
void free(uint8_t* p) override {
auto const page_size = Xbyak::inner::getPageSize();
size_t size;
std::memcpy(&size, p - DYNARMIC_PAGE_SIZE, sizeof(size_t));
munmap(p - DYNARMIC_PAGE_SIZE, size);
std::memcpy(&size, p - page_size, sizeof(size_t));
munmap(p - page_size, size);
}
# ifdef DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT

View file

@ -40,9 +40,10 @@ EmitContext::EmitContext(RegAlloc& reg_alloc, IR::Block& block, boost::container
EmitContext::~EmitContext() = default;
EmitX64::EmitX64(BlockOfCode& code)
: code(code) {
EmitX64::EmitX64(BlockOfCode& code) : code(code) {
#ifndef __OPENORBIS__
exception_handler.Register(code);
#endif
}
EmitX64::~EmitX64() = default;

View file

@ -13,6 +13,7 @@
#include "dynarmic/backend/x64/abi.h"
#include "dynarmic/backend/x64/hostloc.h"
#include "dynarmic/common/spin_lock.h"
#include "xbyak/xbyak.h"
#ifdef DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT
static const auto default_cg_mode = Xbyak::DontSetProtectRWE;
@ -74,7 +75,7 @@ namespace {
struct SpinLockImpl {
void Initialize() noexcept;
static void GlobalInitialize() noexcept;
Xbyak::CodeGenerator code = Xbyak::CodeGenerator(4096, default_cg_mode);
Xbyak::CodeGenerator code = Xbyak::CodeGenerator(Xbyak::inner::getPageSize(), default_cg_mode);
void (*lock)(volatile int*) = nullptr;
void (*unlock)(volatile int*) = nullptr;
};