REGRESSION(r100517): We're leaking many, many DOM objects!
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jan 2012 23:31:57 +0000 (23:31 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jan 2012 23:31:57 +0000 (23:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75451

Reviewed by Mark Rowe.

* bindings/scripts/CodeGeneratorJS.pm:
Add a temporary workaround to the problem of handle finalizers
not getting called by adding back the destructors (or rather
their replacement, destroy() functions).

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

index 81a9d1f..4c34a4f 100644 (file)
@@ -1,3 +1,15 @@
+2012-01-02  Sam Weinig  <sam@webkit.org>
+
+        REGRESSION(r100517): We're leaking many, many DOM objects!
+        https://bugs.webkit.org/show_bug.cgi?id=75451
+
+        Reviewed by Mark Rowe.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        Add a temporary workaround to the problem of handle finalizers
+        not getting called by adding back the destructors (or rather
+        their replacement, destroy() functions).
+
 2012-01-02  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
 
         Fix chromium mac build after r103905
index bdb66b9..f0fe985 100644 (file)
@@ -816,6 +816,10 @@ sub GenerateHeader
         push(@headerContent, "    bool putDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue, JSC::PutPropertySlot&);\n") if $dataNode->extendedAttributes->{"DelegatingPutFunction"};
     }
 
+    if (!$hasParent) {
+        push(@headerContent, "    static void destroy(JSC::JSCell*);\n");
+    }
+
     # Class info
     push(@headerContent, "    static const JSC::ClassInfo s_info;\n\n");
 
@@ -953,6 +957,7 @@ sub GenerateHeader
     if (!$hasParent) {
         push(@headerContent, "    $implType* impl() const { return m_impl; }\n");
         push(@headerContent, "    void releaseImpl() { m_impl->deref(); m_impl = 0; }\n\n");
+        push(@headerContent, "    void releaseImplIfNotNull() { if (m_impl) { m_impl->deref(); m_impl = 0; } }\n\n");
         push(@headerContent, "private:\n");
         push(@headerContent, "    $implType* m_impl;\n");
     } elsif ($dataNode->extendedAttributes->{"GenerateNativeConverter"}) {
@@ -1670,6 +1675,20 @@ sub GenerateImplementation
         push(@implContent, "}\n\n");
     }
 
+    if (!$hasParent) {
+        # FIXME: This destroy function should not be necessary, as 
+        # a finalizer should be called for each DOM object wrapper.
+        # However, that seems not to be the case, so this has been
+        # added back to avoid leaking while we figure out why the
+        # finalizers are not always getting called. The work tracking
+        # the finalizer issue is being tracked in http://webkit.org/b/75451
+        push(@implContent, "void ${className}::destroy(JSC::JSCell* cell)\n");
+        push(@implContent, "{\n");
+        push(@implContent, "    ${className}* thisObject = jsCast<${className}*>(cell);\n");
+        push(@implContent, "    releaseImplIfNotNull();\n");
+        push(@implContent, "}\n\n");
+    }
+
     my $hasGetter = $numAttributes > 0 
                  || !$dataNode->extendedAttributes->{"OmitConstructor"} 
                  || $dataNode->extendedAttributes->{"HasIndexGetter"}