| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 // the dangling pointer. | 34 // the dangling pointer. |
| 35 // Release builds don't have the ASSERT, but it is OK because | 35 // Release builds don't have the ASSERT, but it is OK because |
| 36 // release builds will crash in the following header->isMarked() | 36 // release builds will crash in the following header->isMarked() |
| 37 // because all the entries of the orphaned heaps are zapped. | 37 // because all the entries of the orphaned heaps are zapped. |
| 38 ASSERT(!pageFromObject(objectPointer)->orphaned()); | 38 ASSERT(!pageFromObject(objectPointer)->orphaned()); |
| 39 | 39 |
| 40 if (header->isMarked()) | 40 if (header->isMarked()) |
| 41 return; | 41 return; |
| 42 | 42 |
| 43 ASSERT(ThreadState::current()->isInGC()); | 43 ASSERT(ThreadState::current()->isInGC()); |
| 44 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); | 44 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing); |
| 45 | 45 |
| 46 header->mark(); | 46 header->mark(); |
| 47 | 47 |
| 48 if (callback) | 48 if (callback) |
| 49 Heap::pushTraceCallback(const_cast<void*>(objectPointer), callback); | 49 Heap::pushTraceCallback(const_cast<void*>(objectPointer), callback); |
| 50 } | 50 } |
| 51 | 51 |
| 52 inline void mark(const void* objectPointer, TraceCallback callback) | 52 inline void mark(const void* objectPointer, TraceCallback callback) |
| 53 { | 53 { |
| 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(const void* objectPointer) |
| 61 { | 61 { |
| 62 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); | 62 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing); |
| 63 Heap::pushPostMarkingCallback(const_cast<void*>(objectPointer), &markNoT
racingCallback); | 63 Heap::pushPostMarkingCallback(const_cast<void*>(objectPointer), &markNoT
racingCallback); |
| 64 } | 64 } |
| 65 | 65 |
| 66 inline void registerWeakMembers(const void* closure, const void* objectPoint
er, WeakCallback callback) | 66 inline void registerWeakMembers(const void* closure, const void* objectPoint
er, WeakCallback callback) |
| 67 { | 67 { |
| 68 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); | 68 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing); |
| 69 // We don't want to run weak processings when taking a snapshot. | 69 // We don't want to run weak processings when taking a snapshot. |
| 70 if (toDerived()->markingMode() == Visitor::SnapshotMarking) | 70 if (toDerived()->getMarkingMode() == Visitor::SnapshotMarking) |
| 71 return; | 71 return; |
| 72 Heap::pushThreadLocalWeakCallback(const_cast<void*>(closure), const_cast
<void*>(objectPointer), callback); | 72 Heap::pushThreadLocalWeakCallback(const_cast<void*>(closure), const_cast
<void*>(objectPointer), callback); |
| 73 } | 73 } |
| 74 | 74 |
| 75 inline void registerWeakTable(const void* closure, EphemeronCallback iterati
onCallback, EphemeronCallback iterationDoneCallback) | 75 inline void registerWeakTable(const void* closure, EphemeronCallback iterati
onCallback, EphemeronCallback iterationDoneCallback) |
| 76 { | 76 { |
| 77 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); | 77 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing); |
| 78 Heap::registerWeakTable(const_cast<void*>(closure), iterationCallback, i
terationDoneCallback); | 78 Heap::registerWeakTable(const_cast<void*>(closure), iterationCallback, i
terationDoneCallback); |
| 79 } | 79 } |
| 80 | 80 |
| 81 #if ENABLE(ASSERT) | 81 #if ENABLE(ASSERT) |
| 82 inline bool weakTableRegistered(const void* closure) | 82 inline bool weakTableRegistered(const void* closure) |
| 83 { | 83 { |
| 84 return Heap::weakTableRegistered(closure); | 84 return Heap::weakTableRegistered(closure); |
| 85 } | 85 } |
| 86 #endif | 86 #endif |
| 87 | 87 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 Derived* toDerived() | 110 Derived* toDerived() |
| 111 { | 111 { |
| 112 return static_cast<Derived*>(this); | 112 return static_cast<Derived*>(this); |
| 113 } | 113 } |
| 114 | 114 |
| 115 protected: | 115 protected: |
| 116 inline void registerWeakCellWithCallback(void** cell, WeakCallback callback) | 116 inline void registerWeakCellWithCallback(void** cell, WeakCallback callback) |
| 117 { | 117 { |
| 118 ASSERT(toDerived()->markingMode() != Visitor::WeakProcessing); | 118 ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing); |
| 119 // We don't want to run weak processings when taking a snapshot. | 119 // We don't want to run weak processings when taking a snapshot. |
| 120 if (toDerived()->markingMode() == Visitor::SnapshotMarking) | 120 if (toDerived()->getMarkingMode() == Visitor::SnapshotMarking) |
| 121 return; | 121 return; |
| 122 Heap::pushGlobalWeakCallback(cell, callback); | 122 Heap::pushGlobalWeakCallback(cell, callback); |
| 123 } | 123 } |
| 124 | 124 |
| 125 private: | 125 private: |
| 126 static void markNoTracingCallback(Visitor* visitor, void* object) | 126 static void markNoTracingCallback(Visitor* visitor, void* object) |
| 127 { | 127 { |
| 128 visitor->markNoTracing(object); | 128 visitor->markNoTracing(object); |
| 129 } | 129 } |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 } // namespace blink | 132 } // namespace blink |
| 133 | 133 |
| 134 #endif | 134 #endif |
| OLD | NEW |