Ignore:
Timestamp:
Feb 11, 2010, 9:01:07 PM (15 years ago)
Author:
[email protected]
Message:

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

Reviewed by Oliver Hunt and Darin Adler.

The rest of the fix for
https://bugs.webkit.org/show_bug.cgi?id=34864 | <rdar://problem/7594198>
Many objects left uncollected after visiting mail.google.com and closing
window


Don't unconditionally hang onto small strings. Instead, hang onto all
small strings as long as any small string is still referenced.


SunSpider reports no change.

  • runtime/Collector.cpp: (JSC::Heap::markRoots): Mark the small strings cache last, so it can check if anything else has kept any strings alive.
  • runtime/SmallStrings.cpp: (JSC::isMarked): (JSC::SmallStrings::markChildren): Only keep our strings alive if some other reference to at least one of them exists, too.
File:
1 edited

Legend:

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

    r54574 r54701  
    3535static const unsigned numCharactersToStore = 0x100;
    3636
     37static inline bool isMarked(JSString* string)
     38{
     39    return string && Heap::isCellMarked(string);
     40}
     41
    3742class SmallStringsStorage : public Noncopyable {
    3843public:
     
    6772void SmallStrings::markChildren(MarkStack& markStack)
    6873{
     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   
    6993    if (m_emptyString)
    7094        markStack.append(m_emptyString);
Note: See TracChangeset for help on using the changeset viewer.