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

Unified Diff: Source/platform/heap/Heap.h

Issue 858363005: Oilpan: expose near-finalized predicate as Heap::willObjectBeLazilySwept() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: assert for valid object reference Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/Timer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.h
diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
index 6dec9e0a89de94e8247627cfcd06d3dfaa54415a..0050cb97ada166093406999e01230f26179c8292 100644
--- a/Source/platform/heap/Heap.h
+++ b/Source/platform/heap/Heap.h
@@ -852,29 +852,33 @@ public:
static bool containedInHeapOrOrphanedPage(void*);
#endif
- // Is the finalizable GC object still alive? If no GC is in progress,
- // it must be true. If a lazy sweep is in progress, it will be true if
- // the object hasn't been swept yet and it is marked, or it has
- // been swept and it is still alive.
- //
- // isFinalizedObjectAlive() must not be used with already-finalized object
- // references.
+ // Is the finalizable GC object still alive, but slated for lazy sweeping?
+ // If a lazy sweep is in progress, returns true if the object was found
+ // to be not reachable during the marking phase, but it has yet to be swept
+ // and finalized. The predicate returns false in all other cases.
//
+ // Holding a reference to an already-dead object is not a valid state
+ // to be in; willObjectBeLazilySwept() has undefined behavior if passed
+ // such a reference.
template<typename T>
- static bool isFinalizedObjectAlive(const T* objectPointer)
+ static bool willObjectBeLazilySwept(const T* objectPointer)
{
static_assert(IsGarbageCollectedType<T>::value, "only objects deriving from GarbageCollected can be used.");
+#if ENABLE(ASSERT)
+ ASSERT(objectPointer);
+ HeapObjectHeader::fromPayload(objectPointer)->checkHeader();
+#endif
#if ENABLE(OILPAN)
BaseHeapPage* page = pageFromObject(objectPointer);
if (page->hasBeenSwept())
- return true;
+ return false;
ASSERT(page->heap()->threadState()->isSweepingInProgress());
- return ObjectAliveTrait<T>::isHeapObjectAlive(s_markingVisitor, const_cast<T*>(objectPointer));
+ return !ObjectAliveTrait<T>::isHeapObjectAlive(s_markingVisitor, const_cast<T*>(objectPointer));
#else
// FIXME: remove when lazy sweeping is always on
// (cf. ThreadState::postGCProcessing()).
- return true;
+ return false;
#endif
}
« no previous file with comments | « Source/platform/Timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698