Changeset 54701 in webkit for trunk/JavaScriptCore
- Timestamp:
- Feb 11, 2010, 9:01:07 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r54696 r54701 1 2010-02-11 Geoffrey Garen <[email protected]> 2 3 Reviewed by Oliver Hunt and Darin Adler. 4 5 The rest of the fix for 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 Don't unconditionally hang onto small strings. Instead, hang onto all 11 small strings as long as any small string is still referenced. 12 13 SunSpider reports no change. 14 15 * runtime/Collector.cpp: 16 (JSC::Heap::markRoots): Mark the small strings cache last, so it can 17 check if anything else has kept any strings alive. 18 19 * runtime/SmallStrings.cpp: 20 (JSC::isMarked): 21 (JSC::SmallStrings::markChildren): Only keep our strings alive if some 22 other reference to at least one of them exists, too. 23 1 24 2010-02-11 Geoffrey Garen <[email protected]> 2 25 -
trunk/JavaScriptCore/runtime/Collector.cpp
r54672 r54701 1123 1123 if (m_globalData->exception) 1124 1124 markStack.append(m_globalData->exception); 1125 m_globalData->smallStrings.markChildren(markStack);1126 1125 if (m_globalData->functionCodeBlockBeingReparsed) 1127 1126 m_globalData->functionCodeBlockBeingReparsed->markAggregate(markStack); 1128 1127 if (m_globalData->firstStringifierToMark) 1129 1128 JSONObject::markStringifiers(markStack, m_globalData->firstStringifierToMark); 1129 1130 // Mark the small strings cache last, since it will clear itself if nothing 1131 // else has marked it. 1132 m_globalData->smallStrings.markChildren(markStack); 1130 1133 1131 1134 markStack.drain(); -
trunk/JavaScriptCore/runtime/SmallStrings.cpp
r54574 r54701 35 35 static const unsigned numCharactersToStore = 0x100; 36 36 37 static inline bool isMarked(JSString* string) 38 { 39 return string && Heap::isCellMarked(string); 40 } 41 37 42 class SmallStringsStorage : public Noncopyable { 38 43 public: … … 67 72 void SmallStrings::markChildren(MarkStack& markStack) 68 73 { 74 /* 75 Our hypothesis is that small strings are very common. So, we cache them 76 to avoid GC churn. However, in cases where this hypothesis turns out to 77 be false -- including the degenerate case where all JavaScript execution 78 has terminated -- we don't want to waste memory. 79 80 To test our hypothesis, we check if any small string has been marked. If 81 so, it's probably reasonable to mark the rest. If not, we clear the cache. 82 */ 83 84 bool isAnyStringMarked = isMarked(m_emptyString); 85 for (unsigned i = 0; i < numCharactersToStore && !isAnyStringMarked; ++i) 86 isAnyStringMarked |= isMarked(m_singleCharacterStrings[i]); 87 88 if (!isAnyStringMarked) { 89 clear(); 90 return; 91 } 92 69 93 if (m_emptyString) 70 94 markStack.append(m_emptyString);
Note:
See TracChangeset
for help on using the changeset viewer.