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

Side by Side Diff: third_party/WebKit/Source/platform/heap/ThreadState.h

Issue 2640163004: Replace ENABLE(ASSERT) with DCHECK_IS_ON(). (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return **s_threadSpecific; 184 return **s_threadSpecific;
185 } 185 }
186 186
187 static ThreadState* mainThreadState() { 187 static ThreadState* mainThreadState() {
188 return reinterpret_cast<ThreadState*>(s_mainThreadStateStorage); 188 return reinterpret_cast<ThreadState*>(s_mainThreadStateStorage);
189 } 189 }
190 190
191 static ThreadState* fromObject(const void*); 191 static ThreadState* fromObject(const void*);
192 192
193 bool isMainThread() const { return this == mainThreadState(); } 193 bool isMainThread() const { return this == mainThreadState(); }
194 #if ENABLE(ASSERT) 194 #if DCHECK_IS_ON()
195 bool checkThread() const { return m_thread == currentThread(); } 195 bool checkThread() const { return m_thread == currentThread(); }
196 #endif 196 #endif
197 197
198 ThreadHeap& heap() const { return *m_heap; } 198 ThreadHeap& heap() const { return *m_heap; }
199 199
200 // When ThreadState is detaching from non-main thread its 200 // When ThreadState is detaching from non-main thread its
201 // heap is expected to be empty (because it is going away). 201 // heap is expected to be empty (because it is going away).
202 // Perform registered cleanup tasks and garbage collection 202 // Perform registered cleanup tasks and garbage collection
203 // to sweep away any objects that are left on this heap. 203 // to sweep away any objects that are left on this heap.
204 // We assert that nothing must remain after this cleanup. 204 // We assert that nothing must remain after this cleanup.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 // Get one of the heap structures for this thread. 348 // Get one of the heap structures for this thread.
349 // The thread heap is split into multiple heap parts based on object types 349 // The thread heap is split into multiple heap parts based on object types
350 // and object sizes. 350 // and object sizes.
351 BaseArena* arena(int arenaIndex) const { 351 BaseArena* arena(int arenaIndex) const {
352 ASSERT(0 <= arenaIndex); 352 ASSERT(0 <= arenaIndex);
353 ASSERT(arenaIndex < BlinkGC::NumberOfArenas); 353 ASSERT(arenaIndex < BlinkGC::NumberOfArenas);
354 return m_arenas[arenaIndex]; 354 return m_arenas[arenaIndex];
355 } 355 }
356 356
357 #if ENABLE(ASSERT) 357 #if DCHECK_IS_ON()
358 // Infrastructure to determine if an address is within one of the 358 // Infrastructure to determine if an address is within one of the
359 // address ranges for the Blink heap. If the address is in the Blink 359 // address ranges for the Blink heap. If the address is in the Blink
360 // heap the containing heap page is returned. 360 // heap the containing heap page is returned.
361 BasePage* findPageFromAddress(Address); 361 BasePage* findPageFromAddress(Address);
362 BasePage* findPageFromAddress(const void* pointer) { 362 BasePage* findPageFromAddress(const void* pointer) {
363 return findPageFromAddress( 363 return findPageFromAddress(
364 reinterpret_cast<Address>(const_cast<void*>(pointer))); 364 reinterpret_cast<Address>(const_cast<void*>(pointer)));
365 } 365 }
366 #endif 366 #endif
367 367
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 521
522 // Register the pre-finalizer for the |self| object. The class T must have 522 // Register the pre-finalizer for the |self| object. The class T must have
523 // USING_PRE_FINALIZER(). 523 // USING_PRE_FINALIZER().
524 template <typename T> 524 template <typename T>
525 class PrefinalizerRegistration final { 525 class PrefinalizerRegistration final {
526 public: 526 public:
527 PrefinalizerRegistration(T* self) { 527 PrefinalizerRegistration(T* self) {
528 static_assert(sizeof(&T::invokePreFinalizer) > 0, 528 static_assert(sizeof(&T::invokePreFinalizer) > 0,
529 "USING_PRE_FINALIZER(T) must be defined."); 529 "USING_PRE_FINALIZER(T) must be defined.");
530 ThreadState* state = ThreadState::current(); 530 ThreadState* state = ThreadState::current();
531 #if ENABLE(ASSERT) 531 #if DCHECK_IS_ON()
532 DCHECK(state->checkThread()); 532 DCHECK(state->checkThread());
533 #endif 533 #endif
534 DCHECK(!state->sweepForbidden()); 534 DCHECK(!state->sweepForbidden());
535 DCHECK(!state->m_orderedPreFinalizers.contains( 535 DCHECK(!state->m_orderedPreFinalizers.contains(
536 PreFinalizer(self, T::invokePreFinalizer))); 536 PreFinalizer(self, T::invokePreFinalizer)));
537 state->m_orderedPreFinalizers.add( 537 state->m_orderedPreFinalizers.add(
538 PreFinalizer(self, T::invokePreFinalizer)); 538 PreFinalizer(self, T::invokePreFinalizer));
539 } 539 }
540 }; 540 };
541 541
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 class ThreadStateFor<AnyThread> { 736 class ThreadStateFor<AnyThread> {
737 STATIC_ONLY(ThreadStateFor); 737 STATIC_ONLY(ThreadStateFor);
738 738
739 public: 739 public:
740 static ThreadState* state() { return ThreadState::current(); } 740 static ThreadState* state() { return ThreadState::current(); }
741 }; 741 };
742 742
743 } // namespace blink 743 } // namespace blink
744 744
745 #endif // ThreadState_h 745 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698