Skip to content

Commit

Permalink
ios: enable concurrent garbage collection
Browse files Browse the repository at this point in the history
Enables the concurrent garbage collection feature of ChakraCore
on iOS. Also restores the original ChakraCore garbage collection
memory heuristics for iOS.
  • Loading branch information
jaimecbernardo committed Jul 3, 2018
1 parent 3bde748 commit fc6b25d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
7 changes: 0 additions & 7 deletions deps/chakrashim/core/lib/Common/CommonDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions deps/chakrashim/core/lib/Common/Memory/RecyclerHeuristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
13 changes: 2 additions & 11 deletions deps/chakrashim/core/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fc6b25d

Please sign in to comment.