Changeset 54724 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Feb 12, 2010, 6:29:02 AM (15 years ago)
Author:
[email protected]
Message:

Additional refptr/passrefptr workarounds for WINSCW compiler

https://bugs.webkit.org/show_bug.cgi?id=28054

Patch by Janne Koskinen <[email protected]> on 2010-02-12

Reviewed by Tor Arne Vestbø.

  • wtf/PassRefPtr.h:

(WTF::refIfNotNull):
(WTF::PassRefPtr::PassRefPtr):
(WTF::PassRefPtr::~PassRefPtr):
(WTF::PassRefPtr::clear):
(WTF::::operator):

  • wtf/RefPtr.h:

(WTF::RefPtr::RefPtr):
(WTF::::operator):

Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r54722 r54724  
     12010-02-12  Janne Koskinen  <[email protected]>
     2
     3        Reviewed by Tor Arne Vestbø.
     4
     5        Additional refptr/passrefptr workarounds for WINSCW compiler
     6        https://bugs.webkit.org/show_bug.cgi?id=28054
     7
     8        * wtf/PassRefPtr.h:
     9        (WTF::refIfNotNull):
     10        (WTF::PassRefPtr::PassRefPtr):
     11        (WTF::PassRefPtr::~PassRefPtr):
     12        (WTF::PassRefPtr::clear):
     13        (WTF::::operator):
     14        * wtf/RefPtr.h:
     15        (WTF::RefPtr::RefPtr):
     16        (WTF::::operator):
     17
    1182010-02-12  Janne Koskinen  <[email protected]>
    219
  • trunk/JavaScriptCore/wtf/PassRefPtr.h

    r48836 r54724  
    2929    template<typename T> class PassRefPtr;
    3030    template <typename T> PassRefPtr<T> adoptRef(T*);
    31    
    32     // Remove inline for winscw compiler to prevent the compiler agressively resolving
    33     // T::deref(), which will fail compiling when PassRefPtr<T> is used as class member
    34     // or function arguments before T is defined.
     31
     32
     33    // Remove inline for WINSCW compiler to prevent the compiler agressively resolving
     34    // T::ref() and T::deref(), which will fail compiling when PassRefPtr<T> is used as
     35    // a class member or function arguments before T is defined.
     36    template<typename T>
     37#if !COMPILER(WINSCW)
     38    inline
     39#endif
     40    void refIfNotNull(T* ptr)
     41    {
     42        if (UNLIKELY(ptr != 0))
     43            ptr->ref();
     44    }
     45
    3546    template<typename T>
    3647#if !COMPILER(WINSCW)
     
    4657    public:
    4758        PassRefPtr() : m_ptr(0) {}
    48         PassRefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }
     59        PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); }
    4960        // It somewhat breaks the type system to allow transfer of ownership out of
    5061        // a const PassRefPtr. However, it makes it much easier to work with PassRefPtr
     
    5465        template <typename U> PassRefPtr(const PassRefPtr<U>& o) : m_ptr(o.releaseRef()) { }
    5566
    56         ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull<T>(m_ptr); }
     67        ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); }
    5768
    5869        template <class U>
    59         PassRefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); }
     70        PassRefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { T* ptr = m_ptr; refIfNotNull(ptr); }
    6071       
    6172        T* get() const { return m_ptr; }
    6273
    63         void clear() { if (T* ptr = m_ptr) ptr->deref(); m_ptr = 0; }
     74        void clear() { T* ptr = m_ptr; derefIfNotNull(ptr); m_ptr = 0; }
    6475        T* releaseRef() const { T* tmp = m_ptr; m_ptr = 0; return tmp; }
    6576
     
    144155    {
    145156        T* optr = o.get();
    146         if (optr)
    147             optr->ref();
     157        refIfNotNull(optr);
    148158        T* ptr = m_ptr;
    149159        m_ptr = optr;
    150         if (ptr)
    151             ptr->deref();
     160        derefIfNotNull(ptr);
    152161        return *this;
    153162    }
     
    155164    template <typename T> inline PassRefPtr<T>& PassRefPtr<T>::operator=(T* optr)
    156165    {
    157         if (optr)
    158             optr->ref();
     166        refIfNotNull(optr);
    159167        T* ptr = m_ptr;
    160168        m_ptr = optr;
    161         if (ptr)
    162             ptr->deref();
     169        derefIfNotNull(ptr);
    163170        return *this;
    164171    }
     
    168175        T* ptr = m_ptr;
    169176        m_ptr = ref.releaseRef();
    170         if (ptr)
    171             ptr->deref();
     177        derefIfNotNull(ptr);
    172178        return *this;
    173179    }
     
    177183        T* ptr = m_ptr;
    178184        m_ptr = ref.releaseRef();
    179         if (ptr)
    180             ptr->deref();
     185        derefIfNotNull(ptr);
    181186        return *this;
    182187    }
  • trunk/JavaScriptCore/wtf/RefPtr.h

    r54596 r54724  
    3939    public:
    4040        RefPtr() : m_ptr(0) { }
    41         RefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }
    42         RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { if (T* ptr = m_ptr) ptr->ref(); }
     41        RefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); }
     42        RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { T* ptr = m_ptr; refIfNotNull(ptr); }
    4343        // see comment in PassRefPtr.h for why this takes const reference
    4444        template <typename U> RefPtr(const PassRefPtr<U>&);
     
    5454        ~RefPtr() { derefIfNotNull(m_ptr); }
    5555       
    56         template <typename U> RefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); }
     56        template <typename U> RefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { T* ptr = m_ptr; refIfNotNull(ptr); }
    5757       
    5858        T* get() const { return m_ptr; }
     
    9999    {
    100100        T* optr = o.get();
    101         if (optr)
    102             optr->ref();
     101        refIfNotNull(optr);
    103102        T* ptr = m_ptr;
    104103        m_ptr = optr;
    105         if (ptr)
    106             ptr->deref();
     104        derefIfNotNull(ptr);
    107105        return *this;
    108106    }
     
    111109    {
    112110        T* optr = o.get();
    113         if (optr)
    114             optr->ref();
     111        refIfNotNull(optr);
    115112        T* ptr = m_ptr;
    116113        m_ptr = optr;
    117         if (ptr)
    118             ptr->deref();
     114        derefIfNotNull(ptr);
    119115        return *this;
    120116    }
     
    122118    template <typename T> inline RefPtr<T>& RefPtr<T>::operator=(T* optr)
    123119    {
    124         if (optr)
    125             optr->ref();
     120        refIfNotNull(optr);
    126121        T* ptr = m_ptr;
    127122        m_ptr = optr;
    128         if (ptr)
    129             ptr->deref();
     123        derefIfNotNull(ptr);
    130124        return *this;
    131125    }
     
    135129        T* ptr = m_ptr;
    136130        m_ptr = o.releaseRef();
    137         if (ptr)
    138             ptr->deref();
     131        derefIfNotNull(ptr);
    139132        return *this;
    140133    }
     
    144137        T* ptr = m_ptr;
    145138        m_ptr = o.releaseRef();
    146         if (ptr)
    147             ptr->deref();
     139        derefIfNotNull(ptr);
    148140        return *this;
    149141    }
     
    153145        T* ptr = m_ptr;
    154146        m_ptr = o.releaseRef();
    155         if (ptr)
    156             ptr->deref();
     147        derefIfNotNull(ptr);
    157148        return *this;
    158149    }
     
    162153        T* ptr = m_ptr;
    163154        m_ptr = o.releaseRef();
    164         if (ptr)
    165             ptr->deref();
     155        derefIfNotNull(ptr);
    166156        return *this;
    167157    }
Note: See TracChangeset for help on using the changeset viewer.