From 22a258874aa6d94d4d909e9f07913b55e61d6787 Mon Sep 17 00:00:00 2001 From: "weinig@apple.com" Date: Mon, 2 Jan 2012 23:31:57 +0000 Subject: [PATCH] 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). git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103913 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 12 ++++++++++++ Source/WebCore/bindings/scripts/CodeGeneratorJS.pm | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 81a9d1f..4c34a4f 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,15 @@ +2012-01-02 Sam Weinig + + 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 Fix chromium mac build after r103905 diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm index bdb66b9..f0fe985 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -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"} -- 2.7.4