Use PAGE_SIZE, fix a comment, fix some indentation.

This commit is contained in:
Henrik Rydgard 2016-08-28 18:07:54 +02:00
parent d82ba24485
commit 1e4b77fb49
4 changed files with 28 additions and 33 deletions

View File

@ -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_) {

View File

@ -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
*/
}

View File

@ -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 <typename T>
class SimpleBuf {

View File

@ -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]));
}