Commit 66868c0d authored by ap@webkit.org's avatar ap@webkit.org

Reviewed by Cameron Zwarich.

        Make ParserRefCountedCounter actually perform a leak check.

        * kjs/nodes.cpp:
        (KJS::ParserRefCountedCounter::~ParserRefCountedCounter): Check for leaks in destructor,
        not in constructor.
        (KJS::ParserRefCountedCounter::increment):
        (KJS::ParserRefCountedCounter::decrement):
        (KJS::ParserRefCounted::ParserRefCounted):
        (KJS::ParserRefCounted::~ParserRefCounted):
        While at it, also made counting thread-safe.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34760 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f8103d3a
2008-06-24 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Cameron Zwarich.
Make ParserRefCountedCounter actually perform a leak check.
* kjs/nodes.cpp:
(KJS::ParserRefCountedCounter::~ParserRefCountedCounter): Check for leaks in destructor,
not in constructor.
(KJS::ParserRefCountedCounter::increment):
(KJS::ParserRefCountedCounter::decrement):
(KJS::ParserRefCounted::ParserRefCounted):
(KJS::ParserRefCounted::~ParserRefCounted):
While at it, also made counting thread-safe.
2008-06-24 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Oliver.
......
......@@ -42,6 +42,7 @@
#include <wtf/HashCountedSet.h>
#include <wtf/HashSet.h>
#include <wtf/MathExtras.h>
#include <wtf/Threading.h>
namespace KJS {
......@@ -59,15 +60,47 @@ static inline UString::Rep* rep(const Identifier& ident)
static WTFLogChannel LogKJSNodeLeaks = { 0x00000000, "", WTFLogChannelOn };
struct ParserRefCountedCounter {
static unsigned count;
ParserRefCountedCounter()
~ParserRefCountedCounter()
{
if (count)
LOG(KJSNodeLeaks, "LEAK: %u KJS::Node\n", count);
}
static void increment();
static void decrement();
private:
static volatile int count;
};
unsigned ParserRefCountedCounter::count = 0;
volatile int ParserRefCountedCounter::count = 0;
#if USE(MULTIPLE_THREADS)
void ParserRefCountedCounter::increment()
{
atomicIncrement(&count);
}
void ParserRefCountedCounter::decrement()
{
atomicDecrement(&count);
}
#else
void ParserRefCountedCounter::increment()
{
++count;
}
void ParserRefCountedCounter::decrement()
{
--count;
}
#endif
static ParserRefCountedCounter parserRefCountedCounter;
#endif
static HashSet<ParserRefCounted*>* newTrackedObjects;
......@@ -76,7 +109,7 @@ static HashCountedSet<ParserRefCounted*>* trackedObjectExtraRefCounts;
ParserRefCounted::ParserRefCounted()
{
#ifndef NDEBUG
++ParserRefCountedCounter::count;
ParserRefCountedCounter::increment();
#endif
if (!newTrackedObjects)
newTrackedObjects = new HashSet<ParserRefCounted*>;
......@@ -87,7 +120,7 @@ ParserRefCounted::ParserRefCounted()
ParserRefCounted::~ParserRefCounted()
{
#ifndef NDEBUG
--ParserRefCountedCounter::count;
ParserRefCountedCounter::decrement();
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment