| // Copyright 2019 the V8 project authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| @cppObjectLayoutDefinition |
| extern class FixedArray extends FixedArrayBase { |
| objects[length]: Object; |
| } |
| |
| type EmptyFixedArray extends FixedArray; |
| |
| @cppObjectLayoutDefinition |
| extern class TrustedFixedArray extends TrustedFixedArrayBase { |
| objects[length]: Object; |
| } |
| |
| @cppObjectLayoutDefinition |
| extern class ProtectedFixedArray extends TrustedFixedArrayBase { |
| objects[length]: TrustedObject|Smi; |
| } |
| |
| @cppObjectLayoutDefinition |
| extern class WeakFixedArray extends FixedArrayBase { |
| objects[length]: MaybeObject; |
| } |
| |
| @cppObjectLayoutDefinition |
| extern class WeakHomomorphicFixedArray extends FixedArrayBase { |
| objects[length]: MaybeObject; |
| } |
| |
| @cppObjectLayoutDefinition |
| extern class TrustedWeakFixedArray extends TrustedFixedArrayBase { |
| objects[length]: MaybeObject; |
| } |
| |
| @cppObjectLayoutDefinition |
| extern class ProtectedWeakFixedArray extends TrustedFixedArrayBase { |
| // TODO(jkummerow): Define "TrustedMaybeObject" if we ever write Torque |
| // code accessing these values. |
| objects[length]: TrustedObject|Smi; |
| } |
| |
| @cppObjectLayoutDefinition |
| extern class ArrayList extends HeapObject { |
| const capacity: uint32; |
| length: uint32; |
| objects[capacity]: Object; |
| } |
| |
| @cppObjectLayoutDefinition |
| extern class WeakArrayList extends HeapObject { |
| const capacity: uint32; |
| length: uint32; |
| objects[capacity]: MaybeObject; |
| } |
| |
| extern operator '.objects[]' macro LoadFixedArrayElement( |
| FixedArray, intptr): Object; |
| extern operator '.objects[]' macro LoadFixedArrayElement( |
| FixedArray, Smi): Object; |
| extern operator '.objects[]' macro LoadFixedArrayElement( |
| FixedArray, constexpr int31): Object; |
| extern operator '.objects[]=' macro StoreFixedArrayElement( |
| FixedArray, intptr, Smi): void; |
| extern operator '.objects[]=' macro StoreFixedArrayElement( |
| FixedArray, Smi, Smi): void; |
| extern operator '.objects[]=' macro StoreFixedArrayElement( |
| FixedArray, intptr, HeapObject): void; |
| extern operator '.objects[]=' macro StoreFixedArrayElement( |
| FixedArray, intptr, Object): void; |
| extern operator '.objects[]=' macro StoreFixedArrayElement( |
| FixedArray, constexpr int31, Smi): void; |
| extern operator '.objects[]=' macro StoreFixedArrayElement( |
| FixedArray, constexpr int31, HeapObject): void; |
| extern operator '.objects[]=' macro StoreFixedArrayElement( |
| FixedArray, Smi, Object): void; |
| extern macro StoreFixedArrayElement( |
| FixedArray, Smi, Object, constexpr WriteBarrierMode): void; |
| extern macro StoreFixedArrayElement( |
| FixedArray, Smi, Smi, constexpr WriteBarrierMode): void; |
| extern macro StoreFixedArrayElement( |
| FixedArray, constexpr int31, Object, constexpr WriteBarrierMode): void; |
| extern macro StoreFixedArrayElement( |
| FixedArray, constexpr int31, Smi, constexpr WriteBarrierMode): void; |
| extern macro StoreFixedArrayElement( |
| FixedArray, intptr, Object, constexpr WriteBarrierMode): void; |
| extern macro StoreFixedArrayElement( |
| FixedArray, intptr, Smi, constexpr WriteBarrierMode): void; |
| operator '[]=' macro StoreFixedArrayDirect( |
| a: FixedArray, i: Smi, v: Object): void { |
| a.objects[i] = v; |
| } |
| extern macro AllocateFixedArray( |
| constexpr ElementsKind, intptr): FixedArrayBase; |
| extern macro AllocateFixedArray( |
| constexpr ElementsKind, intptr, constexpr AllocationFlag): FixedArrayBase; |
| |
| extern macro FillEntireFixedArrayWithSmiZero( |
| constexpr ElementsKind, FixedArray, intptr): void; |
| |
| extern macro AllocateZeroedFixedArray(intptr): FixedArray; |
| extern macro CalculateNewElementsCapacity(Smi): Smi; |
| extern macro CalculateNewElementsCapacity(intptr): intptr; |
| |
| extern macro FillFixedArrayWithSmiZero( |
| constexpr ElementsKind, FixedArray, intptr, intptr): void; |
| |
| extern macro AllocateFixedArrayWithHoles(intptr): FixedArray; |
| extern macro AllocateFixedArrayWithHoles( |
| intptr, constexpr AllocationFlag): FixedArray; |
| extern macro CopyFixedArrayElements( |
| constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray, |
| intptr, intptr): void; |
| extern macro CopyFixedArrayElements( |
| constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray, |
| intptr, intptr, intptr): void; |
| |
| macro ExtractFixedArray( |
| source: FixedArray, first: intptr, count: intptr, capacity: intptr, |
| initialElement: Hole): FixedArray { |
| // TODO(turbofan): This should be optimized to use memcpy for initialization. |
| return NewFixedArray( |
| capacity, |
| IteratorSequence<Object>( |
| (&source.objects).Iterator(first, first + count), |
| ConstantIterator(initialElement))); |
| } |
| |
| namespace runtime { |
| extern runtime FatalProcessOutOfMemoryInvalidArrayLength(NoContext): never; |
| } |
| |
| @if(TAGGED_SIZE_8_BYTES) |
| macro NewFixedArray<Iterator: type>( |
| length: intptr, it: Iterator): FixedArray { |
| const length: uint32 = Unsigned(Convert<int32>(length)); |
| if (length == 0) return kEmptyFixedArray; |
| if (length > kFixedArrayMaxLength) deferred { |
| runtime::FatalProcessOutOfMemoryInvalidArrayLength(kNoContext); |
| } |
| return new FixedArray{ |
| map: kFixedArrayMap, |
| length, |
| optional_padding: 0, |
| objects: ...it |
| }; |
| } |
| |
| @ifnot(TAGGED_SIZE_8_BYTES) |
| macro NewFixedArray<Iterator: type>( |
| length: intptr, it: Iterator): FixedArray { |
| const length: uint32 = Unsigned(Convert<int32>(length)); |
| if (length == 0) return kEmptyFixedArray; |
| if (length > kFixedArrayMaxLength) deferred { |
| runtime::FatalProcessOutOfMemoryInvalidArrayLength(kNoContext); |
| } |
| return new FixedArray{map: kFixedArrayMap, length, objects: ...it}; |
| } |