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

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

Issue 2531973002: Simple BlinkGC heap compaction. (Closed)
Patch Set: tidy up comment Created 4 years 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 callback); 50 callback);
51 } 51 }
52 52
53 inline void mark(const void* objectPointer, TraceCallback callback) { 53 inline void mark(const void* objectPointer, TraceCallback callback) {
54 if (!objectPointer) 54 if (!objectPointer)
55 return; 55 return;
56 HeapObjectHeader* header = HeapObjectHeader::fromPayload(objectPointer); 56 HeapObjectHeader* header = HeapObjectHeader::fromPayload(objectPointer);
57 markHeader(header, header->payload(), callback); 57 markHeader(header, header->payload(), callback);
58 } 58 }
59 59
60 inline void registerDelayedMarkNoTracing(const void* objectPointer) { 60 inline void registerDelayedMarkNoTracing(void** objectPointer) {
61 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing); 61 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing);
62 toDerived()->heap().pushPostMarkingCallback( 62 toDerived()->heap().pushPostMarkingCallback(
63 const_cast<void*>(objectPointer), &markNoTracingCallback); 63 reinterpret_cast<void*>(objectPointer), &markNoTracingCallback);
64 } 64 }
65 65
66 inline void registerWeakMembers(const void* closure, 66 inline void registerWeakMembers(const void* closure,
67 const void* objectPointer, 67 const void* objectPointer,
68 WeakCallback callback) { 68 WeakCallback callback) {
69 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing); 69 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing);
70 // We don't want to run weak processings when taking a snapshot. 70 // We don't want to run weak processings when taking a snapshot.
71 if (toDerived()->getMarkingMode() == Visitor::SnapshotMarking) 71 if (toDerived()->getMarkingMode() == Visitor::SnapshotMarking)
72 return; 72 return;
73 toDerived()->heap().pushThreadLocalWeakCallback( 73 toDerived()->heap().pushThreadLocalWeakCallback(
74 const_cast<void*>(closure), const_cast<void*>(objectPointer), callback); 74 const_cast<void*>(closure), const_cast<void*>(objectPointer), callback);
75 } 75 }
76 76
77 inline void registerWeakTable(const void* closure, 77 inline void registerWeakTable(const void* closure,
78 EphemeronCallback iterationCallback, 78 EphemeronCallback iterationCallback,
79 EphemeronCallback iterationDoneCallback) { 79 EphemeronCallback iterationDoneCallback) {
80 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing); 80 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing);
81 toDerived()->heap().registerWeakTable( 81 toDerived()->heap().registerWeakTable(
82 const_cast<void*>(closure), iterationCallback, iterationDoneCallback); 82 const_cast<void*>(closure), iterationCallback, iterationDoneCallback);
83 } 83 }
84 84
85 #if ENABLE(ASSERT) 85 #if ENABLE(ASSERT)
86 inline bool weakTableRegistered(const void* closure) { 86 inline bool weakTableRegistered(const void* closure) {
87 return toDerived()->heap().weakTableRegistered(closure); 87 return toDerived()->heap().weakTableRegistered(closure);
88 } 88 }
89 #endif 89 #endif
90 90
91 inline void registerMovingObjectReference(MovableReference* slot) {
92 if (toDerived()->getMarkingMode() != Visitor::GlobalMarkCompacting)
93 return;
94 toDerived()->heap().registerMovingObjectReference(slot);
95 }
96
97 inline void registerMovingObjectCallback(MovableReference reference,
98 MovingObjectCallback callback,
99 void* callbackData) {
100 if (toDerived()->getMarkingMode() != Visitor::GlobalMarkCompacting)
101 return;
102 toDerived()->heap().registerMovingObjectCallback(reference, callback,
103 callbackData);
104 }
105
91 inline bool ensureMarked(const void* objectPointer) { 106 inline bool ensureMarked(const void* objectPointer) {
92 if (!objectPointer) 107 if (!objectPointer)
93 return false; 108 return false;
94 if (!toDerived()->shouldMarkObject(objectPointer)) 109 if (!toDerived()->shouldMarkObject(objectPointer))
95 return false; 110 return false;
96 #if ENABLE(ASSERT) 111 #if ENABLE(ASSERT)
97 if (HeapObjectHeader::fromPayload(objectPointer)->isMarked()) 112 if (HeapObjectHeader::fromPayload(objectPointer)->isMarked())
98 return false; 113 return false;
99 114
100 toDerived()->markNoTracing(objectPointer); 115 toDerived()->markNoTracing(objectPointer);
(...skipping 13 matching lines...) Expand all
114 // We don't want to run weak processings when taking a snapshot. 129 // We don't want to run weak processings when taking a snapshot.
115 if (toDerived()->getMarkingMode() == Visitor::SnapshotMarking) 130 if (toDerived()->getMarkingMode() == Visitor::SnapshotMarking)
116 return; 131 return;
117 toDerived()->heap().pushGlobalWeakCallback(cell, callback); 132 toDerived()->heap().pushGlobalWeakCallback(cell, callback);
118 } 133 }
119 134
120 Derived* toDerived() { return static_cast<Derived*>(this); } 135 Derived* toDerived() { return static_cast<Derived*>(this); }
121 136
122 private: 137 private:
123 static void markNoTracingCallback(Visitor* visitor, void* object) { 138 static void markNoTracingCallback(Visitor* visitor, void* object) {
124 visitor->markNoTracing(object); 139 // |object| is really the hash table's slot pointing
140 // to the backing store table. Adjust types accordingly..
141 void** reference = reinterpret_cast<void**>(object);
142 visitor->markNoTracing(*reference);
143 visitor->registerBackingStoreReference(reference);
haraken 2016/11/30 06:29:53 What is this change for? Aren't we registering all
sof 2016/11/30 06:52:43 Not the weakly-held backing stores, which is what
haraken 2016/11/30 07:09:49 What's a reason you need to handle weak backing st
sof 2016/11/30 07:26:38 Keeping their marking and fixup registration toget
125 } 144 }
126 }; 145 };
127 146
128 } // namespace blink 147 } // namespace blink
129 148
130 #endif 149 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698