source: webkit/trunk/JavaScriptCore/wtf/RefCountedLeakCounter.cpp@ 35419

Last change on this file since 35419 was 35148, checked in by Stephanie Lewis, 17 years ago

2008-07-11 Stephanie Lewis <Stephanie Lewis>

Reviewed by Darin Adler and Oliver Hunt.

JavaScriptCore:

Refactor RefCounting Leak counting code into a common class.

In order to export the symbols I needed to put the debug defines inside the function names


Before we had a separate channel for each Logging each Leak type. Since the leak channels were only used in one location, and only at quit for simplicity I combined them all into one leak channel.

  • JavaScriptCore.exp:
  • JavaScriptCore.xcodeproj/project.pbxproj: add new class
  • kjs/nodes.cpp: remove old leak counting code
  • wtf/RefCountedLeakCounter.cpp: Added. create a common leak counting class
  • wtf/RefCountedLeakCounter.h: Added.

WebCore:

No Functionality Changed. Change all the leak counting code to use the new WTF leak counter class.

  • bindings/js/JSCustomSQLTransactionCallback.cpp: (WebCore::JSCustomSQLTransactionCallback::JSCustomSQLTransactionCallback): (WebCore::JSCustomSQLTransactionCallback::~JSCustomSQLTransactionCallback):
  • bindings/js/JSEventListener.cpp: (WebCore::JSEventListener::JSEventListener): (WebCore::JSEventListener::~JSEventListener):
  • dom/Node.cpp: (WebCore::Node::Node): (WebCore::Node::~Node):
  • dom/Range.cpp: (WebCore::Range::Range): (WebCore::Range::~Range):
  • history/CachedPage.cpp: (WebCore::CachedPage::CachedPage): (WebCore::CachedPage::~CachedPage):
  • loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::SubresourceLoader): (WebCore::SubresourceLoader::~SubresourceLoader):
  • page/Frame.cpp: (WebCore::Frame::Frame): (WebCore::Frame::~Frame):
  • page/Page.cpp: (WebCore::Page::Page): (WebCore::Page::~Page):
  • rendering/RenderObject.cpp: (WebCore::RenderObject::RenderObject): (WebCore::RenderObject::~RenderObject):
  • rendering/bidi.cpp: (WebCore::throw): (WebCore::BidiRun::operator delete):

WebKit

Move WebPreferences.m to objc++ so it can include the new WTF leak counting class.

  • WebKit.xcodeproj/project.pbxproj:

Disable WTF leak messages when using fast teardown. Use full document teardown while running in debug.

  • WebView/WebPreferences.m: Removed.
  • WebView/WebPreferences.mm: Copied from http:/svn.webkit.org/repository/webkit/trunk/WebKit/mac/WebView/WebPreferences.m. (+[WebPreferences initialize]): if running in Default enable full document teardown (-[WebPreferences editableLinkBehavior]): (-[WebPreferences setFullDocumentTeardownEnabled:]):
  • WebView/WebView.mm: (-[WebView _close]): disable leak messages if using fast teardown

WebKitTools:

Make sure we read WebCore Leak messages. Force full document teardown for DumpRenderTree.

Up timeout limit, some slower machines were timing out before crashtracer finished writing out to disk and quitting DRT.

  • DumpRenderTree/mac/DumpRenderTree.mm: (setDefaultsToConsistentValuesForTesting): (resetWebViewToConsistentStateBeforeTesting):
  • Scripts/run-webkit-tests:
File size: 2.1 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#include "config.h"
22
23#include "RefCountedLeakCounter.h"
24#include "UnusedParam.h"
25
26namespace WTF {
27
28#ifndef NDEBUG
29 static bool logLeakMessages = true;
30#endif
31
32 void setLogLeakMessages(bool _logLeakMessages )
33 {
34 UNUSED_PARAM(_logLeakMessages);
35#ifndef NDEBUG
36 logLeakMessages = _logLeakMessages;
37#endif
38 }
39
40
41#ifndef NDEBUG
42#define LOG_CHANNEL_PREFIX Log
43 static WTFLogChannel LogRefCountedLeaks = { 0x00000000, "", WTFLogChannelOn };
44#endif
45
46 RefCountedLeakCounter::~RefCountedLeakCounter()
47 {
48#ifndef NDEBUG
49 if (count && logLeakMessages)
50 LOG(RefCountedLeaks, "LEAK: %u %s\n", count, description);
51#endif
52 }
53
54 RefCountedLeakCounter::RefCountedLeakCounter(const char* desc)
55 {
56 UNUSED_PARAM(desc);
57#ifndef NDEBUG
58 description = desc;
59#endif
60 }
61
62#if USE(MULTIPLE_THREADS)
63
64 void RefCountedLeakCounter::increment()
65 {
66#ifndef NDEBUG
67 atomicIncrement(&count);
68#endif
69 }
70
71 void RefCountedLeakCounter::decrement()
72 {
73#ifndef NDEBUG
74 atomicDecrement(&count);
75#endif
76 }
77
78#else
79
80 void RefCountedLeakCounter::increment()
81 {
82#ifndef NDEBUG
83 ++count;
84#endif
85 }
86
87 void RefCountedLeakCounter::decrement()
88 {
89#ifndef NDEBUG
90 --count;
91#endif
92 }
93
94#endif
95
96} // Namespace WTF
Note: See TracBrowser for help on using the repository browser.