Changeset 253244 in webkit for trunk/Source/JavaScriptCore/heap


Ignore:
Timestamp:
Dec 6, 2019, 11:50:19 PM (5 years ago)
Author:
[email protected]
Message:

[GTK][WPE] Use bmalloc's memory footprint API for JSC heap growth management
https://bugs.webkit.org/show_bug.cgi?id=204576

Reviewed by Saam Barati.

Source/JavaScriptCore:

Use the new USE(BMALLOC_MEMORY_FOOTPRINT_API) build guard to enable
bmalloc-based JSC heap growth management on iOS family ports as well
as additionally the Linux-based ports, if the configuration allows it
(i.e. system malloc enforcement kept disabled).

  • heap/Heap.cpp:

(JSC::Heap::overCriticalMemoryThreshold):
(JSC::Heap::updateAllocationLimits):
(JSC::Heap::collectIfNecessaryOrDefer):

  • heap/Heap.h:

Initialize the two member variables and fix a typo in one of them.

  • runtime/Options.cpp:

(JSC::overrideDefaults):
Also guard two default overrides with the new flag.

Source/WTF:

Add the new USE_BMALLOC_MEMORY_FOOTPRINT_API, enabled for the iOS-family
ports and the Linux ports, as long as system malloc enforcement is
disabled and bmalloc is subsequently built and used. The flag is used in
JavaScriptCore to enable usage of bmalloc's memory footprint API for
JSC heap growth control.

  • wtf/Platform.h:
Location:
trunk/Source/JavaScriptCore/heap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r252385 r253244  
    9090#include <wtf/Threading.h>
    9191
    92 #if PLATFORM(IOS_FAMILY)
     92#if USE(BMALLOC_MEMORY_FOOTPRINT_API)
    9393#include <bmalloc/bmalloc.h>
    9494#endif
     
    131131        return Options::miniVMHeapGrowthFactor() * heapSize;
    132132
    133 #if PLATFORM(IOS_FAMILY)
     133#if USE(BMALLOC_MEMORY_FOOTPRINT_API)
    134134    size_t memoryFootprint = bmalloc::api::memoryFootprint();
    135135    if (memoryFootprint < ramSize * Options::smallHeapRAMFraction())
     
    540540bool Heap::overCriticalMemoryThreshold(MemoryThresholdCallType memoryThresholdCallType)
    541541{
    542 #if PLATFORM(IOS_FAMILY)
    543     if (memoryThresholdCallType == MemoryThresholdCallType::Direct || ++m_precentAvailableMemoryCachedCallCount >= 100) {
     542#if USE(BMALLOC_MEMORY_FOOTPRINT_API)
     543    if (memoryThresholdCallType == MemoryThresholdCallType::Direct || ++m_percentAvailableMemoryCachedCallCount >= 100) {
    544544        m_overCriticalMemoryThreshold = bmalloc::api::percentAvailableMemoryInUse() > Options::criticalGCMemoryThreshold();
    545         m_precentAvailableMemoryCachedCallCount = 0;
     545        m_percentAvailableMemoryCachedCallCount = 0;
    546546    }
    547547
     
    23412341    }
    23422342
    2343 #if PLATFORM(IOS_FAMILY)
     2343#if USE(BMALLOC_MEMORY_FOOTPRINT_API)
    23442344    // Get critical memory threshold for next cycle.
    23452345    overCriticalMemoryThreshold(MemoryThresholdCallType::Direct);
     
    26382638        size_t bytesAllowedThisCycle = m_maxEdenSize;
    26392639
    2640 #if PLATFORM(IOS_FAMILY)
     2640#if USE(BMALLOC_MEMORY_FOOTPRINT_API)
    26412641        if (overCriticalMemoryThreshold())
    26422642            bytesAllowedThisCycle = std::min(m_maxEdenSizeWhenCritical, bytesAllowedThisCycle);
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r252024 r253244  
    741741    Thread* m_currentThread { nullptr }; // It's OK if this becomes a dangling pointer.
    742742
    743 #if PLATFORM(IOS_FAMILY)
    744     unsigned m_precentAvailableMemoryCachedCallCount;
    745     bool m_overCriticalMemoryThreshold;
     743#if USE(BMALLOC_MEMORY_FOOTPRINT_API)
     744    unsigned m_percentAvailableMemoryCachedCallCount { 0 };
     745    bool m_overCriticalMemoryThreshold { false };
    746746#endif
    747747
Note: See TracChangeset for help on using the changeset viewer.