Changeset 77077 in webkit


Ignore:
Timestamp:
Jan 29, 2011 7:32:52 PM (13 years ago)
Author:
ggaren@apple.com
Message:

2011-01-28 Geoffrey Garen <ggaren@apple.com>

Reviewed by Maciej Stachowiak.

Some more Heap cleanup.
https://bugs.webkit.org/show_bug.cgi?id=53357


  • runtime/Heap.cpp: (JSC::Heap::reportExtraMemoryCostSlowCase): Renamed recordExtraCost to reportExtraMemoryCostSlowCase to match our naming conventions.

(JSC::Heap::capacity): Renamed size to capacity because this function
returns the capacity of the heap, including unused portions.

  • runtime/Heap.h: (JSC::Heap::globalData): (JSC::Heap::markedSpace): (JSC::Heap::machineStackMarker): (JSC::Heap::reportExtraMemoryCost): Moved statics to the top of the file. Moved ctor and dtor to the beginning of the class definition. Grouped functions by purpose.
  • runtime/MarkedSpace.cpp: (JSC::MarkedSpace::capacity): Renamed size to capacity because this function returns the capacity of the heap, including unused portions.
  • runtime/MarkedSpace.h: Removed statistics and the Statistics class because the same information can be gotten just by calling size() and capacity().
  • runtime/MemoryStatistics.cpp:
  • runtime/MemoryStatistics.h: Ditto.

2011-01-28 Geoffrey Garen <ggaren@apple.com>

Reviewed by Maciej Stachowiak.

Some more Heap cleanup.
https://bugs.webkit.org/show_bug.cgi?id=53357

Updated for JavaScriptCore changes.

  • Misc/WebCoreStatistics.mm: (+[WebCoreStatistics memoryStatistics]):

2011-01-28 Geoffrey Garen <ggaren@apple.com>

Reviewed by Maciej Stachowiak.

Some more Heap cleanup.
https://bugs.webkit.org/show_bug.cgi?id=53357


Updated for JavaScriptCore changes.

  • bindings/js/ScriptGCEvent.cpp: (WebCore::ScriptGCEvent::getHeapSize):
Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r77070 r77077  
     12011-01-28  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Some more Heap cleanup.
     6        https://bugs.webkit.org/show_bug.cgi?id=53357
     7       
     8        * JavaScriptCore.exp:
     9        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Updated exported symbols.
     10
     11        * runtime/Heap.cpp:
     12        (JSC::Heap::reportExtraMemoryCostSlowCase): Renamed recordExtraCost to
     13        reportExtraMemoryCostSlowCase to match our naming conventions.
     14
     15        (JSC::Heap::capacity): Renamed size to capacity because this function
     16        returns the capacity of the heap, including unused portions.
     17
     18        * runtime/Heap.h:
     19        (JSC::Heap::globalData):
     20        (JSC::Heap::markedSpace):
     21        (JSC::Heap::machineStackMarker):
     22        (JSC::Heap::reportExtraMemoryCost): Moved statics to the top of the file.
     23        Moved ctor and dtor to the beginning of the class definition. Grouped
     24        functions by purpose.
     25
     26        * runtime/MarkedSpace.cpp:
     27        (JSC::MarkedSpace::capacity): Renamed size to capacity because this
     28        function returns the capacity of the heap, including unused portions.
     29
     30        * runtime/MarkedSpace.h: Removed statistics and the Statistics class because
     31        the same information can be gotten just by calling size() and capacity().
     32
     33        * runtime/MemoryStatistics.cpp:
     34        * runtime/MemoryStatistics.h: Ditto.
     35
    1362011-01-29  Daniel Bates  <dbates@rim.com>
    237
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r77044 r77077  
    167167__ZN3JSC14TimeoutChecker10didTimeOutEPNS_9ExecStateE
    168168__ZN3JSC14TimeoutChecker5resetEv
    169 __ZN3JSC14heapStatisticsEPNS_12JSGlobalDataE
    170169__ZN3JSC14throwTypeErrorEPNS_9ExecStateE
    171170__ZN3JSC15JSWrapperObject12markChildrenERNS_9MarkStackE
     
    211210__ZN3JSC4Heap14primaryHeapEndEv
    212211__ZN3JSC4Heap15addWeakGCHandleEPNS_6JSCellE
    213 __ZN3JSC4Heap15recordExtraCostEm
    214212__ZN3JSC4Heap16objectTypeCountsEv
    215213__ZN3JSC4Heap16primaryHeapBeginEv
     
    220218__ZN3JSC4Heap25protectedObjectTypeCountsEv
    221219__ZN3JSC4Heap26protectedGlobalObjectCountEv
     220__ZN3JSC4Heap29reportExtraMemoryCostSlowCaseEm
    222221__ZN3JSC4Heap6isBusyEv
    223222__ZN3JSC4Heap7destroyEv
     
    520519__ZNK3JSC19SourceProviderCache8byteSizeEv
    521520__ZNK3JSC24JSObjectWithGlobalObject12globalObjectEv
    522 __ZNK3JSC4Heap10statisticsEv
    523521__ZNK3JSC4Heap11objectCountEv
    524522__ZNK3JSC4Heap4sizeEv
     523__ZNK3JSC4Heap8capacityEv
    525524__ZNK3JSC6JSCell11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
    526525__ZNK3JSC6JSCell12toThisObjectEPNS_9ExecStateE
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r77044 r77077  
    7171    ?callOnMainThreadAndWait@WTF@@YAXP6AXPAX@Z0@Z
    7272    ?cancelCallOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
     73    ?capacity@Heap@JSC@@QBEIXZ
    7374    ?changePrototypeTransition@Structure@JSC@@SA?AV?$PassRefPtr@VStructure@JSC@@@WTF@@PAV12@VJSValue@2@@Z
    7475    ?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVExecState@2@@Z
     
    268269    ?randomNumber@WTF@@YANXZ
    269270    ?recompileAllJSFunctions@Debugger@JSC@@QAEXPAVJSGlobalData@2@@Z
    270     ?recordExtraCost@Heap@JSC@@AAEXI@Z
    271271    ?reifyString@StringBuilder@WTF@@AAEXXZ
    272272    ?releaseDecommitted@OSAllocator@WTF@@SAXPAXI@Z
    273273    ?releaseStack@MarkStack@JSC@@CAXPAXI@Z
     274    ?reportExtraMemoryCostSlowCase@Heap@JSC@@AAEXI@Z
    274275    ?reserveAndCommit@OSAllocator@WTF@@SAPAXIW4Usage@12@_N1@Z
    275276    ?reset@ParserArena@JSC@@QAEXXZ
  • trunk/Source/JavaScriptCore/runtime/Heap.cpp

    r77044 r77077  
    8080}
    8181
    82 void Heap::recordExtraCost(size_t cost)
     82void Heap::reportExtraMemoryCostSlowCase(size_t cost)
    8383{
    8484    // Our frequency of garbage collection tries to balance memory use against speed
     
    9393    // collecting more frequently as long as it stays alive.
    9494
    95     if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.size() / 2) {
     95    if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.capacity() / 2) {
    9696        JAVASCRIPTCORE_GC_BEGIN();
    9797
     
    303303}
    304304
    305 MarkedSpace::Statistics Heap::statistics() const
    306 {
    307     return m_markedSpace.statistics();
    308 }
    309 
    310305size_t Heap::size() const
    311306{
    312307    return m_markedSpace.size();
     308}
     309
     310size_t Heap::capacity() const
     311{
     312    return m_markedSpace.capacity();
    313313}
    314314
  • trunk/Source/JavaScriptCore/runtime/Heap.h

    r76425 r77077  
    5151        WTF_MAKE_NONCOPYABLE(Heap);
    5252    public:
    53         void destroy();
     53        static Heap* heap(JSValue); // 0 for immediate values
     54        static Heap* heap(JSCell*);
    5455
    55         void* allocate(size_t);
     56        static bool isCellMarked(const JSCell*);
     57        static bool checkMarkCell(const JSCell*);
     58        static void markCell(JSCell*);
     59       
     60        Heap(JSGlobalData*);
     61        ~Heap();
     62        void destroy(); // JSGlobalData must call destroy() before ~Heap().
    5663
    57         bool isBusy(); // true if an allocation or collection is in progress
    58         void collectAllGarbage();
     64        JSGlobalData* globalData() const { return m_globalData; }
     65        MarkedSpace& markedSpace() { return m_markedSpace; }
     66        MachineStackMarker& machineStackMarker() { return m_machineStackMarker; }
    5967
    6068        GCActivityCallback* activityCallback();
    6169        void setActivityCallback(PassOwnPtr<GCActivityCallback>);
    6270
    63         static const size_t minExtraCost = 256;
    64         static const size_t maxExtraCost = 1024 * 1024;
     71        bool isBusy(); // true if an allocation or collection is in progress
     72        void* allocate(size_t);
     73        void collectAllGarbage();
    6574
    6675        void reportExtraMemoryCost(size_t cost);
    6776
     77        void protect(JSValue);
     78        bool unprotect(JSValue); // True when the protect count drops to 0.
     79
     80        bool contains(void*);
     81
     82        size_t size() const;
     83        size_t capacity() const;
    6884        size_t objectCount() const;
    69         MarkedSpace::Statistics statistics() const;
    70         size_t size() const;
    71 
    72         void protect(JSValue);
    73         // Returns true if the value is no longer protected by any protect pointers
    74         // (though it may still be alive due to heap/stack references).
    75         bool unprotect(JSValue);
    76 
    77         static Heap* heap(JSValue); // 0 for immediate values
    78         static Heap* heap(JSCell*);
    79 
    8085        size_t globalObjectCount();
    8186        size_t protectedObjectCount();
     
    8388        HashCountedSet<const char*>* protectedObjectTypeCounts();
    8489        HashCountedSet<const char*>* objectTypeCounts();
    85 
    86         static bool isCellMarked(const JSCell*);
    87         static bool checkMarkCell(const JSCell*);
    88         static void markCell(JSCell*);
    89        
    90         bool contains(void*);
    9190
    9291        WeakGCHandle* addWeakGCHandle(JSCell*);
     
    9796        HashSet<MarkedArgumentBuffer*>& markListSet() { if (!m_markListSet) m_markListSet = new HashSet<MarkedArgumentBuffer*>; return *m_markListSet; }
    9897
    99         JSGlobalData* globalData() const { return m_globalData; }
    100        
    10198        LiveObjectIterator primaryHeapBegin();
    10299        LiveObjectIterator primaryHeapEnd();
    103100       
    104         MachineStackMarker& machineStackMarker() { return m_machineStackMarker; }
    105 
    106         MarkedSpace& markedSpace() { return m_markedSpace; }
    107 
    108101    private:
    109102        friend class JSGlobalData;
    110         Heap(JSGlobalData*);
    111         ~Heap();
    112103
    113         void recordExtraCost(size_t);
     104        static const size_t minExtraCost = 256;
     105        static const size_t maxExtraCost = 1024 * 1024;
     106
     107        void reportExtraMemoryCostSlowCase(size_t);
    114108
    115109        void markRoots();
     
    164158    {
    165159        if (cost > minExtraCost)
    166             recordExtraCost(cost);
     160            reportExtraMemoryCostSlowCase(cost);
    167161    }
    168162   
  • trunk/Source/JavaScriptCore/runtime/MarkedSpace.cpp

    r76425 r77077  
    296296}
    297297
    298 void MarkedSpace::addToStatistics(Statistics& statistics) const
    299 {
    300     statistics.size += m_heap.usedBlocks * BLOCK_SIZE;
    301     statistics.free += m_heap.usedBlocks * BLOCK_SIZE - (objectCount() * HeapConstants::cellSize);
    302 }
    303 
    304 MarkedSpace::Statistics MarkedSpace::statistics() const
    305 {
    306     Statistics statistics = { 0, 0 };
    307     addToStatistics(statistics);
    308     return statistics;
    309 }
    310 
    311298size_t MarkedSpace::size() const
     299{
     300    return objectCount() * HeapConstants::cellSize;
     301}
     302
     303size_t MarkedSpace::capacity() const
    312304{
    313305    return m_heap.usedBlocks * BLOCK_SIZE;
  • trunk/Source/JavaScriptCore/runtime/MarkedSpace.h

    r76432 r77077  
    6565        WTF_MAKE_NONCOPYABLE(MarkedSpace);
    6666    public:
    67         struct Statistics {
    68             size_t size;
    69             size_t free;
    70         };
    71 
    7267        static Heap* heap(JSCell*);
    7368
     
    8984
    9085        size_t size() const;
     86        size_t capacity() const;
    9187        size_t objectCount() const;
    92         Statistics statistics() const;
    9388
    9489        bool contains(void*);
     
    113108        void clearMarkBits(CollectorBlock*);
    114109        size_t markedCells(size_t startBlock = 0, size_t startCell = 0) const;
    115 
    116         void addToStatistics(Statistics&) const;
    117110
    118111        CollectorHeap m_heap;
  • trunk/Source/JavaScriptCore/runtime/MemoryStatistics.cpp

    r75855 r77077  
    3333namespace JSC {
    3434
    35 MarkedSpace::Statistics heapStatistics(JSGlobalData* commonGlobalData)
    36 {
    37     return commonGlobalData->heap.statistics();
    38 }       
    39 
    4035GlobalMemoryStatistics globalMemoryStatistics()
    4136{
  • trunk/Source/JavaScriptCore/runtime/MemoryStatistics.h

    r75855 r77077  
    3838};
    3939
    40 MarkedSpace::Statistics heapStatistics(JSGlobalData* commonGlobalData);
    4140GlobalMemoryStatistics globalMemoryStatistics();
    4241
  • trunk/Source/WebCore/ChangeLog

    r77076 r77077  
     12011-01-28  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Some more Heap cleanup.
     6        https://bugs.webkit.org/show_bug.cgi?id=53357
     7       
     8        Updated for JavaScriptCore changes.
     9
     10        * bindings/js/ScriptGCEvent.cpp:
     11        (WebCore::ScriptGCEvent::getHeapSize):
     12
    1132011-01-29  Adam Barth  <abarth@webkit.org>
    214
  • trunk/Source/WebCore/bindings/js/ScriptGCEvent.cpp

    r75443 r77077  
    4646{
    4747    JSGlobalData* globalData = JSDOMWindow::commonJSGlobalData();
    48     totalHeapSize = globalData->heap.size();
     48    totalHeapSize = globalData->heap.capacity();
    4949    usedHeapSize = totalHeapSize;
    5050}
     51
    5152} // namespace WebCore
    5253
  • trunk/Source/WebKit/mac/ChangeLog

    r77044 r77077  
     12011-01-28  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Some more Heap cleanup.
     6        https://bugs.webkit.org/show_bug.cgi?id=53357
     7
     8        Updated for JavaScriptCore changes.
     9
     10        * Misc/WebCoreStatistics.mm:
     11        (+[WebCoreStatistics memoryStatistics]):
     12
    1132011-01-28  Sheriff Bot  <webkit.review.bot@gmail.com>
    214
  • trunk/Source/WebKit/mac/Misc/WebCoreStatistics.mm

    r75855 r77077  
    198198   
    199199    JSLock lock(SilenceAssertionsOnly);
    200     MarkedSpace::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
     200    size_t heapSize = JSDOMWindow::commonJSGlobalData()->heap.size();
     201    size_t heapFree = JSDOMWindow::commonJSGlobalData()->heap.capacity() - heapSize;
    201202    GlobalMemoryStatistics globalMemoryStats = globalMemoryStatistics();
    202203   
     
    205206                [NSNumber numberWithInt:fastMallocStatistics.committedVMBytes], @"FastMallocCommittedVMBytes",
    206207                [NSNumber numberWithInt:fastMallocStatistics.freeListBytes], @"FastMallocFreeListBytes",
    207                 [NSNumber numberWithInt:heapMemoryStats.size], @"JavaScriptHeapSize",
    208                 [NSNumber numberWithInt:heapMemoryStats.free], @"JavaScriptFreeSize",
     208                [NSNumber numberWithInt:heapSize], @"JavaScriptHeapSize",
     209                [NSNumber numberWithInt:heapFree], @"JavaScriptFreeSize",
    209210                [NSNumber numberWithUnsignedInt:(unsigned int)globalMemoryStats.stackBytes], @"JavaScriptStackSize",
    210211                [NSNumber numberWithUnsignedInt:(unsigned int)globalMemoryStats.JITBytes], @"JavaScriptJITSize",
  • trunk/Source/WebKit2/Shared/mac/WebMemorySampler.mac.mm

    r76991 r77077  
    117117   
    118118    JSLock lock(SilenceAssertionsOnly);
    119     MarkedSpace::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
    120     size_t jscHeapBytesInUse = heapMemoryStats.size - heapMemoryStats.free;
    121     size_t jscHeapBytesCommitted = heapMemoryStats.size;
     119    size_t jscHeapBytesInUse = JSDOMWindow::commonJSGlobalData()->heap.size();
     120    size_t jscHeapBytesCommitted = JSDOMWindow::commonJSGlobalData()->heap.capacity();
    122121    totalBytesInUse += jscHeapBytesInUse;
    123122    totalBytesCommitted += jscHeapBytesCommitted;
Note: See TracChangeset for help on using the changeset viewer.