Skip to content

Commit

Permalink
Taking some IOS GC branches for WPE as well
Browse files Browse the repository at this point in the history
The aim is to make the GC more reliable on low-memory platforms.
IOS branches applied:

- FullGCActivityCallback::doCollection - do not bail out of GC early
- MemoryPressureHandler - apply IOS defaults for conservative/strict mode thresholds
- MemoryRelease / releaseCriticalMemory - request immediate GC
- WorkerGlobalScope::deleteJSCodeAndGC - collect even if called with Synchronous::No
  • Loading branch information
tomasz-karczewski-red committed Oct 22, 2024
1 parent f0b98a4 commit 7cd0bde
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/heap/FullGCActivityCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void FullGCActivityCallback::doCollection(VM& vm)
Heap& heap = vm.heap;
m_didGCRecently = false;

#if !PLATFORM(IOS_FAMILY) || PLATFORM(MACCATALYST)
#if (!PLATFORM(IOS_FAMILY) && !PLATFORM(WPE)) || PLATFORM(MACCATALYST)
MonotonicTime startTime = MonotonicTime::now();
if (MemoryPressureHandler::singleton().isUnderMemoryPressure() && heap.isPagedOut()) {
cancel();
Expand Down
2 changes: 1 addition & 1 deletion Source/WTF/wtf/MemoryPressureHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace WTF {

WTF_EXPORT_PRIVATE bool MemoryPressureHandler::ReliefLogger::s_loggingEnabled = false;

#if PLATFORM(IOS_FAMILY)
#if PLATFORM(IOS_FAMILY) || PLATFORM(WPE)
static const double s_conservativeThresholdFraction = 0.5;
static const double s_strictThresholdFraction = 0.65;
#else
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/MemoryRelease.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void releaseCriticalMemory(Synchronous synchronous, MaintainBackForwardCa
GCController::singleton().deleteAllCode(JSC::DeleteAllCodeIfNotCollecting);
GCController::singleton().garbageCollectNow();
} else {
#if PLATFORM(IOS_FAMILY)
#if PLATFORM(IOS_FAMILY) || PLATFORM(WPE)
GCController::singleton().garbageCollectNowIfNotDoneRecently();
#else
GCController::singleton().garbageCollectSoon();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/workers/WorkerGlobalScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ void WorkerGlobalScope::deleteJSCodeAndGC(Synchronous synchronous)
return;
}
}
#if PLATFORM(IOS_FAMILY)
#if PLATFORM(IOS_FAMILY) || PLATFORM(WPE)
if (!vm().heap.currentThreadIsDoingGCWork()) {
vm().heap.collectNowFullIfNotDoneRecently(JSC::Async);
return;
Expand Down

0 comments on commit 7cd0bde

Please sign in to comment.