Changeset 67130 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Sep 9, 2010, 5:21:43 PM (15 years ago)
Author:
Stephanie Lewis
Message:

Added statistics sampling and reporting for JavaScriptCore's RegisterFile and ExecutableAllocator classes
https://bugs.webkit.org/show_bug.cgi?id=45134

Reviewed by Alexey Proskuryakov.

JavaScriptCore:

Added thread-safe committed byte counting and reporting functionality to RegisterFile and
ExecutableAllocator.

Exported new symbols to allow for WebKit to get statistics from JavaScriptCore classes.

  • interpreter/RegisterFile.cpp:

(JSC::registerFileStatisticsMutex):
Added function which returns a static Mutex used for locking during read/write access to
static committed byte count variable.
(JSC::RegisterFile::~RegisterFile):
Added call to addToStatistics since memory is decommitted here.
(JSC::RegisterFile::releaseExcessCapacity):
Added call to addToStatistics since memory is decommitted here.
(JSC::RegisterFile::initializeThreading):
Added function which calls registerFileStatisticsMutex().
(JSC::RegisterFile::committedByteCount):
Added function which returns the current committed byte count for RegisterFile.
(JSC::RegisterFile::addToCommittedByteCount):
Added function which updates committed byte count.

  • interpreter/RegisterFile.h:

(JSC::RegisterFile::RegisterFile):
Added call to addToStatistics since memory is committed here.
(JSC::RegisterFile::grow):
Added call to addToStatistics since memory is committed here.

  • jit/ExecutableAllocator.h:

Added function prototype for public static function committedByteCount().

  • jit/ExecutableAllocatorFixedVMPool.cpp:

(JSC::FixedVMPoolAllocator::release):
Added call to addToStatistics since memory is decommitted here.
(JSC::FixedVMPoolAllocator::reuse):
Added call to addToStatistics since memory is committed here.
(JSC::FixedVMPoolAllocator::addToCommittedByteCount):
Added function which updates committed byte count.
(JSC::ExecutableAllocator::committedByteCount):
Added function which returns the current committed byte count for ExecutableAllocator.

  • runtime/InitializeThreading.cpp:

(JSC::initializeThreadingOnce):
Added call to RegisterFile::initializeThreading.

WebKit/mac:

Added ability to enable new JavaScriptCore statistics sampling and reporting for RegisterFile
and ExecutableAllocator classes. Added reporting of JavaScriptCore's stack committed memory
and JIT code committed memory statistics to WebCoreStatistics memoryStatistics.

  • Misc/WebCoreStatistics.mm:

(+[WebCoreStatistics memoryStatistics]):
Added statistics reporting for JSC RegisterFile and ExecutableAllocator.

Location:
trunk/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r67129 r67130  
     12010-09-09  John Therrell  <[email protected]>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        Added statistics sampling and reporting for JavaScriptCore's RegisterFile and ExecutableAllocator classes
     6        https://bugs.webkit.org/show_bug.cgi?id=45134
     7
     8        Added thread-safe committed byte counting and reporting functionality to RegisterFile and
     9        ExecutableAllocator.
     10
     11        * JavaScriptCore.exp:
     12        Exported new symbols to allow for WebKit to get statistics from JavaScriptCore classes.
     13       
     14        * interpreter/RegisterFile.cpp:
     15        (JSC::registerFileStatisticsMutex):
     16        Added function which returns a static Mutex used for locking during read/write access to
     17        static committed byte count variable.
     18        (JSC::RegisterFile::~RegisterFile):
     19        Added call to addToStatistics since memory is decommitted here.
     20        (JSC::RegisterFile::releaseExcessCapacity):
     21        Added call to addToStatistics since memory is decommitted here.
     22        (JSC::RegisterFile::initializeThreading):
     23        Added function which calls registerFileStatisticsMutex().
     24        (JSC::RegisterFile::committedByteCount):
     25        Added function which returns the current committed byte count for RegisterFile.
     26        (JSC::RegisterFile::addToCommittedByteCount):
     27        Added function which updates committed byte count.
     28       
     29        * interpreter/RegisterFile.h:
     30        (JSC::RegisterFile::RegisterFile):
     31        Added call to addToStatistics since memory is committed here.
     32        (JSC::RegisterFile::grow):
     33        Added call to addToStatistics since memory is committed here.
     34       
     35        * jit/ExecutableAllocator.h:
     36        Added function prototype for public static function committedByteCount().
     37       
     38        * jit/ExecutableAllocatorFixedVMPool.cpp:
     39        (JSC::FixedVMPoolAllocator::release):
     40        Added call to addToStatistics since memory is decommitted here.
     41        (JSC::FixedVMPoolAllocator::reuse):
     42        Added call to addToStatistics since memory is committed here.
     43        (JSC::FixedVMPoolAllocator::addToCommittedByteCount):
     44        Added function which updates committed byte count.
     45        (JSC::ExecutableAllocator::committedByteCount):
     46        Added function which returns the current committed byte count for ExecutableAllocator.
     47       
     48        * runtime/InitializeThreading.cpp:
     49        (JSC::initializeThreadingOnce):
     50        Added call to RegisterFile::initializeThreading.
     51
    1522010-09-09  Mark Rowe  <[email protected]>
    253
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r66936 r67130  
    132132__ZN3JSC12JSGlobalData6createENS_15ThreadStackTypeE
    133133__ZN3JSC12JSGlobalDataD1Ev
     134__ZN3JSC12RegisterFile18committedByteCountEv
    134135__ZN3JSC12SamplingTool5setupEv
    135136__ZN3JSC12SmallStrings17createEmptyStringEPNS_12JSGlobalDataE
     
    192193__ZN3JSC18PropertyDescriptor9setGetterENS_7JSValueE
    193194__ZN3JSC18PropertyDescriptor9setSetterENS_7JSValueE
     195__ZN3JSC19ExecutableAllocator18committedByteCountEv
    194196__ZN3JSC19initializeThreadingEv
    195197__ZN3JSC20MarkedArgumentBuffer10slowAppendENS_7JSValueE
  • trunk/JavaScriptCore/interpreter/RegisterFile.cpp

    r64782 r67130  
    3434namespace JSC {
    3535
     36static size_t committedBytesCount = 0;
     37
     38static Mutex& registerFileStatisticsMutex()
     39{
     40    DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
     41    return staticMutex;
     42}   
     43   
    3644RegisterFile::~RegisterFile()
    3745{
    3846    void* base = m_reservation.base();
    3947    m_reservation.decommit(base, reinterpret_cast<intptr_t>(m_commitEnd) - reinterpret_cast<intptr_t>(base));
     48    addToCommittedByteCount(-(reinterpret_cast<intptr_t>(m_commitEnd) - reinterpret_cast<intptr_t>(base)));
    4049    m_reservation.deallocate();
    4150}
     
    4453{
    4554    m_reservation.decommit(m_start, reinterpret_cast<intptr_t>(m_commitEnd) - reinterpret_cast<intptr_t>(m_start));
     55    addToCommittedByteCount(-(reinterpret_cast<intptr_t>(m_commitEnd) - reinterpret_cast<intptr_t>(m_start)));
    4656    m_commitEnd = m_start;
    4757    m_maxUsed = m_start;
     
    6373}
    6474
     75void RegisterFile::initializeThreading()
     76{
     77    registerFileStatisticsMutex();
     78}
     79
     80size_t RegisterFile::committedByteCount()
     81{
     82    MutexLocker locker(registerFileStatisticsMutex());
     83    return committedBytesCount;
     84}
     85
     86void RegisterFile::addToCommittedByteCount(long byteCount)
     87{
     88    MutexLocker locker(registerFileStatisticsMutex());
     89    ASSERT(static_cast<long>(committedBytesCount) + byteCount > -1);
     90    committedBytesCount += byteCount;
     91}
     92
    6593} // namespace JSC
  • trunk/JavaScriptCore/interpreter/RegisterFile.h

    r65311 r67130  
    135135        void markCallFrames(MarkStack& markStack, Heap* heap) { heap->markConservatively(markStack, m_start, m_end); }
    136136
     137        static size_t committedByteCount();
     138        static void initializeThreading();
     139
    137140    private:
    138141        void checkAllocatedOkay(bool okay);
    139 
    140142        void releaseExcessCapacity();
     143        void addToCommittedByteCount(long);
    141144        size_t m_numGlobals;
    142145        const size_t m_maxGlobals;
     
    167170        size_t committedSize = roundUpAllocationSize(maxGlobals * sizeof(Register), commitSize);
    168171        checkAllocatedOkay(m_reservation.commit(base, committedSize));
     172        addToCommittedByteCount(static_cast<long>(committedSize));
    169173        m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(base) + committedSize);
    170174        m_start = static_cast<Register*>(base) + maxGlobals;
     
    194198            size_t size = roundUpAllocationSize(reinterpret_cast<char*>(newEnd) - reinterpret_cast<char*>(m_commitEnd), commitSize);
    195199            checkAllocatedOkay(m_reservation.commit(m_commitEnd, size));
     200            addToCommittedByteCount(static_cast<long>(size));
    196201            m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(m_commitEnd) + size);
    197202        }
  • trunk/JavaScriptCore/jit/ExecutableAllocator.h

    r66150 r67130  
    298298    #error "The cacheFlush support is missing on this platform."
    299299#endif
     300    static size_t committedByteCount();
    300301
    301302private:
  • trunk/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp

    r66150 r67130  
    5555
    5656namespace JSC {
     57   
     58static size_t committedBytesCount = 0; 
     59static SpinLock spinlock = SPINLOCK_INITIALIZER;
    5760
    5861// FreeListEntry describes a free chunk of memory, stored in the freeList.
     
    129132    {
    130133        m_allocation.decommit(position, size);
     134        addToCommittedByteCount(-static_cast<long>(size));
    131135    }
    132136
     
    135139        bool okay = m_allocation.commit(position, size);
    136140        ASSERT_UNUSED(okay, okay);
     141        addToCommittedByteCount(static_cast<long>(size));
    137142    }
    138143
     
    416421#endif
    417422
     423    void addToCommittedByteCount(long byteCount)
     424    {
     425        ASSERT(spinlock.IsHeld());
     426        ASSERT(static_cast<long>(committedBytesCount) + byteCount > -1);
     427        committedBytesCount += byteCount;
     428    }
     429
    418430    // Freed space from the most common sized allocations will be held in this list, ...
    419431    const size_t m_commonSize;
     
    429441};
    430442
     443size_t ExecutableAllocator::committedByteCount()
     444{
     445    SpinLockHolder lockHolder(&spinlock);
     446    return committedBytesCount;
     447}   
     448
    431449void ExecutableAllocator::intializePageSize()
    432450{
     
    435453
    436454static FixedVMPoolAllocator* allocator = 0;
    437 static SpinLock spinlock = SPINLOCK_INITIALIZER;
    438 
     455   
    439456bool ExecutableAllocator::isValid() const
    440457{
  • trunk/JavaScriptCore/runtime/InitializeThreading.cpp

    r65104 r67130  
    5959    s_dtoaP5Mutex = new Mutex;
    6060    initializeDates();
     61    RegisterFile::initializeThreading();
    6162#endif
    6263}
Note: See TracChangeset for help on using the changeset viewer.