Changeset 54696 in webkit for trunk/JavaScriptCore
- Timestamp:
- Feb 11, 2010, 6:51:35 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r54684 r54696 1 2010-02-11 Geoffrey Garen <[email protected]> 2 3 Reviewed by Gavin Barraclough. 4 5 Some progress toward fixing 6 https://bugs.webkit.org/show_bug.cgi?id=34864 | <rdar://problem/7594198> 7 Many objects left uncollected after visiting mail.google.com and closing 8 window 9 10 SunSpider reports no change. 11 12 Keep weak references, rather than protected references, to cached for-in 13 property name enumerators. 14 15 One problem with protected references is that a chain like 16 [ gc object 1 ] => [ non-gc object ] => [ gc object 2 ] 17 takes two GC passes to break, since the first pass collects [ gc object 1 ], 18 releasing [ non-gc object ] and unprotecting [ gc object 2 ], and only 19 then can a second pass collect [ gc object 2 ]. 20 21 Another problem with protected references is that they can keep a bunch 22 of strings alive long after they're useful. In SunSpider and a few popular 23 websites, the size-speed tradeoff seems to favor weak references. 24 25 * runtime/JSPropertyNameIterator.cpp: 26 (JSC::JSPropertyNameIterator::JSPropertyNameIterator): Moved this constructor 27 into the .cpp file, since it's not used elsewhere. 28 29 (JSC::JSPropertyNameIterator::~JSPropertyNameIterator): Added a destructor 30 to support our weak reference. 31 32 * runtime/JSPropertyNameIterator.h: 33 (JSC::Structure::setEnumerationCache): 34 (JSC::Structure::clearEnumerationCache): 35 (JSC::Structure::enumerationCache): Added a function for clearing a 36 Structure's enumeration cache, used by our new destructor. Also fixed 37 indentation to match the rest of the file. 38 39 * runtime/Structure.h: Changed from protected pointer to weak pointer. 40 1 41 2010-02-11 Chris Rogers <[email protected]> 2 42 -
trunk/JavaScriptCore/runtime/JSPropertyNameIterator.cpp
r51801 r54696 35 35 36 36 ASSERT_CLASS_FITS_IN_CELL(JSPropertyNameIterator); 37 38 inline 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 50 JSPropertyNameIterator::~JSPropertyNameIterator() 51 { 52 if (m_cachedStructure) 53 m_cachedStructure->clearEnumerationCache(this); 54 } 37 55 38 56 JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject* o) -
trunk/JavaScriptCore/runtime/JSPropertyNameIterator.h
r54022 r54696 50 50 return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren), AnonymousSlotCount); 51 51 } 52 53 virtual ~JSPropertyNameIterator(); 52 54 53 55 virtual bool isPropertyNameIterator() const { return true; } … … 82 84 }; 83 85 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 } 95 91 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 } 101 101 102 102 } // namespace JSC -
trunk/JavaScriptCore/runtime/Structure.h
r54520 r54696 37 37 #include "JSTypeInfo.h" 38 38 #include "UString.h" 39 #include "WeakGCPtr.h" 39 40 #include <wtf/PassRefPtr.h> 40 41 #include <wtf/RefCounted.h> … … 136 137 137 138 void setEnumerationCache(JSPropertyNameIterator* enumerationCache); // Defined in JSPropertyNameIterator.h. 138 JSPropertyNameIterator* enumerationCache() { return m_enumerationCache.get(); } 139 void clearEnumerationCache(JSPropertyNameIterator* enumerationCache); // Defined in JSPropertyNameIterator.h. 140 JSPropertyNameIterator* enumerationCache(); // Defined in JSPropertyNameIterator.h. 139 141 void getPropertyNames(PropertyNameArray&, EnumerationMode mode); 140 142 … … 200 202 StructureTransitionTable table; 201 203 202 ProtectedPtr<JSPropertyNameIterator> m_enumerationCache;204 WeakGCPtr<JSPropertyNameIterator> m_enumerationCache; 203 205 204 206 PropertyMapHashTable* m_propertyTable;
Note:
See TracChangeset
for help on using the changeset viewer.