From fc6b25df6736157ef53e9ba743990e9edf3bd181 Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Thu, 28 Jun 2018 08:16:31 +0100 Subject: [PATCH] ios: enable concurrent garbage collection Enables the concurrent garbage collection feature of ChakraCore on iOS. Also restores the original ChakraCore garbage collection memory heuristics for iOS. --- deps/chakrashim/core/lib/Common/CommonDefines.h | 7 ------- .../core/lib/Common/Memory/RecyclerHeuristic.cpp | 5 ----- .../lib/Common/Memory/RecyclerWriteBarrierManager.h | 10 ++++++++++ deps/chakrashim/core/pal/src/misc/sysinfo.cpp | 13 ++----------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/deps/chakrashim/core/lib/Common/CommonDefines.h b/deps/chakrashim/core/lib/Common/CommonDefines.h index 4ebd0379dfc..777a29c875d 100644 --- a/deps/chakrashim/core/lib/Common/CommonDefines.h +++ b/deps/chakrashim/core/lib/Common/CommonDefines.h @@ -153,15 +153,8 @@ #else #define SYSINFO_IMAGE_BASE_AVAILABLE 0 #ifndef ENABLE_VALGRIND -#if defined(__IOS__) -//FIXME: Disabled concurrent garbage collection, which seems to require -// RECYCLER_WRITE_BARRIER, and that is not feasable on a 18 exabyte -// VM address space. -#define ENABLE_CONCURRENT_GC 0 -#else #define ENABLE_CONCURRENT_GC 1 #define ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP 1 // Only takes effect when ENABLE_CONCURRENT_GC is enabled. -#endif //defined(__IOS__) #else #define ENABLE_CONCURRENT_GC 0 #define ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP 0 // Only takes effect when ENABLE_CONCURRENT_GC is enabled. diff --git a/deps/chakrashim/core/lib/Common/Memory/RecyclerHeuristic.cpp b/deps/chakrashim/core/lib/Common/Memory/RecyclerHeuristic.cpp index 1b195a58fb5..a992b2f0b0d 100644 --- a/deps/chakrashim/core/lib/Common/Memory/RecyclerHeuristic.cpp +++ b/deps/chakrashim/core/lib/Common/Memory/RecyclerHeuristic.cpp @@ -46,12 +46,7 @@ RecyclerHeuristic::RecyclerHeuristic() else if (isSuccess && physicalMemoryBytes <= 1024 MEGABYTES) { // Tablet/slate/high-end Apollo scenario, including 512MB non-Apollo. -#if defined(__IOS__) - // 64MB is too little for the require phase of many node modules on a mobile device. - baseFactor = 192; -#else baseFactor = 64; -#endif this->DefaultMaxFreePageCount = 64 MEGABYTES_OF_PAGES; this->DefaultMaxAllocPageCount = 64; } diff --git a/deps/chakrashim/core/lib/Common/Memory/RecyclerWriteBarrierManager.h b/deps/chakrashim/core/lib/Common/Memory/RecyclerWriteBarrierManager.h index 40f2030a541..d7b11a8670c 100644 --- a/deps/chakrashim/core/lib/Common/Memory/RecyclerWriteBarrierManager.h +++ b/deps/chakrashim/core/lib/Common/Memory/RecyclerWriteBarrierManager.h @@ -211,10 +211,20 @@ class RecyclerWriteBarrierManager static DWORD GetWriteBarrier(void * address); #endif +#if defined(__IOS__)&&defined(_M_ARM64) +//Apple documentation reveals that virtual page size is 16KB on +// newer versions of iOS. + static size_t const s_WriteBarrierPageSize = 16384; + // A card is a DWORD. For a 16KB page size to be represented by a DWORD, each bit represents 512 bytes. + static uint const s_BitArrayCardTableShift = 9; + static uint const s_BytesPerCardBit = 1 << s_BitArrayCardTableShift; // 512 = 1 << 9 + static uint const s_BytesPerCard = s_BytesPerCardBit * 32; // 16K = 1 << 14 = 512 << 5 +#else static size_t const s_WriteBarrierPageSize = 4096; static uint const s_BitArrayCardTableShift = 7; static uint const s_BytesPerCardBit = 1 << s_BitArrayCardTableShift; // 128 = 1 << 7 static uint const s_BytesPerCard = s_BytesPerCardBit * 32; // 4K = 1 << 12 = 128 << 5 +#endif private: diff --git a/deps/chakrashim/core/pal/src/misc/sysinfo.cpp b/deps/chakrashim/core/pal/src/misc/sysinfo.cpp index 1317f2767a5..2a4230017a7 100644 --- a/deps/chakrashim/core/pal/src/misc/sysinfo.cpp +++ b/deps/chakrashim/core/pal/src/misc/sysinfo.cpp @@ -104,15 +104,6 @@ SET_DEFAULT_DEBUG_CHANNEL(MISC); #endif #endif // __LINUX__ -#ifdef __IOS__ -#ifdef BIT64 -// This is the size of the virtual address space on 64 bits IOS, -// according to Apple, is 18 exabytes. -#define MAX_PROCESS_VA_SPACE_IOS64 \ - (18ull * 1024 * 1024 * 1024 * 1024 * 1024 * 1024) -#endif -#endif - /*++ Function: GetSystemInfo @@ -183,13 +174,13 @@ GetSystemInfo( lpSystemInfo->lpMaximumApplicationAddress = (PVOID) VM_MAXUSER_ADDRESS; #elif defined(__LINUX__) lpSystemInfo->lpMaximumApplicationAddress = (PVOID) MAX_PROCESS_VA_SPACE_LINUX; -#elif defined(__IOS__)&&defined(BIT64) - lpSystemInfo->lpMaximumApplicationAddress = (PVOID) MAX_PROCESS_VA_SPACE_IOS64; #elif defined(USERLIMIT) lpSystemInfo->lpMaximumApplicationAddress = (PVOID) USERLIMIT; #elif defined(_WIN64) #if defined(USRSTACK64) lpSystemInfo->lpMaximumApplicationAddress = (PVOID) USRSTACK64; +#elif defined(MACH_VM_MAX_ADDRESS) + lpSystemInfo->lpMaximumApplicationAddress = (PVOID) MACH_VM_MAX_ADDRESS; #else // !USRSTACK64 #error How come USRSTACK64 is not defined for 64bit? #endif // USRSTACK64