5#ifndef V8_HEAP_MARKING_H_
6#define V8_HEAP_MARKING_H_
34 template <AccessMode mode = AccessMode::NON_ATOMIC>
37 template <AccessMode mode = AccessMode::NON_ATOMIC>
38 inline bool Get()
const;
46 return cell_ == other.cell_ &&
mask_ == other.mask_;
63inline bool MarkBit::Set<AccessMode::NON_ATOMIC>() {
64 CellType old_value = *
cell_;
65 if ((old_value & mask_) == mask_)
return false;
66 *
cell_ = old_value | mask_;
71inline bool MarkBit::Set<AccessMode::ATOMIC>() {
76inline bool MarkBit::Get<AccessMode::NON_ATOMIC>()
const {
77 return (*
cell_ & mask_) != 0;
81inline bool MarkBit::Get<AccessMode::ATOMIC>()
const {
87 *
cell_ = old_value & ~mask_;
98 static constexpr uint32_t kBitsPerCell =
sizeof(
CellType) * kBitsPerByte;
99 static constexpr uint32_t kBitsPerCellLog2 =
100 base::bits::CountTrailingZeros(kBitsPerCell);
101 static constexpr uint32_t kBitIndexMask = kBitsPerCell - 1;
103 static constexpr uint32_t kBytesPerCellLog2 =
109 static constexpr size_t kCellsCount =
110 (kLength + kBitsPerCell - 1) >> kBitsPerCellLog2;
113 static constexpr size_t kSize = kCellsCount * kBytesPerCell;
120 return index >> kBitsPerCellLog2;
128 return IndexToAddressOffset(cell_index << kBitsPerCellLog2);
132 return index & kBitIndexMask;
136 return static_cast<CellType>(1u) << IndexInCell(index);
141 return index & ~kBitIndexMask;
162 bool AllBitsClearInRange(MarkBitIndex start_index,
163 MarkBitIndex end_index)
const;
166 bool AllBitsSetInRange(MarkBitIndex start_index,
167 MarkBitIndex end_index)
const;
169 template <AccessMode mode>
175 template <AccessMode mode>
176 inline void SetRange(MarkBitIndex start_index, MarkBitIndex end_index);
181 template <AccessMode mode>
182 inline void ClearRange(MarkBitIndex start_index, MarkBitIndex end_index);
185 bool IsClean()
const;
191 const auto mask = IndexInCellMask(index);
203 static inline Address FindPreviousValidObject(
const PageMetadata* page,
204 Address maybe_inner_ptr);
211 template <AccessMode mode>
216 template <AccessMode mode>
221 template <AccessMode mode>
224 template <AccessMode mode>
228 uint32_t end_cell_index);
258 template <
typename MarkingStateT>
260 MarkingStateT* marking_state,
265 template <
typename MarkingStateT>
267 MarkingStateT* marking_state,
273 template <
typename MarkingState>
constexpr int kPageSizeBits
static T Relaxed_Load(T *addr)
static bool Relaxed_SetBits(T *addr, T bits, T mask)
MarkBit(CellType *cell, CellType mask)
const CellType * CellAddress() const
static V8_ALLOW_UNUSED MarkBit FromForTesting(Address)
static V8_ALLOW_UNUSED MarkBit From(Address)
static V8_INLINE constexpr Address IndexToAddressOffset(MarkBitIndex index)
static V8_INLINE constexpr uint32_t CellAlignIndex(uint32_t index)
MarkingBitmap(const MarkingBitmap &)=delete
void ClearBitsInCell(uint32_t cell_index, MarkBit::CellType mask)
V8_INLINE const CellType * cells() const
V8_INLINE MarkBit MarkBitFromIndexForTesting(uint32_t index)
MarkingBitmap & operator=(const MarkingBitmap &)=delete
void SetCellRangeRelaxed(uint32_t start_cell_index, uint32_t end_cell_index)
static V8_INLINE constexpr uint32_t IndexInCell(MarkBitIndex index)
void SetBitsInCell(uint32_t cell_index, MarkBit::CellType mask)
void ClearCellRangeRelaxed(uint32_t start_cell_index, uint32_t end_cell_index)
MarkBit::CellType CellType
V8_INLINE CellType * cells()
static V8_INLINE constexpr CellIndex IndexToCell(MarkBitIndex index)
static V8_INLINE constexpr Address CellToBase(CellIndex cell_index)
static V8_INLINE MarkingBitmap * Cast(Address addr)
static V8_INLINE constexpr CellType IndexInCellMask(MarkBitIndex index)
const PropertyCellRef cell_
constexpr int kBitsPerByte
constexpr int kTaggedSizeLog2
bool operator==(ExternalReference lhs, ExternalReference rhs)
constexpr int kBitsPerByteLog2
#define V8_EXPORT_PRIVATE
static V8_INLINE bool TryMarkAndPush(Heap *heap, MarkingWorklists::Local *marking_worklist, MarkingState *marking_state, WorklistTarget target_worklis, Tagged< HeapObject > object)
static V8_INLINE bool IsMarkedOrAlwaysLive(Heap *heap, MarkingStateT *marking_state, Tagged< HeapObject > object)
static V8_INLINE bool IsUnmarkedAndNotAlwaysLive(Heap *heap, MarkingStateT *marking_state, Tagged< HeapObject > object)
static V8_INLINE std::optional< WorklistTarget > ShouldMarkObject(Heap *heap, Tagged< HeapObject > object)
static V8_INLINE LivenessMode GetLivenessMode(Heap *heap, Tagged< HeapObject > object)