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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@143279 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Style tweaks to StringHasher.h
https://bugs.webkit.org/show_bug.cgi?id=110042

Reviewed by Alexey Proskuryakov.

I have a bug fix coming soon, but figured I'd separate out style tweaks and land them
first to make that patch easier to undrestand.

* wtf/StringHasher.h: Tweak and rearrange comments a bit.
(WTF::StringHasher::addCharacter): Use character instead of ch.
(WTF::StringHasher::addCharacters): Use remainder instead of rem. Also capitalize the U
that we use to make an unsigned 1 constant.
(WTF::StringHasher::computeHashAndMaskTop8Bits): Ditto.
(WTF::StringHasher::hashMemory): Change version that takes size as a template argument
to call the version that takes the size at runtime, since both generate the same code
anyway. Added a FIXME questioning why this function uses the "mask top 8 bits" version
of the hash. Fix incorrect compile assertion that required sizes that are multiples
of four. This function works on sizes that are multiples of two. Also fixed a spelling
error where we called it a "multible".
(WTF::StringHasher::defaultConverter): Use character instead of ch.
(WTF::StringHasher::addCharactersToHash): Eliminated unnecessary local variable.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@143280 268f45cc-cd09-0410-ab3c-d52691b4dbfc