Changeset 90415 in webkit


Ignore:
Timestamp:
Jul 5, 2011 4:55:45 PM (13 years ago)
Author:
oliver@apple.com
Message:

2011-07-05 Oliver Hunt <oliver@apple.com>

Don't throw out compiled code repeatedly
https://bugs.webkit.org/show_bug.cgi?id=63960

Reviewed by Gavin Barraclough.

Stop throwing away all compiled code every time
we're told to do a full GC. Instead unlink all
callsites during such GC passes to maximise the
number of collectable functions, but otherwise
leave compiled functions alone.

  • API/JSBase.cpp: (JSGarbageCollect):
  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::visitAggregate):
  • heap/Heap.cpp: (JSC::Heap::collectAllGarbage):
  • heap/MarkStack.h: (JSC::MarkStack::shouldUnlinkCalls): (JSC::MarkStack::setShouldUnlinkCalls):
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::recompileAllJSFunctions): (JSC::JSGlobalData::releaseExecutableMemory):
  • runtime/RegExp.cpp: (JSC::RegExp::compile): (JSC::RegExp::invalidateCode):
  • runtime/RegExp.h:
Location:
trunk/Source/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSBase.cpp

    r58115 r90415  
    9898
    9999    JSGlobalData& globalData = exec->globalData();
    100     if (!globalData.heap.isBusy())
    101         globalData.heap.collectAllGarbage();
     100    if (!globalData.heap.isBusy()) {
     101        // releaseExecutableMemory forces a full GC
     102        globalData.releaseExecutableMemory();
     103    }
    102104
    103105    // FIXME: Perhaps we should trigger a second mark and sweep
  • trunk/Source/JavaScriptCore/ChangeLog

    r90414 r90415  
     12011-07-05  Oliver Hunt  <oliver@apple.com>
     2
     3        Don't throw out compiled code repeatedly
     4        https://bugs.webkit.org/show_bug.cgi?id=63960
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Stop throwing away all compiled code every time
     9        we're told to do a full GC.  Instead unlink all
     10        callsites during such GC passes to maximise the
     11        number of collectable functions, but otherwise
     12        leave compiled functions alone.
     13
     14        * API/JSBase.cpp:
     15        (JSGarbageCollect):
     16        * bytecode/CodeBlock.cpp:
     17        (JSC::CodeBlock::visitAggregate):
     18        * heap/Heap.cpp:
     19        (JSC::Heap::collectAllGarbage):
     20        * heap/MarkStack.h:
     21        (JSC::MarkStack::shouldUnlinkCalls):
     22        (JSC::MarkStack::setShouldUnlinkCalls):
     23        * runtime/JSGlobalData.cpp:
     24        (JSC::JSGlobalData::recompileAllJSFunctions):
     25        (JSC::JSGlobalData::releaseExecutableMemory):
     26        * runtime/RegExp.cpp:
     27        (JSC::RegExp::compile):
     28        (JSC::RegExp::invalidateCode):
     29        * runtime/RegExp.h:
     30
    1312011-07-05  Filip Pizlo  <fpizlo@apple.com>
    232
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r90371 r90415  
    15371537        visitor.append(&m_functionDecls[i]);
    15381538#if ENABLE(JIT)
     1539    if (visitor.shouldUnlinkCalls())
     1540        unlinkCalls();
    15391541    for (unsigned i = 0; i < numberOfCallLinkInfos(); ++i)
    15401542        if (callLinkInfo(i).isLinked())
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r89885 r90415  
    526526void Heap::collectAllGarbage()
    527527{
    528     if (!m_globalData->dynamicGlobalObject)
    529         m_globalData->recompileAllJSFunctions();
    530 
     528    m_slotVisitor.setShouldUnlinkCalls(true);
    531529    collect(DoSweep);
     530    m_slotVisitor.setShouldUnlinkCalls(false);
    532531}
    533532
  • trunk/Source/JavaScriptCore/heap/MarkStack.h

    r89630 r90415  
    9898        void reset();
    9999
     100        bool shouldUnlinkCalls() const { return m_shouldUnlinkCalls; }
     101        void setShouldUnlinkCalls(bool shouldUnlinkCalls) { m_shouldUnlinkCalls = shouldUnlinkCalls; }
     102
    100103    protected:
    101104#if ENABLE(GC_VALIDATION)
     
    121124        bool m_isDraining;
    122125#endif
     126
     127    private:
     128        bool m_shouldUnlinkCalls;
    123129    };
    124130
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r89885 r90415  
    490490        }
    491491        heap.forEachCell<StackPreservingRecompiler>(recompiler);
    492     }
     492    } else
     493        recompileAllJSFunctions();
     494
    493495    m_regExpCache->invalidateCode();
    494496    heap.collectAllGarbage();
  • trunk/Source/JavaScriptCore/runtime/RegExp.cpp

    r89885 r90415  
    109109    ASSERT(m_state == NotCompiled);
    110110    m_representation = adoptPtr(new RegExpRepresentation);
     111    m_state = Compiling;
    111112    Yarr::YarrPattern pattern(m_patternString, ignoreCase(), multiline(), &m_constructionError);
    112113    if (m_constructionError) {
     
    119120
    120121    ASSERT(m_numSubpatterns == pattern.m_numSubpatterns);
    121 
    122     m_state = ByteCode;
    123122
    124123#if ENABLE(YARR_JIT)
     
    140139
    141140    m_representation->m_regExpBytecode = Yarr::byteCompile(pattern, &globalData->m_regExpAllocator);
     141
     142    m_state = ByteCode;
    142143}
    143144
     
    200201void RegExp::invalidateCode()
    201202{
    202     if (!m_representation)
     203    if (!m_representation || m_state == Compiling)
    203204        return;
    204205    m_state = NotCompiled;
  • trunk/Source/JavaScriptCore/runtime/RegExp.h

    r87445 r90415  
    8282            JITCode,
    8383            ByteCode,
    84             NotCompiled
     84            NotCompiled,
     85            Compiling
    8586        } m_state;
    8687
Note: See TracChangeset for help on using the changeset viewer.