Changeset 196104 in webkit


Ignore:
Timestamp:
Feb 3, 2016 7:12:23 PM (8 years ago)
Author:
akling@apple.com
Message:

[iOS] Throw away linked code when navigating to a new page.
<https://webkit.org/b/153851>

Reviewed by Gavin Barraclough.

Source/JavaScriptCore:

Add a VM API for throwing away linked code only.

  • runtime/VM.cpp:

(JSC::VM::deleteAllLinkedCode):

  • runtime/VM.h:

Source/WebCore:

When navigating to a new page, tell JSC to throw out any linked code it has lying around.
Linked code is tied to a specific global object, and as we're creating a new one for the
new page, none of it is useful to us here.
In the event that the user navigates back, the cost of relinking some code will be far
lower than the memory cost of keeping all of it around.

  • bindings/js/GCController.cpp:

(WebCore::GCController::deleteAllLinkedCode):

  • bindings/js/GCController.h:
  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::commitProvisionalLoad):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r196077 r196104  
     12016-02-03  Andreas Kling  <akling@apple.com>
     2
     3        [iOS] Throw away linked code when navigating to a new page.
     4        <https://webkit.org/b/153851>
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Add a VM API for throwing away linked code only.
     9
     10        * runtime/VM.cpp:
     11        (JSC::VM::deleteAllLinkedCode):
     12        * runtime/VM.h:
     13
    1142016-02-03  Michael Catanzaro  <mcatanzaro@igalia.com>
    215
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r196022 r196104  
    543543}
    544544
     545void VM::deleteAllLinkedCode()
     546{
     547    whenIdle([this]() {
     548        heap.deleteAllCodeBlocks();
     549        heap.reportAbandonedObjectGraph();
     550    });
     551}
     552
    545553void VM::deleteAllCode()
    546554{
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r196022 r196104  
    575575
    576576    JS_EXPORT_PRIVATE void deleteAllCode();
     577    JS_EXPORT_PRIVATE void deleteAllLinkedCode();
    577578
    578579    void registerWatchpointForImpureProperty(const Identifier&, Watchpoint*);
  • trunk/Source/WebCore/ChangeLog

    r196101 r196104  
     12016-02-03  Andreas Kling  <akling@apple.com>
     2
     3        [iOS] Throw away linked code when navigating to a new page.
     4        <https://webkit.org/b/153851>
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        When navigating to a new page, tell JSC to throw out any linked code it has lying around.
     9        Linked code is tied to a specific global object, and as we're creating a new one for the
     10        new page, none of it is useful to us here.
     11        In the event that the user navigates back, the cost of relinking some code will be far
     12        lower than the memory cost of keeping all of it around.
     13
     14        * bindings/js/GCController.cpp:
     15        (WebCore::GCController::deleteAllLinkedCode):
     16        * bindings/js/GCController.h:
     17        * loader/FrameLoader.cpp:
     18        (WebCore::FrameLoader::commitProvisionalLoad):
     19
    1202016-02-03  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WebCore/bindings/js/GCController.cpp

    r192775 r196104  
    123123}
    124124
     125void GCController::deleteAllLinkedCode()
     126{
     127    JSLockHolder lock(JSDOMWindow::commonVM());
     128    JSDOMWindow::commonVM().deleteAllLinkedCode();
     129}
     130
    125131} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/GCController.h

    r188394 r196104  
    4747    WEBCORE_EXPORT void setJavaScriptGarbageCollectorTimerEnabled(bool);
    4848    WEBCORE_EXPORT void deleteAllCode();
     49    WEBCORE_EXPORT void deleteAllLinkedCode();
    4950
    5051private:
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r195948 r196104  
    6767#include "FrameTree.h"
    6868#include "FrameView.h"
     69#include "GCController.h"
    6970#include "HTMLAnchorElement.h"
    7071#include "HTMLFormElement.h"
     
    17621763        PageCache::singleton().addIfCacheable(*history().currentItem(), m_frame.page());
    17631764
     1765#if PLATFORM(IOS)
     1766    // For top-level navigations, have JSC throw away linked code. The immediate memory savings far
     1767    // outweigh the cost of recompiling in the case of a future backwards navigation.
     1768    if (!m_frame.tree().parent())
     1769        GCController::singleton().deleteAllLinkedCode();
     1770#endif
     1771
    17641772    if (m_loadType != FrameLoadType::Replace)
    17651773        closeOldDataSources();
Note: See TracChangeset for help on using the changeset viewer.