Changeset 136773 in webkit


Ignore:
Timestamp:
Dec 5, 2012, 3:43:06 PM (12 years ago)
Author:
oliver@apple.com
Message:

Empty parse cache when receiving a low memory warning
https://bugs.webkit.org/show_bug.cgi?id=104161

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

This adds a function to the globaldata to empty all code related data
structures (code in the heap and the code cache).
It also adds a function to allow the CodeCache to actually be cleared
at all.

  • runtime/CodeCache.h:

(CacheMap):
(JSC::CacheMap::clear):
(JSC::CodeCache::clear):
(CodeCache):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::discardAllCode):
(JSC):

  • runtime/JSGlobalData.h:

(JSGlobalData):

Source/WebCore:

Use new discardAllCode() function on the global data, rather than
directly interacting with the heap.

  • bindings/js/GCController.cpp:

(WebCore::GCController::discardAllCompiledCode):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r136720 r136773  
     12012-12-05  Oliver Hunt  <oliver@apple.com>
     2
     3        Empty parse cache when receiving a low memory warning
     4        https://bugs.webkit.org/show_bug.cgi?id=104161
     5
     6        Reviewed by Filip Pizlo.
     7
     8        This adds a function to the globaldata to empty all code related data
     9        structures (code in the heap and the code cache).
     10        It also adds a function to allow the CodeCache to actually be cleared
     11        at all.
     12
     13        * runtime/CodeCache.h:
     14        (CacheMap):
     15        (JSC::CacheMap::clear):
     16        (JSC::CodeCache::clear):
     17        (CodeCache):
     18        * runtime/JSGlobalData.cpp:
     19        (JSC::JSGlobalData::discardAllCode):
     20        (JSC):
     21        * runtime/JSGlobalData.h:
     22        (JSGlobalData):
     23
    1242012-12-05  Filip Pizlo  <fpizlo@apple.com>
    225
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r136608 r136773  
    188188    ?detachThread@WTF@@YAXI@Z
    189189    ?didTimeOut@TimeoutChecker@JSC@@QAE_NPAVExecState@2@@Z
     190    ?discardAllCode@JSGlobalData@JSC@@QAEXXZ
    190191    ?displayName@JSFunction@JSC@@QAE?AVString@WTF@@PAVExecState@2@@Z
    191192    ?dtoa@WTF@@YAXQADNAA_NAAHAAI@Z
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r136261 r136773  
    8383        ASSERT(m_map.size() <= CacheSize);
    8484    }
     85
     86    void clear()
     87    {
     88        m_map.clear();
     89        for (size_t i = 0; i < CacheSize; i++) {
     90            m_data[i].first = KeyType();
     91            m_data[i].second = EntryType();
     92        }
     93    }
     94
     95
    8596private:
    8697    HashMap<KeyType, unsigned> m_map;
     
    99110    void usedFunctionCode(JSGlobalData&, UnlinkedFunctionCodeBlock*);
    100111    ~CodeCache();
     112
     113    void clear()
     114    {
     115        m_cachedCodeBlocks.clear();
     116        m_cachedFunctionExecutables.clear();
     117        m_cachedGlobalFunctions.clear();
     118        m_recentlyUsedFunctionCode.clear();
     119    }
    101120
    102121    enum CodeType { EvalType, ProgramType, FunctionCallType, FunctionConstructType };
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r136601 r136773  
    432432}
    433433
     434void JSGlobalData::discardAllCode()
     435{
     436    m_codeCache->clear();
     437    heap.deleteAllCompiledCode();
     438}
     439
    434440void JSGlobalData::dumpSampleData(ExecState* exec)
    435441{
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r136601 r136773  
    451451        CodeCache* codeCache() { return m_codeCache.get(); }
    452452
     453        JS_EXPORT_PRIVATE void discardAllCode();
     454
    453455    private:
    454456        friend class LLIntOffsetsExtractor;
  • trunk/Source/WebCore/ChangeLog

    r136765 r136773  
     12012-12-05  Oliver Hunt  <oliver@apple.com>
     2
     3        Empty parse cache when receiving a low memory warning
     4        https://bugs.webkit.org/show_bug.cgi?id=104161
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Use new discardAllCode() function on the global data, rather than
     9        directly interacting with the heap.
     10
     11        * bindings/js/GCController.cpp:
     12        (WebCore::GCController::discardAllCompiledCode):
     13
    1142012-12-05  Dan Bernstein  <mitz@apple.com>
    215
  • trunk/Source/WebCore/bindings/js/GCController.cpp

    r127278 r136773  
    106106{
    107107    JSLockHolder lock(JSDOMWindow::commonJSGlobalData());
    108     JSDOMWindow::commonJSGlobalData()->heap.deleteAllCompiledCode();
     108    JSDOMWindow::commonJSGlobalData()->discardAllCode();
    109109}
    110110
Note: See TracChangeset for help on using the changeset viewer.