JavaScriptCore:
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Oct 2008 21:41:40 +0000 (21:41 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Oct 2008 21:41:40 +0000 (21:41 +0000)
2008-10-13  Sam Weinig  <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Fix for https://bugs.webkit.org/show_bug.cgi?id=21577
        5 false positive StructureID leaks

        - Add leak ignore set to StructureID to selectively ignore leaking some StructureIDs.
        - Add create method to JSGlolalData to be used when the data will be intentionally
          leaked and ignore all leaks caused the StructureIDs stored in it.

        * JavaScriptCore.exp:
        * kjs/JSGlobalData.cpp:
        (JSC::JSGlobalData::createLeaked):
        * kjs/JSGlobalData.h:
        * kjs/StructureID.cpp:
        (JSC::StructureID::StructureID):
        (JSC::StructureID::~StructureID):
        (JSC::StructureID::startIgnoringLeaks):
        (JSC::StructureID::stopIgnoringLeaks):
        * kjs/StructureID.h:

WebCore:

2008-10-13  Sam Weinig  <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Fix for https://bugs.webkit.org/show_bug.cgi?id=21577
        5 false positive StructureID leaks

        In WebCore, we intentionally leak the common JSGlobalData which in turn
        leaks 5 StructureIDs.  Use the new JSGlobalData::createLeaked in order to
        ignore the StructureIDs leaked within.

        * bindings/js/JSDOMWindowBase.cpp:
        (WebCore::JSDOMWindowBase::commonJSGlobalData):

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

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/kjs/JSGlobalData.cpp
JavaScriptCore/kjs/JSGlobalData.h
JavaScriptCore/kjs/StructureID.cpp
JavaScriptCore/kjs/StructureID.h
WebCore/ChangeLog
WebCore/bindings/js/JSDOMWindowBase.cpp

index a4a2078197a5e533aed5f79ec07b587fc75d87ae..537fbf2cfab9a98dfe1efa64059610d7de41cd7e 100644 (file)
@@ -1,3 +1,25 @@
+2008-10-13  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=21577
+        5 false positive StructureID leaks
+
+        - Add leak ignore set to StructureID to selectively ignore leaking some StructureIDs.
+        - Add create method to JSGlolalData to be used when the data will be intentionally
+          leaked and ignore all leaks caused the StructureIDs stored in it.
+
+        * JavaScriptCore.exp:
+        * kjs/JSGlobalData.cpp:
+        (JSC::JSGlobalData::createLeaked):
+        * kjs/JSGlobalData.h:
+        * kjs/StructureID.cpp:
+        (JSC::StructureID::StructureID):
+        (JSC::StructureID::~StructureID):
+        (JSC::StructureID::startIgnoringLeaks):
+        (JSC::StructureID::stopIgnoringLeaks):
+        * kjs/StructureID.h:
+
 2008-10-13  Marco Barisione  <marco.barisione@collabora.co.uk>
 
         Reviewed by Darin Adler. Landed by Jan Alonzo.
index 20c7631f016ba2baa0ff245505f9906dd24e40ad..84b8a4d43bcf773fb1a4a61b84ae4216172f3051 100644 (file)
@@ -120,6 +120,7 @@ __ZN3JSC11StructureIDC1EPNS_7JSValueERKNS_8TypeInfoE
 __ZN3JSC11StructureIDD1Ev
 __ZN3JSC12DateInstance4infoE
 __ZN3JSC12JSGlobalData10ClientDataD2Ev
+__ZN3JSC12JSGlobalData12createLeakedEv
 __ZN3JSC12JSGlobalData6createEv
 __ZN3JSC12JSGlobalDataD1Ev
 __ZN3JSC12SamplingTool4dumpEPNS_9ExecStateE
index 9e5654ab740478e956abd0b06cfa3604edd407f0..396c625dd50868fcbee87efb50cd1d1308ce10c3 100644 (file)
@@ -146,6 +146,18 @@ PassRefPtr<JSGlobalData> JSGlobalData::create()
     return adoptRef(new JSGlobalData);
 }
 
+PassRefPtr<JSGlobalData> JSGlobalData::createLeaked()
+{
+#ifndef NDEBUG
+    StructureID::startIgnoringLeaks();
+    RefPtr<JSGlobalData> data = create();
+    StructureID::stopIgnoringLeaks();
+    return data.release();
+#else
+    return create();
+#endif
+}
+
 bool JSGlobalData::sharedInstanceExists()
 {
     return sharedInstanceInternal();
index 3033fed5d55d2b267f72024159b2ec531e169771..e5bccf83d49cab35d1c9d0f5b8f250a70ef3810c 100644 (file)
@@ -60,6 +60,7 @@ namespace JSC {
         static JSGlobalData& sharedInstance();
 
         static PassRefPtr<JSGlobalData> create();
+        static PassRefPtr<JSGlobalData> createLeaked();
         ~JSGlobalData();
 
         Machine* machine;
index 916e97daece27c1681e77e3d69c609eb0d82c2cb..e28267e7ee8395844f0ae676a4a090cbf7e9daa3 100644 (file)
@@ -39,6 +39,9 @@ namespace JSC {
 
 #ifndef NDEBUG    
 static WTF::RefCountedLeakCounter structureIDCounter("StructureID");
+
+static bool shouldIgnoreLeaks;
+static HashSet<StructureID*> ignoreSet;
 #endif
 
 StructureID::StructureID(JSValue* prototype, const TypeInfo& typeInfo)
@@ -57,7 +60,10 @@ StructureID::StructureID(JSValue* prototype, const TypeInfo& typeInfo)
     ASSERT(m_prototype->isObject() || m_prototype->isNull());
 
 #ifndef NDEBUG
-    structureIDCounter.increment();
+    if (shouldIgnoreLeaks)
+        ignoreSet.add(this);
+    else
+        structureIDCounter.increment();
 #endif
 }
 
@@ -72,7 +78,25 @@ StructureID::~StructureID()
         m_cachedPropertyNameArrayData->setCachedStructureID(0);
 
 #ifndef NDEBUG
-    structureIDCounter.decrement();
+    HashSet<StructureID*>::iterator it = ignoreSet.find(this);
+    if (it != ignoreSet.end())
+        ignoreSet.remove(it);
+    else
+        structureIDCounter.decrement();
+#endif
+}
+
+void StructureID::startIgnoringLeaks()
+{
+#ifndef NDEBUG
+    shouldIgnoreLeaks = true;
+#endif
+}
+
+void StructureID::stopIgnoringLeaks()
+{
+#ifndef NDEBUG
+    shouldIgnoreLeaks = false;
 #endif
 }
 
index 16d33a0d7d4f7e689e3bdfdf0a780d973bd610ba..7470c6e06199ed86a74de875aed1e5c091031d45 100644 (file)
@@ -82,6 +82,9 @@ namespace JSC {
             return adoptRef(new StructureID(prototype, typeInfo));
         }
 
+        static void startIgnoringLeaks();
+        static void stopIgnoringLeaks();
+
         static PassRefPtr<StructureID> changePrototypeTransition(StructureID*, JSValue* prototype);
         static PassRefPtr<StructureID> addPropertyTransition(StructureID*, const Identifier& propertyName, unsigned attributes, size_t& offset);
         static PassRefPtr<StructureID> getterSetterTransition(StructureID*);
index 46a289889bcb067c1886d0fd4a1475e8b5c6713b..196d6ed2d84ac981e738a99784345b2fe6ee2761 100644 (file)
@@ -1,3 +1,17 @@
+2008-10-13  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=21577
+        5 false positive StructureID leaks
+
+        In WebCore, we intentionally leak the common JSGlobalData which in turn
+        leaks 5 StructureIDs.  Use the new JSGlobalData::createLeaked in order to
+        ignore the StructureIDs leaked within.
+
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::JSDOMWindowBase::commonJSGlobalData):
+
 2008-10-13  David Hyatt  <hyatt@apple.com>
 
         Add support for the :corner-present pseudoclass, which enables scrollbar pieces to change their
index 258660be89d482ae20b3bb075388ff31ab86f28b..c37a862dbde7b3a3bcb051a441d18c0fd91d6bba 100644 (file)
@@ -781,7 +781,7 @@ JSDOMWindowShell* JSDOMWindowBase::shell() const
 
 JSGlobalData* JSDOMWindowBase::commonJSGlobalData()
 {
-    static JSGlobalData* globalData = JSGlobalData::create().releaseRef();
+    static JSGlobalData* globalData = JSGlobalData::createLeaked().releaseRef();
     return globalData;
 }