JavaScriptCore:
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Nov 2006 21:06:14 +0000 (21:06 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Nov 2006 21:06:14 +0000 (21:06 +0000)
        Reviewed by Beth Dakin.

        Fixed up garbage collection at window close time.

        * kjs/interpreter.cpp:
        (KJS::Interpreter::~Interpreter): Garbage collect here, since
        destroying the interpreter frees the global object and
        therefore creates a lot of garbage.

WebCore:

        Reviewed by Beth Dakin.

        Fixed up garbage collection at window close time.

        * bindings/js/kjs_proxy.cpp: Don't garbage collect in the KJSProxy
        destructor, since the global object hasn't been freed yet.
        * bindings/js/kjs_proxy.h:
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::detachFromParent): Made this function cross-
        platform.
        * loader/FrameLoader.h:
        * loader/mac/FrameLoaderMac.mm:
        (WebCore::FrameLoader::setTitle): Moved this function to FrameLoaderMac,
        since it's Mac-only.
        (WebCore::FrameLoader::closeBridge):
        * page/Page.cpp:
        (WebCore::Page::~Page): Don't garbage collect in the Page destructor,
        since the Interpreter destructor will do it for us.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17945 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/interpreter.cpp
WebCore/ChangeLog
WebCore/bindings/js/kjs_proxy.cpp
WebCore/bindings/js/kjs_proxy.h
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h
WebCore/loader/mac/FrameLoaderMac.mm
WebCore/page/Page.cpp

index 5902ab9ad9dfd55270d819685a2491c5b245515c..9603be35ace7887cedb5d23b4ad8dbeda3dc2253 100644 (file)
@@ -1,3 +1,14 @@
+2006-11-30  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Beth Dakin.
+        
+        Fixed up garbage collection at window close time.
+
+        * kjs/interpreter.cpp:
+        (KJS::Interpreter::~Interpreter): Garbage collect here, since
+        destroying the interpreter frees the global object and 
+        therefore creates a lot of garbage.
+
 2006-11-20  W. Andy Carrel  <wac@google.com>
 
         Reviewed by Maciej.
index 7ce74ea31c4a619e4cf9a99476055287ab7c36e0..9de1ed230dadda0237d11bfb3f3307fa2a3977ea 100644 (file)
@@ -272,6 +272,9 @@ Interpreter::~Interpreter()
     }
     
     interpreterMap().remove(m_globalObject);
+
+    // It's likely that destroying the interpreter has created a lot of garbage.
+    Collector::collect();
 }
 
 JSObject* Interpreter::globalObject() const
index 44865bf84ad6c03ab4dafc08e980a0598b23cb46..991bde76dfca5e00a56b6dc4db1394063c6ebb6d 100644 (file)
@@ -1,3 +1,24 @@
+2006-11-30  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Beth Dakin.
+        
+        Fixed up garbage collection at window close time.
+
+        * bindings/js/kjs_proxy.cpp: Don't garbage collect in the KJSProxy
+        destructor, since the global object hasn't been freed yet.
+        * bindings/js/kjs_proxy.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::detachFromParent): Made this function cross-
+        platform.
+        * loader/FrameLoader.h:
+        * loader/mac/FrameLoaderMac.mm:
+        (WebCore::FrameLoader::setTitle): Moved this function to FrameLoaderMac,
+        since it's Mac-only.
+        (WebCore::FrameLoader::closeBridge):
+        * page/Page.cpp:
+        (WebCore::Page::~Page): Don't garbage collect in the Page destructor,
+        since the Interpreter destructor will do it for us.
+
 2006-11-30  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Tim's rubberstamp
index a3da9610d02e30ae46879281b51159d8406153aa..e063cf427ffdd0a91b1d949ab6cb44d15c113c05 100644 (file)
@@ -43,12 +43,6 @@ KJSProxy::KJSProxy(Frame* frame)
     m_handlerLineno = 0;
 }
 
-KJSProxy::~KJSProxy()
-{
-    JSLock lock;
-    Collector::collect();
-}
-
 JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String& str, Node* n) 
 {
   // evaluate code. Returns the JS return value or 0
index 5e0b575a9c4b264df53078107316a635226393c3..0bcd19185950ee7947084332beb1d992f08cc1e6 100644 (file)
@@ -39,7 +39,6 @@ class String;
 class KJSProxy {
 public:
     KJSProxy(Frame*);
-    ~KJSProxy();
     KJS::JSValue* evaluate(const String& filename, int baseLine, const String& code, Node*);
     void clear();
     EventListener* createHTMLEventHandler(const String& functionName, const String& code, Node*);
index 56ac97600235626f6ec324b2ef9e7284727a5e61..8ef010c7b94e4974bc5918f1b0f39bcb46e71e78 100644 (file)
@@ -2257,11 +2257,24 @@ void FrameLoader::frameDetached()
     detachFromParent();
 }
 
-#if PLATFORM(MAC)
-void FrameLoader::setTitle(const String& title)
+void FrameLoader::detachFromParent()
 {
-    documentLoader()->setTitle(title);
-}
+    RefPtr<Frame> protect(m_frame);
+
+    closeDocument();
+    stopAllLoaders();
+    m_client->detachedFromParent1();
+    detachChildren();
+    m_client->detachedFromParent2();
+    setDocumentLoader(0);
+    m_client->detachedFromParent3();
+    if (Frame* parent = m_frame->tree()->parent())
+        parent->tree()->removeChild(m_frame);
+    m_frame->setView(0);
+#if PLATFORM(MAC)
+    closeBridge();
 #endif
+    m_client->detachedFromParent4();
+}
 
 } // namespace WebCore
index 7d8833eb19a59c6c992536eecf267e09338c13fd..301d7e29191603e91e05dcfe04ce8c7c0885aad8 100644 (file)
@@ -200,6 +200,7 @@ namespace WebCore {
         void stopLoadingPlugIns();
         void stopLoadingSubresources();
 #if PLATFORM(MAC)
+        void closeBridge();
         void cancelMainResourceLoad(NSError *);
 #endif
         void stopAllLoaders();
index 1509394d71c95fce861b45af5a5dd872dfc050f0..b49a004945969e1adc5ce8e9afaff69e8e7304ec 100644 (file)
@@ -1135,24 +1135,6 @@ void FrameLoader::post(const KURL& URL, const String& referrer, const String& fr
     [request release];
 }
 
-void FrameLoader::detachFromParent()
-{
-    RefPtr<Frame> protect(m_frame);
-
-    closeDocument();
-    stopAllLoaders();
-    m_client->detachedFromParent1();
-    detachChildren();
-    m_client->detachedFromParent2();
-    setDocumentLoader(0);
-    m_client->detachedFromParent3();
-    if (Frame* parent = m_frame->tree()->parent())
-        parent->tree()->removeChild(m_frame);
-    m_frame->setView(0);
-    [Mac(m_frame)->bridge() close];
-    m_client->detachedFromParent4();
-}
-
 void FrameLoader::addExtraFieldsToRequest(NSMutableURLRequest *request, bool mainResource, bool alwaysFromRequest)
 {
     applyUserAgent(request);
@@ -1431,6 +1413,16 @@ void FrameLoader::didFinishLoad(ResourceLoader* loader)
     m_client->dispatchDidFinishLoading(activeDocumentLoader(), loader->identifier());
 }
 
+void FrameLoader::setTitle(const String& title)
+{
+    documentLoader()->setTitle(title);
+}
+
+void FrameLoader::closeBridge()
+{
+    [Mac(m_frame)->bridge() close];
+}
+
 PolicyCheck::PolicyCheck()
     : m_navigationFunction(0)
     , m_newWindowFunction(0)
index 7d25bfb89fa47b787ca73d6ecb34ca6f874b3c10..81a34506533584463b22f3dcd5941e2ff07e04dd 100644 (file)
@@ -72,9 +72,8 @@ Page::~Page()
     if (allPages->isEmpty()) {
         Frame::endAllLifeSupport();
 #ifndef NDEBUG
+        // Force garbage collection, to release all Nodes before exiting.
         m_mainFrame = 0;
-        JSLock lock;
-        Collector::collect();
 #endif
     }