Changeset 36631 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Sep 18, 2008, 4:30:23 PM (17 years ago)
Author:
Darin Adler
Message:

2008-09-18 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

  • JavaScriptCore.exp: Updated, and also added an export needed for future WebCore use of JSC::StructureID.
  • wtf/RefCountedLeakCounter.cpp: (WTF::RefCountedLeakCounter::suppressMessages): Added. (WTF::RefCountedLeakCounter::cancelMessageSuppression): Added. (WTF::RefCountedLeakCounter::RefCountedLeakCounter): Tweaked a bit. (WTF::RefCountedLeakCounter::~RefCountedLeakCounter): Added code to log the reason there was no leak checking done. (WTF::RefCountedLeakCounter::increment): Tweaked a bit. (WTF::RefCountedLeakCounter::decrement): Ditto.
  • wtf/RefCountedLeakCounter.h: Replaced setLogLeakMessages with two new functions, suppressMessages and cancelMessageSuppression. Also added m_ prefixes to the data member names.

2008-09-18 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

  • WebView/WebPreferences.mm: (-[WebPreferences setFullDocumentTeardownEnabled:]): Removed unneeded call to setLogLeakMessages.
  • WebView/WebView.mm: (-[WebView _closeWithFastTeardown]): Call RefCountedLeakCounter::suppressMessages, telling it that we can't track leaks because at least one WebView was closed with fast teardown. (-[WebView _close]): Removed unneeded call to setLogLeakMessages. Added a call to cancelMessageSuppression since the WebView is no longer open. Added an explicit garbage collect to help with the case where we're closing during the quit process -- the garbageCollectSoon() calls done inside WebCore won't help us in that case. (-[WebView initWithFrame:frameName:groupName:]): Call RefCountedLeakCounter::suppressMessages telling it that we can't track leaks because at least one WebView is currently open.
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r36630 r36631  
     12008-09-18  Darin Adler  <[email protected]>
     2
     3        Reviewed by Sam Weinig.
     4
     5        - fix https://bugs.webkit.org/show_bug.cgi?id=20925
     6          LEAK messages appear every time I quit
     7
     8        * JavaScriptCore.exp: Updated, and also added an export
     9        needed for future WebCore use of JSC::StructureID.
     10
     11        * wtf/RefCountedLeakCounter.cpp:
     12        (WTF::RefCountedLeakCounter::suppressMessages): Added.
     13        (WTF::RefCountedLeakCounter::cancelMessageSuppression): Added.
     14        (WTF::RefCountedLeakCounter::RefCountedLeakCounter): Tweaked a bit.
     15        (WTF::RefCountedLeakCounter::~RefCountedLeakCounter): Added code to
     16        log the reason there was no leak checking done.
     17        (WTF::RefCountedLeakCounter::increment): Tweaked a bit.
     18        (WTF::RefCountedLeakCounter::decrement): Ditto.
     19
     20        * wtf/RefCountedLeakCounter.h: Replaced setLogLeakMessages with two
     21        new functions, suppressMessages and cancelMessageSuppression. Also
     22        added m_ prefixes to the data member names.
     23
    1242008-09-18  Holger Hans Peter Freyther  <[email protected]>
    225
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r36417 r36631  
    111111__ZN3JSC11StructureID24fromDictionaryTransitionEPS0_
    112112__ZN3JSC11StructureID25changePrototypeTransitionEPS0_PNS_7JSValueE
     113__ZN3JSC11StructureIDC1EPNS_7JSValueENS_6JSTypeE
    113114__ZN3JSC11StructureIDD1Ev
    114115__ZN3JSC12DateInstance4infoE
     
    262263__ZN3WTF16callOnMainThreadEPFvPvES0_
    263264__ZN3WTF16fastZeroedMallocEm
    264 __ZN3WTF18setLogLeakMessagesEb
    265265__ZN3WTF19initializeThreadingEv
     266__ZN3WTF21RefCountedLeakCounter16suppressMessagesEPKc
     267__ZN3WTF21RefCountedLeakCounter24cancelMessageSuppressionEPKc
    266268__ZN3WTF21RefCountedLeakCounter9decrementEv
    267269__ZN3WTF21RefCountedLeakCounter9incrementEv
  • trunk/JavaScriptCore/wtf/RefCountedLeakCounter.cpp

    r35476 r36631  
    2020
    2121#include "config.h"
     22#include "RefCountedLeakCounter.h"
    2223
    23 #include "RefCountedLeakCounter.h"
    24 #include "UnusedParam.h"
     24#include <wtf/HashCountedSet.h>
    2525
    2626namespace WTF {
    2727
    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
     28#ifdef NDEBUG
    4529
    46     RefCountedLeakCounter::~RefCountedLeakCounter()
    47     {
    48 #ifndef NDEBUG
    49         if (count && logLeakMessages)
    50             LOG(RefCountedLeaks, "LEAK: %u %s\n", count, description);
    51 #endif
    52     }
     30static void RefCountedLeakCounter::suppressMessages(const char*) { }
     31static void RefCountedLeakCounter::cancelMessageSuppression(const char*) { }
    5332
    54     RefCountedLeakCounter::RefCountedLeakCounter(const char* desc)
    55     {
    56         UNUSED_PARAM(desc);
    57 #ifndef NDEBUG
    58         description = desc;
    59 #endif
    60     }
     33RefCountedLeakCounter::RefCountedLeakCounter(const char*) { }
     34RefCountedLeakCounter::~RefCountedLeakCounter() { }
    6135
    62 #if ENABLE(JSC_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     }
     36void RefCountedLeakCounter::increment() { }
     37void RefCountedLeakCounter::decrement() { }
    7738
    7839#else
    7940
    80     void RefCountedLeakCounter::increment()
    81     {
    82 #ifndef NDEBUG
    83         ++count;
     41#define LOG_CHANNEL_PREFIX Log
     42static WTFLogChannel LogRefCountedLeaks = { 0x00000000, "", WTFLogChannelOn };
     43
     44typedef HashCountedSet<const char*, PtrHash<const char*> > ReasonSet;
     45static ReasonSet* leakMessageSuppressionReasons;
     46
     47void RefCountedLeakCounter::suppressMessages(const char* reason)
     48{
     49    if (!leakMessageSuppressionReasons)
     50        leakMessageSuppressionReasons = new ReasonSet;
     51    leakMessageSuppressionReasons->add(reason);
     52}
     53
     54void RefCountedLeakCounter::cancelMessageSuppression(const char* reason)
     55{
     56    ASSERT(leakMessageSuppressionReasons);
     57    ASSERT(leakMessageSuppressionReasons->contains(reason));
     58    leakMessageSuppressionReasons->remove(reason);
     59}
     60
     61RefCountedLeakCounter::RefCountedLeakCounter(const char* description)
     62    : m_description(description)
     63{
     64}   
     65
     66RefCountedLeakCounter::~RefCountedLeakCounter()
     67{
     68    static bool loggedSuppressionReason;
     69    if (m_count) {
     70        if (!leakMessageSuppressionReasons || leakMessageSuppressionReasons->isEmpty())
     71            LOG(RefCountedLeaks, "LEAK: %u %s", m_count, m_description);
     72        else if (!loggedSuppressionReason) {
     73            // This logs only one reason. Later we could change it so we log all the reasons.
     74            LOG(RefCountedLeaks, "No leak checking done: %s", leakMessageSuppressionReasons->begin()->first);
     75            loggedSuppressionReason = true;
     76        }
     77    }
     78}
     79
     80void RefCountedLeakCounter::increment()
     81{
     82#if ENABLE(JSC_MULTIPLE_THREADS)
     83    atomicIncrement(&m_count);
     84#else
     85    ++m_count;
    8486#endif
    85     }
     87}
    8688
    87     void RefCountedLeakCounter::decrement()
    88     {
    89 #ifndef NDEBUG
    90         --count;
     89void RefCountedLeakCounter::decrement()
     90{
     91#if ENABLE(JSC_MULTIPLE_THREADS)
     92    atomicDecrement(&m_count);
     93#else
     94    --m_count;
    9195#endif
    92     }
     96}
    9397
    9498#endif
    9599
    96 } // Namespace WTF
     100} // namespace WTF
  • trunk/JavaScriptCore/wtf/RefCountedLeakCounter.h

    r35148 r36631  
    1919 */
    2020 
    21 #ifndef REF_COUNTED_LEAK_COUNTER_H_
    22 #define REF_COUNTED_LEAK_COUNTER_H_
     21#ifndef RefCountedLeakCounter_h
     22#define RefCountedLeakCounter_h
    2323 
    2424#include "Assertions.h"
     
    2626
    2727namespace WTF {
    28 
    29     void setLogLeakMessages(bool _logLeakMessages);
    3028   
    3129    struct RefCountedLeakCounter {
    32         RefCountedLeakCounter(const char* desc);
     30        static void suppressMessages(const char*);
     31        static void cancelMessageSuppression(const char*);
     32       
     33        explicit RefCountedLeakCounter(const char* description);
    3334        ~RefCountedLeakCounter();
    3435
    3536        void increment();
    3637        void decrement();
    37        
     38
     39#ifndef NDEBUG
    3840    private:
    39 #ifndef NDEBUG
    40         volatile int count;
    41         const char* description;
     41        volatile int m_count;
     42        const char* m_description;
    4243#endif
    4344    };
    44            
     45
    4546}  // namespace WTF
    4647
Note: See TracChangeset for help on using the changeset viewer.