void pin();
bool isPinned();
+ bool isOld();
bool isOversize();
+ void didPromote();
unsigned liveBytes();
- void reportLiveBytes(JSCell*, unsigned);
+ bool shouldReportLiveBytes(SpinLockHolder&, JSCell* owner);
+ void reportLiveBytes(SpinLockHolder&, JSCell*, CopyToken, unsigned);
+ void reportLiveBytesDuringCopying(unsigned);
void didSurviveGC();
void didEvacuateBytes(unsigned);
bool shouldEvacuate();
bool hasWorkList();
CopyWorkList& workList();
+ SpinLock& workListLock() { return m_workListLock; }
private:
CopiedBlock(Region*);
void zeroFillWilderness(); // Can be called at any time to zero-fill to the end of the block.
-#if ENABLE(PARALLEL_GC)
+ void checkConsistency();
+
SpinLock m_workListLock;
-#endif
OwnPtr<CopyWorkList> m_workList;
size_t m_remaining;
- uintptr_t m_isPinned;
+ bool m_isPinned : 1;
+ bool m_isOld : 1;
unsigned m_liveBytes;
+#ifndef NDEBUG
+ unsigned m_liveObjects;
+#endif
};
inline CopiedBlock* CopiedBlock::createNoZeroFill(DeadBlock* block)
: HeapBlock<CopiedBlock>(region)
, m_remaining(payloadCapacity())
, m_isPinned(false)
+ , m_isOld(false)
, m_liveBytes(0)
+#ifndef NDEBUG
+ , m_liveObjects(0)
+#endif
{
-#if ENABLE(PARALLEL_GC)
m_workListLock.Init();
-#endif
ASSERT(is8ByteAligned(reinterpret_cast<void*>(m_remaining)));
}
inline void CopiedBlock::didSurviveGC()
{
+ checkConsistency();
+ ASSERT(isOld());
m_liveBytes = 0;
+#ifndef NDEBUG
+ m_liveObjects = 0;
+#endif
m_isPinned = false;
if (m_workList)
m_workList.clear();
inline void CopiedBlock::didEvacuateBytes(unsigned bytes)
{
ASSERT(m_liveBytes >= bytes);
+ ASSERT(m_liveObjects);
+ checkConsistency();
m_liveBytes -= bytes;
+#ifndef NDEBUG
+ m_liveObjects--;
+#endif
+ checkConsistency();
}
inline bool CopiedBlock::canBeRecycled()
{
+ checkConsistency();
return !m_liveBytes;
}
inline bool CopiedBlock::shouldEvacuate()
{
+ checkConsistency();
return static_cast<double>(m_liveBytes) / static_cast<double>(payloadCapacity()) <= Options::minCopiedBlockUtilization();
}
return m_isPinned;
}
+inline bool CopiedBlock::isOld()
+{
+ return m_isOld;
+}
+
+inline void CopiedBlock::didPromote()
+{
+ m_isOld = true;
+}
+
inline bool CopiedBlock::isOversize()
{
return region()->isCustomSize();
inline unsigned CopiedBlock::liveBytes()
{
+ checkConsistency();
return m_liveBytes;
}
return *m_workList;
}
+inline void CopiedBlock::checkConsistency()
+{
+ ASSERT(!!m_liveBytes == !!m_liveObjects);
+}
+
} // namespace JSC
#endif