SlotVisitorInlines.h [plain text]
#pragma once
#include "SlotVisitor.h"
#include "Weak.h"
#include "WeakInlines.h"
namespace JSC {
ALWAYS_INLINE void SlotVisitor::appendUnbarriered(JSValue* slot, size_t count)
{
for (size_t i = count; i--;)
appendUnbarriered(slot[i]);
}
ALWAYS_INLINE void SlotVisitor::appendUnbarriered(JSCell* cell)
{
if (!cell)
return;
Dependency dependency;
if (UNLIKELY(cell->isLargeAllocation())) {
dependency = nullDependency();
if (LIKELY(cell->largeAllocation().isMarked())) {
if (LIKELY(!m_heapSnapshotBuilder))
return;
}
} else {
MarkedBlock& block = cell->markedBlock();
dependency = block.aboutToMark(m_markingVersion);
if (LIKELY(block.isMarked(cell, dependency))) {
if (LIKELY(!m_heapSnapshotBuilder))
return;
}
}
appendSlow(cell, dependency);
}
ALWAYS_INLINE void SlotVisitor::appendUnbarriered(JSValue value)
{
if (value.isCell())
appendUnbarriered(value.asCell());
}
ALWAYS_INLINE void SlotVisitor::appendHiddenUnbarriered(JSValue value)
{
if (value.isCell())
appendHiddenUnbarriered(value.asCell());
}
ALWAYS_INLINE void SlotVisitor::appendHiddenUnbarriered(JSCell* cell)
{
if (!cell)
return;
Dependency dependency;
if (UNLIKELY(cell->isLargeAllocation())) {
dependency = nullDependency();
if (LIKELY(cell->largeAllocation().isMarked()))
return;
} else {
MarkedBlock& block = cell->markedBlock();
dependency = block.aboutToMark(m_markingVersion);
if (LIKELY(block.isMarked(cell, dependency)))
return;
}
appendHiddenSlow(cell, dependency);
}
template<typename T>
ALWAYS_INLINE void SlotVisitor::append(const Weak<T>& weak)
{
appendUnbarriered(weak.get());
}
template<typename T>
ALWAYS_INLINE void SlotVisitor::append(const WriteBarrierBase<T>& slot)
{
appendUnbarriered(slot.get());
}
template<typename T>
ALWAYS_INLINE void SlotVisitor::appendHidden(const WriteBarrierBase<T>& slot)
{
appendHiddenUnbarriered(slot.get());
}
template<typename Iterator>
ALWAYS_INLINE void SlotVisitor::append(Iterator begin, Iterator end)
{
for (auto it = begin; it != end; ++it)
append(*it);
}
ALWAYS_INLINE void SlotVisitor::appendValues(const WriteBarrierBase<Unknown>* barriers, size_t count)
{
for (size_t i = 0; i < count; ++i)
append(barriers[i]);
}
ALWAYS_INLINE void SlotVisitor::appendValuesHidden(const WriteBarrierBase<Unknown>* barriers, size_t count)
{
for (size_t i = 0; i < count; ++i)
appendHidden(barriers[i]);
}
inline void SlotVisitor::reportExtraMemoryVisited(size_t size)
{
if (m_isFirstVisit) {
heap()->reportExtraMemoryVisited(size);
m_nonCellVisitCount += size;
}
}
#if ENABLE(RESOURCE_USAGE)
inline void SlotVisitor::reportExternalMemoryVisited(size_t size)
{
if (m_isFirstVisit)
heap()->reportExternalMemoryVisited(size);
}
#endif
inline Heap* SlotVisitor::heap() const
{
return &m_heap;
}
inline VM& SlotVisitor::vm()
{
return *m_heap.m_vm;
}
inline const VM& SlotVisitor::vm() const
{
return *m_heap.m_vm;
}
template<typename Func>
IterationStatus SlotVisitor::forEachMarkStack(const Func& func)
{
if (func(m_collectorStack) == IterationStatus::Done)
return IterationStatus::Done;
if (func(m_mutatorStack) == IterationStatus::Done)
return IterationStatus::Done;
return IterationStatus::Continue;
}
}