Ignore:
Timestamp:
Feb 11, 2010, 1:28:52 PM (15 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Added an SPI for asking about all the different live objects on the heap.
Useful for memory debugging.

Reviewed by Oliver Hunt.

  • runtime/Collector.cpp:

(JSC::typeName): Use a little capitalization. Don't crash in the case of
a non-object cell, since it might just be an uninitialized cell.

(JSC::Heap::objectTypeCounts): The new SPI.

  • runtime/Collector.h:
  • runtime/CollectorHeapIterator.h:

(JSC::CollectorHeapIterator::advance):
(JSC::LiveObjectIterator::operator++):
(JSC::DeadObjectIterator::operator++):
(JSC::ObjectIterator::operator++): Made 2 tweaks to these iterators:
(1) Skip the last cell in the block, since it's a dummy sentinel, and
we don't want it to confuse the object count; (2) Fixed a logic error
in LiveObjectIterator that could cause it to iterate dead objects if
m_block were equal to m_heap.nextBlock and m_cell were less than
m_heap.nextCell. No test for this since I can't think of a way that this
could make WebKit behave badly.

WebKit/mac: Exported some new JavaScript heap introspection.

Reviewed by Oliver Hunt.

  • Misc/WebCoreStatistics.h:
  • Misc/WebCoreStatistics.mm:

(+[WebCoreStatistics javaScriptObjectTypeCounts]): Just like
javaScriptProtectedObjectTypeCounts, except this function enumerates all
live objects, not just protected objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r53572 r54672  
    11981198#endif
    11991199    if (cell->isGetterSetter())
    1200         return "gettersetter";
     1200        return "Getter-Setter";
    12011201    if (cell->isAPIValueWrapper())
    1202         return "value wrapper";
     1202        return "API wrapper";
    12031203    if (cell->isPropertyNameIterator())
    1204         return "for-in iterator";
    1205     ASSERT(cell->isObject());
     1204        return "For-in iterator";
     1205    if (!cell->isObject())
     1206        return "[empty cell]";
    12061207    const ClassInfo* info = cell->classInfo();
    12071208    return info ? info->className : "Object";
     
    12151216    for (ProtectCountSet::iterator it = m_protectedValues.begin(); it != end; ++it)
    12161217        counts->add(typeName(it->first));
     1218
     1219    return counts;
     1220}
     1221
     1222HashCountedSet<const char*>* Heap::objectTypeCounts()
     1223{
     1224    HashCountedSet<const char*>* counts = new HashCountedSet<const char*>;
     1225
     1226    LiveObjectIterator it = primaryHeapBegin();
     1227    LiveObjectIterator heapEnd = primaryHeapEnd();
     1228    for ( ; it != heapEnd; ++it)
     1229        counts->add(typeName(*it));
    12171230
    12181231    return counts;
Note: See TracChangeset for help on using the changeset viewer.