mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-06-28 09:59:41 -06:00
JIT: Add bits for Windows ARM64 support
This commit is contained in:
@ -21,10 +21,12 @@
|
|||||||
#include "../ARMJIT_Internal.h"
|
#include "../ARMJIT_Internal.h"
|
||||||
#include "../ARMInterpreter.h"
|
#include "../ARMInterpreter.h"
|
||||||
|
|
||||||
#ifdef __SWITCH__
|
#if defined(__SWITCH__)
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
extern char __start__;
|
extern char __start__;
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -256,10 +258,21 @@ Compiler::Compiler()
|
|||||||
SetCodeBase((u8*)JitRWStart, (u8*)JitRXStart);
|
SetCodeBase((u8*)JitRWStart, (u8*)JitRXStart);
|
||||||
JitMemMainSize = JitMemSize;
|
JitMemMainSize = JitMemSize;
|
||||||
#else
|
#else
|
||||||
|
#ifdef _WIN32
|
||||||
|
SYSTEM_INFO sysInfo;
|
||||||
|
GetSystemInfo(&sysInfo);
|
||||||
|
|
||||||
|
u64 pageSize = (u64)sysInfo.dwPageSize;
|
||||||
|
#else
|
||||||
u64 pageSize = sysconf(_SC_PAGE_SIZE);
|
u64 pageSize = sysconf(_SC_PAGE_SIZE);
|
||||||
|
#endif
|
||||||
u8* pageAligned = (u8*)(((u64)JitMem & ~(pageSize - 1)) + pageSize);
|
u8* pageAligned = (u8*)(((u64)JitMem & ~(pageSize - 1)) + pageSize);
|
||||||
u64 alignedSize = (((u64)JitMem + sizeof(JitMem)) & ~(pageSize - 1)) - (u64)pageAligned;
|
u64 alignedSize = (((u64)JitMem + sizeof(JitMem)) & ~(pageSize - 1)) - (u64)pageAligned;
|
||||||
#ifdef __APPLE__
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
DWORD dummy;
|
||||||
|
VirtualProtect(pageAligned, alignedSize, PAGE_EXECUTE_READWRITE, &dummy);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
pageAligned = (u8*)mmap(NULL, 1024*1024*16, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS | MAP_JIT,-1, 0);
|
pageAligned = (u8*)mmap(NULL, 1024*1024*16, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS | MAP_JIT,-1, 0);
|
||||||
JitEnableWrite();
|
JitEnableWrite();
|
||||||
#else
|
#else
|
||||||
|
@ -81,11 +81,10 @@ bool FaultHandler(FaultDescription& faultDesc);
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Yes I know this looks messy, but better here than somewhere else in the code
|
// Yes I know this looks messy, but better here than somewhere else in the code
|
||||||
#if defined(_WIN32)
|
#if defined(__x86_64__)
|
||||||
|
#if defined(_WIN32)
|
||||||
#define CONTEXT_PC Rip
|
#define CONTEXT_PC Rip
|
||||||
#else
|
#elif defined(__linux__)
|
||||||
#if defined(__x86_64__)
|
|
||||||
#if defined(__linux__)
|
|
||||||
#define CONTEXT_PC uc_mcontext.gregs[REG_RIP]
|
#define CONTEXT_PC uc_mcontext.gregs[REG_RIP]
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define CONTEXT_PC uc_mcontext->__ss.__rip
|
#define CONTEXT_PC uc_mcontext->__ss.__rip
|
||||||
@ -94,8 +93,10 @@ bool FaultHandler(FaultDescription& faultDesc);
|
|||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
#define CONTEXT_PC uc_mcontext.__gregs[_REG_RIP]
|
#define CONTEXT_PC uc_mcontext.__gregs[_REG_RIP]
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
#if defined(__linux__)
|
#if defined(_WIN32)
|
||||||
|
#define CONTEXT_PC Pc
|
||||||
|
#elif defined(__linux__)
|
||||||
#define CONTEXT_PC uc_mcontext.pc
|
#define CONTEXT_PC uc_mcontext.pc
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define CONTEXT_PC uc_mcontext->__ss.__pc
|
#define CONTEXT_PC uc_mcontext->__ss.__pc
|
||||||
@ -104,7 +105,6 @@ bool FaultHandler(FaultDescription& faultDesc);
|
|||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
#define CONTEXT_PC uc_mcontext.__gregs[_REG_PC]
|
#define CONTEXT_PC uc_mcontext.__gregs[_REG_PC]
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
#include "MathUtil.h"
|
#include "MathUtil.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <libkern/OSCacheControl.h>
|
#include <libkern/OSCacheControl.h>
|
||||||
#endif
|
#endif
|
||||||
@ -392,6 +396,8 @@ void ARM64XEmitter::FlushIcacheSection(u8* start, u8* end)
|
|||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
// Header file says this is equivalent to: sys_icache_invalidate(start, end - start);
|
// Header file says this is equivalent to: sys_icache_invalidate(start, end - start);
|
||||||
sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start);
|
sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
FlushInstructionCache(GetCurrentProcess(), start, end - start);
|
||||||
#else
|
#else
|
||||||
// Don't rely on GCC's __clear_cache implementation, as it caches
|
// Don't rely on GCC's __clear_cache implementation, as it caches
|
||||||
// icache/dcache cache line sizes, that can vary between cores on
|
// icache/dcache cache line sizes, that can vary between cores on
|
||||||
|
Reference in New Issue
Block a user