Ignore:
Timestamp:
Feb 18, 2013, 5:39:12 PM (12 years ago)
Author:
[email protected]
Message:

Shrank the SourceProvider cache
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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SourceProvider.h

    r143147 r143279  
    3838namespace JSC {
    3939
    40     class SourceProviderCache;
    41 
    4240    class SourceProvider : public RefCounted<SourceProvider> {
    4341    public:
    4442        static const intptr_t nullID = 1;
    4543       
    46         JS_EXPORT_PRIVATE SourceProvider(const String& url, const TextPosition& startPosition, SourceProviderCache* = 0);
     44        JS_EXPORT_PRIVATE SourceProvider(const String& url, const TextPosition& startPosition);
    4745
    4846        JS_EXPORT_PRIVATE virtual ~SourceProvider();
     
    6765        void setValid() { m_validated = true; }
    6866
    69         SourceProviderCache* cache() const { return m_cache; }
    70         void notifyCacheSizeChanged(int delta) { if (!m_cacheOwned) cacheSizeChanged(delta); }
    71        
    7267    private:
    73         virtual void cacheSizeChanged(int delta) { UNUSED_PARAM(delta); }
    7468
    7569        String m_url;
    7670        TextPosition m_startPosition;
    7771        bool m_validated;
    78         SourceProviderCache* m_cache;
    79         bool m_cacheOwned;
    8072    };
    8173
Note: See TracChangeset for help on using the changeset viewer.