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.h

    r54022 r54696  
    5050            return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren), AnonymousSlotCount);
    5151        }
     52       
     53        virtual ~JSPropertyNameIterator();
    5254
    5355        virtual bool isPropertyNameIterator() const { return true; }
     
    8284    };
    8385
    84 inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlots)
    85     : JSCell(exec->globalData().propertyNameIteratorStructure.get())
    86     , m_cachedStructure(0)
    87     , m_numCacheableSlots(numCacheableSlots)
    88     , m_jsStringsSize(propertyNameArrayData->propertyNameVector().size())
    89     , m_jsStrings(new JSValue[m_jsStringsSize])
    90 {
    91     PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArrayData->propertyNameVector();
    92     for (size_t i = 0; i < m_jsStringsSize; ++i)
    93         m_jsStrings[i] = jsOwnedString(exec, propertyNameVector[i].ustring());
    94 }
     86    inline void Structure::setEnumerationCache(JSPropertyNameIterator* enumerationCache)
     87    {
     88        ASSERT(!isDictionary());
     89        m_enumerationCache = enumerationCache;
     90    }
    9591
    96 inline void Structure::setEnumerationCache(JSPropertyNameIterator* enumerationCache)
    97 {
    98     ASSERT(!isDictionary());
    99     m_enumerationCache = enumerationCache;
    100 }
     92    inline void Structure::clearEnumerationCache(JSPropertyNameIterator* enumerationCache)
     93    {
     94        m_enumerationCache.clear(enumerationCache);
     95    }
     96
     97    inline JSPropertyNameIterator* Structure::enumerationCache()
     98    {
     99        return m_enumerationCache.get();
     100    }
    101101
    102102} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.