diff --git a/Common/CodeBlock.h b/Common/CodeBlock.h index 3601f1a42c..41970932b9 100644 --- a/Common/CodeBlock.h +++ b/Common/CodeBlock.h @@ -71,8 +71,8 @@ public: ResetCodePtr(); } - // BeginWrite/EndWrite assumes that we keep appending. If you don't specify a size and we encounter later executable block, we're screwed. - // These CANNOT be nested. + // BeginWrite/EndWrite assume that we keep appending. If you don't specify a size and we encounter later executable block, we're screwed. + // These CANNOT be nested. We rely on the memory protection starting at READ|WRITE after start and reset. void BeginWrite(size_t sizeEstimate = 1) { #ifdef _DEBUG if (writeStart_) { diff --git a/Common/MemoryUtil.cpp b/Common/MemoryUtil.cpp index 69757d319c..5d854010aa 100644 --- a/Common/MemoryUtil.cpp +++ b/Common/MemoryUtil.cpp @@ -285,9 +285,8 @@ void FreeAlignedMemory(void* ptr) { } bool PlatformIsWXExclusive() { - // Only 64-bit iOS9 really needs this mode, but that's most iOS devices and all future ones, - // so let's keep things the same for all of them. Even without block linking, still should be much - // faster than IR JIT. + // Only iOS really needs this mode currently. Even without block linking, still should be much faster than IR JIT. + // This might also come in useful for UWP (Universal Windows Platform) if I'm understanding things correctly. #ifdef IOS return true; #else @@ -325,17 +324,16 @@ void ProtectMemoryPages(const void* ptr, size_t size, uint32_t memProtFlags) { #endif } -// Hardcoded in the header. This is a way to check it dynamically in case it ever becomes necessary. -/* -#ifdef _WIN32 - -// 4k on most archs, 8k on Itanium (but who cares). -// Should not be confused with the allocation granularity which is 65k and is how precise -// VirtualAlloc allocations can be located in memory. We don't really care about that much though. int GetMemoryProtectPageSize() { - if (sys_info.dwPageSize == 0) - GetSystemInfo(&sys_info); - return sys_info.dwPageSize; -} +#ifdef _WIN32 + // This is 4096 on all Windows platforms we care about. 8k on Itanium but meh. + return 4096; + // For reference, here's how to check: + // if (sys_info.dwPageSize == 0) + // GetSystemInfo(&sys_info); + // return sys_info.dwPageSize; + +#else + return PAGE_SIZE; #endif -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/Common/MemoryUtil.h b/Common/MemoryUtil.h index 9f2b40304c..50a0671a50 100644 --- a/Common/MemoryUtil.h +++ b/Common/MemoryUtil.h @@ -54,10 +54,7 @@ void FreeAlignedMemory(void* ptr); void ResetExecutableMemory(void* ptr); #endif -inline int GetMemoryProtectPageSize() { - // This is 4096 on all platforms we care about. 8k on Itanium but meh. - return 4096; -} +int GetMemoryProtectPageSize(); template class SimpleBuf { diff --git a/ios/main.mm b/ios/main.mm index 0a294c20cf..44ad25d202 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -58,16 +58,16 @@ std::string System_GetProperty(SystemProperty prop) { } int System_GetPropertyInt(SystemProperty prop) { - switch (prop) { - case SYSPROP_AUDIO_SAMPLE_RATE: - return 44100; - case SYSPROP_DISPLAY_REFRESH_RATE: - return 60000; - case SYSPROP_DEVICE_TYPE: - return DEVICE_TYPE_MOBILE; - default: - return -1; - } + switch (prop) { + case SYSPROP_AUDIO_SAMPLE_RATE: + return 44100; + case SYSPROP_DISPLAY_REFRESH_RATE: + return 60000; + case SYSPROP_DEVICE_TYPE: + return DEVICE_TYPE_MOBILE; + default: + return -1; + } } void System_SendMessage(const char *command, const char *parameter) { @@ -94,8 +94,8 @@ void Vibrate(int length_ms) { int main(int argc, char *argv[]) { - // Simulates a debugger. Makes it possible to use JIT (though only W^X) - syscall(SYS_ptrace, 0 /*PTRACE_TRACEME*/, 0, 0, 0); + // Simulates a debugger. Makes it possible to use JIT (though only W^X) + syscall(SYS_ptrace, 0 /*PTRACE_TRACEME*/, 0, 0, 0); @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); }