Changeset 93918 in webkit


Ignore:
Timestamp:
Aug 26, 2011, 3:23:43 PM (14 years ago)
Author:
fpizlo@apple.com
Message:

The GC does not have a facility for profiling the kinds of objects
that occupy the heap
https://bugs.webkit.org/show_bug.cgi?id=66849

Reviewed by Geoffrey Garen.

Destructor calls and object scans are now optionally counted, per
vtable. When the heap is destroyed and profiling is enabled, the
counts are dumped, with care taken to print the names of classes
(modulo C++ mangling) sorted in descending commonality.

(JSC::Heap::destroy):

  • heap/Heap.h:
  • heap/MarkStack.cpp:

(JSC::SlotVisitor::visitChildren):
(JSC::SlotVisitor::drain):

  • heap/MarkStack.h:
  • heap/MarkedBlock.cpp:

(JSC::MarkedBlock::callDestructor):

  • heap/MarkedBlock.h:
  • heap/VTableSpectrum.cpp: Added.

(JSC::VTableSpectrum::VTableSpectrum):
(JSC::VTableSpectrum::~VTableSpectrum):
(JSC::VTableSpectrum::countVPtr):
(JSC::VTableSpectrum::count):
(JSC::VTableAndCount::VTableAndCount):
(JSC::VTableAndCount::operator<):
(JSC::VTableSpectrum::dump):

  • heap/VTableSpectrum.h: Added.
  • wtf/Platform.h:
Location:
trunk/Source/JavaScriptCore
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r93915 r93918  
     12011-08-26  Filip Pizlo  <fpizlo@apple.com>
     2
     3        The GC does not have a facility for profiling the kinds of objects
     4        that occupy the heap
     5        https://bugs.webkit.org/show_bug.cgi?id=66849
     6
     7        Reviewed by Geoffrey Garen.
     8       
     9        Destructor calls and object scans are now optionally counted, per
     10        vtable. When the heap is destroyed and profiling is enabled, the
     11        counts are dumped, with care taken to print the names of classes
     12        (modulo C++ mangling) sorted in descending commonality.
     13
     14        * GNUmakefile.list.am:
     15        * JavaScriptCore.exp:
     16        * JavaScriptCore.pro:
     17        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
     18        * JavaScriptCore.xcodeproj/project.pbxproj:
     19        * heap/Heap.cpp:
     20        (JSC::Heap::destroy):
     21        * heap/Heap.h:
     22        * heap/MarkStack.cpp:
     23        (JSC::SlotVisitor::visitChildren):
     24        (JSC::SlotVisitor::drain):
     25        * heap/MarkStack.h:
     26        * heap/MarkedBlock.cpp:
     27        (JSC::MarkedBlock::callDestructor):
     28        * heap/MarkedBlock.h:
     29        * heap/VTableSpectrum.cpp: Added.
     30        (JSC::VTableSpectrum::VTableSpectrum):
     31        (JSC::VTableSpectrum::~VTableSpectrum):
     32        (JSC::VTableSpectrum::countVPtr):
     33        (JSC::VTableSpectrum::count):
     34        (JSC::VTableAndCount::VTableAndCount):
     35        (JSC::VTableAndCount::operator<):
     36        (JSC::VTableSpectrum::dump):
     37        * heap/VTableSpectrum.h: Added.
     38        * wtf/Platform.h:
     39
    1402011-08-26  Juan C. Montemayor  <jmont@apple.com>
    241
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r93698 r93918  
    150150        Source/JavaScriptCore/heap/OldSpace.h \
    151151        Source/JavaScriptCore/heap/Strong.h \
     152        Source/JavaScriptCore/heap/VTableSpectrum.cpp \
     153        Source/JavaScriptCore/heap/VTableSpectrum.h \
    152154        Source/JavaScriptCore/heap/Weak.h \
    153155        Source/JavaScriptCore/heap/WriteBarrierSupport.cpp \
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r93698 r93918  
    175175__ZN3JSC14TimeoutChecker10didTimeOutEPNS_9ExecStateE
    176176__ZN3JSC14TimeoutChecker5resetEv
     177__ZN3JSC14VTableSpectrum5countEPNS_6JSCellE
    177178__ZN3JSC14throwTypeErrorEPNS_9ExecStateE
    178179__ZN3JSC15JSWrapperObject13visitChildrenERNS_11SlotVisitorE
  • trunk/Source/JavaScriptCore/JavaScriptCore.pro

    r93698 r93918  
    8080    heap/NewSpace.cpp \
    8181    heap/OldSpace.cpp \
     82    heap/VTableSpectrum.cpp \
    8283    heap/WriteBarrierSupport.cpp \
    8384    debugger/DebuggerActivation.cpp \
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r93698 r93918  
    19671967                            </File>
    19681968                            <File
     1969                                    RelativePath="..\..\heap\VTableSpectrum.h"
     1970                                    >
     1971                            </File>
     1972                            <File
     1973                                    RelativePath="..\..\heap\VTableSpectrum.cpp"
     1974                                    >
     1975                            </File>
     1976                            <File
    19691977                                    RelativePath="..\..\heap\Weak.h"
    19701978                                    >
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r93698 r93918  
    5353                0F7700921402FF3C0078EB39 /* SamplingCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7700911402FF280078EB39 /* SamplingCounter.cpp */; };
    5454                0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F963B3613FC6FDE0002D9B2 /* ValueProfile.h */; settings = {ATTRIBUTES = (Private, ); }; };
     55                0FC815151405119B00CFA603 /* VTableSpectrum.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC815141405118D00CFA603 /* VTableSpectrum.h */; settings = {ATTRIBUTES = (Private, ); }; };
     56                0FC81516140511B500CFA603 /* VTableSpectrum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC815121405118600CFA603 /* VTableSpectrum.cpp */; };
    5557                0FC8150A14043BF500CFA603 /* WriteBarrierSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */; settings = {ATTRIBUTES = (Private, ); }; };
    5658                0FC8150B14043C0E00CFA603 /* WriteBarrierSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */; };
     
    738740                0F7700911402FF280078EB39 /* SamplingCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SamplingCounter.cpp; sourceTree = "<group>"; };
    739741                0F963B3613FC6FDE0002D9B2 /* ValueProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueProfile.h; sourceTree = "<group>"; };
     742                0FC815121405118600CFA603 /* VTableSpectrum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VTableSpectrum.cpp; sourceTree = "<group>"; };
     743                0FC815141405118D00CFA603 /* VTableSpectrum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VTableSpectrum.h; sourceTree = "<group>"; };
    740744                0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WriteBarrierSupport.cpp; sourceTree = "<group>"; };
    741745                0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WriteBarrierSupport.h; sourceTree = "<group>"; };
     
    15101514                        isa = PBXGroup;
    15111515                        children = (
     1516                                0FC815141405118D00CFA603 /* VTableSpectrum.h */,
     1517                                0FC815121405118600CFA603 /* VTableSpectrum.cpp */,
    15121518                                0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */,
    15131519                                0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */,
     
    22462252                                86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
    22472253                                BC18C3E60E16F5CD00B34460 /* ArrayConstructor.h in Headers */,
     2254                                0FC815151405119B00CFA603 /* VTableSpectrum.h in Headers */,
    22482255                                0FC8150A14043BF500CFA603 /* WriteBarrierSupport.h in Headers */,
    22492256                                0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */,
     
    28562863                        buildActionMask = 2147483647;
    28572864                        files = (
     2865                                0FC81516140511B500CFA603 /* VTableSpectrum.cpp in Sources */,
    28582866                                0FC8150B14043C0E00CFA603 /* WriteBarrierSupport.cpp in Sources */,
    28592867                                0F7700921402FF3C0078EB39 /* SamplingCounter.cpp in Sources */,
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r92329 r93918  
    312312    shrink();
    313313    ASSERT(!size());
     314   
     315#if ENABLE(SIMPLE_HEAP_PROFILING)
     316    m_slotVisitor.m_visitedTypeCounts.dump(stderr, "Visited Type Counts");
     317    m_destroyedTypeCounts.dump(stderr, "Destroyed Type Counts");
     318#endif
    314319   
    315320#if ENABLE(LAZY_BLOCK_FREEING)
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r93698 r93918  
    125125
    126126    private:
     127        friend class MarkedBlock;
     128       
    127129        typedef HashSet<MarkedBlock*>::iterator BlockIterator;
    128130
     
    184186        ThreadCondition m_freeBlockCondition;
    185187        bool m_blockFreeingThreadShouldQuit;
     188#endif
     189
     190#if ENABLE(SIMPLE_HEAP_PROFILING)
     191        VTableSpectrum m_destroyedTypeCounts;
    186192#endif
    187193
  • trunk/Source/JavaScriptCore/heap/MarkStack.cpp

    r89069 r93918  
    5454inline void SlotVisitor::visitChildren(JSCell* cell)
    5555{
     56#if ENABLE(SIMPLE_HEAP_PROFILING)
     57    m_visitedTypeCounts.count(cell);
     58#endif
     59
    5660    ASSERT(Heap::isMarked(cell));
    5761    if (cell->structure()->typeInfo().type() < CompoundType) {
     
    109113
    110114            if (cell->structure()->typeInfo().type() < CompoundType) {
     115#if ENABLE(SIMPLE_HEAP_PROFILING)
     116                m_visitedTypeCounts.count(cell);
     117#endif
    111118                cell->JSCell::visitChildren(*this);
    112119                if (current.m_values == end) {
  • trunk/Source/JavaScriptCore/heap/MarkStack.h

    r91869 r93918  
    3030#include "JSValue.h"
    3131#include "Register.h"
     32#include "VTableSpectrum.h"
     33#include <wtf/HashMap.h>
    3234#include <wtf/HashSet.h>
    3335#include <wtf/Vector.h>
     
    98100        void reset();
    99101
     102#if ENABLE(SIMPLE_HEAP_PROFILING)
     103        VTableSpectrum m_visitedTypeCounts;
     104#endif
     105
    100106    protected:
    101107#if ENABLE(GC_VALIDATION)
     
    115121        MarkStackArray<JSCell*> m_values;
    116122        HashSet<void*> m_opaqueRoots; // Handle-owning data structures not visible to the garbage collector.
    117 
     123       
    118124#if !ASSERT_DISABLED
    119125    public:
  • trunk/Source/JavaScriptCore/heap/MarkedBlock.cpp

    r92233 r93918  
    6868    void* vptr = cell->vptr();
    6969    if (specializedDestructorState == AllFreeCellsHaveObjects || vptr) {
     70#if ENABLE(SIMPLE_HEAP_PROFILING)
     71        m_heap->m_destroyedTypeCounts.countVPtr(vptr);
     72#endif
    7073        if (vptr == jsFinalObjectVPtr) {
    7174            JSFinalObject* object = reinterpret_cast<JSFinalObject*>(cell);
  • trunk/Source/JavaScriptCore/heap/MarkedBlock.h

    r92233 r93918  
    173173       
    174174        template<DestructorState destructorState>
    175         static void callDestructor(JSCell*, void* jsFinalObjectVPtr);
     175        void callDestructor(JSCell*, void* jsFinalObjectVPtr);
    176176       
    177177        template<DestructorState destructorState>
  • trunk/Source/JavaScriptCore/wtf/Platform.h

    r93698 r93918  
    964964#endif
    965965
     966#if !defined(ENABLE_SIMPLE_HEAP_PROFILING)
     967#define ENABLE_SIMPLE_HEAP_PROFILING 0
     968#endif
     969
    966970/* Counts uses of write barriers using sampling counters. Be sure to also
    967971   set ENABLE_SAMPLING_COUNTERS to 1. */
Note: See TracChangeset for help on using the changeset viewer.