21template <
template <
typename>
typename HandleType>
25 HandleType<FixedArray> array,
28 int len = array->length();
34 array->FillWithHoles(len, new_capacity);
37 array->set(index, *value);
53template <
template <
typename>
typename HandleType>
59 return isolate->factory()->empty_fixed_array();
77 int length = array->length();
93 int length = array->length();
99 array->set(length, *obj);
110 int length = array->length();
116 array->set(length + 0, *obj0);
117 array->set(length + 1, *obj1);
126 int length = array->length();
127 if (length == 0)
return isolate->factory()->empty_fixed_array();
134 ObjectSlot src_slot(array->RawFieldOfElementAt(0));
135 isolate->heap()->CopyRange(*
result, dst_slot, src_slot, length, mode);
150 int old_capacity = array->capacity();
151 if (old_capacity >= length)
return array;
153 int old_length = array->length();
155 int new_capacity = length + std::max(length / 2, 2);
159 new_array->set_length(old_length);
161 CopyElements(isolate, *new_array, 0, *array, 0, old_length, mode);
169 int length = array->length();
175 length = raw->length();
176 raw->Set(length, *value);
177 raw->set_length(length + 1);
186 int length = array->length();
192 length = array->length();
193 raw->Set(length, *value1);
194 raw->Set(length + 1, value2);
195 raw->set_length(length + 2);
209 length = raw->length();
212 raw->Set(length, *value);
213 raw->set_length(length + 1);
225 if (shrink || grow) {
228 array = isolate->factory()->CompactWeakArrayList(array, new_capacity,
233 array->Compact(isolate);
237 DCHECK_LT(array->length(), array->capacity());
243 int index = raw->length();
244 raw->Set(index, *value);
245 raw->set_length(index + 1);
252 int length = this->
length();
258 if (!value.IsCleared()) {
276 int capacity = array->capacity();
277 if (capacity < length) {
279 array = isolate->factory()->CopyWeakArrayListAndGrow(array, grow_by,
286 int live_weak_references = 0;
289 ++live_weak_references;
292 return live_weak_references;
296 int non_cleared_objects = 0;
298 if (!
Get(
i).IsCleared()) {
299 ++non_cleared_objects;
302 return non_cleared_objects;
306 int last_index =
length() - 1;
308 for (
int i = last_index;
i >= 0; --
i) {
309 if (
Get(
i) != *value)
continue;
314 set_length(last_index);
322 if (
Get(
i) == value)
return true;
static V8_EXPORT_PRIVATE DirectHandle< ArrayList > Add(Isolate *isolate, DirectHandle< ArrayList > array, Tagged< Smi > obj, AllocationType allocation=AllocationType::kYoung)
static V8_EXPORT_PRIVATE DirectHandle< FixedArray > ToFixedArray(Isolate *isolate, DirectHandle< ArrayList > array, AllocationType allocation=AllocationType::kYoung)
static DirectHandle< ArrayList > EnsureSpace(Isolate *isolate, DirectHandle< ArrayList > array, int length, AllocationType allocation=AllocationType::kYoung)
void set_length(int value)
void RightTrim(Isolate *isolate, int new_capacity)
static DirectHandle< ArrayList > New(IsolateT *isolate, int capacity, AllocationType allocation=AllocationType::kYoung)
V8_EXPORT_PRIVATE bool IsCowArray() const
static int GetMaxLengthForNewSpaceAllocation(ElementsKind kind)
static constexpr int kHeaderSize
V8_EXPORT_PRIVATE void RightTrim(Isolate *isolate, int new_capacity)
static HandleType< FixedArray > RightTrimOrEmpty(Isolate *isolate, HandleType< FixedArray > array, int new_length)
static Handle< FixedArray > New(IsolateT *isolate, int capacity, AllocationType allocation=AllocationType::kYoung)
static V8_EXPORT_PRIVATE HandleType< FixedArray > SetAndGrow(Isolate *isolate, HandleType< FixedArray > array, int index, DirectHandle< Object > value)
static Handle< FixedArray > Resize(Isolate *isolate, DirectHandle< FixedArray > xs, int new_capacity, AllocationType allocation=AllocationType::kYoung, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
void RightTrim(Isolate *isolate, int new_capacity)
static void CopyElements(Isolate *isolate, Tagged< ArrayList > dst, int dst_index, Tagged< ArrayList > src, int src_index, int len, WriteBarrierMode mode=kDefaultMode)
static constexpr int NewCapacityForIndex(int index, int old_capacity)
int CountLiveElements() const
V8_EXPORT_PRIVATE bool Contains(Tagged< MaybeObject > value)
static Handle< WeakArrayList > EnsureSpace(Isolate *isolate, Handle< WeakArrayList > array, int length, AllocationType allocation=AllocationType::kYoung)
V8_EXPORT_PRIVATE bool IsFull() const
V8_EXPORT_PRIVATE bool RemoveOne(MaybeObjectDirectHandle value)
int CountLiveWeakReferences() const
static V8_WARN_UNUSED_RESULT DirectHandle< WeakArrayList > Append(Isolate *isolate, DirectHandle< WeakArrayList > array, MaybeObjectDirectHandle value, AllocationType allocation=AllocationType::kYoung)
void Set(int index, Tagged< MaybeObject > value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
NEVER_READ_ONLY_SPACE static V8_EXPORT_PRIVATE Handle< WeakArrayList > AddToEnd(Isolate *isolate, Handle< WeakArrayList > array, MaybeObjectDirectHandle value)
static constexpr int CapacityForLength(int length)
V8_EXPORT_PRIVATE void Compact(Isolate *isolate)
Tagged< MaybeObject > Get(int index) const
#define EXPORT_TEMPLATE_DEFINE(export)
ZoneVector< RpoNumber > & result
constexpr int kMaxRegularHeapObjectSize
ReadOnlyRoots GetReadOnlyRoots()
V8_INLINE constexpr bool IsWeak(TaggedImpl< HeapObjectReferenceType::WEAK, StorageType > obj)
constexpr int ElementsKindToShiftSize(ElementsKind elements_kind)
Tagged< ClearedWeakValue > ClearedValue(PtrComprCageBase cage_base)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define DCHECK_NE(v1, v2)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define V8_EXPORT_PRIVATE