5#ifndef V8_HEAP_REMEMBERED_SET_H_
6#define V8_HEAP_REMEMBERED_SET_H_
29 template <AccessMode access_mode>
32 ? v8::internal::SlotSet::AccessMode::ATOMIC
33 : v8::internal::SlotSet::AccessMode::NON_ATOMIC>(
37 template <AccessMode access_mode = AccessMode::ATOMIC,
typename Callback>
41 if (slot_set !=
nullptr) {
42 slots += slot_set->
Iterate<access_mode>(
50 if (slot_set !=
nullptr) {
59 if (slot_set !=
nullptr) {
64 slot_set->
RemoveRange(
static_cast<int>(start_offset),
65 static_cast<int>(end_offset),
66 page->BucketsInSlotSet(), mode);
72 if (slot_set !=
nullptr) {
81 chunk->
address(), start_bucket, end_bucket,
83 CHECK(slot.address() < start || slot.address() >= end);
91template <RememberedSetType type>
96 template <AccessMode access_mode>
98 SlotSet* slot_set = page->slot_set<
type, access_mode>();
99 if (slot_set ==
nullptr) {
100 slot_set = page->AllocateSlotSet(type);
112 if (slot_set ==
nullptr) {
127 if (typed_slot_set ==
nullptr) {
132 typed_slot_set->
Merge(&other_typed_slot_set);
133 delete &other_typed_slot_set;
137 delete &other_typed_slot_set;
145 if (slot_set ==
nullptr) {
154 SlotSet* slot_set = page->slot_set<type>();
178 template <
typename Callback>
182 while ((chunk = it.next()) !=
nullptr) {
185 if (slot_set !=
nullptr || typed_slot_set !=
nullptr) {
197 template <AccessMode access_mode = AccessMode::ATOMIC,
typename Callback>
204 template <AccessMode access_mode = AccessMode::ATOMIC,
typename Callback>
211 template <
typename Callback>
217 if (slot_set !=
nullptr) {
222 possibly_empty_buckets);
223 if (!possibly_empty_buckets->
IsEmpty()) empty_chunks->
Push(chunk);
231 if (slot_set !=
nullptr &&
246 if (slot_set ==
nullptr) {
253 std::unique_ptr<TypedSlots> other) {
255 if (slot_set ==
nullptr) {
256 slot_set = page->AllocateTypedSlotSet(type);
258 slot_set->
Merge(other.get());
266 if (slot_set !=
nullptr) {
269 return start <= slot_addr && slot_addr <
end ? REMOVE_SLOT
279 template <
typename Callback>
282 if (!slot_set)
return 0;
286 template <
typename Callback>
297 while ((chunk = it.next()) !=
nullptr) {
311 template <
typename Callback>
324 template <
typename Callback>
332 if (code != old_code) {
340 template <
typename Callback>
358 template <
typename Callback>
static void Delete(BasicSlotSet *slot_set)
static constexpr size_t BucketForSlot(size_t slot_offset)
void Insert(size_t slot_offset)
void RemoveRange(size_t start_offset, size_t end_offset, size_t buckets, EmptyBucketMode mode)
bool Contains(size_t slot_offset)
void Remove(size_t slot_offset)
V8_INLINE void Push(EntryType entry)
static Tagged< InstructionStream > FromTargetAddress(Address address)
static Tagged< InstructionStream > FromEntryAddress(Address location_of_address)
size_t OffsetMaybeOutOfRange(Address addr) const
V8_INLINE Address address() const
size_t Offset(Address addr) const
void set_typed_slot_set(TypedSlotSet *typed_slot_set)
void ReleaseTypedSlotSet(RememberedSetType type)
void set_slot_set(SlotSet *slot_set)
TypedSlotSet * typed_slot_set()
size_t BucketsInSlotSet() const
TypedSlotSet * AllocateTypedSlotSet(RememberedSetType type)
PossiblyEmptyBuckets * possibly_empty_buckets()
void ReleaseSlotSet(RememberedSetType type)
static constexpr bool IsCodeTargetMode(Mode mode)
V8_INLINE Address target_address()
static constexpr bool IsEmbeddedObjectMode(Mode mode)
V8_INLINE Tagged< HeapObject > target_object(PtrComprCageBase cage_base)
static int Iterate(SlotSet *slot_set, const MutablePageMetadata *chunk, Callback callback, SlotSet::EmptyBucketMode mode)
static void Remove(SlotSet *slot_set, MutablePageMetadata *chunk, Address slot_addr)
static void CheckNoneInRange(SlotSet *slot_set, MemoryChunk *chunk, Address start, Address end)
static void Insert(SlotSet *slot_set, size_t slot_offset)
static void RemoveRange(SlotSet *slot_set, MutablePageMetadata *page, Address start, Address end, SlotSet::EmptyBucketMode mode)
static int Iterate(SlotSet *slot_set, const MutablePageMetadata *chunk, Callback callback, SlotSet::EmptyBucketMode mode)
static void IterateMemoryChunks(Heap *heap, Callback callback)
static bool CheckPossiblyEmptyBuckets(MutablePageMetadata *chunk)
static void DeleteTyped(TypedSlotSet &&other_typed_slot_set)
static void InsertTyped(MutablePageMetadata *memory_chunk, SlotType slot_type, uint32_t offset)
static void Insert(MutablePageMetadata *page, size_t slot_offset)
static void MergeTyped(MutablePageMetadata *page, std::unique_ptr< TypedSlots > other)
static int IterateTyped(TypedSlotSet *slot_set, Callback callback)
static void ClearAll(Heap *heap)
static int IterateAndTrackEmptyBuckets(MutablePageMetadata *chunk, Callback callback, ::heap::base::Worklist< MutablePageMetadata *, 64 >::Local *empty_chunks)
static void RemoveRangeTyped(MutablePageMetadata *page, Address start, Address end)
static int IterateTyped(MutablePageMetadata *chunk, Callback callback)
static void MergeAndDelete(MutablePageMetadata *chunk, SlotSet &&other_slot_set)
static void Remove(MutablePageMetadata *chunk, Address slot_addr)
static bool Contains(MutablePageMetadata *chunk, Address slot_addr)
static void MergeAndDeleteTyped(MutablePageMetadata *chunk, TypedSlotSet &&other_typed_slot_set)
static void RemoveRange(MutablePageMetadata *chunk, Address start, Address end, SlotSet::EmptyBucketMode mode)
static void CheckNoneInRange(MutablePageMetadata *page, Address start, Address end)
static int Iterate(MutablePageMetadata *chunk, Callback callback, SlotSet::EmptyBucketMode mode)
size_t Iterate(Address chunk_start, size_t start_bucket, size_t end_bucket, Callback callback, EmptyBucketMode mode)
size_t IterateAndTrackEmptyBuckets(Address chunk_start, size_t start_bucket, size_t end_bucket, Callback callback, PossiblyEmptyBuckets *possibly_empty_buckets)
bool CheckPossiblyEmptyBuckets(size_t buckets, PossiblyEmptyBuckets *possibly_empty_buckets)
void Merge(SlotSet *other, size_t buckets)
int Iterate(Callback callback, IterationMode mode)
void Insert(SlotType type, uint32_t offset)
void Merge(TypedSlots *other)
static SlotCallbackResult UpdateCodeEntry(Address entry_address, Callback callback)
static SlotCallbackResult UpdateTypedSlot(WritableJitAllocation &jit_allocation, Heap *heap, SlotType slot_type, Address addr, Callback callback)
static Tagged< HeapObject > GetTargetObject(Heap *heap, SlotType slot_type, Address addr)
static SlotCallbackResult UpdateCodeTarget(WritableRelocInfo *rinfo, Callback callback)
static SlotCallbackResult UpdateEmbeddedPointer(Heap *heap, WritableRelocInfo *rinfo, Callback callback)
V8_INLINE void set_target_object(Tagged< InstructionStream > host, Tagged< HeapObject > target, WriteBarrierMode write_barrier_mode=UPDATE_WRITE_BARRIER, ICacheFlushMode icache_flush_mode=FLUSH_ICACHE_IF_NEEDED)
void set_target_address(Tagged< InstructionStream > host, Address target, WriteBarrierMode write_barrier_mode=UPDATE_WRITE_BARRIER, ICacheFlushMode icache_flush_mode=FLUSH_ICACHE_IF_NEEDED)
DirectHandle< Object > new_target
ZoneVector< RpoNumber > & result
static V8_INLINE bool HasWeakHeapObjectTag(const Tagged< Object > value)
constexpr int kTaggedSize
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define DCHECK_LE(v1, v2)
#define DCHECK_NOT_NULL(val)
#define DCHECK(condition)