Changeset 54724 in webkit for trunk/JavaScriptCore
- Timestamp:
- Feb 12, 2010, 6:29:02 AM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r54722 r54724 1 2010-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 1 18 2010-02-12 Janne Koskinen <[email protected]> 2 19 -
trunk/JavaScriptCore/wtf/PassRefPtr.h
r48836 r54724 29 29 template<typename T> class PassRefPtr; 30 30 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 35 46 template<typename T> 36 47 #if !COMPILER(WINSCW) … … 46 57 public: 47 58 PassRefPtr() : m_ptr(0) {} 48 PassRefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }59 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } 49 60 // It somewhat breaks the type system to allow transfer of ownership out of 50 61 // a const PassRefPtr. However, it makes it much easier to work with PassRefPtr … … 54 65 template <typename U> PassRefPtr(const PassRefPtr<U>& o) : m_ptr(o.releaseRef()) { } 55 66 56 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull <T>(m_ptr); }67 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } 57 68 58 69 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); } 60 71 61 72 T* get() const { return m_ptr; } 62 73 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; } 64 75 T* releaseRef() const { T* tmp = m_ptr; m_ptr = 0; return tmp; } 65 76 … … 144 155 { 145 156 T* optr = o.get(); 146 if (optr) 147 optr->ref(); 157 refIfNotNull(optr); 148 158 T* ptr = m_ptr; 149 159 m_ptr = optr; 150 if (ptr) 151 ptr->deref(); 160 derefIfNotNull(ptr); 152 161 return *this; 153 162 } … … 155 164 template <typename T> inline PassRefPtr<T>& PassRefPtr<T>::operator=(T* optr) 156 165 { 157 if (optr) 158 optr->ref(); 166 refIfNotNull(optr); 159 167 T* ptr = m_ptr; 160 168 m_ptr = optr; 161 if (ptr) 162 ptr->deref(); 169 derefIfNotNull(ptr); 163 170 return *this; 164 171 } … … 168 175 T* ptr = m_ptr; 169 176 m_ptr = ref.releaseRef(); 170 if (ptr) 171 ptr->deref(); 177 derefIfNotNull(ptr); 172 178 return *this; 173 179 } … … 177 183 T* ptr = m_ptr; 178 184 m_ptr = ref.releaseRef(); 179 if (ptr) 180 ptr->deref(); 185 derefIfNotNull(ptr); 181 186 return *this; 182 187 } -
trunk/JavaScriptCore/wtf/RefPtr.h
r54596 r54724 39 39 public: 40 40 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); } 43 43 // see comment in PassRefPtr.h for why this takes const reference 44 44 template <typename U> RefPtr(const PassRefPtr<U>&); … … 54 54 ~RefPtr() { derefIfNotNull(m_ptr); } 55 55 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); } 57 57 58 58 T* get() const { return m_ptr; } … … 99 99 { 100 100 T* optr = o.get(); 101 if (optr) 102 optr->ref(); 101 refIfNotNull(optr); 103 102 T* ptr = m_ptr; 104 103 m_ptr = optr; 105 if (ptr) 106 ptr->deref(); 104 derefIfNotNull(ptr); 107 105 return *this; 108 106 } … … 111 109 { 112 110 T* optr = o.get(); 113 if (optr) 114 optr->ref(); 111 refIfNotNull(optr); 115 112 T* ptr = m_ptr; 116 113 m_ptr = optr; 117 if (ptr) 118 ptr->deref(); 114 derefIfNotNull(ptr); 119 115 return *this; 120 116 } … … 122 118 template <typename T> inline RefPtr<T>& RefPtr<T>::operator=(T* optr) 123 119 { 124 if (optr) 125 optr->ref(); 120 refIfNotNull(optr); 126 121 T* ptr = m_ptr; 127 122 m_ptr = optr; 128 if (ptr) 129 ptr->deref(); 123 derefIfNotNull(ptr); 130 124 return *this; 131 125 } … … 135 129 T* ptr = m_ptr; 136 130 m_ptr = o.releaseRef(); 137 if (ptr) 138 ptr->deref(); 131 derefIfNotNull(ptr); 139 132 return *this; 140 133 } … … 144 137 T* ptr = m_ptr; 145 138 m_ptr = o.releaseRef(); 146 if (ptr) 147 ptr->deref(); 139 derefIfNotNull(ptr); 148 140 return *this; 149 141 } … … 153 145 T* ptr = m_ptr; 154 146 m_ptr = o.releaseRef(); 155 if (ptr) 156 ptr->deref(); 147 derefIfNotNull(ptr); 157 148 return *this; 158 149 } … … 162 153 T* ptr = m_ptr; 163 154 m_ptr = o.releaseRef(); 164 if (ptr) 165 ptr->deref(); 155 derefIfNotNull(ptr); 166 156 return *this; 167 157 }
Note:
See TracChangeset
for help on using the changeset viewer.