diff options
Diffstat (limited to 'deps/v8/src/objects/fixed-array-inl.h')
-rw-r--r-- | deps/v8/src/objects/fixed-array-inl.h | 93 |
1 files changed, 34 insertions, 59 deletions
diff --git a/deps/v8/src/objects/fixed-array-inl.h b/deps/v8/src/objects/fixed-array-inl.h index 4608f2ea21a..174d4abc5b4 100644 --- a/deps/v8/src/objects/fixed-array-inl.h +++ b/deps/v8/src/objects/fixed-array-inl.h @@ -21,55 +21,35 @@ #include "src/roots/roots-inl.h" #include "src/sanitizer/tsan.h" +#include "torque-generated/class-definitions-tq-inl.h" + // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" namespace v8 { namespace internal { -OBJECT_CONSTRUCTORS_IMPL(FixedArrayBase, HeapObject) -OBJECT_CONSTRUCTORS_IMPL(FixedArray, FixedArrayBase) -OBJECT_CONSTRUCTORS_IMPL(FixedDoubleArray, FixedArrayBase) -OBJECT_CONSTRUCTORS_IMPL(ArrayList, FixedArray) -OBJECT_CONSTRUCTORS_IMPL(ByteArray, FixedArrayBase) -OBJECT_CONSTRUCTORS_IMPL(TemplateList, FixedArray) -OBJECT_CONSTRUCTORS_IMPL(WeakFixedArray, HeapObject) -OBJECT_CONSTRUCTORS_IMPL(WeakArrayList, HeapObject) - -FixedArrayBase::FixedArrayBase(Address ptr, AllowInlineSmiStorage allow_smi) - : HeapObject(ptr, allow_smi) { - SLOW_DCHECK( - (allow_smi == AllowInlineSmiStorage::kAllowBeingASmi && IsSmi()) || - IsFixedArrayBase()); -} - -ByteArray::ByteArray(Address ptr, AllowInlineSmiStorage allow_smi) - : FixedArrayBase(ptr, allow_smi) { - SLOW_DCHECK( - (allow_smi == AllowInlineSmiStorage::kAllowBeingASmi && IsSmi()) || - IsByteArray()); -} +TQ_OBJECT_CONSTRUCTORS_IMPL(FixedArrayBase) +FixedArrayBase::FixedArrayBase(Address ptr, + HeapObject::AllowInlineSmiStorage allow_smi) + : TorqueGeneratedFixedArrayBase(ptr, allow_smi) {} +TQ_OBJECT_CONSTRUCTORS_IMPL(FixedArray) +TQ_OBJECT_CONSTRUCTORS_IMPL(FixedDoubleArray) +TQ_OBJECT_CONSTRUCTORS_IMPL(ArrayList) +TQ_OBJECT_CONSTRUCTORS_IMPL(ByteArray) +ByteArray::ByteArray(Address ptr, HeapObject::AllowInlineSmiStorage allow_smi) + : TorqueGeneratedByteArray(ptr, allow_smi) {} +TQ_OBJECT_CONSTRUCTORS_IMPL(TemplateList) +TQ_OBJECT_CONSTRUCTORS_IMPL(WeakFixedArray) +TQ_OBJECT_CONSTRUCTORS_IMPL(WeakArrayList) NEVER_READ_ONLY_SPACE_IMPL(WeakArrayList) -CAST_ACCESSOR(ArrayList) -CAST_ACCESSOR(ByteArray) -CAST_ACCESSOR(FixedArray) -CAST_ACCESSOR(FixedArrayBase) -CAST_ACCESSOR(FixedDoubleArray) -CAST_ACCESSOR(TemplateList) -CAST_ACCESSOR(WeakFixedArray) -CAST_ACCESSOR(WeakArrayList) - -SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) -SMI_ACCESSORS(WeakFixedArray, length, kLengthOffset) SYNCHRONIZED_SMI_ACCESSORS(WeakFixedArray, length, kLengthOffset) -SMI_ACCESSORS(WeakArrayList, capacity, kCapacityOffset) SYNCHRONIZED_SMI_ACCESSORS(WeakArrayList, capacity, kCapacityOffset) -SMI_ACCESSORS(WeakArrayList, length, kLengthOffset) Object FixedArrayBase::unchecked_synchronized_length() const { return ACQUIRE_READ_FIELD(*this, kLengthOffset); @@ -212,6 +192,19 @@ void FixedArray::CopyElements(Isolate* isolate, int dst_index, FixedArray src, isolate->heap()->CopyRange(*this, dst_slot, src_slot, len, mode); } +// Due to left- and right-trimming, concurrent visitors need to read the length +// with acquire semantics. +// TODO(ulan): Acquire should not be needed anymore. +inline int FixedArray::AllocatedSize() { + return SizeFor(synchronized_length()); +} +inline int WeakFixedArray::AllocatedSize() { + return SizeFor(synchronized_length()); +} +inline int WeakArrayList::AllocatedSize() { + return SizeFor(synchronized_capacity()); +} + // Perform a binary search in a fixed array. template <SearchMode search_mode, typename T> int BinarySearch(T* array, Name name, int valid_entries, @@ -392,28 +385,15 @@ MaybeObject WeakFixedArray::Get(int index) const { MaybeObject WeakFixedArray::Get(const Isolate* isolate, int index) const { DCHECK_LT(static_cast<unsigned>(index), static_cast<unsigned>(length())); - return TaggedField<MaybeObject>::Relaxed_Load(isolate, *this, - OffsetOfElementAt(index)); -} - -void WeakFixedArray::Set(int index, MaybeObject value) { - DCHECK_GE(index, 0); - DCHECK_LT(index, length()); - int offset = OffsetOfElementAt(index); - RELAXED_WRITE_WEAK_FIELD(*this, offset, value); - WEAK_WRITE_BARRIER(*this, offset, value); + return objects(isolate, index); } void WeakFixedArray::Set(int index, MaybeObject value, WriteBarrierMode mode) { - DCHECK_GE(index, 0); - DCHECK_LT(index, length()); - int offset = OffsetOfElementAt(index); - RELAXED_WRITE_WEAK_FIELD(*this, offset, value); - CONDITIONAL_WEAK_WRITE_BARRIER(*this, offset, value, mode); + set_objects(index, value, mode); } MaybeObjectSlot WeakFixedArray::data_start() { - return RawMaybeWeakField(kHeaderSize); + return RawMaybeWeakField(kObjectsOffset); } MaybeObjectSlot WeakFixedArray::RawFieldOfElementAt(int index) { @@ -440,20 +420,15 @@ MaybeObject WeakArrayList::Get(int index) const { MaybeObject WeakArrayList::Get(const Isolate* isolate, int index) const { DCHECK_LT(static_cast<unsigned>(index), static_cast<unsigned>(capacity())); - return TaggedField<MaybeObject>::Relaxed_Load(isolate, *this, - OffsetOfElementAt(index)); + return objects(isolate, index); } void WeakArrayList::Set(int index, MaybeObject value, WriteBarrierMode mode) { - DCHECK_GE(index, 0); - DCHECK_LT(index, this->capacity()); - int offset = OffsetOfElementAt(index); - RELAXED_WRITE_WEAK_FIELD(*this, offset, value); - CONDITIONAL_WEAK_WRITE_BARRIER(*this, offset, value, mode); + set_objects(index, value, mode); } MaybeObjectSlot WeakArrayList::data_start() { - return RawMaybeWeakField(kHeaderSize); + return RawMaybeWeakField(kObjectsOffset); } void WeakArrayList::CopyElements(Isolate* isolate, int dst_index, |