Ignore:
Timestamp:
Oct 11, 2011, 5:24:12 PM (14 years ago)
Author:
[email protected]
Message:

Tidy up card walking logic
https://bugs.webkit.org/show_bug.cgi?id=69883

Reviewed by Gavin Barraclough.

Special case common cell sizes when walking a block's
cards.

  • heap/CardSet.h:

(JSC::::testAndClear):

  • heap/Heap.cpp:

(JSC::GCTimer::GCCounter::GCCounter):
(JSC::GCTimer::GCCounter::count):
(JSC::GCTimer::GCCounter::~GCCounter):
(JSC::Heap::markRoots):

  • heap/MarkStack.cpp:

(JSC::MarkStack::reset):

  • heap/MarkStack.h:

(JSC::MarkStack::visitCount):
(JSC::MarkStack::MarkStack):
(JSC::MarkStack::append):

  • heap/MarkedBlock.h:

(JSC::MarkedBlock::gatherDirtyCellsWithSize):
(JSC::MarkedBlock::gatherDirtyCells):

  • runtime/Structure.h:

(JSC::MarkStack::internalAppend):

File:
1 edited

Legend:

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

    r96760 r97203  
    4444static const size_t largeHeapSize = 16 * 1024 * 1024;
    4545static const size_t smallHeapSize = 512 * 1024;
    46 
     46#define ENABLE_GC_LOGGING 1
    4747#if ENABLE(GC_LOGGING)
    48    
     48#if COMPILER(CLANG)
     49#define DEFINE_GC_LOGGING_GLOBAL(type, name, arguments) \
     50_Pragma("clang diagnostic push") \
     51_Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") \
     52_Pragma("clang diagnostic ignored \"-Wexit-time-destructors\"") \
     53static type name arguments; \
     54_Pragma("clang diagnostic pop")
     55#else
     56#define DEFINE_GC_LOGGING_GLOBAL(type, name, arguments) \
     57static type name arguments;
     58#endif // COMPILER(CLANG)
     59
    4960struct GCTimer {
    5061    GCTimer(const char* name)
     
    8798};
    8899
    89 #define GCPHASE(name) static GCTimer name##Timer(#name); GCTimerScope name##TimerScope(&name##Timer)
    90 #define COND_GCPHASE(cond, name1, name2) static GCTimer name1##Timer(#name1); static GCTimer name2##Timer(#name2); GCTimerScope name1##CondTimerScope(cond ? &name1##Timer : &name2##Timer)
    91 
     100struct GCCounter {
     101    GCCounter(const char* name)
     102        : m_name(name)
     103        , m_count(0)
     104        , m_total(0)
     105        , m_min(10000000)
     106        , m_max(0)
     107    {
     108    }
     109   
     110    void count(size_t amount)
     111    {
     112        m_count++;
     113        m_total += amount;
     114        if (amount < m_min)
     115            m_min = amount;
     116        if (amount > m_max)
     117            m_max = amount;
     118    }
     119    ~GCCounter()
     120    {
     121        printf("%s: %zu values (avg. %zu, min. %zu, max. %zu)\n", m_name, m_total, m_total / m_count, m_min, m_max);
     122    }
     123    const char* m_name;
     124    size_t m_count;
     125    size_t m_total;
     126    size_t m_min;
     127    size_t m_max;
     128};
     129
     130#define GCPHASE(name) DEFINE_GC_LOGGING_GLOBAL(GCTimer, name##Timer, (#name)); GCTimerScope name##TimerScope(&name##Timer)
     131#define COND_GCPHASE(cond, name1, name2) DEFINE_GC_LOGGING_GLOBAL(GCTimer, name1##Timer, (#name1)); DEFINE_GC_LOGGING_GLOBAL(GCTimer, name2##Timer, (#name2)); GCTimerScope name1##CondTimerScope(cond ? &name1##Timer : &name2##Timer)
     132#define GCCOUNTER(name, value) do { DEFINE_GC_LOGGING_GLOBAL(GCCounter, name##Counter, (#name)); name##Counter.count(value); } while (false)
     133   
    92134#else
    93135
    94136#define GCPHASE(name) do { } while (false)
    95137#define COND_GCPHASE(cond, name1, name2) do { } while (false)
    96 
     138#define GCCOUNTER(name, value) do { } while (false)
    97139#endif
    98140
     
    549591
    550592#if ENABLE(GGC)
    551     if (size_t dirtyCellCount = dirtyCells.size()) {
     593    {
     594        size_t dirtyCellCount = dirtyCells.size();
    552595        GCPHASE(VisitDirtyCells);
     596        GCCOUNTER(DirtyCellCount, dirtyCellCount);
    553597        for (size_t i = 0; i < dirtyCellCount; i++) {
    554598            heapRootVisitor.visitChildren(dirtyCells[i]);
     
    622666        } while (lastOpaqueRootCount != visitor.opaqueRootCount());
    623667    }
     668    GCCOUNTER(VisitedValueCount, visitor.visitCount());
    624669    visitor.reset();
    625670
Note: See TracChangeset for help on using the changeset viewer.