Skip to content

Commit cbcfca0

Browse files
committed
Add jsc_heap_gc_like_ios.patch
1 parent 736adce commit cbcfca0

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

patches/jsc_heap_gc_like_ios.patch

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--- download/webkit/Source/JavaScriptCore/heap/Heap.cpp 2019-09-17 23:35:30.000000000 +0800
2+
+++ target/webkit/Source/JavaScriptCore/heap/Heap.cpp 2019-09-17 23:18:36.000000000 +0800
3+
@@ -88,7 +88,7 @@
4+
#include <wtf/SimpleStats.h>
5+
#include <wtf/Threading.h>
6+
7+
-#if PLATFORM(IOS_FAMILY)
8+
+#if PLATFORM(IOS_FAMILY) || defined(__ANDROID__)
9+
#include <bmalloc/bmalloc.h>
10+
#endif
11+
12+
@@ -129,7 +129,7 @@
13+
if (VM::isInMiniMode())
14+
return Options::miniVMHeapGrowthFactor() * heapSize;
15+
16+
-#if PLATFORM(IOS_FAMILY)
17+
+#if PLATFORM(IOS_FAMILY) || defined(__ANDROID__)
18+
size_t memoryFootprint = bmalloc::api::memoryFootprint();
19+
if (memoryFootprint < ramSize * Options::smallHeapRAMFraction())
20+
return Options::smallHeapGrowthFactor() * heapSize;
21+
@@ -538,7 +538,7 @@
22+
23+
bool Heap::overCriticalMemoryThreshold(MemoryThresholdCallType memoryThresholdCallType)
24+
{
25+
-#if PLATFORM(IOS_FAMILY)
26+
+#if PLATFORM(IOS_FAMILY) || defined(__ANDROID__)
27+
if (memoryThresholdCallType == MemoryThresholdCallType::Direct || ++m_precentAvailableMemoryCachedCallCount >= 100) {
28+
m_overCriticalMemoryThreshold = bmalloc::api::percentAvailableMemoryInUse() > Options::criticalGCMemoryThreshold();
29+
m_precentAvailableMemoryCachedCallCount = 0;
30+
@@ -2332,7 +2332,7 @@
31+
}
32+
}
33+
34+
-#if PLATFORM(IOS_FAMILY)
35+
+#if PLATFORM(IOS_FAMILY) || defined(__ANDROID__)
36+
// Get critical memory threshold for next cycle.
37+
overCriticalMemoryThreshold(MemoryThresholdCallType::Direct);
38+
#endif
39+
@@ -2629,7 +2629,7 @@
40+
} else {
41+
size_t bytesAllowedThisCycle = m_maxEdenSize;
42+
43+
-#if PLATFORM(IOS_FAMILY)
44+
+#if PLATFORM(IOS_FAMILY) || defined(__ANDROID__)
45+
if (overCriticalMemoryThreshold())
46+
bytesAllowedThisCycle = std::min(m_maxEdenSizeWhenCritical, bytesAllowedThisCycle);
47+
#endif
48+
--- download/webkit/Source/JavaScriptCore/heap/Heap.h 2019-09-17 23:35:36.000000000 +0800
49+
+++ target/webkit/Source/JavaScriptCore/heap/Heap.h 2019-09-17 23:18:36.000000000 +0800
50+
@@ -739,7 +739,7 @@
51+
CurrentThreadState* m_currentThreadState { nullptr };
52+
Thread* m_currentThread { nullptr }; // It's OK if this becomes a dangling pointer.
53+
54+
-#if PLATFORM(IOS_FAMILY)
55+
+#if PLATFORM(IOS_FAMILY) || defined(__ANDROID__)
56+
unsigned m_precentAvailableMemoryCachedCallCount;
57+
bool m_overCriticalMemoryThreshold;
58+
#endif

scripts/patch.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ JSC_PATCHSET=(
5757

5858
# Intl default timezone with Android integration
5959
"jsc_intl_timezone.patch"
60+
61+
# Improve heap GC mechanism like iOS
62+
"jsc_heap_gc_like_ios.patch"
6063
)
6164

6265
if [[ "$I18N" = false ]]

0 commit comments

Comments
 (0)