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

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

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored Created 4 years, 10 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MarkingVisitorImpl_h 5 #ifndef MarkingVisitorImpl_h
6 #define MarkingVisitorImpl_h 6 #define MarkingVisitorImpl_h
7 7
8 #include "platform/heap/Heap.h" 8 #include "platform/heap/Heap.h"
9 #include "platform/heap/ThreadState.h" 9 #include "platform/heap/ThreadState.h"
10 #include "platform/heap/Visitor.h" 10 #include "platform/heap/Visitor.h"
(...skipping 20 matching lines...) Expand all
31 // from a live thread heap to a dead thread heap. We must eliminate 31 // from a live thread heap to a dead thread heap. We must eliminate
32 // the dangling pointer. 32 // the dangling pointer.
33 // Release builds don't have the ASSERT, but it is OK because 33 // Release builds don't have the ASSERT, but it is OK because
34 // release builds will crash in the following header->isMarked() 34 // release builds will crash in the following header->isMarked()
35 // because all the entries of the orphaned heaps are zapped. 35 // because all the entries of the orphaned heaps are zapped.
36 ASSERT(!pageFromObject(objectPointer)->orphaned()); 36 ASSERT(!pageFromObject(objectPointer)->orphaned());
37 37
38 if (header->isMarked()) 38 if (header->isMarked())
39 return; 39 return;
40 40
41 ASSERT(ThreadState::current()->isInGC()); 41 ASSERT(toDerived()->gcData()->threadState()->isInGC());
42 RELEASE_ASSERT(ThreadState::forObject(objectPointer)->gcGroup() == toDer ived()->gcData()->threadState()->gcGroup());
42 #if !defined(NDEBUG) 43 #if !defined(NDEBUG)
43 ASSERT(Heap::findPageFromAddress(header)); 44 ASSERT(Heap::findPageFromAddress(header));
44 #endif 45 #endif
45 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); 46 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing);
46 47
47 header->mark(); 48 header->mark();
48 49
49 if (callback) 50 if (callback)
50 Heap::pushTraceCallback(const_cast<void*>(objectPointer), callback); 51 Heap::pushTraceCallback(const_cast<void*>(objectPointer), callback, toDerived()->gcData());
51 } 52 }
52 53
53 inline void mark(const void* objectPointer, TraceCallback callback) 54 inline void mark(const void* objectPointer, TraceCallback callback)
54 { 55 {
55 if (!objectPointer) 56 if (!objectPointer)
56 return; 57 return;
57 HeapObjectHeader* header = HeapObjectHeader::fromPayload(objectPointer); 58 HeapObjectHeader* header = HeapObjectHeader::fromPayload(objectPointer);
58 markHeader(header, header->payload(), callback); 59 markHeader(header, header->payload(), callback);
59 } 60 }
60 61
61 inline void registerDelayedMarkNoTracing(const void* objectPointer) 62 inline void registerDelayedMarkNoTracing(const void* objectPointer)
62 { 63 {
63 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); 64 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing);
64 Heap::pushPostMarkingCallback(const_cast<void*>(objectPointer), &markNoT racingCallback); 65 Heap::pushPostMarkingCallback(const_cast<void*>(objectPointer), &markNoT racingCallback, toDerived()->gcData());
65 } 66 }
66 67
67 inline void registerWeakMembers(const void* closure, const void* objectPoint er, WeakCallback callback) 68 inline void registerWeakMembers(const void* closure, const void* objectPoint er, WeakCallback callback)
68 { 69 {
69 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); 70 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing);
70 // We don't want to run weak processings when taking a snapshot. 71 // We don't want to run weak processings when taking a snapshot.
71 if (toDerived()->markingMode() == Visitor::SnapshotMarking) 72 if (toDerived()->markingMode() == Visitor::SnapshotMarking)
72 return; 73 return;
73 Heap::pushThreadLocalWeakCallback(const_cast<void*>(closure), const_cast <void*>(objectPointer), callback); 74 Heap::pushThreadLocalWeakCallback(const_cast<void*>(closure), const_cast <void*>(objectPointer), callback);
74 } 75 }
75 76
76 inline void registerWeakTable(const void* closure, EphemeronCallback iterati onCallback, EphemeronCallback iterationDoneCallback) 77 inline void registerWeakTable(const void* closure, EphemeronCallback iterati onCallback, EphemeronCallback iterationDoneCallback)
77 { 78 {
78 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); 79 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing);
79 Heap::registerWeakTable(const_cast<void*>(closure), iterationCallback, i terationDoneCallback); 80 Heap::registerWeakTable(const_cast<void*>(closure), iterationCallback, i terationDoneCallback, toDerived()->gcData());
80 } 81 }
81 82
82 #if ENABLE(ASSERT) 83 #if ENABLE(ASSERT)
83 inline bool weakTableRegistered(const void* closure) 84 inline bool weakTableRegistered(const void* closure)
84 { 85 {
85 return Heap::weakTableRegistered(closure); 86 return Heap::weakTableRegistered(closure, toDerived()->gcData());
86 } 87 }
87 #endif 88 #endif
88 89
89 inline bool ensureMarked(const void* objectPointer) 90 inline bool ensureMarked(const void* objectPointer)
90 { 91 {
91 if (!objectPointer) 92 if (!objectPointer)
92 return false; 93 return false;
93 if (!toDerived()->shouldMarkObject(objectPointer)) 94 if (!toDerived()->shouldMarkObject(objectPointer))
94 return false; 95 return false;
95 #if ENABLE(ASSERT) 96 #if ENABLE(ASSERT)
(...skipping 17 matching lines...) Expand all
113 return static_cast<Derived*>(this); 114 return static_cast<Derived*>(this);
114 } 115 }
115 116
116 protected: 117 protected:
117 inline void registerWeakCellWithCallback(void** cell, WeakCallback callback) 118 inline void registerWeakCellWithCallback(void** cell, WeakCallback callback)
118 { 119 {
119 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); 120 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing);
120 // We don't want to run weak processings when taking a snapshot. 121 // We don't want to run weak processings when taking a snapshot.
121 if (toDerived()->markingMode() == Visitor::SnapshotMarking) 122 if (toDerived()->markingMode() == Visitor::SnapshotMarking)
122 return; 123 return;
123 Heap::pushGlobalWeakCallback(cell, callback); 124 Heap::pushGlobalWeakCallback(cell, callback, toDerived()->gcData());
124 } 125 }
125 126
126 private: 127 private:
127 static void markNoTracingCallback(Visitor* visitor, void* object) 128 static void markNoTracingCallback(Visitor* visitor, void* object)
128 { 129 {
129 visitor->markNoTracing(object); 130 visitor->markNoTracing(object);
130 } 131 }
131 }; 132 };
132 133
133 } // namespace blink 134 } // namespace blink
134 135
135 #endif 136 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698