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

Side by Side Diff: src/elements.cc

Issue 11416238: Move CopyElements to the accessor of the target. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed more comments. Created 8 years 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') | src/objects.cc » ('j') | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 return obj; 679 return obj;
680 } 680 }
681 681
682 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj, 682 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj,
683 uint32_t key, 683 uint32_t key,
684 JSReceiver::DeleteMode mode) = 0; 684 JSReceiver::DeleteMode mode) = 0;
685 685
686 MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 686 MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
687 uint32_t from_start, 687 uint32_t from_start,
688 FixedArrayBase* to, 688 FixedArrayBase* to,
689 ElementsKind to_kind, 689 ElementsKind from_kind,
690 uint32_t to_start, 690 uint32_t to_start,
691 int packed_size, 691 int packed_size,
692 int copy_size) { 692 int copy_size) {
693 UNREACHABLE(); 693 UNREACHABLE();
694 return NULL; 694 return NULL;
695 } 695 }
696 696
697 MUST_USE_RESULT virtual MaybeObject* CopyElements(JSObject* from_holder, 697 MUST_USE_RESULT virtual MaybeObject* CopyElements(JSObject* from_holder,
698 uint32_t from_start, 698 uint32_t from_start,
699 ElementsKind from_kind,
699 FixedArrayBase* to, 700 FixedArrayBase* to,
700 ElementsKind to_kind,
701 uint32_t to_start, 701 uint32_t to_start,
702 int copy_size, 702 int copy_size,
703 FixedArrayBase* from) { 703 FixedArrayBase* from) {
704 int packed_size = kPackedSizeNotKnown; 704 int packed_size = kPackedSizeNotKnown;
705 if (from == NULL) { 705 if (from == NULL) {
706 from = from_holder->elements(); 706 from = from_holder->elements();
707 } 707 }
708 708
709 if (from_holder) { 709 if (from_holder) {
710 ElementsKind elements_kind = from_holder->GetElementsKind(); 710 bool is_packed = IsFastPackedElementsKind(from_kind) &&
711 bool is_packed = IsFastPackedElementsKind(elements_kind) &&
712 from_holder->IsJSArray(); 711 from_holder->IsJSArray();
713 if (is_packed) { 712 if (is_packed) {
714 packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value(); 713 packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value();
715 if (copy_size >= 0 && packed_size > copy_size) { 714 if (copy_size >= 0 && packed_size > copy_size) {
716 packed_size = copy_size; 715 packed_size = copy_size;
717 } 716 }
718 } 717 }
719 } 718 }
720 return ElementsAccessorSubclass::CopyElementsImpl( 719 return ElementsAccessorSubclass::CopyElementsImpl(
721 from, from_start, to, to_kind, to_start, packed_size, copy_size); 720 from, from_start, to, from_kind, to_start, packed_size, copy_size);
722 } 721 }
723 722
724 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( 723 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray(
725 Object* receiver, 724 Object* receiver,
726 JSObject* holder, 725 JSObject* holder,
727 FixedArray* to, 726 FixedArray* to,
728 FixedArrayBase* from) { 727 FixedArrayBase* from) {
729 int len0 = to->length(); 728 int len0 = to->length();
730 #ifdef DEBUG 729 #ifdef DEBUG
731 if (FLAG_enable_slow_asserts) { 730 if (FLAG_enable_slow_asserts) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 ASSERT((!IsFastSmiElementsKind(KindTraits::Kind) || 995 ASSERT((!IsFastSmiElementsKind(KindTraits::Kind) ||
997 static_cast<Object*>(backing_store->get(i))->IsSmi()) || 996 static_cast<Object*>(backing_store->get(i))->IsSmi()) ||
998 (IsFastHoleyElementsKind(KindTraits::Kind) == 997 (IsFastHoleyElementsKind(KindTraits::Kind) ==
999 backing_store->is_the_hole(i))); 998 backing_store->is_the_hole(i)));
1000 } 999 }
1001 #endif 1000 #endif
1002 } 1001 }
1003 }; 1002 };
1004 1003
1005 1004
1005 static ElementsKind ElementsKindForArray(FixedArrayBase* array) {
danno 2012/12/11 17:07:04 Not sure how performance sensitive this is, but ho
Toon Verwaest 2012/12/14 12:39:12 Done.
1006 switch (array->map()->instance_type()) {
1007 case FIXED_ARRAY_TYPE:
1008 if (array->IsDictionary()) {
1009 return DICTIONARY_ELEMENTS;
1010 } else {
1011 return FAST_HOLEY_ELEMENTS;
1012 }
1013 case FIXED_DOUBLE_ARRAY_TYPE:
1014 return FAST_HOLEY_DOUBLE_ELEMENTS;
danno 2012/12/11 17:07:04 How about a lookup array instead of the switch for
Toon Verwaest 2012/12/14 12:39:12 The problem is that this switches over instances t
1015 case EXTERNAL_BYTE_ARRAY_TYPE:
1016 return EXTERNAL_BYTE_ELEMENTS;
1017 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
1018 return EXTERNAL_UNSIGNED_BYTE_ELEMENTS;
1019 case EXTERNAL_SHORT_ARRAY_TYPE:
1020 return EXTERNAL_SHORT_ELEMENTS;
1021 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
1022 return EXTERNAL_UNSIGNED_SHORT_ELEMENTS;
1023 case EXTERNAL_INT_ARRAY_TYPE:
1024 return EXTERNAL_INT_ELEMENTS;
1025 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
1026 return EXTERNAL_UNSIGNED_INT_ELEMENTS;
1027 case EXTERNAL_FLOAT_ARRAY_TYPE:
1028 return EXTERNAL_FLOAT_ELEMENTS;
1029 case EXTERNAL_DOUBLE_ARRAY_TYPE:
1030 return EXTERNAL_DOUBLE_ELEMENTS;
1031 case EXTERNAL_PIXEL_ARRAY_TYPE:
1032 return EXTERNAL_PIXEL_ELEMENTS;
1033 default:
1034 UNREACHABLE();
1035 }
1036 return FAST_HOLEY_ELEMENTS;
1037 }
1038
1039
1006 template<typename FastElementsAccessorSubclass, 1040 template<typename FastElementsAccessorSubclass,
1007 typename KindTraits> 1041 typename KindTraits>
1008 class FastSmiOrObjectElementsAccessor 1042 class FastSmiOrObjectElementsAccessor
1009 : public FastElementsAccessor<FastElementsAccessorSubclass, 1043 : public FastElementsAccessor<FastElementsAccessorSubclass,
1010 KindTraits, 1044 KindTraits,
1011 kPointerSize> { 1045 kPointerSize> {
1012 public: 1046 public:
1013 explicit FastSmiOrObjectElementsAccessor(const char* name) 1047 explicit FastSmiOrObjectElementsAccessor(const char* name)
1014 : FastElementsAccessor<FastElementsAccessorSubclass, 1048 : FastElementsAccessor<FastElementsAccessorSubclass,
1015 KindTraits, 1049 KindTraits,
1016 kPointerSize>(name) {} 1050 kPointerSize>(name) {}
1017 1051
1018 static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 1052 static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
1019 uint32_t from_start, 1053 uint32_t from_start,
1020 FixedArrayBase* to, 1054 FixedArrayBase* to,
1021 ElementsKind to_kind, 1055 ElementsKind from_kind,
1022 uint32_t to_start, 1056 uint32_t to_start,
1023 int packed_size, 1057 int packed_size,
1024 int copy_size) { 1058 int copy_size) {
1025 if (IsFastSmiOrObjectElementsKind(to_kind)) { 1059 ElementsKind to_kind = KindTraits::Kind;
1026 CopyObjectToObjectElements( 1060 switch (from_kind) {
1027 from, KindTraits::Kind, from_start, to, to_kind, to_start, copy_size); 1061 case FAST_SMI_ELEMENTS:
1028 } else if (IsFastDoubleElementsKind(to_kind)) { 1062 case FAST_HOLEY_SMI_ELEMENTS:
1029 if (IsFastSmiElementsKind(KindTraits::Kind)) { 1063 case FAST_ELEMENTS:
1030 if (IsFastPackedElementsKind(KindTraits::Kind) && 1064 case FAST_HOLEY_ELEMENTS:
1031 packed_size != kPackedSizeNotKnown) { 1065 CopyObjectToObjectElements(
1032 CopyPackedSmiToDoubleElements( 1066 from, from_kind, from_start, to, to_kind, to_start, copy_size);
1033 from, from_start, to, to_start, packed_size, copy_size); 1067 return to->GetHeap()->undefined_value();
1034 } else { 1068 case FAST_DOUBLE_ELEMENTS:
1035 CopySmiToDoubleElements(from, from_start, to, to_start, copy_size); 1069 case FAST_HOLEY_DOUBLE_ELEMENTS:
1036 } 1070 return CopyDoubleToObjectElements(
1037 } else { 1071 from, from_start, to, to_kind, to_start, copy_size);
1038 CopyObjectToDoubleElements(from, from_start, to, to_start, copy_size); 1072 case DICTIONARY_ELEMENTS:
1073 CopyDictionaryToObjectElements(
1074 from, from_start, to, to_kind, to_start, copy_size);
1075 return to->GetHeap()->undefined_value();
1076 case NON_STRICT_ARGUMENTS_ELEMENTS: {
1077 // TODO(verwaest): This is a temporary hack to support extending
1078 // NON_STRICT_ARGUMENTS_ELEMENTS in SetFastElementsCapacityAndLength.
1079 // This case should be UNREACHABLE().
danno 2012/12/11 17:07:04 Yikes, this is totally scary.
Toon Verwaest 2012/12/14 12:39:12 Indeed. This should be cleaned up sometime; but th
1080 FixedArray* parameter_map = FixedArray::cast(from);
1081 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1));
1082 ElementsKind from_kind = ElementsKindForArray(arguments);
1083 return CopyElementsImpl(arguments, from_start, to, from_kind,
1084 to_start, packed_size, copy_size);
1039 } 1085 }
1040 } else { 1086 case EXTERNAL_BYTE_ELEMENTS:
1041 UNREACHABLE(); 1087 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
1088 case EXTERNAL_SHORT_ELEMENTS:
1089 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
1090 case EXTERNAL_INT_ELEMENTS:
1091 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
1092 case EXTERNAL_FLOAT_ELEMENTS:
1093 case EXTERNAL_DOUBLE_ELEMENTS:
1094 case EXTERNAL_PIXEL_ELEMENTS:
1095 UNREACHABLE();
1042 } 1096 }
1043 return to->GetHeap()->undefined_value(); 1097 return NULL;
1044 } 1098 }
1045 1099
1046 1100
1047 static MaybeObject* SetFastElementsCapacityAndLength(JSObject* obj, 1101 static MaybeObject* SetFastElementsCapacityAndLength(JSObject* obj,
1048 uint32_t capacity, 1102 uint32_t capacity,
1049 uint32_t length) { 1103 uint32_t length) {
1050 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode = 1104 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode =
1051 obj->HasFastSmiElements() 1105 obj->HasFastSmiElements()
1052 ? JSObject::kAllowSmiElements 1106 ? JSObject::kAllowSmiElements
1053 : JSObject::kDontAllowSmiElements; 1107 : JSObject::kDontAllowSmiElements;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 uint32_t capacity, 1176 uint32_t capacity,
1123 uint32_t length) { 1177 uint32_t length) {
1124 return obj->SetFastDoubleElementsCapacityAndLength(capacity, 1178 return obj->SetFastDoubleElementsCapacityAndLength(capacity,
1125 length); 1179 length);
1126 } 1180 }
1127 1181
1128 protected: 1182 protected:
1129 static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 1183 static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
1130 uint32_t from_start, 1184 uint32_t from_start,
1131 FixedArrayBase* to, 1185 FixedArrayBase* to,
1132 ElementsKind to_kind, 1186 ElementsKind from_kind,
1133 uint32_t to_start, 1187 uint32_t to_start,
1134 int packed_size, 1188 int packed_size,
1135 int copy_size) { 1189 int copy_size) {
1136 switch (to_kind) { 1190 switch (from_kind) {
1137 case FAST_SMI_ELEMENTS: 1191 case FAST_SMI_ELEMENTS:
1138 case FAST_ELEMENTS: 1192 CopyPackedSmiToDoubleElements(
1193 from, from_start, to, to_start, packed_size, copy_size);
1194 break;
1139 case FAST_HOLEY_SMI_ELEMENTS: 1195 case FAST_HOLEY_SMI_ELEMENTS:
1140 case FAST_HOLEY_ELEMENTS: 1196 CopySmiToDoubleElements(from, from_start, to, to_start, copy_size);
1141 return CopyDoubleToObjectElements( 1197 break;
1142 from, from_start, to, to_kind, to_start, copy_size);
1143 case FAST_DOUBLE_ELEMENTS: 1198 case FAST_DOUBLE_ELEMENTS:
1144 case FAST_HOLEY_DOUBLE_ELEMENTS: 1199 case FAST_HOLEY_DOUBLE_ELEMENTS:
1145 CopyDoubleToDoubleElements(from, from_start, to, to_start, copy_size); 1200 CopyDoubleToDoubleElements(from, from_start, to, to_start, copy_size);
1146 return from; 1201 break;
1147 default: 1202 case FAST_ELEMENTS:
1203 case FAST_HOLEY_ELEMENTS:
1204 CopyObjectToDoubleElements(from, from_start, to, to_start, copy_size);
1205 break;
1206 case DICTIONARY_ELEMENTS:
1207 CopyDictionaryToDoubleElements(
1208 from, from_start, to, to_start, copy_size);
1209 break;
1210 case NON_STRICT_ARGUMENTS_ELEMENTS:
1211 case EXTERNAL_BYTE_ELEMENTS:
1212 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
1213 case EXTERNAL_SHORT_ELEMENTS:
1214 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
1215 case EXTERNAL_INT_ELEMENTS:
1216 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
1217 case EXTERNAL_FLOAT_ELEMENTS:
1218 case EXTERNAL_DOUBLE_ELEMENTS:
1219 case EXTERNAL_PIXEL_ELEMENTS:
1148 UNREACHABLE(); 1220 UNREACHABLE();
1149 } 1221 }
1150 return to->GetHeap()->undefined_value(); 1222 return to->GetHeap()->undefined_value();
1151 } 1223 }
1152 }; 1224 };
1153 1225
1154 1226
1155 class FastPackedDoubleElementsAccessor 1227 class FastPackedDoubleElementsAccessor
1156 : public FastDoubleElementsAccessor< 1228 : public FastDoubleElementsAccessor<
1157 FastPackedDoubleElementsAccessor, 1229 FastPackedDoubleElementsAccessor,
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 } else { 1525 } else {
1454 obj->set_elements(new_elements); 1526 obj->set_elements(new_elements);
1455 } 1527 }
1456 } 1528 }
1457 return heap->true_value(); 1529 return heap->true_value();
1458 } 1530 }
1459 1531
1460 MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 1532 MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
1461 uint32_t from_start, 1533 uint32_t from_start,
1462 FixedArrayBase* to, 1534 FixedArrayBase* to,
1463 ElementsKind to_kind, 1535 ElementsKind from_kind,
1464 uint32_t to_start, 1536 uint32_t to_start,
1465 int packed_size, 1537 int packed_size,
1466 int copy_size) { 1538 int copy_size) {
1467 switch (to_kind) { 1539 UNREACHABLE();
1468 case FAST_SMI_ELEMENTS: 1540 return NULL;
1469 case FAST_ELEMENTS:
1470 case FAST_HOLEY_SMI_ELEMENTS:
1471 case FAST_HOLEY_ELEMENTS:
1472 CopyDictionaryToObjectElements(
1473 from, from_start, to, to_kind, to_start, copy_size);
1474 return from;
1475 case FAST_DOUBLE_ELEMENTS:
1476 case FAST_HOLEY_DOUBLE_ELEMENTS:
1477 CopyDictionaryToDoubleElements(
1478 from, from_start, to, to_start, copy_size);
1479 return from;
1480 default:
1481 UNREACHABLE();
1482 }
1483 return to->GetHeap()->undefined_value();
1484 } 1541 }
1485 1542
1486 1543
1487 protected: 1544 protected:
1488 friend class ElementsAccessorBase<DictionaryElementsAccessor, 1545 friend class ElementsAccessorBase<DictionaryElementsAccessor,
1489 ElementsKindTraits<DICTIONARY_ELEMENTS> >; 1546 ElementsKindTraits<DICTIONARY_ELEMENTS> >;
1490 1547
1491 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj, 1548 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj,
1492 uint32_t key, 1549 uint32_t key,
1493 JSReceiver::DeleteMode mode) { 1550 JSReceiver::DeleteMode mode) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 // the class for the most generalized ElementsKind subclass. 1757 // the class for the most generalized ElementsKind subclass.
1701 return FastHoleyObjectElementsAccessor::DeleteCommon(obj, key, mode); 1758 return FastHoleyObjectElementsAccessor::DeleteCommon(obj, key, mode);
1702 } 1759 }
1703 } 1760 }
1704 return obj->GetHeap()->true_value(); 1761 return obj->GetHeap()->true_value();
1705 } 1762 }
1706 1763
1707 MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 1764 MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
1708 uint32_t from_start, 1765 uint32_t from_start,
1709 FixedArrayBase* to, 1766 FixedArrayBase* to,
1710 ElementsKind to_kind, 1767 ElementsKind from_kind,
1711 uint32_t to_start, 1768 uint32_t to_start,
1712 int packed_size, 1769 int packed_size,
1713 int copy_size) { 1770 int copy_size) {
1714 FixedArray* parameter_map = FixedArray::cast(from); 1771 UNREACHABLE();
1715 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); 1772 return NULL;
1716 ElementsAccessor* accessor = ElementsAccessor::ForArray(arguments);
1717 return accessor->CopyElements(NULL, from_start, to, to_kind,
1718 to_start, copy_size, arguments);
1719 } 1773 }
1720 1774
1721 static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) { 1775 static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) {
1722 FixedArray* parameter_map = FixedArray::cast(backing_store); 1776 FixedArray* parameter_map = FixedArray::cast(backing_store);
1723 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); 1777 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1));
1724 return Max(static_cast<uint32_t>(parameter_map->length() - 2), 1778 return Max(static_cast<uint32_t>(parameter_map->length() - 2),
1725 ForArray(arguments)->GetCapacity(arguments)); 1779 ForArray(arguments)->GetCapacity(arguments));
1726 } 1780 }
1727 1781
1728 static uint32_t GetKeyForIndexImpl(FixedArrayBase* dict, 1782 static uint32_t GetKeyForIndexImpl(FixedArrayBase* dict,
(...skipping 25 matching lines...) Expand all
1754 ? Smi::cast(JSArray::cast(holder)->length())->value() 1808 ? Smi::cast(JSArray::cast(holder)->length())->value()
1755 : parameter_map->length(); 1809 : parameter_map->length();
1756 return key < (length - 2) 1810 return key < (length - 2)
1757 ? parameter_map->get(key + 2) 1811 ? parameter_map->get(key + 2)
1758 : parameter_map->GetHeap()->the_hole_value(); 1812 : parameter_map->GetHeap()->the_hole_value();
1759 } 1813 }
1760 }; 1814 };
1761 1815
1762 1816
1763 ElementsAccessor* ElementsAccessor::ForArray(FixedArrayBase* array) { 1817 ElementsAccessor* ElementsAccessor::ForArray(FixedArrayBase* array) {
1764 switch (array->map()->instance_type()) { 1818 return elements_accessors_[ElementsKindForArray(array)];
1765 case FIXED_ARRAY_TYPE:
1766 if (array->IsDictionary()) {
1767 return elements_accessors_[DICTIONARY_ELEMENTS];
1768 } else {
1769 return elements_accessors_[FAST_HOLEY_ELEMENTS];
1770 }
1771 case EXTERNAL_BYTE_ARRAY_TYPE:
1772 return elements_accessors_[EXTERNAL_BYTE_ELEMENTS];
1773 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
1774 return elements_accessors_[EXTERNAL_UNSIGNED_BYTE_ELEMENTS];
1775 case EXTERNAL_SHORT_ARRAY_TYPE:
1776 return elements_accessors_[EXTERNAL_SHORT_ELEMENTS];
1777 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
1778 return elements_accessors_[EXTERNAL_UNSIGNED_SHORT_ELEMENTS];
1779 case EXTERNAL_INT_ARRAY_TYPE:
1780 return elements_accessors_[EXTERNAL_INT_ELEMENTS];
1781 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
1782 return elements_accessors_[EXTERNAL_UNSIGNED_INT_ELEMENTS];
1783 case EXTERNAL_FLOAT_ARRAY_TYPE:
1784 return elements_accessors_[EXTERNAL_FLOAT_ELEMENTS];
1785 case EXTERNAL_DOUBLE_ARRAY_TYPE:
1786 return elements_accessors_[EXTERNAL_DOUBLE_ELEMENTS];
1787 case EXTERNAL_PIXEL_ARRAY_TYPE:
1788 return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS];
1789 default:
1790 UNREACHABLE();
1791 return NULL;
1792 }
1793 } 1819 }
1794 1820
1795 1821
1796 void ElementsAccessor::InitializeOncePerProcess() { 1822 void ElementsAccessor::InitializeOncePerProcess() {
1797 static ElementsAccessor* accessor_array[] = { 1823 static ElementsAccessor* accessor_array[] = {
1798 #define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind), 1824 #define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind),
1799 ELEMENTS_LIST(ACCESSOR_ARRAY) 1825 ELEMENTS_LIST(ACCESSOR_ARRAY)
1800 #undef ACCESSOR_ARRAY 1826 #undef ACCESSOR_ARRAY
1801 }; 1827 };
1802 1828
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 1896 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
1871 new_backing_store->set(0, length); 1897 new_backing_store->set(0, length);
1872 { MaybeObject* result = array->SetContent(new_backing_store); 1898 { MaybeObject* result = array->SetContent(new_backing_store);
1873 if (result->IsFailure()) return result; 1899 if (result->IsFailure()) return result;
1874 } 1900 }
1875 return array; 1901 return array;
1876 } 1902 }
1877 1903
1878 1904
1879 } } // namespace v8::internal 1905 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698