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

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

Issue 2090893003: Experiment: assert for stack-allocated GarbageCollected<>s. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix boundary condition Created 4 years, 6 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 | third_party/WebKit/Source/platform/heap/StackFrameDepth.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) 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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef Heap_h 31 #ifndef Heap_h
32 #define Heap_h 32 #define Heap_h
33 33
34 #include "platform/PlatformExport.h" 34 #include "platform/PlatformExport.h"
35 #include "platform/heap/GCInfo.h" 35 #include "platform/heap/GCInfo.h"
36 #include "platform/heap/HeapPage.h" 36 #include "platform/heap/HeapPage.h"
37 #include "platform/heap/PageMemory.h" 37 #include "platform/heap/PageMemory.h"
38 #include "platform/heap/StackFrameDepth.h"
38 #include "platform/heap/ThreadState.h" 39 #include "platform/heap/ThreadState.h"
39 #include "platform/heap/Visitor.h" 40 #include "platform/heap/Visitor.h"
40 #include "wtf/AddressSanitizer.h" 41 #include "wtf/AddressSanitizer.h"
41 #include "wtf/Allocator.h" 42 #include "wtf/Allocator.h"
42 #include "wtf/Assertions.h" 43 #include "wtf/Assertions.h"
43 #include "wtf/Atomics.h" 44 #include "wtf/Atomics.h"
44 #include "wtf/Forward.h" 45 #include "wtf/Forward.h"
45 #include <memory> 46 #include <memory>
46 47
47 namespace blink { 48 namespace blink {
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 468 }
468 469
469 void operator delete(void* p) 470 void operator delete(void* p)
470 { 471 {
471 ASSERT_NOT_REACHED(); 472 ASSERT_NOT_REACHED();
472 } 473 }
473 474
474 protected: 475 protected:
475 GarbageCollected() 476 GarbageCollected()
476 { 477 {
478 // A GarbageCollected<> object should not be stack allocated
479 // as it won't be prefixed with a (heap) header which would
480 // fail if the stack object ends up being stored in a traceable
481 // member field (say.)
482 DCHECK(!StackFrameDepth::isStackAddress(this));
477 } 483 }
478 }; 484 };
479 485
480 // Assigning class types to their arenas. 486 // Assigning class types to their arenas.
481 // 487 //
482 // We use sized arenas for most 'normal' objects to improve memory locality. 488 // We use sized arenas for most 'normal' objects to improve memory locality.
483 // It seems that the same type of objects are likely to be accessed together, 489 // It seems that the same type of objects are likely to be accessed together,
484 // which means that we want to group objects by type. That's one reason 490 // which means that we want to group objects by type. That's one reason
485 // why we provide dedicated arenas for popular types (e.g., Node, CSSValue), 491 // why we provide dedicated arenas for popular types (e.g., Node, CSSValue),
486 // but it's not practical to prepare dedicated arenas for all types. 492 // but it's not practical to prepare dedicated arenas for all types.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) 625 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object)
620 { 626 {
621 T** cell = reinterpret_cast<T**>(object); 627 T** cell = reinterpret_cast<T**>(object);
622 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) 628 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell))
623 *cell = nullptr; 629 *cell = nullptr;
624 } 630 }
625 631
626 } // namespace blink 632 } // namespace blink
627 633
628 #endif // Heap_h 634 #endif // Heap_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/StackFrameDepth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698