Ignore:
Timestamp:
Sep 11, 2015, 9:08:39 AM (10 years ago)
Author:
[email protected]
Message:

JavaScriptCore should discard optimized code after some time
https://bugs.webkit.org/show_bug.cgi?id=149048

Reviewed by Michael Saboff.

This patch adds a new jettison type -- JettisonDueToOldAge -- and starts
using it for DFG and FTL code. Baseline and LLInt code will come in a
follow-up patch.

The primary goal is to save memory. Some popular websites leave about 10MB
of dead code sitting around immediately after they finish loading.

Throwing away code periodically might also save us from profiling
pathologies that lead to performance dead ends.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::visitAggregate): Updated for rename, and removed a
stale comment.

(JSC::CodeBlock::shouldVisitStrongly): Renamed to shouldVisitStrongly
because the practical effect of this function is to trigger a call to
visitStrongly.

(JSC::CodeBlock::isKnownToBeLiveDuringGC): Check the
m_visitStronglyHasBeenCalled flag instead of
shouldImmediatelyAssumeLivenessDuringScan / shouldVisitStrongly because
m_visitStronglyHasBeenCalled can be set by anybody even if the CodeBlock
would not otherwise visit itself strongly.

(JSC::CodeBlock::shouldJettisonDueToWeakReference): New helper function
for readability.

(JSC::CodeBlock::shouldJettisonDueToOldAge): New helper function that
tells if a CodeBlock is old enough for deletion.

(JSC::CodeBlock::determineLiveness): There's no need to check
shouldImmediatelyAssumeLivenessDuringScan here because we will not call
this function if shouldImmediatelyAssumeLivenessDuringScan is true.
Also, it's just not clear -- if someone chooses to call this function --
that it would be safe to ignore them simply because
shouldImmediatelyAssumeLivenessDuringScan was true.

(JSC::CodeBlock::finalizeLLIntInlineCaches): Moved code out into a helper
function to make the main function more readable.

(JSC::CodeBlock::finalizeBaselineJITInlineCaches): Ditto.

(JSC::CodeBlock::finalizeUnconditionally): Added code for jettisoning a
CodeBlock if it is too old. Moved large sections of code into helper
functions to aid readability in this function.

(JSC::CodeBlock::jettison): Account for the fact that we might jettison
a CodeBlock without OSR exit and without requiring a stack shoot-down.

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::setInstallTime):
(JSC::CodeBlock::timeSinceInstall): Track CodeBlock age to help us
decide when to delete.

  • jit/JITCode.h:

(JSC::JITCode::timeToLive): Static limits on CodeBlock lifetime. I got
these numbers from the place where numbers come from.

  • profiler/ProfilerJettisonReason.cpp:

(WTF::printInternal):

  • profiler/ProfilerJettisonReason.h: Updated for new jettison type.
  • runtime/Executable.cpp:

(JSC::ScriptExecutable::installCode): Record install time so that we
can measure how old a CodeBlock is.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r189616 r189620  
     12015-09-11  Geoffrey Garen  <[email protected]>
     2
     3        JavaScriptCore should discard optimized code after some time
     4        https://bugs.webkit.org/show_bug.cgi?id=149048
     5
     6        Reviewed by Michael Saboff.
     7
     8        This patch adds a new jettison type -- JettisonDueToOldAge -- and starts
     9        using it for DFG and FTL code. Baseline and LLInt code will come in a
     10        follow-up patch.
     11
     12        The primary goal is to save memory. Some popular websites leave about 10MB
     13        of dead code sitting around immediately after they finish loading.
     14
     15        Throwing away code periodically might also save us from profiling
     16        pathologies that lead to performance dead ends.
     17
     18        * bytecode/CodeBlock.cpp:
     19        (JSC::CodeBlock::visitAggregate): Updated for rename, and removed a
     20        stale comment.
     21
     22        (JSC::CodeBlock::shouldVisitStrongly): Renamed to shouldVisitStrongly
     23        because the practical effect of this function is to trigger a call to
     24        visitStrongly.
     25
     26        (JSC::CodeBlock::isKnownToBeLiveDuringGC): Check the
     27        m_visitStronglyHasBeenCalled flag instead of
     28        shouldImmediatelyAssumeLivenessDuringScan / shouldVisitStrongly because
     29        m_visitStronglyHasBeenCalled can be set by anybody even if the CodeBlock
     30        would not otherwise visit itself strongly.
     31
     32        (JSC::CodeBlock::shouldJettisonDueToWeakReference): New helper function
     33        for readability.
     34
     35        (JSC::CodeBlock::shouldJettisonDueToOldAge): New helper function that
     36        tells if a CodeBlock is old enough for deletion.
     37
     38        (JSC::CodeBlock::determineLiveness): There's no need to check
     39        shouldImmediatelyAssumeLivenessDuringScan here because we will not call
     40        this function if shouldImmediatelyAssumeLivenessDuringScan is true.
     41        Also, it's just not clear -- if someone chooses to call this function --
     42        that it would be safe to ignore them simply because
     43        shouldImmediatelyAssumeLivenessDuringScan was true.
     44
     45        (JSC::CodeBlock::finalizeLLIntInlineCaches): Moved code out into a helper
     46        function to make the main function more readable.
     47
     48        (JSC::CodeBlock::finalizeBaselineJITInlineCaches): Ditto.
     49
     50        (JSC::CodeBlock::finalizeUnconditionally): Added code for jettisoning a
     51        CodeBlock if it is too old. Moved large sections of code into helper
     52        functions to aid readability in this function.
     53
     54        (JSC::CodeBlock::jettison): Account for the fact that we might jettison
     55        a CodeBlock without OSR exit and without requiring a stack shoot-down.
     56
     57        * bytecode/CodeBlock.h:
     58        (JSC::CodeBlock::setInstallTime):
     59        (JSC::CodeBlock::timeSinceInstall): Track CodeBlock age to help us
     60        decide when to delete.
     61
     62        * jit/JITCode.h:
     63        (JSC::JITCode::timeToLive): Static limits on CodeBlock lifetime. I got
     64        these numbers from the place where numbers come from.
     65
     66        * profiler/ProfilerJettisonReason.cpp:
     67        (WTF::printInternal):
     68        * profiler/ProfilerJettisonReason.h: Updated for new jettison type.
     69
     70        * runtime/Executable.cpp:
     71        (JSC::ScriptExecutable::installCode): Record install time so that we
     72        can measure how old a CodeBlock is.
     73
    1742015-09-11  Andreas Kling  <[email protected]>
    275
Note: See TracChangeset for help on using the changeset viewer.