Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: src/elements.cc

Issue 597103003: ArrayConcat regression recover after r20312 (appeared on dromaeo benchmarks). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/elements.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (!heap->InNewSpace(to)) { 240 if (!heap->InNewSpace(to)) {
241 heap->RecordWrites(to->address(), 241 heap->RecordWrites(to->address(),
242 to->OffsetOfElementAt(to_start), 242 to->OffsetOfElementAt(to_start),
243 copy_size); 243 copy_size);
244 } 244 }
245 heap->incremental_marking()->RecordWrites(to); 245 heap->incremental_marking()->RecordWrites(to);
246 } 246 }
247 } 247 }
248 248
249 249
250 static void CopyDoubleToObjectElements(Handle<FixedArrayBase> from_base, 250 // NOTE: this method violates the handlified function signature convention:
251 // raw pointer parameters in the function that allocates.
252 // See ElementsAccessorBase::CopyElements() for details.
253 static void CopyDoubleToObjectElements(FixedArrayBase* from_base,
251 uint32_t from_start, 254 uint32_t from_start,
252 Handle<FixedArrayBase> to_base, 255 FixedArrayBase* to_base,
253 ElementsKind to_kind, 256 ElementsKind to_kind, uint32_t to_start,
254 uint32_t to_start,
255 int raw_copy_size) { 257 int raw_copy_size) {
256 DCHECK(IsFastSmiOrObjectElementsKind(to_kind)); 258 DCHECK(IsFastSmiOrObjectElementsKind(to_kind));
257 int copy_size = raw_copy_size; 259 int copy_size = raw_copy_size;
258 if (raw_copy_size < 0) { 260 if (raw_copy_size < 0) {
261 DisallowHeapAllocation no_allocation;
259 DCHECK(raw_copy_size == ElementsAccessor::kCopyToEnd || 262 DCHECK(raw_copy_size == ElementsAccessor::kCopyToEnd ||
260 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); 263 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
261 copy_size = Min(from_base->length() - from_start, 264 copy_size = Min(from_base->length() - from_start,
262 to_base->length() - to_start); 265 to_base->length() - to_start);
263 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { 266 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
264 // Also initialize the area that will be copied over since HeapNumber 267 // Also initialize the area that will be copied over since HeapNumber
265 // allocation below can cause an incremental marking step, requiring all 268 // allocation below can cause an incremental marking step, requiring all
266 // existing heap objects to be propertly initialized. 269 // existing heap objects to be propertly initialized.
267 int start = to_start; 270 int start = to_start;
268 int length = to_base->length() - start; 271 int length = to_base->length() - start;
269 if (length > 0) { 272 if (length > 0) {
270 Heap* heap = from_base->GetHeap(); 273 Heap* heap = from_base->GetHeap();
271 MemsetPointer(FixedArray::cast(*to_base)->data_start() + start, 274 MemsetPointer(FixedArray::cast(to_base)->data_start() + start,
272 heap->the_hole_value(), length); 275 heap->the_hole_value(), length);
273 } 276 }
274 } 277 }
275 } 278 }
276 DCHECK((copy_size + static_cast<int>(to_start)) <= to_base->length() && 279 DCHECK((copy_size + static_cast<int>(to_start)) <= to_base->length() &&
277 (copy_size + static_cast<int>(from_start)) <= from_base->length()); 280 (copy_size + static_cast<int>(from_start)) <= from_base->length());
278 if (copy_size == 0) return; 281 if (copy_size == 0) return;
282
283 // From here on, the code below could actually allocate. Therefore the raw
284 // values are wrapped into handles.
279 Isolate* isolate = from_base->GetIsolate(); 285 Isolate* isolate = from_base->GetIsolate();
280 Handle<FixedDoubleArray> from = Handle<FixedDoubleArray>::cast(from_base); 286 Handle<FixedDoubleArray> from(FixedDoubleArray::cast(from_base), isolate);
281 Handle<FixedArray> to = Handle<FixedArray>::cast(to_base); 287 Handle<FixedArray> to(FixedArray::cast(to_base), isolate);
282 for (int i = 0; i < copy_size; ++i) { 288 for (int i = 0; i < copy_size; ++i) {
283 HandleScope scope(isolate); 289 HandleScope scope(isolate);
284 if (IsFastSmiElementsKind(to_kind)) { 290 if (IsFastSmiElementsKind(to_kind)) {
285 UNIMPLEMENTED(); 291 UNIMPLEMENTED();
286 } else { 292 } else {
287 DCHECK(IsFastObjectElementsKind(to_kind)); 293 DCHECK(IsFastObjectElementsKind(to_kind));
288 Handle<Object> value = FixedDoubleArray::get(from, i + from_start); 294 Handle<Object> value = FixedDoubleArray::get(from, i + from_start);
289 to->set(i + to_start, *value, UPDATE_WRITE_BARRIER); 295 to->set(i + to_start, *value, UPDATE_WRITE_BARRIER);
290 } 296 }
291 } 297 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 int capacity, 701 int capacity,
696 int length) { 702 int length) {
697 UNIMPLEMENTED(); 703 UNIMPLEMENTED();
698 } 704 }
699 705
700 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( 706 MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
701 Handle<JSObject> obj, 707 Handle<JSObject> obj,
702 uint32_t key, 708 uint32_t key,
703 JSReceiver::DeleteMode mode) OVERRIDE = 0; 709 JSReceiver::DeleteMode mode) OVERRIDE = 0;
704 710
705 static void CopyElementsImpl(Handle<FixedArrayBase> from, 711 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
706 uint32_t from_start, 712 FixedArrayBase* to, ElementsKind from_kind,
707 Handle<FixedArrayBase> to, 713 uint32_t to_start, int packed_size,
708 ElementsKind from_kind,
709 uint32_t to_start,
710 int packed_size,
711 int copy_size) { 714 int copy_size) {
712 UNREACHABLE(); 715 UNREACHABLE();
713 } 716 }
714 717
715 virtual void CopyElements( 718 virtual void CopyElements(
716 Handle<FixedArrayBase> from, 719 Handle<FixedArrayBase> from,
717 uint32_t from_start, 720 uint32_t from_start,
718 ElementsKind from_kind, 721 ElementsKind from_kind,
719 Handle<FixedArrayBase> to, 722 Handle<FixedArrayBase> to,
720 uint32_t to_start, 723 uint32_t to_start,
721 int copy_size) FINAL OVERRIDE { 724 int copy_size) FINAL OVERRIDE {
722 DCHECK(!from.is_null()); 725 DCHECK(!from.is_null());
723 ElementsAccessorSubclass::CopyElementsImpl( 726 // NOTE: the ElementsAccessorSubclass::CopyElementsImpl() methods
724 from, from_start, to, from_kind, to_start, kPackedSizeNotKnown, 727 // violate the handlified function signature convention:
725 copy_size); 728 // raw pointer parameters in the function that allocates. This is done
729 // intentionally to avoid ArrayConcat() builtin performance degradation.
730 // See the comment in another ElementsAccessorBase::CopyElements() for
731 // details.
732 ElementsAccessorSubclass::CopyElementsImpl(*from, from_start, *to,
733 from_kind, to_start,
734 kPackedSizeNotKnown, copy_size);
726 } 735 }
727 736
728 virtual void CopyElements( 737 virtual void CopyElements(
729 JSObject* from_holder, 738 JSObject* from_holder,
730 uint32_t from_start, 739 uint32_t from_start,
731 ElementsKind from_kind, 740 ElementsKind from_kind,
732 Handle<FixedArrayBase> to, 741 Handle<FixedArrayBase> to,
733 uint32_t to_start, 742 uint32_t to_start,
734 int copy_size) FINAL OVERRIDE { 743 int copy_size) FINAL OVERRIDE {
735 int packed_size = kPackedSizeNotKnown; 744 int packed_size = kPackedSizeNotKnown;
736 bool is_packed = IsFastPackedElementsKind(from_kind) && 745 bool is_packed = IsFastPackedElementsKind(from_kind) &&
737 from_holder->IsJSArray(); 746 from_holder->IsJSArray();
738 if (is_packed) { 747 if (is_packed) {
739 packed_size = 748 packed_size =
740 Smi::cast(JSArray::cast(from_holder)->length())->value(); 749 Smi::cast(JSArray::cast(from_holder)->length())->value();
741 if (copy_size >= 0 && packed_size > copy_size) { 750 if (copy_size >= 0 && packed_size > copy_size) {
742 packed_size = copy_size; 751 packed_size = copy_size;
743 } 752 }
744 } 753 }
745 Handle<FixedArrayBase> from(from_holder->elements()); 754 FixedArrayBase* from = from_holder->elements();
755 // NOTE: the ElementsAccessorSubclass::CopyElementsImpl() methods
756 // violate the handlified function signature convention:
757 // raw pointer parameters in the function that allocates. This is done
758 // intentionally to avoid ArrayConcat() builtin performance degradation.
759 //
760 // Details: The idea is that allocations actually happen only in case of
761 // copying from object with fast double elements to object with object
762 // elements. In all the other cases there are no allocations performed and
763 // handle creation causes noticeable performance degradation of the builtin.
746 ElementsAccessorSubclass::CopyElementsImpl( 764 ElementsAccessorSubclass::CopyElementsImpl(
747 from, from_start, to, from_kind, to_start, packed_size, copy_size); 765 from, from_start, *to, from_kind, to_start, packed_size, copy_size);
748 } 766 }
749 767
750 virtual MaybeHandle<FixedArray> AddElementsToFixedArray( 768 virtual MaybeHandle<FixedArray> AddElementsToFixedArray(
751 Handle<Object> receiver, 769 Handle<Object> receiver,
752 Handle<JSObject> holder, 770 Handle<JSObject> holder,
753 Handle<FixedArray> to, 771 Handle<FixedArray> to,
754 Handle<FixedArrayBase> from) FINAL OVERRIDE { 772 Handle<FixedArrayBase> from) FINAL OVERRIDE {
755 int len0 = to->length(); 773 int len0 = to->length();
756 #ifdef ENABLE_SLOW_DCHECKS 774 #ifdef ENABLE_SLOW_DCHECKS
757 if (FLAG_enable_slow_asserts) { 775 if (FLAG_enable_slow_asserts) {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 DCHECK((!IsFastSmiElementsKind(KindTraits::Kind) || 1029 DCHECK((!IsFastSmiElementsKind(KindTraits::Kind) ||
1012 BackingStore::get(backing_store, i)->IsSmi()) || 1030 BackingStore::get(backing_store, i)->IsSmi()) ||
1013 (IsFastHoleyElementsKind(KindTraits::Kind) == 1031 (IsFastHoleyElementsKind(KindTraits::Kind) ==
1014 backing_store->is_the_hole(i))); 1032 backing_store->is_the_hole(i)));
1015 } 1033 }
1016 #endif 1034 #endif
1017 } 1035 }
1018 }; 1036 };
1019 1037
1020 1038
1021 static inline ElementsKind ElementsKindForArray(Handle<FixedArrayBase> array) { 1039 static inline ElementsKind ElementsKindForArray(FixedArrayBase* array) {
1022 switch (array->map()->instance_type()) { 1040 switch (array->map()->instance_type()) {
1023 case FIXED_ARRAY_TYPE: 1041 case FIXED_ARRAY_TYPE:
1024 if (array->IsDictionary()) { 1042 if (array->IsDictionary()) {
1025 return DICTIONARY_ELEMENTS; 1043 return DICTIONARY_ELEMENTS;
1026 } else { 1044 } else {
1027 return FAST_HOLEY_ELEMENTS; 1045 return FAST_HOLEY_ELEMENTS;
1028 } 1046 }
1029 case FIXED_DOUBLE_ARRAY_TYPE: 1047 case FIXED_DOUBLE_ARRAY_TYPE:
1030 return FAST_HOLEY_DOUBLE_ELEMENTS; 1048 return FAST_HOLEY_DOUBLE_ELEMENTS;
1031 1049
(...skipping 15 matching lines...) Expand all
1047 1065
1048 template<typename FastElementsAccessorSubclass, 1066 template<typename FastElementsAccessorSubclass,
1049 typename KindTraits> 1067 typename KindTraits>
1050 class FastSmiOrObjectElementsAccessor 1068 class FastSmiOrObjectElementsAccessor
1051 : public FastElementsAccessor<FastElementsAccessorSubclass, KindTraits> { 1069 : public FastElementsAccessor<FastElementsAccessorSubclass, KindTraits> {
1052 public: 1070 public:
1053 explicit FastSmiOrObjectElementsAccessor(const char* name) 1071 explicit FastSmiOrObjectElementsAccessor(const char* name)
1054 : FastElementsAccessor<FastElementsAccessorSubclass, 1072 : FastElementsAccessor<FastElementsAccessorSubclass,
1055 KindTraits>(name) {} 1073 KindTraits>(name) {}
1056 1074
1057 static void CopyElementsImpl(Handle<FixedArrayBase> from, 1075 // NOTE: this method violates the handlified function signature convention:
1058 uint32_t from_start, 1076 // raw pointer parameters in the function that allocates.
1059 Handle<FixedArrayBase> to, 1077 // See ElementsAccessor::CopyElements() for details.
1060 ElementsKind from_kind, 1078 // This method could actually allocate if copying from double elements to
1061 uint32_t to_start, 1079 // object elements.
1062 int packed_size, 1080 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
1081 FixedArrayBase* to, ElementsKind from_kind,
1082 uint32_t to_start, int packed_size,
1063 int copy_size) { 1083 int copy_size) {
1084 DisallowHeapAllocation no_gc;
1064 ElementsKind to_kind = KindTraits::Kind; 1085 ElementsKind to_kind = KindTraits::Kind;
1065 switch (from_kind) { 1086 switch (from_kind) {
1066 case FAST_SMI_ELEMENTS: 1087 case FAST_SMI_ELEMENTS:
1067 case FAST_HOLEY_SMI_ELEMENTS: 1088 case FAST_HOLEY_SMI_ELEMENTS:
1068 case FAST_ELEMENTS: 1089 case FAST_ELEMENTS:
1069 case FAST_HOLEY_ELEMENTS: 1090 case FAST_HOLEY_ELEMENTS:
1070 CopyObjectToObjectElements(*from, from_kind, from_start, *to, to_kind, 1091 CopyObjectToObjectElements(from, from_kind, from_start, to, to_kind,
1071 to_start, copy_size); 1092 to_start, copy_size);
1072 break; 1093 break;
1073 case FAST_DOUBLE_ELEMENTS: 1094 case FAST_DOUBLE_ELEMENTS:
1074 case FAST_HOLEY_DOUBLE_ELEMENTS: 1095 case FAST_HOLEY_DOUBLE_ELEMENTS: {
1096 AllowHeapAllocation allow_allocation;
1075 CopyDoubleToObjectElements( 1097 CopyDoubleToObjectElements(
1076 from, from_start, to, to_kind, to_start, copy_size); 1098 from, from_start, to, to_kind, to_start, copy_size);
1077 break; 1099 break;
1100 }
1078 case DICTIONARY_ELEMENTS: 1101 case DICTIONARY_ELEMENTS:
1079 CopyDictionaryToObjectElements(*from, from_start, *to, to_kind, 1102 CopyDictionaryToObjectElements(from, from_start, to, to_kind, to_start,
1080 to_start, copy_size); 1103 copy_size);
1081 break; 1104 break;
1082 case SLOPPY_ARGUMENTS_ELEMENTS: { 1105 case SLOPPY_ARGUMENTS_ELEMENTS: {
1083 // TODO(verwaest): This is a temporary hack to support extending 1106 // TODO(verwaest): This is a temporary hack to support extending
1084 // SLOPPY_ARGUMENTS_ELEMENTS in SetFastElementsCapacityAndLength. 1107 // SLOPPY_ARGUMENTS_ELEMENTS in SetFastElementsCapacityAndLength.
1085 // This case should be UNREACHABLE(). 1108 // This case should be UNREACHABLE().
1086 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(from); 1109 FixedArray* parameter_map = FixedArray::cast(from);
1087 Handle<FixedArrayBase> arguments( 1110 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1));
1088 FixedArrayBase::cast(parameter_map->get(1)));
1089 ElementsKind from_kind = ElementsKindForArray(arguments); 1111 ElementsKind from_kind = ElementsKindForArray(arguments);
1090 CopyElementsImpl(arguments, from_start, to, from_kind, 1112 CopyElementsImpl(arguments, from_start, to, from_kind,
1091 to_start, packed_size, copy_size); 1113 to_start, packed_size, copy_size);
1092 break; 1114 break;
1093 } 1115 }
1094 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1116 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1095 case EXTERNAL_##TYPE##_ELEMENTS: \ 1117 case EXTERNAL_##TYPE##_ELEMENTS: \
1096 case TYPE##_ELEMENTS: \ 1118 case TYPE##_ELEMENTS: \
1097 UNREACHABLE(); 1119 UNREACHABLE();
1098 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1120 TYPED_ARRAYS(TYPED_ARRAY_CASE)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 : FastElementsAccessor<FastElementsAccessorSubclass, 1194 : FastElementsAccessor<FastElementsAccessorSubclass,
1173 KindTraits>(name) {} 1195 KindTraits>(name) {}
1174 1196
1175 static void SetFastElementsCapacityAndLength(Handle<JSObject> obj, 1197 static void SetFastElementsCapacityAndLength(Handle<JSObject> obj,
1176 uint32_t capacity, 1198 uint32_t capacity,
1177 uint32_t length) { 1199 uint32_t length) {
1178 JSObject::SetFastDoubleElementsCapacityAndLength(obj, capacity, length); 1200 JSObject::SetFastDoubleElementsCapacityAndLength(obj, capacity, length);
1179 } 1201 }
1180 1202
1181 protected: 1203 protected:
1182 static void CopyElementsImpl(Handle<FixedArrayBase> from, 1204 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
1183 uint32_t from_start, 1205 FixedArrayBase* to, ElementsKind from_kind,
1184 Handle<FixedArrayBase> to, 1206 uint32_t to_start, int packed_size,
1185 ElementsKind from_kind,
1186 uint32_t to_start,
1187 int packed_size,
1188 int copy_size) { 1207 int copy_size) {
1208 DisallowHeapAllocation no_allocation;
1189 switch (from_kind) { 1209 switch (from_kind) {
1190 case FAST_SMI_ELEMENTS: 1210 case FAST_SMI_ELEMENTS:
1191 CopyPackedSmiToDoubleElements(*from, from_start, *to, to_start, 1211 CopyPackedSmiToDoubleElements(from, from_start, to, to_start,
1192 packed_size, copy_size); 1212 packed_size, copy_size);
1193 break; 1213 break;
1194 case FAST_HOLEY_SMI_ELEMENTS: 1214 case FAST_HOLEY_SMI_ELEMENTS:
1195 CopySmiToDoubleElements(*from, from_start, *to, to_start, copy_size); 1215 CopySmiToDoubleElements(from, from_start, to, to_start, copy_size);
1196 break; 1216 break;
1197 case FAST_DOUBLE_ELEMENTS: 1217 case FAST_DOUBLE_ELEMENTS:
1198 case FAST_HOLEY_DOUBLE_ELEMENTS: 1218 case FAST_HOLEY_DOUBLE_ELEMENTS:
1199 CopyDoubleToDoubleElements(*from, from_start, *to, to_start, copy_size); 1219 CopyDoubleToDoubleElements(from, from_start, to, to_start, copy_size);
1200 break; 1220 break;
1201 case FAST_ELEMENTS: 1221 case FAST_ELEMENTS:
1202 case FAST_HOLEY_ELEMENTS: 1222 case FAST_HOLEY_ELEMENTS:
1203 CopyObjectToDoubleElements(*from, from_start, *to, to_start, copy_size); 1223 CopyObjectToDoubleElements(from, from_start, to, to_start, copy_size);
1204 break; 1224 break;
1205 case DICTIONARY_ELEMENTS: 1225 case DICTIONARY_ELEMENTS:
1206 CopyDictionaryToDoubleElements(*from, from_start, *to, to_start, 1226 CopyDictionaryToDoubleElements(from, from_start, to, to_start,
1207 copy_size); 1227 copy_size);
1208 break; 1228 break;
1209 case SLOPPY_ARGUMENTS_ELEMENTS: 1229 case SLOPPY_ARGUMENTS_ELEMENTS:
1210 UNREACHABLE(); 1230 UNREACHABLE();
1211 1231
1212 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1232 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1213 case EXTERNAL_##TYPE##_ELEMENTS: \ 1233 case EXTERNAL_##TYPE##_ELEMENTS: \
1214 case TYPE##_ELEMENTS: \ 1234 case TYPE##_ELEMENTS: \
1215 UNREACHABLE(); 1235 UNREACHABLE();
1216 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1236 TYPED_ARRAYS(TYPED_ARRAY_CASE)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 1452
1433 if (is_arguments) { 1453 if (is_arguments) {
1434 FixedArray::cast(obj->elements())->set(1, *new_elements); 1454 FixedArray::cast(obj->elements())->set(1, *new_elements);
1435 } else { 1455 } else {
1436 obj->set_elements(*new_elements); 1456 obj->set_elements(*new_elements);
1437 } 1457 }
1438 } 1458 }
1439 return isolate->factory()->true_value(); 1459 return isolate->factory()->true_value();
1440 } 1460 }
1441 1461
1442 static void CopyElementsImpl(Handle<FixedArrayBase> from, 1462 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
1443 uint32_t from_start, 1463 FixedArrayBase* to, ElementsKind from_kind,
1444 Handle<FixedArrayBase> to, 1464 uint32_t to_start, int packed_size,
1445 ElementsKind from_kind,
1446 uint32_t to_start,
1447 int packed_size,
1448 int copy_size) { 1465 int copy_size) {
1449 UNREACHABLE(); 1466 UNREACHABLE();
1450 } 1467 }
1451 1468
1452 1469
1453 protected: 1470 protected:
1454 friend class ElementsAccessorBase<DictionaryElementsAccessor, 1471 friend class ElementsAccessorBase<DictionaryElementsAccessor,
1455 ElementsKindTraits<DICTIONARY_ELEMENTS> >; 1472 ElementsKindTraits<DICTIONARY_ELEMENTS> >;
1456 1473
1457 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( 1474 MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 } else { 1664 } else {
1648 // It's difficult to access the version of DeleteCommon that is declared 1665 // It's difficult to access the version of DeleteCommon that is declared
1649 // in the templatized super class, call the concrete implementation in 1666 // in the templatized super class, call the concrete implementation in
1650 // the class for the most generalized ElementsKind subclass. 1667 // the class for the most generalized ElementsKind subclass.
1651 return FastHoleyObjectElementsAccessor::DeleteCommon(obj, key, mode); 1668 return FastHoleyObjectElementsAccessor::DeleteCommon(obj, key, mode);
1652 } 1669 }
1653 } 1670 }
1654 return isolate->factory()->true_value(); 1671 return isolate->factory()->true_value();
1655 } 1672 }
1656 1673
1657 static void CopyElementsImpl(Handle<FixedArrayBase> from, 1674 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
1658 uint32_t from_start, 1675 FixedArrayBase* to, ElementsKind from_kind,
1659 Handle<FixedArrayBase> to, 1676 uint32_t to_start, int packed_size,
1660 ElementsKind from_kind,
1661 uint32_t to_start,
1662 int packed_size,
1663 int copy_size) { 1677 int copy_size) {
1664 UNREACHABLE(); 1678 UNREACHABLE();
1665 } 1679 }
1666 1680
1667 static uint32_t GetCapacityImpl(Handle<FixedArrayBase> backing_store) { 1681 static uint32_t GetCapacityImpl(Handle<FixedArrayBase> backing_store) {
1668 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(backing_store); 1682 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(backing_store);
1669 Handle<FixedArrayBase> arguments( 1683 Handle<FixedArrayBase> arguments(
1670 FixedArrayBase::cast(parameter_map->get(1))); 1684 FixedArrayBase::cast(parameter_map->get(1)));
1671 return Max(static_cast<uint32_t>(parameter_map->length() - 2), 1685 return Max(static_cast<uint32_t>(parameter_map->length() - 2),
1672 ForArray(arguments)->GetCapacity(arguments)); 1686 ForArray(arguments)->GetCapacity(arguments));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 ? Smi::cast(Handle<JSArray>::cast(holder)->length())->value() 1722 ? Smi::cast(Handle<JSArray>::cast(holder)->length())->value()
1709 : parameter_map->length(); 1723 : parameter_map->length();
1710 return key < (length - 2) 1724 return key < (length - 2)
1711 ? handle(parameter_map->get(key + 2), isolate) 1725 ? handle(parameter_map->get(key + 2), isolate)
1712 : Handle<Object>::cast(isolate->factory()->the_hole_value()); 1726 : Handle<Object>::cast(isolate->factory()->the_hole_value());
1713 } 1727 }
1714 }; 1728 };
1715 1729
1716 1730
1717 ElementsAccessor* ElementsAccessor::ForArray(Handle<FixedArrayBase> array) { 1731 ElementsAccessor* ElementsAccessor::ForArray(Handle<FixedArrayBase> array) {
1718 return elements_accessors_[ElementsKindForArray(array)]; 1732 return elements_accessors_[ElementsKindForArray(*array)];
1719 } 1733 }
1720 1734
1721 1735
1722 void ElementsAccessor::InitializeOncePerProcess() { 1736 void ElementsAccessor::InitializeOncePerProcess() {
1723 static ElementsAccessor* accessor_array[] = { 1737 static ElementsAccessor* accessor_array[] = {
1724 #define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind), 1738 #define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind),
1725 ELEMENTS_LIST(ACCESSOR_ARRAY) 1739 ELEMENTS_LIST(ACCESSOR_ARRAY)
1726 #undef ACCESSOR_ARRAY 1740 #undef ACCESSOR_ARRAY
1727 }; 1741 };
1728 1742
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 UNREACHABLE(); 1911 UNREACHABLE();
1898 break; 1912 break;
1899 } 1913 }
1900 1914
1901 array->set_elements(*elms); 1915 array->set_elements(*elms);
1902 array->set_length(Smi::FromInt(number_of_elements)); 1916 array->set_length(Smi::FromInt(number_of_elements));
1903 return array; 1917 return array;
1904 } 1918 }
1905 1919
1906 } } // namespace v8::internal 1920 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698