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

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

Issue 397733004: Allow assertions to be enabled in Blink Release builds. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/graphics/ImageDecodingStore.cpp ('k') | 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 ASSERT(isAlive()); 196 ASSERT(isAlive());
197 ASSERT(m_next->isAlive()); 197 ASSERT(m_next->isAlive());
198 ASSERT(m_prev->isAlive()); 198 ASSERT(m_prev->isAlive());
199 m_next->m_prev = m_prev; 199 m_next->m_prev = m_prev;
200 m_prev->m_next = m_next; 200 m_prev->m_next = m_next;
201 } 201 }
202 202
203 protected: 203 protected:
204 inline PersistentBase() 204 inline PersistentBase()
205 : PersistentNode(TraceMethodDelegate<Owner, &Owner::trace>::trampoline) 205 : PersistentNode(TraceMethodDelegate<Owner, &Owner::trace>::trampoline)
206 #ifndef NDEBUG 206 #if ENABLE(ASSERT)
207 , m_roots(RootsAccessor::roots()) 207 , m_roots(RootsAccessor::roots())
208 #endif 208 #endif
209 { 209 {
210 typename RootsAccessor::Lock lock; 210 typename RootsAccessor::Lock lock;
211 m_prev = RootsAccessor::roots(); 211 m_prev = RootsAccessor::roots();
212 m_next = m_prev->m_next; 212 m_next = m_prev->m_next;
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 #if ENABLE(ASSERT)
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 223 // We don't support allocation of thread local Persistents while doing
224 // thread shutdown/cleanup. 224 // thread shutdown/cleanup.
225 ASSERT(!ThreadState::current()->isTerminating()); 225 ASSERT(!ThreadState::current()->isTerminating());
226 typename RootsAccessor::Lock lock; 226 typename RootsAccessor::Lock lock;
227 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.
228 PersistentBase* other = const_cast<PersistentBase*>(&otherref); 228 PersistentBase* other = const_cast<PersistentBase*>(&otherref);
229 m_prev = other; 229 m_prev = other;
230 m_next = other->m_next; 230 m_next = other->m_next;
231 other->m_next = this; 231 other->m_next = this;
232 m_next->m_prev = this; 232 m_next->m_prev = this;
233 } 233 }
234 234
235 inline PersistentBase& operator=(const PersistentBase& otherref) { return *t his; } 235 inline PersistentBase& operator=(const PersistentBase& otherref) { return *t his; }
236 236
237 #ifndef NDEBUG 237 #if ENABLE(ASSERT)
238 private: 238 private:
239 PersistentNode* m_roots; 239 PersistentNode* m_roots;
240 #endif 240 #endif
241 }; 241 };
242 242
243 // 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.
244 // This removes a test from a hot path. 244 // This removes a test from a hot path.
245 class PersistentAnchor : public PersistentNode { 245 class PersistentAnchor : public PersistentNode {
246 public: 246 public:
247 void trace(Visitor* visitor) 247 void trace(Visitor* visitor)
(...skipping 21 matching lines...) Expand all
269 private: 269 private:
270 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P ersistentAnchor::trace>::trampoline) 270 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P ersistentAnchor::trace>::trampoline)
271 { 271 {
272 m_next = this; 272 m_next = this;
273 m_prev = this; 273 m_prev = this;
274 } 274 }
275 275
276 friend class ThreadState; 276 friend class ThreadState;
277 }; 277 };
278 278
279 #ifndef NDEBUG 279 #if ENABLE(ASSERT)
280 // For global persistent handles we cannot check that the 280 // For global persistent handles we cannot check that the
281 // pointer is in the heap because that would involve 281 // pointer is in the heap because that would involve
282 // inspecting the heap of running threads. 282 // inspecting the heap of running threads.
283 #define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer) \ 283 #define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer) \
284 bool isGlobalPersistent = WTF::IsSubclass<RootsAccessor, GlobalPersistents>: :value; \ 284 bool isGlobalPersistent = WTF::IsSubclass<RootsAccessor, GlobalPersistents>: :value; \
285 ASSERT(!pointer || isGlobalPersistent || ThreadStateFor<ThreadingTrait<T>::A ffinity>::state()->contains(pointer)) 285 ASSERT(!pointer || isGlobalPersistent || ThreadStateFor<ThreadingTrait<T>::A ffinity>::state()->contains(pointer))
286 #else 286 #else
287 #define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer) 287 #define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer)
288 #endif 288 #endif
289 289
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is GarbageCollectedType<T>::value> { 1190 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, WebCore::Is GarbageCollectedType<T>::value> {
1191 }; 1191 };
1192 1192
1193 template<typename T> 1193 template<typename T>
1194 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web Core::IsGarbageCollectedType<T>::value> { 1194 struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, Web Core::IsGarbageCollectedType<T>::value> {
1195 }; 1195 };
1196 1196
1197 } // namespace WTF 1197 } // namespace WTF
1198 1198
1199 #endif 1199 #endif
OLDNEW
« no previous file with comments | « Source/platform/graphics/ImageDecodingStore.cpp ('k') | Source/platform/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698