Changeset 24493 in webkit


Ignore:
Timestamp:
Jul 20, 2007 3:58:24 PM (17 years ago)
Author:
ggaren
Message:

Reviewed by Darin Adler.


Fixed http://bugs.webkit.org/show_bug.cgi?id=12900 Page tear-down
forces garbage collection once per frame

Also fixed <rdar://problem/5286989> GC on window close does not always
bring the JS object count down to 0


Implemented a 0-delay GC timer in WebCore. Instead of forcing GC
immediately, code that thinks it has created a lot of garbage starts
the timer. This has two advantages:

1) Multiple GCs can coalesce. In my pathological test case, this
improves performance by an order of magnitude.


2) Conservative marking is less likely to keep alive important dead
objects, like the window object, because the stack is small and free of
JS processing when the timer fires.

Added GCController.h/.cpp, sometimes blindly:

  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • WebCoreSources.bkl:

Added singleton that implements GC on a 0-delay timer:

  • bindings/js/GCController.h: Added.
  • bindings/js/GCController.cpp: Added.


Changed Collector::collect() calls below to call to the singleton:

  • bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::~KJSProxy):
  • bindings/js/kjs_window.cpp: (KJS::Window::clear):
  • history/CachedPage.cpp: (WebCore::CachedPage::clear):


  • page/Frame.cpp: (WebCore::Frame::~Frame): Removed previous slightly hackish attempt to avoid conservative marking of the window object.
Location:
trunk/WebCore
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r24492 r24493  
     12007-07-20  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Darin Adler.
     4       
     5        Fixed http://bugs.webkit.org/show_bug.cgi?id=12900 Page tear-down
     6        forces garbage collection once per frame
     7
     8        Also fixed <rdar://problem/5286989> GC on window close does not always
     9        bring the JS object count down to 0
     10       
     11        Implemented a 0-delay GC timer in WebCore. Instead of forcing GC
     12        immediately, code that thinks it has created a lot of garbage starts
     13        the timer. This has two advantages:
     14
     15        1) Multiple GCs can coalesce. In my pathological test case, this
     16        improves performance by an order of magnitude.
     17       
     18        2) Conservative marking is less likely to keep alive important dead
     19        objects, like the window object, because the stack is small and free of
     20        JS processing when the timer fires.
     21
     22        Added GCController.h/.cpp, sometimes blindly:
     23        * WebCore.pro:
     24        * WebCore.vcproj/WebCore.vcproj:
     25        * WebCore.xcodeproj/project.pbxproj:
     26        * WebCoreSources.bkl:
     27
     28        Added singleton that implements GC on a 0-delay timer:
     29        * bindings/js/GCController.h: Added.
     30        * bindings/js/GCController.cpp: Added.
     31       
     32        Changed Collector::collect() calls below to call to the singleton:
     33        * bindings/js/kjs_proxy.cpp:
     34        (WebCore::KJSProxy::~KJSProxy):
     35        * bindings/js/kjs_window.cpp:
     36        (KJS::Window::clear):
     37        * history/CachedPage.cpp:
     38        (WebCore::CachedPage::clear):
     39       
     40        * page/Frame.cpp:
     41        (WebCore::Frame::~Frame): Removed previous slightly hackish attempt to
     42        avoid conservative marking of the window object.
     43
    1442007-07-20  Anders Carlsson  <andersca@apple.com>
    245   
  • trunk/WebCore/WebCore.pro

    r24485 r24493  
    279279
    280280SOURCES += \
     281    bindings/js/GCController.cpp \
    281282    bindings/js/JSCanvasRenderingContext2DCustom.cpp \
    282283    bindings/js/JSCSSRuleCustom.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r24485 r24493  
    71167116                                >
    71177117                                <File
     7118                                        RelativePath="..\bindings\js\GCController.cpp"
     7119                                        >
     7120                                </File>
     7121                                <File
     7122                                        RelativePath="..\bindings\js\GCController.h"
     7123                                        >
     7124                                </File>
     7125                                <File
    71187126                                        RelativePath="..\bindings\js\JSCanvasRenderingContext2DCustom.cpp"
    71197127                                        >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r24490 r24493  
    4444                06FC442D0BAE5A9E0090EDE1 /* JavaScriptStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06FC442B0BAE5A9E0090EDE1 /* JavaScriptStatistics.cpp */; };
    4545                06FC442E0BAE5A9E0090EDE1 /* JavaScriptStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = 06FC442C0BAE5A9E0090EDE1 /* JavaScriptStatistics.h */; settings = {ATTRIBUTES = (Private, ); }; };
     46                0F31CBF92B654730BA0535E8 /* BidiContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 514AF320BE854014A7DA49FB /* BidiContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    4647                1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1402645D0AFDC19B005919E2 /* LoggingMac.mm */; };
    4748                1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403B99509EB13AF00797C7F /* DOMWindow.h */; };
     
    5455                142011B60A003133008303F9 /* JSCSSStyleDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 142011B40A003133008303F9 /* JSCSSStyleDeclaration.cpp */; };
    5556                142011B70A003133008303F9 /* JSCSSStyleDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 142011B50A003133008303F9 /* JSCSSStyleDeclaration.h */; };
     57                1432E8470C51493800B1500F /* GCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1432E8460C51493800B1500F /* GCController.h */; };
     58                1432E8490C51493F00B1500F /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1432E8480C51493F00B1500F /* GCController.cpp */; };
    5659                1477E7760BF4134A00152872 /* PageCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1477E7740BF4134A00152872 /* PageCache.cpp */; };
    5760                1477E7770BF4134A00152872 /* PageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1477E7750BF4134A00152872 /* PageCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    280283                37919C230B7D188600A56998 /* PositionIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37919C210B7D188600A56998 /* PositionIterator.cpp */; };
    281284                37919C240B7D188600A56998 /* PositionIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 37919C220B7D188600A56998 /* PositionIterator.h */; settings = {ATTRIBUTES = (); }; };
    282                 0F31CBF92B654730BA0535E8 /* BidiContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 514AF320BE854014A7DA49FB /* BidiContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    283                 F971E27FD70F4382BC66D792 /* BidiContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A579C284B928484FB9A446BC /* BidiContext.cpp */; };
    284285                448A29BF0A46D9CB0030759F /* JSHTMLOptionsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */; };
    285286                448A29C00A46D9CB0030759F /* JSHTMLOptionsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 448A29BE0A46D9CB0030759F /* JSHTMLOptionsCollection.cpp */; };
     
    30313032                ED501DC60B249F2900AE18D9 /* EditorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED501DC50B249F2900AE18D9 /* EditorMac.mm */; };
    30323033                EDEC98030AED7E170059137F /* WebCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = EDEC98020AED7E170059137F /* WebCorePrefix.h */; };
     3034                F971E27FD70F4382BC66D792 /* BidiContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A579C284B928484FB9A446BC /* BidiContext.cpp */; };
    30333035                FAE0418F097596C9000540BE /* SVGImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAE0418D097596C9000540BE /* SVGImageLoader.cpp */; };
    30343036                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
     
    32653267                142011B40A003133008303F9 /* JSCSSStyleDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleDeclaration.cpp; sourceTree = "<group>"; };
    32663268                142011B50A003133008303F9 /* JSCSSStyleDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSStyleDeclaration.h; sourceTree = "<group>"; };
     3269                1432E8460C51493800B1500F /* GCController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GCController.h; sourceTree = "<group>"; };
     3270                1432E8480C51493F00B1500F /* GCController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GCController.cpp; sourceTree = "<group>"; };
    32673271                1477E7740BF4134A00152872 /* PageCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PageCache.cpp; sourceTree = "<group>"; };
    32683272                1477E7750BF4134A00152872 /* PageCache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PageCache.h; sourceTree = "<group>"; };
     
    35223526                37919C210B7D188600A56998 /* PositionIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PositionIterator.cpp; sourceTree = "<group>"; };
    35233527                37919C220B7D188600A56998 /* PositionIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PositionIterator.h; sourceTree = "<group>"; };
    3524                 514AF320BE854014A7DA49FB /* BidiContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BidiContext.h; sourceTree = "<group>"; };
    3525                 A579C284B928484FB9A446BC /* BidiContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BidiContext.cpp; sourceTree = "<group>"; };
    35263528                448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLOptionsCollection.h; sourceTree = "<group>"; };
    35273529                448A29BE0A46D9CB0030759F /* JSHTMLOptionsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollection.cpp; sourceTree = "<group>"; };
     
    35753577                513F14510AB634C400094DDF /* IconLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IconLoader.cpp; sourceTree = "<group>"; };
    35763578                513F14520AB634C400094DDF /* IconLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IconLoader.h; sourceTree = "<group>"; };
     3579                514AF320BE854014A7DA49FB /* BidiContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BidiContext.h; sourceTree = "<group>"; };
    35773580                5150C2A10702629000AF642C /* WebDashboardRegion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDashboardRegion.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    35783581                5150C2A50702629800AF642C /* WebDashboardRegion.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebDashboardRegion.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    48434846                93F9B79F0BA6032600854064 /* JSCDATASection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCDATASection.h; sourceTree = "<group>"; };
    48444847                93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; };
     4848                A579C284B928484FB9A446BC /* BidiContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BidiContext.cpp; sourceTree = "<group>"; };
    48454849                A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = "<group>"; };
    48464850                A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragControllerMac.mm; sourceTree = "<group>"; };
     
    93089312                        isa = PBXGroup;
    93099313                        children = (
     9314                                BC4EDEF70C08F414007EDD49 /* Custom */,
    93109315                                14DFB33F0A7DF7630018F769 /* Derived Sources */,
    9311                                 BC4EDEF70C08F414007EDD49 /* Custom */,
    93129316                                93F8B3060A300FEA00F61AB8 /* CodeGeneratorJS.pm */,
     9317                                1432E8480C51493F00B1500F /* GCController.cpp */,
     9318                                1432E8460C51493800B1500F /* GCController.h */,
    93139319                                E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */,
    93149320                                E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */,
     
    1169811704                                B402007C0C4D217800210AA6 /* BidiReorderCharacters.h in Headers */,
    1169911705                                0F31CBF92B654730BA0535E8 /* BidiContext.h in Headers */,
     11706                                1432E8470C51493800B1500F /* GCController.h in Headers */,
    1170011707                        );
    1170111708                        runOnlyForDeploymentPostprocessing = 0;
     
    1313713144                                F971E27FD70F4382BC66D792 /* BidiContext.cpp in Sources */,
    1313813145                                B402007D0C4D217800210AA6 /* BidiReorderCharacters.cpp in Sources */,
     13146                                1432E8490C51493F00B1500F /* GCController.cpp in Sources */,
    1313913147                        );
    1314013148                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/WebCoreSources.bkl

    r24485 r24493  
    728728
    729729    <set append="1" var="WEBCORE_SOURCES_JS">
     730        bindings/js/GCController.cpp
    730731        bindings/js/JSCanvasRenderingContext2DCustom.cpp
    731732        bindings/js/JSCustomXPathNSResolver.cpp
  • trunk/WebCore/bindings/js/kjs_proxy.cpp

    r24126 r24493  
    2626#include "Frame.h"
    2727#include "FrameLoader.h"
     28#include "GCController.h"
    2829#include "JSDOMWindow.h"
    2930#include "Page.h"
     
    5051    // in our interpreter.
    5152    ASSERT(!m_script || !m_script->context());
    52     m_script = 0;
    5353   
    54     // It's likely that destroying the interpreter has created a lot of garbage.
    55     JSLock lock;
    56     Collector::collect();
     54    if (m_script) {
     55        m_script = 0;
     56   
     57        // It's likely that destroying the interpreter has created a lot of garbage.
     58        gcController()->garbageCollectSoon();
     59    }
    5760}
    5861
  • trunk/WebCore/bindings/js/kjs_window.cpp

    r24462 r24493  
    3838#include "FrameTree.h"
    3939#include "FrameView.h"
     40#include "GCController.h"
    4041#include "HTMLDocument.h"
    4142#include "JSCSSRule.h"
     
    10621063
    10631064  // there's likely to be lots of garbage now
    1064   Collector::collect();
     1065  gcController()->garbageCollectSoon();
    10651066}
    10661067
  • trunk/WebCore/history/CachedPage.cpp

    r21745 r24493  
    3434#include "FrameLoader.h"
    3535#include "FrameView.h"
     36#include "GCController.h"
    3637#include "Logging.h"
    3738#include "Page.h"
     
    186187    m_pausedTimeouts.clear();
    187188
    188     Collector::collect();
     189    gcController()->garbageCollectSoon();
    189190}
    190191
  • trunk/WebCore/page/Frame.cpp

    r24398 r24493  
    188188#endif
    189189
    190     if (d->m_jscript && d->m_jscript->haveInterpreter()) {
    191         Window* volatile w = static_cast<Window*>(d->m_jscript->interpreter()->globalObject());
    192         ASSERT(w);
    193         w->disconnectFrame();
    194         // Clear w, otherwise we will not garbage-collect collect the window
    195         // (inside the call to delete d below). w is volatile to ensure that the
    196         // compiler doesn't optimize out this operation.
    197         w = 0;
    198     }
     190    if (d->m_jscript && d->m_jscript->haveInterpreter())
     191        static_cast<Window*>(d->m_jscript->interpreter()->globalObject())->disconnectFrame();
    199192
    200193    disconnectOwnerElement();
Note: See TracChangeset for help on using the changeset viewer.