diff options
Diffstat (limited to 'deps/v8/src/objects/fixed-array-inl.h')
-rw-r--r-- | deps/v8/src/objects/fixed-array-inl.h | 76 |
1 files changed, 25 insertions, 51 deletions
diff --git a/deps/v8/src/objects/fixed-array-inl.h b/deps/v8/src/objects/fixed-array-inl.h index 45107ce7fe0..29c4593cfda 100644 --- a/deps/v8/src/objects/fixed-array-inl.h +++ b/deps/v8/src/objects/fixed-array-inl.h @@ -7,7 +7,9 @@ #include "src/objects/fixed-array.h" +#include "src/objects-inl.h" // Needed for write barriers #include "src/objects/bigint.h" +#include "src/objects/maybe-object-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -22,7 +24,6 @@ CAST_ACCESSOR(FixedArrayBase) CAST_ACCESSOR(FixedDoubleArray) CAST_ACCESSOR(FixedTypedArrayBase) CAST_ACCESSOR(TemplateList) -CAST_ACCESSOR(FixedArrayOfWeakCells) CAST_ACCESSOR(WeakFixedArray) CAST_ACCESSOR(WeakArrayList) @@ -97,7 +98,7 @@ void FixedArray::set(int index, Object* value) { DCHECK_LT(index, this->length()); int offset = kHeaderSize + index * kPointerSize; RELAXED_WRITE_FIELD(this, offset, value); - WRITE_BARRIER(Heap::FromWritableHeapObject(this), this, offset, value); + WRITE_BARRIER(this, offset, value); } void FixedArray::set(int index, Object* value, WriteBarrierMode mode) { @@ -106,8 +107,7 @@ void FixedArray::set(int index, Object* value, WriteBarrierMode mode) { DCHECK_LT(index, this->length()); int offset = kHeaderSize + index * kPointerSize; RELAXED_WRITE_FIELD(this, offset, value); - CONDITIONAL_WRITE_BARRIER(Heap::FromWritableHeapObject(this), this, offset, - value, mode); + CONDITIONAL_WRITE_BARRIER(this, offset, value, mode); } void FixedArray::NoWriteBarrierSet(FixedArray* array, int index, @@ -243,7 +243,7 @@ void WeakFixedArray::Set(int index, MaybeObject* value) { DCHECK_LT(index, length()); int offset = OffsetOfElementAt(index); RELAXED_WRITE_FIELD(this, offset, value); - WEAK_WRITE_BARRIER(Heap::FromWritableHeapObject(this), this, offset, value); + WEAK_WRITE_BARRIER(this, offset, value); } void WeakFixedArray::Set(int index, MaybeObject* value, WriteBarrierMode mode) { @@ -251,8 +251,7 @@ void WeakFixedArray::Set(int index, MaybeObject* value, WriteBarrierMode mode) { DCHECK_LT(index, length()); int offset = OffsetOfElementAt(index); RELAXED_WRITE_FIELD(this, offset, value); - CONDITIONAL_WEAK_WRITE_BARRIER(Heap::FromWritableHeapObject(this), this, - offset, value, mode); + CONDITIONAL_WEAK_WRITE_BARRIER(this, offset, value, mode); } MaybeObject** WeakFixedArray::data_start() { @@ -278,52 +277,21 @@ void WeakArrayList::Set(int index, MaybeObject* value, WriteBarrierMode mode) { DCHECK_LT(index, this->capacity()); int offset = OffsetOfElementAt(index); RELAXED_WRITE_FIELD(this, offset, value); - CONDITIONAL_WEAK_WRITE_BARRIER(Heap::FromWritableHeapObject(this), this, - offset, value, mode); + CONDITIONAL_WEAK_WRITE_BARRIER(this, offset, value, mode); } MaybeObject** WeakArrayList::data_start() { return HeapObject::RawMaybeWeakField(this, kHeaderSize); } -Object* FixedArrayOfWeakCells::Get(int index) const { - Object* raw = FixedArray::cast(this)->get(index + kFirstIndex); - if (raw->IsSmi()) return raw; - DCHECK(raw->IsWeakCell()); - return WeakCell::cast(raw)->value(); -} - -bool FixedArrayOfWeakCells::IsEmptySlot(int index) const { - DCHECK(index < Length()); - return Get(index)->IsSmi(); -} - -void FixedArrayOfWeakCells::Clear(int index) { - FixedArray::cast(this)->set(index + kFirstIndex, Smi::kZero); -} - -int FixedArrayOfWeakCells::Length() const { - return FixedArray::cast(this)->length() - kFirstIndex; -} - -int FixedArrayOfWeakCells::last_used_index() const { - return Smi::ToInt(FixedArray::cast(this)->get(kLastUsedIndexIndex)); -} - -void FixedArrayOfWeakCells::set_last_used_index(int index) { - FixedArray::cast(this)->set(kLastUsedIndexIndex, Smi::FromInt(index)); -} - -template <class T> -T* FixedArrayOfWeakCells::Iterator::Next() { - if (list_ != nullptr) { - // Assert that list did not change during iteration. - DCHECK_EQ(last_used_index_, list_->last_used_index()); - while (index_ < list_->Length()) { - Object* item = list_->Get(index_++); - if (item != Empty()) return T::cast(item); +HeapObject* WeakArrayList::Iterator::Next() { + if (array_ != nullptr) { + while (index_ < array_->length()) { + MaybeObject* item = array_->Get(index_++); + DCHECK(item->IsWeakHeapObject() || item->IsClearedWeakHeapObject()); + if (!item->IsClearedWeakHeapObject()) return item->ToWeakHeapObject(); } - list_ = nullptr; + array_ = nullptr; } return nullptr; } @@ -438,6 +406,11 @@ Handle<PodArray<T>> PodArray<T>::New(Isolate* isolate, int length, isolate->factory()->NewByteArray(length * sizeof(T), pretenure)); } +template <class T> +int PodArray<T>::length() { + return ByteArray::length() / sizeof(T); +} + void* FixedTypedArrayBase::external_pointer() const { intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); return reinterpret_cast<void*>(ptr); @@ -458,9 +431,9 @@ void* FixedTypedArrayBase::DataPtr() { int FixedTypedArrayBase::ElementSize(InstanceType type) { int element_size; switch (type) { -#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ - case FIXED_##TYPE##_ARRAY_TYPE: \ - element_size = size; \ +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \ + case FIXED_##TYPE##_ARRAY_TYPE: \ + element_size = sizeof(ctype); \ break; TYPED_ARRAYS(TYPED_ARRAY_CASE) @@ -688,9 +661,10 @@ inline uint64_t FixedTypedArray<BigUint64ArrayTraits>::FromHandle( } template <class Traits> -Handle<Object> FixedTypedArray<Traits>::get(FixedTypedArray<Traits>* array, +Handle<Object> FixedTypedArray<Traits>::get(Isolate* isolate, + FixedTypedArray<Traits>* array, int index) { - return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index)); + return Traits::ToHandle(isolate, array->get_scalar(index)); } template <class Traits> |