Partial fix for <rdar://problem/9417875> REGRESSION: SunSpider ~17% slower
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 May 2011 22:31:31 +0000 (22:31 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 May 2011 22:31:31 +0000 (22:31 +0000)
commit3f51dfc0812f63a59aa799ab9093861b9169e798
treef5637c98fd69713e8c3108cfcb7d16753116560d
parent88bdbb96937512fde2d8b5756611763f36099a86
Partial fix for <rdar://problem/9417875> REGRESSION: SunSpider ~17% slower
in browser than on command line

Reviewed by Maciej Stachowiak.

This patch fixes a few issues in generated code that could unreasonably
prolong object lifetimes.

* heap/Heap.cpp:
(JSC::Heap::collectAllGarbage): Throw away all function code before doing
a major collection. We want to clear polymorphic caches, since they can
keep alive large object graphs that have gone "stale". For the same reason,
but to a lesser extent, we also want to clear linked functions and other
one-off caches.

This has the side-benefit of reducing memory footprint from run-once
functions, and of allowing predictions and caches that have failed to
re-specialize.

Eventually, if compilation costs rise far enough, we may want a more
limited strategy for de-specializing code without throwing it away
completely, but this works for now, and it's the simplest solution.

* jit/JITStubs.cpp:
(JSC::JITThunks::hostFunctionStub):
* jit/JITStubs.h:
* runtime/JSFunction.cpp: Made the host function stub cache weak --
otherwise it's effectively a memory leak that can seriously fragment the
GC and JIT heaps.

(JSC::JSFunction::JSFunction):
(JSC::JSFunction::visitChildren): Cleared up some comments that confused
me when working with this code.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86510 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/jit/JITStubs.h
Source/JavaScriptCore/runtime/JSFunction.cpp