63 #define ELEMENTS_LIST(V) \
64 V(FastPackedSmiElementsAccessor, FAST_SMI_ELEMENTS, FixedArray) \
65 V(FastHoleySmiElementsAccessor, FAST_HOLEY_SMI_ELEMENTS, \
67 V(FastPackedObjectElementsAccessor, FAST_ELEMENTS, FixedArray) \
68 V(FastHoleyObjectElementsAccessor, FAST_HOLEY_ELEMENTS, FixedArray) \
69 V(FastPackedDoubleElementsAccessor, FAST_DOUBLE_ELEMENTS, \
71 V(FastHoleyDoubleElementsAccessor, FAST_HOLEY_DOUBLE_ELEMENTS, \
73 V(DictionaryElementsAccessor, DICTIONARY_ELEMENTS, \
74 SeededNumberDictionary) \
75 V(SloppyArgumentsElementsAccessor, SLOPPY_ARGUMENTS_ELEMENTS, \
77 V(ExternalInt8ElementsAccessor, EXTERNAL_INT8_ELEMENTS, \
79 V(ExternalUint8ElementsAccessor, \
80 EXTERNAL_UINT8_ELEMENTS, ExternalUint8Array) \
81 V(ExternalInt16ElementsAccessor, EXTERNAL_INT16_ELEMENTS, \
83 V(ExternalUint16ElementsAccessor, \
84 EXTERNAL_UINT16_ELEMENTS, ExternalUint16Array) \
85 V(ExternalInt32ElementsAccessor, EXTERNAL_INT32_ELEMENTS, \
87 V(ExternalUint32ElementsAccessor, \
88 EXTERNAL_UINT32_ELEMENTS, ExternalUint32Array) \
89 V(ExternalFloat32ElementsAccessor, \
90 EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array) \
91 V(ExternalFloat64ElementsAccessor, \
92 EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array) \
93 V(ExternalUint8ClampedElementsAccessor, \
94 EXTERNAL_UINT8_CLAMPED_ELEMENTS, \
95 ExternalUint8ClampedArray) \
96 V(FixedUint8ElementsAccessor, UINT8_ELEMENTS, FixedUint8Array) \
97 V(FixedInt8ElementsAccessor, INT8_ELEMENTS, FixedInt8Array) \
98 V(FixedUint16ElementsAccessor, UINT16_ELEMENTS, FixedUint16Array) \
99 V(FixedInt16ElementsAccessor, INT16_ELEMENTS, FixedInt16Array) \
100 V(FixedUint32ElementsAccessor, UINT32_ELEMENTS, FixedUint32Array) \
101 V(FixedInt32ElementsAccessor, INT32_ELEMENTS, FixedInt32Array) \
102 V(FixedFloat32ElementsAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \
103 V(FixedFloat64ElementsAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \
104 V(FixedUint8ClampedElementsAccessor, UINT8_CLAMPED_ELEMENTS, \
105 FixedUint8ClampedArray)
113 #define ELEMENTS_TRAITS(Class, KindParam, Store) \
114 template<> class ElementsKindTraits<KindParam> { \
116 static const ElementsKind Kind = KindParam; \
117 typedef Store BackingStore; \
120 #undef ELEMENTS_TRAITS
128 Object* key = *key_handle;
129 int len0 = array->length();
130 for (
int i = 0;
i < len0;
i++) {
131 Object* element = array->get(
i);
132 if (element->IsSmi() && element == key)
return true;
133 if (element->IsString() &&
134 key->IsString() && String::cast(element)->Equals(String::cast(key))) {
145 HandleVector<Object>(
NULL, 0)),
159 int copy_size = raw_copy_size;
160 if (raw_copy_size < 0) {
163 copy_size =
Min(from_base->
length() - from_start,
164 to_base->
length() - to_start);
166 int start = to_start + copy_size;
167 int length = to_base->
length() - start;
170 MemsetPointer(FixedArray::cast(to_base)->data_start() + start,
171 heap->the_hole_value(), length);
175 DCHECK((copy_size +
static_cast<int>(to_start)) <= to_base->
length() &&
176 (copy_size +
static_cast<int>(from_start)) <= from_base->
length());
177 if (copy_size == 0)
return;
178 FixedArray* from = FixedArray::cast(from_base);
185 reinterpret_cast<Object**
>(from_address) + from_start,
186 static_cast<size_t>(copy_size));
191 heap->RecordWrites(
to->address(),
192 to->OffsetOfElementAt(to_start),
205 int copy_size = raw_copy_size;
207 if (raw_copy_size < 0) {
212 int start = to_start + copy_size;
213 int length = to_base->
length() - start;
216 MemsetPointer(FixedArray::cast(to_base)->data_start() + start,
217 heap->the_hole_value(), length);
221 DCHECK(to_base != from_base);
223 if (copy_size == 0)
return;
226 if (to_start + copy_size > to_length) {
227 copy_size = to_length - to_start;
229 for (
int i = 0;
i < copy_size;
i++) {
233 DCHECK(!value->IsTheHole());
236 to->set_the_hole(
i + to_start);
241 heap->RecordWrites(
to->address(),
242 to->OffsetOfElementAt(to_start),
259 int copy_size = raw_copy_size;
260 if (raw_copy_size < 0) {
264 copy_size =
Min(from_base->
length() - from_start,
265 to_base->
length() - to_start);
270 int start = to_start;
271 int length = to_base->
length() - start;
274 MemsetPointer(FixedArray::cast(to_base)->data_start() + start,
275 heap->the_hole_value(), length);
279 DCHECK((copy_size +
static_cast<int>(to_start)) <= to_base->
length() &&
280 (copy_size +
static_cast<int>(from_start)) <= from_base->
length());
281 if (copy_size == 0)
return;
288 for (
int i = 0;
i < copy_size; ++
i) {
304 uint32_t to_start,
int raw_copy_size) {
306 int copy_size = raw_copy_size;
307 if (raw_copy_size < 0) {
310 copy_size =
Min(from_base->
length() - from_start,
311 to_base->
length() - to_start);
313 for (
int i = to_start + copy_size;
i < to_base->
length(); ++
i) {
314 FixedDoubleArray::cast(to_base)->set_the_hole(
i);
318 DCHECK((copy_size +
static_cast<int>(to_start)) <= to_base->
length() &&
319 (copy_size +
static_cast<int>(from_start)) <= from_base->
length());
320 if (copy_size == 0)
return;
329 reinterpret_cast<Object**
>(from_address),
330 static_cast<size_t>(words_per_double * copy_size));
339 int copy_size = raw_copy_size;
340 if (raw_copy_size < 0) {
343 copy_size = from_base->
length() - from_start;
345 for (
int i = to_start + copy_size;
i < to_base->
length(); ++
i) {
346 FixedDoubleArray::cast(to_base)->set_the_hole(
i);
350 DCHECK((copy_size +
static_cast<int>(to_start)) <= to_base->
length() &&
351 (copy_size +
static_cast<int>(from_start)) <= from_base->
length());
352 if (copy_size == 0)
return;
353 FixedArray* from = FixedArray::cast(from_base);
357 from_start < from_end; from_start++, to_start++) {
358 Object* hole_or_smi = from->
get(from_start);
359 if (hole_or_smi == the_hole) {
360 to->set_the_hole(to_start);
362 to->set(to_start, Smi::cast(hole_or_smi)->value());
374 int copy_size = raw_copy_size;
376 if (raw_copy_size < 0) {
379 copy_size = packed_size - from_start;
381 to_end = to_base->
length();
382 for (
uint32_t i = to_start + copy_size;
i < to_end; ++
i) {
383 FixedDoubleArray::cast(to_base)->set_the_hole(
i);
386 to_end = to_start +
static_cast<uint32_t>(copy_size);
389 to_end = to_start +
static_cast<uint32_t>(copy_size);
392 DCHECK(packed_size >= 0 && packed_size <= copy_size);
393 DCHECK((copy_size +
static_cast<int>(to_start)) <= to_base->
length() &&
394 (copy_size +
static_cast<int>(from_start)) <= from_base->
length());
395 if (copy_size == 0)
return;
396 FixedArray* from = FixedArray::cast(from_base);
399 from_start < from_end; from_start++, to_start++) {
401 DCHECK(!smi->IsTheHole());
402 to->set(to_start, Smi::cast(smi)->value());
410 uint32_t to_start,
int raw_copy_size) {
412 int copy_size = raw_copy_size;
413 if (raw_copy_size < 0) {
416 copy_size = from_base->
length() - from_start;
418 for (
int i = to_start + copy_size;
i < to_base->
length(); ++
i) {
419 FixedDoubleArray::cast(to_base)->set_the_hole(
i);
423 DCHECK((copy_size +
static_cast<int>(to_start)) <= to_base->
length() &&
424 (copy_size +
static_cast<int>(from_start)) <= from_base->
length());
425 if (copy_size == 0)
return;
426 FixedArray* from = FixedArray::cast(from_base);
429 for (
uint32_t from_end = from_start + copy_size;
430 from_start < from_end; from_start++, to_start++) {
431 Object* hole_or_object = from->
get(from_start);
432 if (hole_or_object == the_hole) {
433 to->set_the_hole(to_start);
435 to->set(to_start, hole_or_object->
Number());
448 int copy_size = raw_copy_size;
454 for (
int i = to_start + copy_size;
i < to_base->
length(); ++
i) {
455 FixedDoubleArray::cast(to_base)->set_the_hole(
i);
459 if (copy_size == 0)
return;
462 if (to_start + copy_size > to_length) {
463 copy_size = to_length - to_start;
465 for (
int i = 0;
i < copy_size;
i++) {
470 to->set_the_hole(
i + to_start);
479 PrintF(
"unknown location (no JavaScript frames present)");
483 if (raw_frame->is_internal()) {
485 Builtins::kFunctionApply);
486 if (raw_frame->unchecked_code() == apply_builtin) {
489 raw_frame = it.
frame();
497 bool allow_appending) {
500 const char* elements_type =
"array";
501 if (obj->IsJSArray()) {
502 JSArray* array = JSArray::cast(*obj);
503 raw_length = array->length();
506 elements_type =
"object";
509 if (raw_length->IsNumber()) {
510 double n = raw_length->
Number();
514 if (allow_appending) compare_length++;
515 if (key >= compare_length) {
516 PrintF(
"[OOB %s %s (%s length = %d, element accessed = %d) in ",
517 elements_type, op, elements_type,
518 static_cast<int>(int32_length),
519 static_cast<int>(key));
524 PrintF(
"[%s elements length not integer value in ", elements_type);
529 PrintF(
"[%s elements length not a number in ", elements_type);
553 template <
typename ElementsAccessorSubclass,
554 typename ElementsTraitsParam>
564 return ElementsTraits::Kind;
572 if (!fixed_array_base->IsHeapObject())
return;
574 if (fixed_array_base->IsFiller())
return;
576 if (holder->IsJSArray()) {
578 if (length_obj->IsSmi()) {
579 length = Smi::cast(length_obj)->value();
582 length = fixed_array_base->length();
584 ElementsAccessorSubclass::ValidateContents(holder, length);
589 ElementsAccessorSubclass::ValidateImpl(holder);
596 return ElementsAccessorSubclass::GetAttributesImpl(
597 receiver, holder, key, backing_store) !=
ABSENT;
605 return ElementsAccessorSubclass::HasElementImpl(
606 receiver, holder, key, backing_store);
615 FLAG_trace_js_array_abuse) {
620 FLAG_trace_external_array_abuse) {
624 return ElementsAccessorSubclass::GetImpl(
625 receiver, holder, key, backing_store);
633 if (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
636 return backing_store->GetIsolate()->factory()->the_hole_value();
645 return ElementsAccessorSubclass::GetAttributesImpl(
646 receiver, holder, key, backing_store);
654 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
667 return ElementsAccessorSubclass::GetAccessorPairImpl(
668 receiver, holder, key, backing_store);
682 return ElementsAccessorSubclass::SetLengthImpl(
683 array, length,
handle(array->elements()));
695 ElementsAccessorSubclass::
696 SetFastElementsCapacityAndLength(array, capacity, length);
732 ElementsAccessorSubclass::CopyElementsImpl(*from, from_start, *
to,
746 from_holder->IsJSArray();
749 Smi::cast(JSArray::cast(from_holder)->length())->value();
750 if (copy_size >= 0 && packed_size > copy_size) {
751 packed_size = copy_size;
764 ElementsAccessorSubclass::CopyElementsImpl(
765 from, from_start, *
to, from_kind, to_start, packed_size, copy_size);
773 int len0 =
to->length();
774 #ifdef ENABLE_SLOW_DCHECKS
776 for (
int i = 0;
i < len0;
i++) {
784 uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(from);
785 if (len1 == 0)
return to;
787 Isolate* isolate = from->GetIsolate();
792 uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from,
y);
793 if (ElementsAccessorSubclass::HasElementImpl(
794 receiver, holder, key, from)) {
798 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from),
801 DCHECK(!value->IsTheHole());
808 if (extra == 0)
return to;
817 for (
int i = 0;
i < len0;
i++) {
819 DCHECK(e->IsString() || e->IsNumber());
820 result->set(
i, e,
mode);
827 ElementsAccessorSubclass::GetKeyForIndexImpl(from,
y);
828 if (ElementsAccessorSubclass::HasElementImpl(
829 receiver, holder, key, from)) {
833 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from),
835 if (!value->IsTheHole() && !
HasKey(
to, value)) {
836 result->set(len0 + index, *value);
847 return backing_store->length();
852 return ElementsAccessorSubclass::GetCapacityImpl(backing_store);
862 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index);
871 template<
typename FastElementsAccessorSubclass,
891 Isolate* isolate = array->GetIsolate();
892 uint32_t old_capacity = backing_store->length();
894 bool same_or_smaller_size = old_length->IsSmi() &&
905 if (length <= old_capacity) {
906 if (array->HasFastSmiOrObjectElements()) {
909 if (2 * length <= old_capacity) {
912 array->initialize_elements();
915 *backing_store, old_capacity - length);
920 for (
int i = length;
i < old_length;
i++) {
924 return length_object;
930 FastElementsAccessorSubclass::SetFastElementsCapacityAndLength(
931 array, new_capacity, length);
933 return length_object;
939 DCHECK(obj->HasFastSmiOrObjectElements() ||
940 obj->HasFastDoubleElements() ||
941 obj->HasFastArgumentsElements());
942 Isolate* isolate = obj->GetIsolate();
943 Heap* heap = obj->GetHeap();
945 if (*elements == heap->empty_fixed_array()) {
946 return isolate->
factory()->true_value();
949 bool is_sloppy_arguments_elements_map =
950 backing_store->map() == heap->sloppy_arguments_elements_map();
951 if (is_sloppy_arguments_elements_map) {
959 : backing_store->length());
961 if (!is_sloppy_arguments_elements_map) {
971 backing_store->set_the_hole(key);
976 const int kMinLengthForSparsenessCheck = 64;
977 if (backing_store->length() >= kMinLengthForSparsenessCheck &&
979 ((key > 0 && backing_store->is_the_hole(key - 1)) ||
980 (key + 1 < length && backing_store->is_the_hole(key + 1)))) {
982 for (
int i = 0;
i < backing_store->length(); ++
i) {
983 if (!backing_store->is_the_hole(
i)) ++num_used;
985 if (4 * num_used > backing_store->length())
break;
987 if (4 * num_used <= backing_store->length()) {
992 return isolate->
factory()->true_value();
1007 if (key >=
static_cast<uint32_t>(backing_store->length())) {
1015 Isolate* isolate = holder->GetIsolate();
1018 Map*
map = elements->map();
1020 (
map == isolate->
heap()->fixed_array_map() ||
1021 map == isolate->
heap()->fixed_cow_array_map())) ||
1023 ((
map == isolate->
heap()->fixed_array_map() && length == 0) ||
1024 map == isolate->
heap()->fixed_double_array_map())));
1026 for (
int i = 0;
i < length;
i++) {
1030 BackingStore::get(backing_store,
i)->IsSmi()) ||
1032 backing_store->is_the_hole(
i)));
1042 if (array->IsDictionary()) {
1050 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1051 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
1052 return EXTERNAL_##TYPE##_ELEMENTS; \
1053 case FIXED_##TYPE##_ARRAY_TYPE: \
1054 return TYPE##_ELEMENTS;
1057 #undef TYPED_ARRAY_CASE
1066 template<
typename FastElementsAccessorSubclass,
1067 typename KindTraits>
1073 KindTraits>(
name) {}
1082 uint32_t to_start,
int packed_size,
1086 switch (from_kind) {
1092 to_start, copy_size);
1098 from, from_start,
to, to_kind, to_start, copy_size);
1109 FixedArray* parameter_map = FixedArray::cast(from);
1113 to_start, packed_size, copy_size);
1116 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1117 case EXTERNAL_##TYPE##_ELEMENTS: \
1118 case TYPE##_ELEMENTS: \
1121 #undef TYPED_ARRAY_CASE
1131 obj->HasFastSmiElements()
1135 obj, capacity, length, set_capacity_mode);
1142 FastPackedSmiElementsAccessor,
1143 ElementsKindTraits<FAST_SMI_ELEMENTS> > {
1154 FastHoleySmiElementsAccessor,
1155 ElementsKindTraits<FAST_HOLEY_SMI_ELEMENTS> > {
1166 FastPackedObjectElementsAccessor,
1167 ElementsKindTraits<FAST_ELEMENTS> > {
1178 FastHoleyObjectElementsAccessor,
1179 ElementsKindTraits<FAST_HOLEY_ELEMENTS> > {
1188 template<
typename FastElementsAccessorSubclass,
1189 typename KindTraits>
1195 KindTraits>(
name) {}
1206 uint32_t to_start,
int packed_size,
1209 switch (from_kind) {
1212 packed_size, copy_size);
1232 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1233 case EXTERNAL_##TYPE##_ELEMENTS: \
1234 case TYPE##_ELEMENTS: \
1237 #undef TYPED_ARRAY_CASE
1245 FastPackedDoubleElementsAccessor,
1246 ElementsKindTraits<FAST_DOUBLE_ELEMENTS> > {
1259 FastHoleyDoubleElementsAccessor,
1260 ElementsKindTraits<FAST_HOLEY_DOUBLE_ELEMENTS> > {
1273 template<ElementsKind Kind>
1276 ElementsKindTraits<Kind> > {
1297 return backing_store->GetIsolate()->factory()->undefined_value();
1325 return obj->GetIsolate()->factory()->true_value();
1334 return key < capacity;
1340 #define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
1341 typedef TypedElementsAccessor<EXTERNAL_##TYPE##_ELEMENTS> \
1342 External##Type##ElementsAccessor;
1345 #undef EXTERNAL_ELEMENTS_ACCESSOR
1347 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
1348 typedef TypedElementsAccessor<TYPE##_ELEMENTS > \
1349 Fixed##Type##ElementsAccessor;
1352 #undef FIXED_ELEMENTS_ACCESSOR
1358 ElementsKindTraits<DICTIONARY_ELEMENTS> > {
1373 Isolate* isolate = array->GetIsolate();
1374 int capacity = dict->Capacity();
1377 if (new_length < old_length) {
1380 for (
int i = 0;
i < capacity;
i++) {
1383 if (key->IsNumber()) {
1385 if (new_length <= number && number < old_length) {
1386 PropertyDetails details = dict->DetailsAt(
i);
1387 if (!details.IsConfigurable()) new_length = number + 1;
1391 if (new_length != length) {
1392 length_object = isolate->
factory()->NewNumberFromUint(new_length);
1396 if (new_length == 0) {
1402 int removed_entries = 0;
1404 for (
int i = 0;
i < capacity;
i++) {
1406 if (key->IsNumber()) {
1408 if (new_length <= number && number < old_length) {
1409 dict->SetEntry(
i, the_hole_value, the_hole_value);
1416 dict->ElementsRemoved(removed_entries);
1418 return length_object;
1425 Isolate* isolate = obj->GetIsolate();
1431 backing_store =
handle(FixedArray::cast(backing_store->get(1)), isolate);
1435 int entry = dictionary->FindEntry(key);
1439 if (*result == *isolate->
factory()->false_value()) {
1448 return isolate->
factory()->false_value();
1454 FixedArray::cast(obj->elements())->set(1, *new_elements);
1456 obj->set_elements(*new_elements);
1459 return isolate->
factory()->true_value();
1464 uint32_t to_start,
int packed_size,
1488 Isolate* isolate = backing_store->GetIsolate();
1489 int entry = backing_store->FindEntry(key);
1492 PropertyDetails details = backing_store->DetailsAt(entry);
1495 obj, receiver, element, key, obj);
1500 return isolate->
factory()->the_hole_value();
1510 int entry = dictionary->FindEntry(key);
1512 return dictionary->DetailsAt(entry).attributes();
1524 int entry = backing_store->FindEntry(key);
1526 backing_store->DetailsAt(entry).type() ==
CALLBACKS &&
1527 backing_store->ValueAt(entry)->IsAccessorPair()) {
1528 return handle(AccessorPair::cast(backing_store->ValueAt(entry)));
1547 Object* key = dict->KeyAt(index);
1548 return Smi::cast(key)->value();
1554 SloppyArgumentsElementsAccessor,
1555 ElementsKindTraits<SLOPPY_ARGUMENTS_ELEMENTS> > {
1571 Isolate* isolate = obj->GetIsolate();
1574 if (!probe->IsTheHole()) {
1578 DCHECK(!context->
get(context_index)->IsTheHole());
1579 return handle(context->
get(context_index), isolate);
1588 receiver, obj, key, arguments),
1591 if (result->IsAliasedArgumentsEntry()) {
1596 DCHECK(!context->
get(context_index)->IsTheHole());
1597 return handle(context->
get(context_index), isolate);
1611 if (!probe->IsTheHole()) {
1617 receiver, obj, key, arguments);
1628 if (!probe->IsTheHole()) {
1634 receiver, obj, key, arguments);
1652 Isolate* isolate = obj->GetIsolate();
1655 if (!probe->IsTheHole()) {
1659 parameter_map->set_the_hole(key + 2);
1662 if (arguments->IsDictionary()) {
1671 return isolate->
factory()->true_value();
1676 uint32_t to_start,
int packed_size,
1684 FixedArrayBase::cast(parameter_map->get(1)));
1685 return Max(
static_cast<uint32_t>(parameter_map->length() - 2),
1700 if (!probe->IsTheHole()) {
1703 Isolate* isolate = holder->GetIsolate();
1710 accessor->
Get(receiver, holder, key, arguments),
1712 return !value->IsTheHole();
1720 Isolate* isolate = holder->GetIsolate();
1721 uint32_t length = holder->IsJSArray()
1723 : parameter_map->length();
1724 return key < (length - 2)
1725 ?
handle(parameter_map->get(key + 2), isolate)
1738 #define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind),
1740 #undef ACCESSOR_ARRAY
1743 STATIC_ASSERT((
sizeof(accessor_array) /
sizeof(*accessor_array)) ==
1752 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
1754 #undef ACCESSOR_DELETE
1759 template <
typename ElementsAccessorSub
class,
typename ElementsKindTraits>
1766 Isolate* isolate = obj->GetIsolate();
1773 smi_length->IsSmi()) {
1777 SetLengthWithoutNormalize(backing_store, array, smi_length, value);
1784 DCHECK(new_length->IsSmi() || new_length->IsHeapNumber() ||
1785 new_length->IsUndefined());
1786 if (new_length->IsSmi()) {
1789 }
else if (new_length->IsHeapNumber()) {
1790 array->set_length(*new_length);
1800 if (length->IsNumber()) {
1802 if (length->ToArrayIndex(&value)) {
1811 DCHECK(new_length->IsNumber());
1812 array->set_length(*new_length);
1822 new_backing_store->set(0, *length);
1832 if (args->length() == 1) {
1845 }
else if (len == 0) {
1858 if (args->length() == 0) {
1863 Factory* factory = array->GetIsolate()->factory();
1866 int number_of_elements = args->length();
1875 factory->NewFixedDoubleArray(number_of_elements));
1878 factory->NewFixedArrayWithHoles(number_of_elements));
1882 switch (array->GetElementsKind()) {
1886 for (
int index = 0; index < number_of_elements; index++) {
1896 for (
int index = 0; index < number_of_elements; index++) {
1897 object_elms->set(index, (*args)[index],
mode);
1905 for (
int index = 0; index < number_of_elements; index++) {
1906 double_elms->set(index, (*args)[index]->
Number());
1915 array->set_elements(*elms);
A JavaScript number value (ECMA-262, 4.3.20)
A single JavaScript stack frame.
int aliased_context_slot() const
Code * builtin(Name name)
static Context * cast(Object *context)
static bool HasElementImpl(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > store)
DictionaryElementsAccessor(const char *name)
static MUST_USE_RESULT MaybeHandle< Object > DeleteCommon(Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode)
static Handle< Object > SetLengthWithoutNormalize(Handle< FixedArrayBase > store, Handle< JSArray > array, Handle< Object > length_object, uint32_t length)
static MUST_USE_RESULT PropertyAttributes GetAttributesImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
static MUST_USE_RESULT MaybeHandle< Object > GetImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > store)
static uint32_t GetKeyForIndexImpl(Handle< FixedArrayBase > store, uint32_t index)
static MUST_USE_RESULT MaybeHandle< AccessorPair > GetAccessorPairImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > store)
static void CopyElementsImpl(FixedArrayBase *from, uint32_t from_start, FixedArrayBase *to, ElementsKind from_kind, uint32_t to_start, int packed_size, int copy_size)
virtual MUST_USE_RESULT MaybeHandle< Object > Delete(Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL OVERRIDE
Object * ValueAt(int entry)
static Handle< Object > DeleteProperty(Handle< SeededNumberDictionary > dictionary, int entry, JSObject::DeleteMode mode)
static MUST_USE_RESULT Handle< SeededNumberDictionary > Shrink(Handle< SeededNumberDictionary > dictionary, uint32_t key)
static void SetFastElementsCapacityAndLength(Handle< JSObject > obj, int capacity, int length)
virtual uint32_t GetCapacity(Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
virtual bool HasElement(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
virtual void SetCapacityAndLength(Handle< JSArray > array, int capacity, int length) FINAL OVERRIDE
static uint32_t GetKeyForIndexImpl(Handle< FixedArrayBase > backing_store, uint32_t index)
virtual void CopyElements(Handle< FixedArrayBase > from, uint32_t from_start, ElementsKind from_kind, Handle< FixedArrayBase > to, uint32_t to_start, int copy_size) FINAL OVERRIDE
static void ValidateContents(Handle< JSObject > holder, int length)
static bool HasElementImpl(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store)
ElementsAccessorBase(const char *name)
virtual MaybeHandle< FixedArray > AddElementsToFixedArray(Handle< Object > receiver, Handle< JSObject > holder, Handle< FixedArray > to, Handle< FixedArrayBase > from) FINAL OVERRIDE
ElementsTraitsParam::BackingStore BackingStore
static uint32_t GetCapacityImpl(Handle< FixedArrayBase > backing_store)
virtual MUST_USE_RESULT MaybeHandle< Object > SetLength(Handle< JSArray > array, Handle< Object > length) FINAL OVERRIDE
static MUST_USE_RESULT PropertyAttributes GetAttributesImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
static void ValidateImpl(Handle< JSObject > holder)
virtual MUST_USE_RESULT MaybeHandle< Object > Get(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
static MUST_USE_RESULT MaybeHandle< AccessorPair > GetAccessorPairImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
virtual uint32_t GetKeyForIndex(Handle< FixedArrayBase > backing_store, uint32_t index) FINAL OVERRIDE
static void CopyElementsImpl(FixedArrayBase *from, uint32_t from_start, FixedArrayBase *to, ElementsKind from_kind, uint32_t to_start, int packed_size, int copy_size)
virtual void CopyElements(JSObject *from_holder, uint32_t from_start, ElementsKind from_kind, Handle< FixedArrayBase > to, uint32_t to_start, int copy_size) FINAL OVERRIDE
ElementsTraitsParam ElementsTraits
virtual MUST_USE_RESULT PropertyAttributes GetAttributes(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase)
virtual MUST_USE_RESULT MaybeHandle< AccessorPair > GetAccessorPair(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
static MUST_USE_RESULT MaybeHandle< Object > SetLengthImpl(Handle< JSObject > obj, Handle< Object > length, Handle< FixedArrayBase > backing_store)
virtual void Validate(Handle< JSObject > holder) FINAL OVERRIDE
virtual MUST_USE_RESULT MaybeHandle< Object > Delete(Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode) OVERRIDE=0
virtual ElementsKind kind() const FINAL OVERRIDE
static MUST_USE_RESULT MaybeHandle< Object > GetImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
static const int kCopyToEndAndInitializeToHole
virtual MUST_USE_RESULT PropertyAttributes GetAttributes(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store)=0
virtual MUST_USE_RESULT MaybeHandle< Object > Get(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store)=0
static ElementsAccessor ** elements_accessors_
static void InitializeOncePerProcess()
static const int kCopyToEnd
const char * name() const
friend class SloppyArgumentsElementsAccessor
static ElementsAccessor * ForArray(Handle< FixedArrayBase > array)
virtual MUST_USE_RESULT MaybeHandle< AccessorPair > GetAccessorPair(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store)=0
FixedArrayBase BackingStore
Source to read snapshot and builtins files from.
FastDoubleElementsAccessor(const char *name)
static void CopyElementsImpl(FixedArrayBase *from, uint32_t from_start, FixedArrayBase *to, ElementsKind from_kind, uint32_t to_start, int packed_size, int copy_size)
static void SetFastElementsCapacityAndLength(Handle< JSObject > obj, uint32_t capacity, uint32_t length)
static void ValidateContents(Handle< JSObject > holder, int length)
static Handle< Object > SetLengthWithoutNormalize(Handle< FixedArrayBase > backing_store, Handle< JSArray > array, Handle< Object > length_object, uint32_t length)
FastElementsAccessor(const char *name)
virtual MaybeHandle< Object > Delete(Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL OVERRIDE
static Handle< Object > DeleteCommon(Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode)
static bool HasElementImpl(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store)
KindTraits::BackingStore BackingStore
FastHoleyDoubleElementsAccessor(const char *name)
FastHoleyObjectElementsAccessor(const char *name)
FastHoleySmiElementsAccessor(const char *name)
FastPackedDoubleElementsAccessor(const char *name)
FastPackedObjectElementsAccessor(const char *name)
FastPackedSmiElementsAccessor(const char *name)
static void SetFastElementsCapacityAndLength(Handle< JSObject > obj, uint32_t capacity, uint32_t length)
FastSmiOrObjectElementsAccessor(const char *name)
static void CopyElementsImpl(FixedArrayBase *from, uint32_t from_start, FixedArrayBase *to, ElementsKind from_kind, uint32_t to_start, int packed_size, int copy_size)
static const int kHeaderSize
static Handle< Object > get(Handle< FixedDoubleArray > array, int index)
static Handle< T > cast(Handle< S > that)
static const int kNotFound
Isolate * GetIsolate() const
bool InNewSpace(Object *object)
IncrementalMarking * incremental_marking()
void RightTrimFixedArray(FixedArrayBase *obj, int elements_to_trim)
void RecordWrites(HeapObject *obj)
static MUST_USE_RESULT MaybeHandle< Object > SetElementsLength(Handle< JSArray > array, Handle< Object > length)
static void SetContent(Handle< JSArray > array, Handle< FixedArrayBase > storage)
static const int kPreallocatedArrayElements
static void Initialize(Handle< JSArray > array, int capacity, int length=0)
static void ResetElements(Handle< JSObject > object)
static MUST_USE_RESULT MaybeHandle< Object > GetElementWithCallback(Handle< JSObject > object, Handle< Object > receiver, Handle< Object > structure, uint32_t index, Handle< Object > holder)
static Handle< FixedArray > SetFastElementsCapacityAndLength(Handle< JSObject > object, int capacity, int length, SetFastElementsCapacitySmiMode smi_mode)
static void SetFastDoubleElementsCapacityAndLength(Handle< JSObject > object, int capacity, int length)
static void TransitionElementsKind(Handle< JSObject > object, ElementsKind to_kind)
static const int kInitialMaxFastElementArray
static int NewElementsCapacity(int old_capacity)
static Handle< FixedArray > EnsureWritableFastElements(Handle< JSObject > object)
SetFastElementsCapacitySmiMode
static void ValidateElements(Handle< JSObject > object)
static void EnsureCanContainElements(Handle< JSObject > object, Object **elements, uint32_t count, EnsureElementsMode mode)
static Handle< SeededNumberDictionary > NormalizeElements(Handle< JSObject > object)
static void PrintTop(Isolate *isolate, FILE *file, bool print_args, bool print_line_number)
InstanceType instance_type()
static MUST_USE_RESULT MaybeHandle< Smi > ToSmi(Isolate *isolate, Handle< Object > object)
uint32_t max_number_key()
static void CopyElementsImpl(FixedArrayBase *from, uint32_t from_start, FixedArrayBase *to, ElementsKind from_kind, uint32_t to_start, int packed_size, int copy_size)
static uint32_t GetKeyForIndexImpl(Handle< FixedArrayBase > dict, uint32_t index)
static MUST_USE_RESULT PropertyAttributes GetAttributesImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
static bool HasElementImpl(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > parameters)
static MUST_USE_RESULT MaybeHandle< Object > SetLengthImpl(Handle< JSObject > obj, Handle< Object > length, Handle< FixedArrayBase > parameter_map)
static Handle< Object > GetParameterMapArg(Handle< JSObject > holder, Handle< FixedArray > parameter_map, uint32_t key)
virtual MUST_USE_RESULT MaybeHandle< Object > Delete(Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL OVERRIDE
static uint32_t GetCapacityImpl(Handle< FixedArrayBase > backing_store)
static MUST_USE_RESULT MaybeHandle< AccessorPair > GetAccessorPairImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > parameters)
static MUST_USE_RESULT MaybeHandle< Object > GetImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > parameters)
static Smi * FromInt(int value)
StackFrame * frame() const
virtual MUST_USE_RESULT MaybeHandle< Object > Delete(Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL OVERRIDE
static bool HasElementImpl(Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store)
ElementsKindTraits< Kind >::BackingStore BackingStore
static MUST_USE_RESULT MaybeHandle< Object > GetImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
static MUST_USE_RESULT MaybeHandle< Object > SetLengthImpl(Handle< JSObject > obj, Handle< Object > length, Handle< FixedArrayBase > backing_store)
TypedElementsAccessor< Kind > AccessorClass
static MUST_USE_RESULT PropertyAttributes GetAttributesImpl(Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
TypedElementsAccessor(const char *name)
#define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size)
#define ACCESSOR_ARRAY(Class, Kind, Store)
#define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size)
#define ACCESSOR_DELETE(Class, Kind, Store)
#define ELEMENTS_TRAITS(Class, KindParam, Store)
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf map
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T)
#define THROW_NEW_ERROR(isolate, call, T)
#define DCHECK(condition)
@ ALLOW_CONVERTED_DOUBLE_ELEMENTS
bool IsFastHoleyElementsKind(ElementsKind kind)
static const int kPackedSizeNotKnown
bool IsExternalArrayElementsKind(ElementsKind kind)
static int min(int a, int b)
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
void CheckArrayAbuse(Handle< JSObject > obj, const char *op, uint32_t key, bool allow_appending)
unsigned int FastD2UI(double x)
static bool HasKey(Handle< FixedArray > array, Handle< Object > key_handle)
void MemsetPointer(T **dest, U *value, int counter)
static void CopyDoubleToDoubleElements(FixedArrayBase *from_base, uint32_t from_start, FixedArrayBase *to_base, uint32_t to_start, int raw_copy_size)
const int kElementsKindCount
static ElementsKind ElementsKindForArray(FixedArrayBase *array)
@ FIXED_DOUBLE_ARRAY_TYPE
@ FAST_HOLEY_DOUBLE_ELEMENTS
@ SLOPPY_ARGUMENTS_ELEMENTS
@ FAST_HOLEY_SMI_ELEMENTS
bool IsFastDoubleElementsKind(ElementsKind kind)
Handle< T > handle(T *t, Isolate *isolate)
static void CopySmiToDoubleElements(FixedArrayBase *from_base, uint32_t from_start, FixedArrayBase *to_base, uint32_t to_start, int raw_copy_size)
bool IsFastPackedElementsKind(ElementsKind kind)
const bool FLAG_enable_slow_asserts
static MUST_USE_RESULT MaybeHandle< Object > ThrowArrayLengthRangeError(Isolate *isolate)
ElementsKind GetHoleyElementsKind(ElementsKind packed_kind)
static void CopyDictionaryToObjectElements(FixedArrayBase *from_base, uint32_t from_start, FixedArrayBase *to_base, ElementsKind to_kind, uint32_t to_start, int raw_copy_size)
static void CopyDictionaryToDoubleElements(FixedArrayBase *from_base, uint32_t from_start, FixedArrayBase *to_base, uint32_t to_start, int raw_copy_size)
static LifetimePosition Max(LifetimePosition a, LifetimePosition b)
bool IsFastElementsKind(ElementsKind kind)
void PrintF(const char *format,...)
Vector< Handle< Object > > HandleVector(v8::internal::Handle< T > *elms, int length)
int32_t DoubleToInt32(double x)
void CopyWords(T *dst, const T *src, size_t num_words)
static void CopyObjectToDoubleElements(FixedArrayBase *from_base, uint32_t from_start, FixedArrayBase *to_base, uint32_t to_start, int raw_copy_size)
static void CopyDoubleToObjectElements(FixedArrayBase *from_base, uint32_t from_start, FixedArrayBase *to_base, ElementsKind to_kind, uint32_t to_start, int raw_copy_size)
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
static void TraceTopFrame(Isolate *isolate)
bool IsFastSmiElementsKind(ElementsKind kind)
int FastD2IChecked(double x)
bool IsFastObjectElementsKind(ElementsKind kind)
static void CopyObjectToObjectElements(FixedArrayBase *from_base, ElementsKind from_kind, uint32_t from_start, FixedArrayBase *to_base, ElementsKind to_kind, uint32_t to_start, int raw_copy_size)
MaybeHandle< Object > ArrayConstructInitializeElements(Handle< JSArray > array, Arguments *args)
static void CopyPackedSmiToDoubleElements(FixedArrayBase *from_base, uint32_t from_start, FixedArrayBase *to_base, uint32_t to_start, int packed_size, int raw_copy_size)
Debugger support for the V8 JavaScript engine.