5#ifndef V8_HEAP_MARKING_INL_H_
6#define V8_HEAP_MARKING_INL_H_
21inline void MarkingBitmap::SetBitsInCell<AccessMode::NON_ATOMIC>(
23 cells()[cell_index] |=
mask;
27inline void MarkingBitmap::SetBitsInCell<AccessMode::ATOMIC>(
33inline void MarkingBitmap::ClearBitsInCell<AccessMode::NON_ATOMIC>(
35 cells()[cell_index] &= ~mask;
39inline void MarkingBitmap::ClearBitsInCell<AccessMode::ATOMIC>(
46inline void MarkingBitmap::ClearCellRangeRelaxed<AccessMode::ATOMIC>(
47 uint32_t start_cell_index, uint32_t end_cell_index) {
49 for (uint32_t
i = start_cell_index;
i < end_cell_index;
i++) {
55inline void MarkingBitmap::ClearCellRangeRelaxed<AccessMode::NON_ATOMIC>(
56 uint32_t start_cell_index, uint32_t end_cell_index) {
57 for (uint32_t
i = start_cell_index;
i < end_cell_index;
i++) {
63inline void MarkingBitmap::SetCellRangeRelaxed<AccessMode::ATOMIC>(
64 uint32_t start_cell_index, uint32_t end_cell_index) {
66 for (uint32_t
i = start_cell_index;
i < end_cell_index;
i++) {
68 std::numeric_limits<MarkBit::CellType>::max());
73inline void MarkingBitmap::SetCellRangeRelaxed<AccessMode::NON_ATOMIC>(
74 uint32_t start_cell_index, uint32_t end_cell_index) {
75 for (uint32_t
i = start_cell_index;
i < end_cell_index;
i++) {
76 cells()[
i] = std::numeric_limits<MarkBit::CellType>::max();
80template <AccessMode mode>
90template <AccessMode mode>
93 if (start_index >= end_index)
return;
101 if (start_cell_index != end_cell_index) {
111 end_index_mask | (end_index_mask - start_index_mask));
120template <AccessMode mode>
123 if (start_index >= end_index)
return;
131 if (start_cell_index != end_cell_index) {
139 end_index_mask | (end_index_mask - 1));
142 end_index_mask | (end_index_mask - start_index_mask));
189 DCHECK(page->Contains(maybe_inner_ptr));
190 const auto* bitmap = page->marking_bitmap();
207 auto cell =
cells[cell_index];
210 cell &= ((~static_cast<MarkBit::CellType>(0)) >>
216 while (cell == 0 && cell_index > start_cell_index) cell =
cells[--cell_index];
220 return page->area_start();
225 const auto leftmost_ones =
227 const auto index_of_last_leftmost_one =
234 if (index_of_last_leftmost_one > 0) {
237 index_of_last_leftmost_one);
242 if (cell_index == start_cell_index) {
244 return page->area_start();
249 cell =
cells[--cell_index];
250 }
while (~cell == 0 && cell_index > start_cell_index);
254 return page->area_start();
259 const auto index_of_last_leading_one =
264 index_of_last_leading_one);
281 const auto flags = chunk->GetFlags();
285 if (
v8_flags.black_allocated_pages &&
297 if (
heap->isolate()->is_shared_space_isolate()) {
307 const auto flags = chunk->GetFlags();
311 if (
v8_flags.black_allocated_pages &&
322 if (
heap->isolate()->is_shared_space_isolate()) {
329template <
typename MarkingStateT>
331 MarkingStateT* marking_state,
335 marking_state->IsMarked(
object);
339template <
typename MarkingStateT>
341 MarkingStateT* marking_state,
345 marking_state->IsUnmarked(
object);
349template <
typename MarkingState>
356 if (marking_state->
TryMark(
object)) {
358 marking_worklist->
Push(
object);
static bool Relaxed_SetBits(T *addr, T bits, T mask)
static V8_ALLOW_UNUSED MarkBit From(Address)
static constexpr size_t kCellsCount
static V8_INLINE constexpr Address IndexToAddressOffset(MarkBitIndex index)
void ClearBitsInCell(uint32_t cell_index, MarkBit::CellType mask)
static Address FindPreviousValidObject(const PageMetadata *page, Address maybe_inner_ptr)
static V8_INLINE MarkBit MarkBitFromAddress(Address address)
static V8_INLINE MarkingBitmap * FromAddress(Address address)
static constexpr size_t kLength
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)
static V8_INLINE constexpr MarkBitIndex LimitAddressToIndex(Address address)
V8_INLINE CellType * cells()
void ClearRange(MarkBitIndex start_index, MarkBitIndex end_index)
static V8_INLINE constexpr CellIndex IndexToCell(MarkBitIndex index)
static constexpr uint32_t kBitsPerCell
static V8_INLINE constexpr MarkBitIndex AddressToIndex(Address address)
static V8_INLINE MarkingBitmap * Cast(Address addr)
void SetRange(MarkBitIndex start_index, MarkBitIndex end_index)
static V8_INLINE constexpr CellType IndexInCellMask(MarkBitIndex index)
V8_INLINE bool TryMark(Tagged< HeapObject > obj)
void Push(Tagged< HeapObject > object)
static constexpr uint32_t AddressToOffset(Address address)
@ IN_WRITABLE_SHARED_SPACE
static constexpr MainThreadFlags kIsInYoungGenerationMask
V8_INLINE Address address() const
static V8_INLINE MemoryChunk * FromHeapObject(Tagged< HeapObject > object)
static V8_INLINE constexpr bool IsAligned(Address address)
static V8_INLINE MutablePageMetadata * FromAddress(Address a)
static constexpr intptr_t MarkingBitmapOffset()
V8_INLINE constexpr StorageType ptr() const
constexpr unsigned CountLeadingZeros(T value)
void Relaxed_Store(volatile Atomic8 *ptr, Atomic8 value)
void SeqCst_MemoryFence()
constexpr int kTaggedSizeLog2
V8_EXPORT_PRIVATE FlagValues v8_flags
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
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)
#define V8_LIKELY(condition)
#define V8_UNLIKELY(condition)