Ignore:
Timestamp:
Feb 11, 2010, 6:51:35 PM (15 years ago)
Author:
[email protected]
Message:

2010-02-11 Geoffrey Garen <[email protected]>

Reviewed by Gavin Barraclough.

Some progress toward fixing
https://bugs.webkit.org/show_bug.cgi?id=34864 | <rdar://problem/7594198>
Many objects left uncollected after visiting mail.google.com and closing
window


SunSpider reports no change.


Keep weak references, rather than protected references, to cached for-in
property name enumerators.


One problem with protected references is that a chain like

[ gc object 1 ] => [ non-gc object ] => [ gc object 2 ]

takes two GC passes to break, since the first pass collects [ gc object 1 ],
releasing [ non-gc object ] and unprotecting [ gc object 2 ], and only
then can a second pass collect [ gc object 2 ].


Another problem with protected references is that they can keep a bunch
of strings alive long after they're useful. In SunSpider and a few popular
websites, the size-speed tradeoff seems to favor weak references.

  • runtime/JSPropertyNameIterator.cpp: (JSC::JSPropertyNameIterator::JSPropertyNameIterator): Moved this constructor into the .cpp file, since it's not used elsewhere.

(JSC::JSPropertyNameIterator::~JSPropertyNameIterator): Added a destructor
to support our weak reference.

  • runtime/JSPropertyNameIterator.h: (JSC::Structure::setEnumerationCache): (JSC::Structure::clearEnumerationCache): (JSC::Structure::enumerationCache): Added a function for clearing a Structure's enumeration cache, used by our new destructor. Also fixed indentation to match the rest of the file.
  • runtime/Structure.h: Changed from protected pointer to weak pointer.
File:
1 edited

Legend:

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

    r51801 r54696  
    3535
    3636ASSERT_CLASS_FITS_IN_CELL(JSPropertyNameIterator);
     37
     38inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlots)
     39    : JSCell(exec->globalData().propertyNameIteratorStructure.get())
     40    , m_cachedStructure(0)
     41    , m_numCacheableSlots(numCacheableSlots)
     42    , m_jsStringsSize(propertyNameArrayData->propertyNameVector().size())
     43    , m_jsStrings(new JSValue[m_jsStringsSize])
     44{
     45    PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArrayData->propertyNameVector();
     46    for (size_t i = 0; i < m_jsStringsSize; ++i)
     47        m_jsStrings[i] = jsOwnedString(exec, propertyNameVector[i].ustring());
     48}
     49
     50JSPropertyNameIterator::~JSPropertyNameIterator()
     51{
     52    if (m_cachedStructure)
     53        m_cachedStructure->clearEnumerationCache(this);
     54}
    3755
    3856JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject* o)
Note: See TracChangeset for help on using the changeset viewer.