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


Ignore:
Timestamp:
Nov 6, 2011, 3:39:12 AM (14 years ago)
Author:
[email protected]
Message:

JSC should be able to sample itself in a more flexible way than just sampling flags
https://bugs.webkit.org/show_bug.cgi?id=71522

Source/JavaScriptCore:

Reviewed by Gavin Barraclough.

Added a construct that looks like SamplingRegion samplingRegion("name").

(JSC::SamplingRegion::Locker::Locker):
(JSC::SamplingRegion::Locker::~Locker):
(JSC::SamplingRegion::sample):
(JSC::SamplingRegion::dump):
(JSC::SamplingRegion::dumpInternal):
(JSC::SamplingThread::threadStartFunc):

  • bytecode/SamplingTool.h:

(JSC::SamplingRegion::SamplingRegion):
(JSC::SamplingRegion::~SamplingRegion):
(JSC::SamplingRegion::exchangeCurrent):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::generate):

  • dfg/DFGDriver.cpp:

(JSC::DFG::compile):

  • heap/Heap.cpp:

(JSC::Heap::markRoots):
(JSC::Heap::collect):

  • heap/VTableSpectrum.cpp:

(JSC::VTableSpectrum::countVPtr):
(JSC::VTableSpectrum::dump):

  • heap/VTableSpectrum.h:
  • jsc.cpp:

(main):
(runWithScripts):

  • parser/Parser.h:

(JSC::parse):

  • runtime/Executable.cpp:

(JSC::EvalExecutable::compileInternal):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::compileForConstructInternal):

  • wtf/Atomics.h:

(WTF::weakCompareAndSwap):

  • wtf/Platform.h:
  • wtf/Spectrum.h: Added.

(WTF::Spectrum::Spectrum):
(WTF::Spectrum::add):
(WTF::Spectrum::get):
(WTF::Spectrum::begin):
(WTF::Spectrum::end):
(WTF::Spectrum::KeyAndCount::KeyAndCount):
(WTF::Spectrum::KeyAndCount::operator<):
(WTF::Spectrum::buildList):

  • wtf/wtf.pri:

Source/JavaScriptGlue:

Reviewed by Gavin Barraclough.

  • ForwardingHeaders/wtf/Spectrum.h: Added.

Source/WebCore:

Reviewed by Gavin Barraclough.

No new tests, since no functionality changed.

  • ForwardingHeaders/wtf/Spectrum.h: Added.
Location:
trunk/Source/JavaScriptCore/heap
Files:
3 edited

Legend:

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

    r98937 r99374  
    554554void Heap::markRoots(bool fullGC)
    555555{
     556    SamplingRegion samplingRegion("Garbage Collection: Tracing");
     557
    556558    COND_GCPHASE(fullGC, MarkFullRoots, MarkYoungRoots);
    557559    UNUSED_PARAM(fullGC);
     
    760762void Heap::collect(SweepToggle sweepToggle)
    761763{
     764    SamplingRegion samplingRegion("Garbage Collection");
     765   
    762766    GCPHASE(Collect);
    763767    ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
     
    793797
    794798    if (sweepToggle == DoSweep) {
     799        SamplingRegion samplingRegion("Garbage Collection: Sweeping");
    795800        GCPHASE(Sweeping);
    796801        sweep();
  • trunk/Source/JavaScriptCore/heap/VTableSpectrum.cpp

    r95901 r99374  
    5050void VTableSpectrum::countVPtr(void* vTablePointer)
    5151{
    52     std::pair<HashMap<void*, unsigned long>::iterator, bool> result = m_map.add(vTablePointer, 1);
    53     if (!result.second)
    54         result.first->second++;
     52    add(vTablePointer);
    5553}
    5654
     
    6058}
    6159
    62 struct VTableAndCount {
    63     void* vtable;
    64     unsigned long count;
    65    
    66     VTableAndCount() { }
    67    
    68     VTableAndCount(void* vtable, unsigned long count)
    69         : vtable(vtable)
    70         , count(count)
    71     {
    72     }
    73    
    74     bool operator<(const VTableAndCount& other) const
    75     {
    76         if (count != other.count)
    77             return count < other.count;
    78         return vtable > other.vtable; // this results in lower-addressed vtables being printed first
    79     }
    80 };
    81 
    8260void VTableSpectrum::dump(FILE* output, const char* comment)
    8361{
    8462    fprintf(output, "%s:\n", comment);
    8563   
    86     HashMap<void*, unsigned long>::iterator begin = m_map.begin();
    87     HashMap<void*, unsigned long>::iterator end = m_map.end();
    88    
    89     Vector<VTableAndCount, 0> list;
    90    
    91     for (HashMap<void*, unsigned long>::iterator iter = begin; iter != end; ++iter)
    92         list.append(VTableAndCount(iter->first, iter->second));
    93    
    94     std::sort(list.begin(), list.end());
     64    Vector<KeyAndCount> list = buildList();
    9565   
    9666    for (size_t index = list.size(); index-- > 0;) {
    97         VTableAndCount item = list.at(index);
     67        KeyAndCount item = list.at(index);
    9868#if PLATFORM(MAC)
    9969        Dl_info info;
    100         if (dladdr(item.vtable, &info)) {
     70        if (dladdr(item.key, &info)) {
    10171            char* findResult = strrchr(info.dli_fname, '/');
    10272            const char* strippedFileName;
     
    10777                strippedFileName = info.dli_fname;
    10878           
    109             fprintf(output, "    %s:%s(%p): %lu\n", strippedFileName, info.dli_sname, item.vtable, item.count);
     79            fprintf(output, "    %s:%s(%p): %lu\n", strippedFileName, info.dli_sname, item.key, item.count);
    11080            continue;
    11181        }
    11282#endif
    113         fprintf(output, "    %p: %lu\n", item.vtable, item.count);
     83        fprintf(output, "    %p: %lu\n", item.key, item.count);
    11484    }
    11585   
  • trunk/Source/JavaScriptCore/heap/VTableSpectrum.h

    r95901 r99374  
    2828
    2929#include <stdio.h>
    30 #include <wtf/HashMap.h>
     30#include <wtf/Spectrum.h>
    3131
    3232namespace JSC {
     
    3434class JSCell;
    3535
    36 class VTableSpectrum {
     36class VTableSpectrum: Spectrum<void*> {
    3737public:
    3838    VTableSpectrum();
     
    4343   
    4444    void dump(FILE* output, const char* comment);
    45    
    46 private:
    47     HashMap<void*, unsigned long> m_map;
    4845};
    4946
Note: See TracChangeset for help on using the changeset viewer.