5 #ifndef V8_OBJECTS_JS_ARRAY_INL_H_ 6 #define V8_OBJECTS_JS_ARRAY_INL_H_ 8 #include "src/objects/js-array.h" 10 #include "src/objects-inl.h" 13 #include "src/objects/object-macros.h" 18 CAST_ACCESSOR(JSArray)
19 CAST_ACCESSOR(JSArrayIterator)
21 ACCESSORS(JSArray, length, Object, kLengthOffset)
23 void JSArray::set_length(Smi length) {
25 set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER);
28 bool JSArray::SetLengthWouldNormalize(Heap* heap,
uint32_t new_length) {
29 return new_length > kMaxFastArrayLength;
32 bool JSArray::AllowsSetLength() {
33 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
34 DCHECK(result == !HasFixedTypedArrayElements());
38 void JSArray::SetContent(Handle<JSArray> array,
39 Handle<FixedArrayBase> storage) {
40 EnsureCanContainElements(array, storage, storage->length(),
41 ALLOW_COPIED_DOUBLE_ELEMENTS);
44 (storage->map() == array->GetReadOnlyRoots().fixed_double_array_map() &&
45 IsDoubleElementsKind(array->GetElementsKind())) ||
46 ((storage->map() != array->GetReadOnlyRoots().fixed_double_array_map()) &&
47 (IsObjectElementsKind(array->GetElementsKind()) ||
48 (IsSmiElementsKind(array->GetElementsKind()) &&
49 Handle<FixedArray>::cast(storage)->ContainsOnlySmisOrHoles()))));
50 array->set_elements(*storage);
51 array->set_length(Smi::FromInt(storage->length()));
54 bool JSArray::HasArrayPrototype(Isolate* isolate) {
55 return map()->prototype() == *isolate->initial_array_prototype();
58 ACCESSORS(JSArrayIterator, iterated_object, Object, kIteratedObjectOffset)
59 ACCESSORS(JSArrayIterator, next_index, Object, kNextIndexOffset)
61 IterationKind JSArrayIterator::kind()
const {
62 return static_cast<IterationKind
>(
63 Smi::cast(READ_FIELD(
this, kKindOffset))->value());
66 void JSArrayIterator::set_kind(IterationKind kind) {
67 WRITE_FIELD(
this, kKindOffset, Smi::FromInt(static_cast<int>(kind)));
73 #include "src/objects/object-macros-undef.h" 75 #endif // V8_OBJECTS_JS_ARRAY_INL_H_