| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 m_prev->m_next = this; | 202 m_prev->m_next = this; |
| 203 m_next->m_prev = this; | 203 m_next->m_prev = this; |
| 204 } | 204 } |
| 205 | 205 |
| 206 inline explicit PersistentBase(const PersistentBase& otherref) | 206 inline explicit PersistentBase(const PersistentBase& otherref) |
| 207 : PersistentNode(otherref.m_trace) | 207 : PersistentNode(otherref.m_trace) |
| 208 #ifndef NDEBUG | 208 #ifndef NDEBUG |
| 209 , m_roots(RootsAccessor::roots()) | 209 , m_roots(RootsAccessor::roots()) |
| 210 #endif | 210 #endif |
| 211 { | 211 { |
| 212 // We don't support allocation of thread local Persistents while doing |
| 213 // thread shutdown/cleanup. |
| 214 ASSERT(!ThreadState::current()->isTerminating()); |
| 212 typename RootsAccessor::Lock lock; | 215 typename RootsAccessor::Lock lock; |
| 213 ASSERT(otherref.m_roots == m_roots); // Handles must belong to the same
list. | 216 ASSERT(otherref.m_roots == m_roots); // Handles must belong to the same
list. |
| 214 PersistentBase* other = const_cast<PersistentBase*>(&otherref); | 217 PersistentBase* other = const_cast<PersistentBase*>(&otherref); |
| 215 m_prev = other; | 218 m_prev = other; |
| 216 m_next = other->m_next; | 219 m_next = other->m_next; |
| 217 other->m_next = this; | 220 other->m_next = this; |
| 218 m_next->m_prev = this; | 221 m_next->m_prev = this; |
| 219 } | 222 } |
| 220 | 223 |
| 221 inline PersistentBase& operator=(const PersistentBase& otherref) { return *t
his; } | 224 inline PersistentBase& operator=(const PersistentBase& otherref) { return *t
his; } |
| 222 | 225 |
| 223 #ifndef NDEBUG | 226 #ifndef NDEBUG |
| 224 private: | 227 private: |
| 225 PersistentNode* m_roots; | 228 PersistentNode* m_roots; |
| 226 #endif | 229 #endif |
| 227 }; | 230 }; |
| 228 | 231 |
| 229 // A dummy Persistent handle that ensures the list of persistents is never null. | 232 // A dummy Persistent handle that ensures the list of persistents is never null. |
| 230 // This removes a test from a hot path. | 233 // This removes a test from a hot path. |
| 231 class PersistentAnchor : public PersistentNode { | 234 class PersistentAnchor : public PersistentNode { |
| 232 public: | 235 public: |
| 233 void trace(Visitor* visitor) | 236 void trace(Visitor* visitor) |
| 234 { | 237 { |
| 235 for (PersistentNode* current = m_next; current != this; current = curren
t->m_next) | 238 for (PersistentNode* current = m_next; current != this; current = curren
t->m_next) |
| 236 current->trace(visitor); | 239 current->trace(visitor); |
| 237 } | 240 } |
| 238 | 241 |
| 242 int numberOfPersistents() |
| 243 { |
| 244 int numberOfPersistents = 0; |
| 245 for (PersistentNode* current = m_next; current != this; current = curren
t->m_next) |
| 246 ++numberOfPersistents; |
| 247 return numberOfPersistents; |
| 248 } |
| 249 |
| 239 virtual ~PersistentAnchor() | 250 virtual ~PersistentAnchor() |
| 240 { | 251 { |
| 241 // FIXME: oilpan: Ideally we should have no left-over persistents at thi
s point. However currently there is a | 252 // FIXME: oilpan: Ideally we should have no left-over persistents at thi
s point. However currently there is a |
| 242 // large number of objects leaked when we tear down the main thread. Sin
ce some of these might contain a | 253 // large number of objects leaked when we tear down the main thread. Sin
ce some of these might contain a |
| 243 // persistent or e.g. be RefCountedGarbageCollected we cannot guarantee
there are no remaining Persistents at | 254 // persistent or e.g. be RefCountedGarbageCollected we cannot guarantee
there are no remaining Persistents at |
| 244 // this point. | 255 // this point. |
| 245 } | 256 } |
| 246 | 257 |
| 247 private: | 258 private: |
| 248 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P
ersistentAnchor::trace>::trampoline) | 259 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P
ersistentAnchor::trace>::trampoline) |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is
GarbageCollectedType<T>::value> { | 1174 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is
GarbageCollectedType<T>::value> { |
| 1164 }; | 1175 }; |
| 1165 | 1176 |
| 1166 template<typename T> | 1177 template<typename T> |
| 1167 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web
Core::IsGarbageCollectedType<T>::value> { | 1178 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web
Core::IsGarbageCollectedType<T>::value> { |
| 1168 }; | 1179 }; |
| 1169 | 1180 |
| 1170 } // namespace WTF | 1181 } // namespace WTF |
| 1171 | 1182 |
| 1172 #endif | 1183 #endif |
| OLD | NEW |