diff --git a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp index a85122b5ad..96f348955d 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp @@ -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(p) + DYNARMIC_PAGE_SIZE; + return static_cast(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 diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp index 3d28365b1c..a4a13a4870 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp @@ -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; diff --git a/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp b/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp index 7607bbaafc..1515a6b8c8 100644 --- a/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp +++ b/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp @@ -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; };