• mhahnenberg@apple.com's avatar
    Safari hangs during test262 run in CodeCache::pruneSlowCase · 0d46b892
    mhahnenberg@apple.com authored
    Reviewed by Geoffrey Garen.
    We can end up hanging for quite some time if we add a lot of small keys to the CodeCache.
    By the time we get around to pruning the cache, we have a potentially tens or hundreds of 
    thousands of small entries, which can cause a noticeable hang when pruning them.
    To fix this issue we added a hard cap to the number of entries in the cache because we 
    could potentially have to remove every element in the map.
    * runtime/CodeCache.cpp:
    (JSC::CodeCacheMap::pruneSlowCase): We need to prune until we're both under the hard cap and the
    capacity in bytes.
    * runtime/CodeCache.h:
    (JSC::CodeCacheMap::numberOfEntries): Convenience accessor function to the number of entries in 
    the map that does the cast to size_t of m_map.size() for us. 
    (JSC::CodeCacheMap::canPruneQuickly): Checks that the total number is under the hard cap. We put this 
    check inside a function to more accurately describe why we're doing the check and to abstract out 
    the actual calculation in case we want to coalesce calls to pruneSlowCase in the future.
    (JSC::CodeCacheMap::prune): Check the number of entries against our hard cap. If it's greater than
    the cap then we need to drop down to pruneSlowCase.
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
CodeCache.cpp 7.08 KB