Skip to content
  • ggaren@apple.com's avatar
    Shrank the SourceProvider cache · d17e17e9
    ggaren@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=110158
    
    Reviewed by Oliver Hunt.
    
    Source/JavaScriptCore: 
    
    CodeCache is now our primary source cache, so a long-lived SourceProvider
    cache is a waste. I measured this as a 10MB Membuster win; with more
    precise instrumentation, Andreas estimated it as up to 30MB.
    
    I didn't eliminate the SourceProvider cache because it's still useful
    in speeding up uncached parsing of scripts with large nested functions
    (i.e., all scripts).
    
    * heap/Heap.cpp:
    (JSC::Heap::collect): Discard all source provider caches after GC. This
    is a convenient place to do so because it's reasonably soon after initial
    parsing without being immediate.
    
    * parser/Parser.cpp:
    (JSC::::Parser): Updated for interface change: The heap now owns the
    source provider cache, since most SourceProviders are not expected to
    have one by default, and the heap is responsible for throwing them away.
    
    (JSC::::parseInner): No need to update statistics on cache size, since
    we're going to throw it away no matter what.
    
    (JSC::::parseFunctionInfo): Reduced the minimum function size to 16. This
    is a 27% win on a new parsing micro-benchmark I've added. Now that the
    cache is temporary, we don't have to worry so much about its memory
    footprint.
    
    * parser/Parser.h:
    (Parser): Updated for interface changes.
    
    * parser/SourceProvider.cpp:
    (JSC::SourceProvider::SourceProvider):
    (JSC::SourceProvider::~SourceProvider):
    * parser/SourceProvider.h:
    (JSC):
    (SourceProvider): SourceProvider doesn't own its cache anymore because
    the cache is temporary.
    
    * parser/SourceProviderCache.cpp:
    (JSC::SourceProviderCache::clear):
    (JSC::SourceProviderCache::add):
    * parser/SourceProviderCache.h:
    (JSC::SourceProviderCache::SourceProviderCache):
    (SourceProviderCache):
    * parser/SourceProviderCacheItem.h:
    (SourceProviderCacheItem): No need to update statistics on cache size,
    since we're going to throw it away no matter what.
    
    * runtime/JSGlobalData.cpp:
    (JSC::JSGlobalData::addSourceProviderCache):
    (JSC):
    (JSC::JSGlobalData::clearSourceProviderCaches):
    * runtime/JSGlobalData.h:
    (JSC):
    (JSGlobalData): Moved the cache here so it's easier to throw away.
    
    Source/WebCore: 
    
    Test: fast/js/regress/nested-function-parsing.html
    
    No need to keep statistics on cache size, since we're going to throw it
    away no matter what.
    
    * WebCore.order:
    * bindings/js/CachedScriptSourceProvider.h:
    (CachedScriptSourceProvider):
    (WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):
    * loader/cache/CachedScript.cpp:
    (WebCore::CachedScript::destroyDecodedData):
    (WebCore):
    (WebCore::CachedScript::reportMemoryUsage):
    * loader/cache/CachedScript.h:
    (CachedScript):
    
    LayoutTests: 
    
    New benchmark to show that a minimum size of 16 is better than 64.
    
    * fast/js/regress/nested-function-parsing-expected.txt: Added.
    * fast/js/regress/nested-function-parsing.html: Added.
    * fast/js/regress/script-tests/nested-function-parsing.js: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@143279 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    d17e17e9