Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: Source/platform/heap/Handle.h

Issue 393823003: Revert "Revert "[oilpan]: Make thread shutdown more robust."" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/platform/heap/Heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 m_prev->m_next = this; 213 m_prev->m_next = this;
214 m_next->m_prev = this; 214 m_next->m_prev = this;
215 } 215 }
216 216
217 inline explicit PersistentBase(const PersistentBase& otherref) 217 inline explicit PersistentBase(const PersistentBase& otherref)
218 : PersistentNode(otherref.m_trace) 218 : PersistentNode(otherref.m_trace)
219 #ifndef NDEBUG 219 #ifndef NDEBUG
220 , m_roots(RootsAccessor::roots()) 220 , m_roots(RootsAccessor::roots())
221 #endif 221 #endif
222 { 222 {
223 // We don't support allocation of thread local Persistents while doing
224 // thread shutdown/cleanup.
225 ASSERT(!ThreadState::current()->isTerminating());
223 typename RootsAccessor::Lock lock; 226 typename RootsAccessor::Lock lock;
224 ASSERT(otherref.m_roots == m_roots); // Handles must belong to the same list. 227 ASSERT(otherref.m_roots == m_roots); // Handles must belong to the same list.
225 PersistentBase* other = const_cast<PersistentBase*>(&otherref); 228 PersistentBase* other = const_cast<PersistentBase*>(&otherref);
226 m_prev = other; 229 m_prev = other;
227 m_next = other->m_next; 230 m_next = other->m_next;
228 other->m_next = this; 231 other->m_next = this;
229 m_next->m_prev = this; 232 m_next->m_prev = this;
230 } 233 }
231 234
232 inline PersistentBase& operator=(const PersistentBase& otherref) { return *t his; } 235 inline PersistentBase& operator=(const PersistentBase& otherref) { return *t his; }
233 236
234 #ifndef NDEBUG 237 #ifndef NDEBUG
235 private: 238 private:
236 PersistentNode* m_roots; 239 PersistentNode* m_roots;
237 #endif 240 #endif
238 }; 241 };
239 242
240 // A dummy Persistent handle that ensures the list of persistents is never null. 243 // A dummy Persistent handle that ensures the list of persistents is never null.
241 // This removes a test from a hot path. 244 // This removes a test from a hot path.
242 class PersistentAnchor : public PersistentNode { 245 class PersistentAnchor : public PersistentNode {
243 public: 246 public:
244 void trace(Visitor* visitor) 247 void trace(Visitor* visitor)
245 { 248 {
246 for (PersistentNode* current = m_next; current != this; current = curren t->m_next) 249 for (PersistentNode* current = m_next; current != this; current = curren t->m_next)
247 current->trace(visitor); 250 current->trace(visitor);
248 } 251 }
249 252
253 int numberOfPersistents()
254 {
255 int numberOfPersistents = 0;
256 for (PersistentNode* current = m_next; current != this; current = curren t->m_next)
257 ++numberOfPersistents;
258 return numberOfPersistents;
259 }
260
250 virtual ~PersistentAnchor() 261 virtual ~PersistentAnchor()
251 { 262 {
252 // FIXME: oilpan: Ideally we should have no left-over persistents at thi s point. However currently there is a 263 // FIXME: oilpan: Ideally we should have no left-over persistents at thi s point. However currently there is a
253 // large number of objects leaked when we tear down the main thread. Sin ce some of these might contain a 264 // large number of objects leaked when we tear down the main thread. Sin ce some of these might contain a
254 // persistent or e.g. be RefCountedGarbageCollected we cannot guarantee there are no remaining Persistents at 265 // persistent or e.g. be RefCountedGarbageCollected we cannot guarantee there are no remaining Persistents at
255 // this point. 266 // this point.
256 } 267 }
257 268
258 private: 269 private:
259 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P ersistentAnchor::trace>::trampoline) 270 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P ersistentAnchor::trace>::trampoline)
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is GarbageCollectedType<T>::value> { 1185 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is GarbageCollectedType<T>::value> {
1175 }; 1186 };
1176 1187
1177 template<typename T> 1188 template<typename T>
1178 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web Core::IsGarbageCollectedType<T>::value> { 1189 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web Core::IsGarbageCollectedType<T>::value> {
1179 }; 1190 };
1180 1191
1181 } // namespace WTF 1192 } // namespace WTF
1182 1193
1183 #endif 1194 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698