OLD | NEW |
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 30 matching lines...) Expand all Loading... |
41 // - ElementsAccessorBase (abstract) | 41 // - ElementsAccessorBase (abstract) |
42 // - FastElementsAccessor (abstract) | 42 // - FastElementsAccessor (abstract) |
43 // - FastSmiOrObjectElementsAccessor | 43 // - FastSmiOrObjectElementsAccessor |
44 // - FastPackedSmiElementsAccessor | 44 // - FastPackedSmiElementsAccessor |
45 // - FastHoleySmiElementsAccessor | 45 // - FastHoleySmiElementsAccessor |
46 // - FastPackedObjectElementsAccessor | 46 // - FastPackedObjectElementsAccessor |
47 // - FastHoleyObjectElementsAccessor | 47 // - FastHoleyObjectElementsAccessor |
48 // - FastDoubleElementsAccessor | 48 // - FastDoubleElementsAccessor |
49 // - FastPackedDoubleElementsAccessor | 49 // - FastPackedDoubleElementsAccessor |
50 // - FastHoleyDoubleElementsAccessor | 50 // - FastHoleyDoubleElementsAccessor |
51 // - TypedElementsAccessor (abstract) | 51 // - TypedElementsAccessor: template, with instantiations: |
52 // - ExternalByteElementsAccessor | 52 // - ExternalInt8ElementsAccessor |
53 // - ExternalUnsignedByteElementsAccessor | 53 // - ExternalUint8ElementsAccessor |
54 // - ExternalShortElementsAccessor | 54 // - ExternalInt16ElementsAccessor |
55 // - ExternalUnsignedShortElementsAccessor | 55 // - ExternalUint16ElementsAccessor |
56 // - ExternalIntElementsAccessor | 56 // - ExternalInt32ElementsAccessor |
57 // - ExternalUnsignedIntElementsAccessor | 57 // - ExternalUint32ElementsAccessor |
58 // - ExternalFloatElementsAccessor | 58 // - ExternalFloat32ElementsAccessor |
59 // - ExternalDoubleElementsAccessor | 59 // - ExternalFloat64ElementsAccessor |
60 // - PixelElementsAccessor | 60 // - ExternalUint8ClampedElementsAccessor |
61 // - FixedUint8ArrayAccessor | 61 // - FixedUint8ElementsAccessor |
62 // - FixedInt8ArrayAccessor | 62 // - FixedInt8ElementsAccessor |
63 // - FixedUint16ArrayAccessor | 63 // - FixedUint16ElementsAccessor |
64 // - FixedInt16ArrayAccessor | 64 // - FixedInt16ElementsAccessor |
65 // - FixedUint32ArrayAccessor | 65 // - FixedUint32ElementsAccessor |
66 // - FixedInt32ArrayAccessor | 66 // - FixedInt32ElementsAccessor |
67 // - FixedFloat32ArrayAccessor | 67 // - FixedFloat32ElementsAccessor |
68 // - FixedFloat64ArrayAccessor | 68 // - FixedFloat64ElementsAccessor |
69 // - FixedUint8ClampedArrayAccessor | 69 // - FixedUint8ClampedElementsAccessor |
70 // - DictionaryElementsAccessor | 70 // - DictionaryElementsAccessor |
71 // - NonStrictArgumentsElementsAccessor | 71 // - NonStrictArgumentsElementsAccessor |
72 | 72 |
73 | 73 |
74 namespace v8 { | 74 namespace v8 { |
75 namespace internal { | 75 namespace internal { |
76 | 76 |
77 | 77 |
78 static const int kPackedSizeNotKnown = -1; | 78 static const int kPackedSizeNotKnown = -1; |
79 | 79 |
(...skipping 10 matching lines...) Expand all Loading... |
90 V(FastPackedObjectElementsAccessor, FAST_ELEMENTS, FixedArray) \ | 90 V(FastPackedObjectElementsAccessor, FAST_ELEMENTS, FixedArray) \ |
91 V(FastHoleyObjectElementsAccessor, FAST_HOLEY_ELEMENTS, FixedArray) \ | 91 V(FastHoleyObjectElementsAccessor, FAST_HOLEY_ELEMENTS, FixedArray) \ |
92 V(FastPackedDoubleElementsAccessor, FAST_DOUBLE_ELEMENTS, \ | 92 V(FastPackedDoubleElementsAccessor, FAST_DOUBLE_ELEMENTS, \ |
93 FixedDoubleArray) \ | 93 FixedDoubleArray) \ |
94 V(FastHoleyDoubleElementsAccessor, FAST_HOLEY_DOUBLE_ELEMENTS, \ | 94 V(FastHoleyDoubleElementsAccessor, FAST_HOLEY_DOUBLE_ELEMENTS, \ |
95 FixedDoubleArray) \ | 95 FixedDoubleArray) \ |
96 V(DictionaryElementsAccessor, DICTIONARY_ELEMENTS, \ | 96 V(DictionaryElementsAccessor, DICTIONARY_ELEMENTS, \ |
97 SeededNumberDictionary) \ | 97 SeededNumberDictionary) \ |
98 V(NonStrictArgumentsElementsAccessor, NON_STRICT_ARGUMENTS_ELEMENTS, \ | 98 V(NonStrictArgumentsElementsAccessor, NON_STRICT_ARGUMENTS_ELEMENTS, \ |
99 FixedArray) \ | 99 FixedArray) \ |
100 V(ExternalByteElementsAccessor, EXTERNAL_BYTE_ELEMENTS, \ | 100 V(ExternalInt8ElementsAccessor, EXTERNAL_INT8_ELEMENTS, \ |
101 ExternalByteArray) \ | 101 ExternalInt8Array) \ |
102 V(ExternalUnsignedByteElementsAccessor, \ | 102 V(ExternalUint8ElementsAccessor, \ |
103 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, ExternalUnsignedByteArray) \ | 103 EXTERNAL_UINT8_ELEMENTS, ExternalUint8Array) \ |
104 V(ExternalShortElementsAccessor, EXTERNAL_SHORT_ELEMENTS, \ | 104 V(ExternalInt16ElementsAccessor, EXTERNAL_INT16_ELEMENTS, \ |
105 ExternalShortArray) \ | 105 ExternalInt16Array) \ |
106 V(ExternalUnsignedShortElementsAccessor, \ | 106 V(ExternalUint16ElementsAccessor, \ |
107 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, ExternalUnsignedShortArray) \ | 107 EXTERNAL_UINT16_ELEMENTS, ExternalUint16Array) \ |
108 V(ExternalIntElementsAccessor, EXTERNAL_INT_ELEMENTS, \ | 108 V(ExternalInt32ElementsAccessor, EXTERNAL_INT32_ELEMENTS, \ |
109 ExternalIntArray) \ | 109 ExternalInt32Array) \ |
110 V(ExternalUnsignedIntElementsAccessor, \ | 110 V(ExternalUint32ElementsAccessor, \ |
111 EXTERNAL_UNSIGNED_INT_ELEMENTS, ExternalUnsignedIntArray) \ | 111 EXTERNAL_UINT32_ELEMENTS, ExternalUint32Array) \ |
112 V(ExternalFloatElementsAccessor, \ | 112 V(ExternalFloat32ElementsAccessor, \ |
113 EXTERNAL_FLOAT_ELEMENTS, ExternalFloatArray) \ | 113 EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array) \ |
114 V(ExternalDoubleElementsAccessor, \ | 114 V(ExternalFloat64ElementsAccessor, \ |
115 EXTERNAL_DOUBLE_ELEMENTS, ExternalDoubleArray) \ | 115 EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array) \ |
116 V(PixelElementsAccessor, EXTERNAL_PIXEL_ELEMENTS, ExternalPixelArray) \ | 116 V(ExternalUint8ClampedElementsAccessor, \ |
117 V(FixedUint8ArrayAccessor, UINT8_ELEMENTS, FixedUint8Array) \ | 117 EXTERNAL_UINT8_CLAMPED_ELEMENTS, \ |
118 V(FixedInt8ArrayAccessor, INT8_ELEMENTS, FixedInt8Array) \ | 118 ExternalUint8ClampedArray) \ |
119 V(FixedUint16ArrayAccessor, UINT16_ELEMENTS, FixedUint16Array) \ | 119 V(FixedUint8ElementsAccessor, UINT8_ELEMENTS, FixedUint8Array) \ |
120 V(FixedInt16ArrayAccessor, INT16_ELEMENTS, FixedInt16Array) \ | 120 V(FixedInt8ElementsAccessor, INT8_ELEMENTS, FixedInt8Array) \ |
121 V(FixedUint32ArrayAccessor, UINT32_ELEMENTS, FixedUint32Array) \ | 121 V(FixedUint16ElementsAccessor, UINT16_ELEMENTS, FixedUint16Array) \ |
122 V(FixedInt32ArrayAccessor, INT32_ELEMENTS, FixedInt32Array) \ | 122 V(FixedInt16ElementsAccessor, INT16_ELEMENTS, FixedInt16Array) \ |
123 V(FixedFloat32ArrayAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \ | 123 V(FixedUint32ElementsAccessor, UINT32_ELEMENTS, FixedUint32Array) \ |
124 V(FixedFloat64ArrayAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \ | 124 V(FixedInt32ElementsAccessor, INT32_ELEMENTS, FixedInt32Array) \ |
125 V(FixedUint8ClampedArrayAccessor, UINT8_CLAMPED_ELEMENTS, \ | 125 V(FixedFloat32ElementsAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \ |
| 126 V(FixedFloat64ElementsAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \ |
| 127 V(FixedUint8ClampedElementsAccessor, UINT8_CLAMPED_ELEMENTS, \ |
126 FixedUint8ClampedArray) | 128 FixedUint8ClampedArray) |
127 | 129 |
128 | 130 |
129 template<ElementsKind Kind> class ElementsKindTraits { | 131 template<ElementsKind Kind> class ElementsKindTraits { |
130 public: | 132 public: |
131 typedef FixedArrayBase BackingStore; | 133 typedef FixedArrayBase BackingStore; |
132 }; | 134 }; |
133 | 135 |
134 #define ELEMENTS_TRAITS(Class, KindParam, Store) \ | 136 #define ELEMENTS_TRAITS(Class, KindParam, Store) \ |
135 template<> class ElementsKindTraits<KindParam> { \ | 137 template<> class ElementsKindTraits<KindParam> { \ |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 static inline ElementsKind ElementsKindForArray(FixedArrayBase* array) { | 1092 static inline ElementsKind ElementsKindForArray(FixedArrayBase* array) { |
1091 switch (array->map()->instance_type()) { | 1093 switch (array->map()->instance_type()) { |
1092 case FIXED_ARRAY_TYPE: | 1094 case FIXED_ARRAY_TYPE: |
1093 if (array->IsDictionary()) { | 1095 if (array->IsDictionary()) { |
1094 return DICTIONARY_ELEMENTS; | 1096 return DICTIONARY_ELEMENTS; |
1095 } else { | 1097 } else { |
1096 return FAST_HOLEY_ELEMENTS; | 1098 return FAST_HOLEY_ELEMENTS; |
1097 } | 1099 } |
1098 case FIXED_DOUBLE_ARRAY_TYPE: | 1100 case FIXED_DOUBLE_ARRAY_TYPE: |
1099 return FAST_HOLEY_DOUBLE_ELEMENTS; | 1101 return FAST_HOLEY_DOUBLE_ELEMENTS; |
1100 case EXTERNAL_BYTE_ARRAY_TYPE: | |
1101 return EXTERNAL_BYTE_ELEMENTS; | |
1102 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: | |
1103 return EXTERNAL_UNSIGNED_BYTE_ELEMENTS; | |
1104 case EXTERNAL_SHORT_ARRAY_TYPE: | |
1105 return EXTERNAL_SHORT_ELEMENTS; | |
1106 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: | |
1107 return EXTERNAL_UNSIGNED_SHORT_ELEMENTS; | |
1108 case EXTERNAL_INT_ARRAY_TYPE: | |
1109 return EXTERNAL_INT_ELEMENTS; | |
1110 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: | |
1111 return EXTERNAL_UNSIGNED_INT_ELEMENTS; | |
1112 case EXTERNAL_FLOAT_ARRAY_TYPE: | |
1113 return EXTERNAL_FLOAT_ELEMENTS; | |
1114 case EXTERNAL_DOUBLE_ARRAY_TYPE: | |
1115 return EXTERNAL_DOUBLE_ELEMENTS; | |
1116 case EXTERNAL_PIXEL_ARRAY_TYPE: | |
1117 return EXTERNAL_PIXEL_ELEMENTS; | |
1118 | 1102 |
1119 case FIXED_UINT8_ARRAY_TYPE: | 1103 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
1120 return UINT8_ELEMENTS; | 1104 case EXTERNAL_##TYPE##_ARRAY_TYPE: \ |
1121 case FIXED_INT8_ARRAY_TYPE: | 1105 return EXTERNAL_##TYPE##_ELEMENTS; \ |
1122 return INT8_ELEMENTS; | 1106 case FIXED_##TYPE##_ARRAY_TYPE: \ |
1123 case FIXED_UINT16_ARRAY_TYPE: | 1107 return TYPE##_ELEMENTS; |
1124 return UINT16_ELEMENTS; | 1108 |
1125 case FIXED_INT16_ARRAY_TYPE: | 1109 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
1126 return INT16_ELEMENTS; | 1110 #undef TYPED_ARRAY_CASE |
1127 case FIXED_UINT32_ARRAY_TYPE: | |
1128 return UINT32_ELEMENTS; | |
1129 case FIXED_INT32_ARRAY_TYPE: | |
1130 return INT32_ELEMENTS; | |
1131 case FIXED_FLOAT32_ARRAY_TYPE: | |
1132 return FLOAT32_ELEMENTS; | |
1133 case FIXED_FLOAT64_ARRAY_TYPE: | |
1134 return FLOAT64_ELEMENTS; | |
1135 case FIXED_UINT8_CLAMPED_ARRAY_TYPE: | |
1136 return UINT8_CLAMPED_ELEMENTS; | |
1137 | 1111 |
1138 default: | 1112 default: |
1139 UNREACHABLE(); | 1113 UNREACHABLE(); |
1140 } | 1114 } |
1141 return FAST_HOLEY_ELEMENTS; | 1115 return FAST_HOLEY_ELEMENTS; |
1142 } | 1116 } |
1143 | 1117 |
1144 | 1118 |
1145 template<typename FastElementsAccessorSubclass, | 1119 template<typename FastElementsAccessorSubclass, |
1146 typename KindTraits> | 1120 typename KindTraits> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 1155 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
1182 // TODO(verwaest): This is a temporary hack to support extending | 1156 // TODO(verwaest): This is a temporary hack to support extending |
1183 // NON_STRICT_ARGUMENTS_ELEMENTS in SetFastElementsCapacityAndLength. | 1157 // NON_STRICT_ARGUMENTS_ELEMENTS in SetFastElementsCapacityAndLength. |
1184 // This case should be UNREACHABLE(). | 1158 // This case should be UNREACHABLE(). |
1185 FixedArray* parameter_map = FixedArray::cast(from); | 1159 FixedArray* parameter_map = FixedArray::cast(from); |
1186 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); | 1160 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
1187 ElementsKind from_kind = ElementsKindForArray(arguments); | 1161 ElementsKind from_kind = ElementsKindForArray(arguments); |
1188 return CopyElementsImpl(arguments, from_start, to, from_kind, | 1162 return CopyElementsImpl(arguments, from_start, to, from_kind, |
1189 to_start, packed_size, copy_size); | 1163 to_start, packed_size, copy_size); |
1190 } | 1164 } |
1191 case EXTERNAL_BYTE_ELEMENTS: | 1165 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
1192 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 1166 case EXTERNAL_##TYPE##_ELEMENTS: \ |
1193 case EXTERNAL_SHORT_ELEMENTS: | 1167 case TYPE##_ELEMENTS: \ |
1194 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
1195 case EXTERNAL_INT_ELEMENTS: | |
1196 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
1197 case EXTERNAL_FLOAT_ELEMENTS: | |
1198 case EXTERNAL_DOUBLE_ELEMENTS: | |
1199 case EXTERNAL_PIXEL_ELEMENTS: | |
1200 case UINT8_ELEMENTS: | |
1201 case INT8_ELEMENTS: | |
1202 case UINT16_ELEMENTS: | |
1203 case INT16_ELEMENTS: | |
1204 case UINT32_ELEMENTS: | |
1205 case INT32_ELEMENTS: | |
1206 case FLOAT32_ELEMENTS: | |
1207 case FLOAT64_ELEMENTS: | |
1208 case UINT8_CLAMPED_ELEMENTS: | |
1209 UNREACHABLE(); | 1168 UNREACHABLE(); |
| 1169 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 1170 #undef TYPED_ARRAY_CASE |
1210 } | 1171 } |
1211 return NULL; | 1172 return NULL; |
1212 } | 1173 } |
1213 | 1174 |
1214 | 1175 |
1215 static MaybeObject* SetFastElementsCapacityAndLength(JSObject* obj, | 1176 static MaybeObject* SetFastElementsCapacityAndLength(JSObject* obj, |
1216 uint32_t capacity, | 1177 uint32_t capacity, |
1217 uint32_t length) { | 1178 uint32_t length) { |
1218 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode = | 1179 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode = |
1219 obj->HasFastSmiElements() | 1180 obj->HasFastSmiElements() |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 break; | 1276 break; |
1316 case FAST_ELEMENTS: | 1277 case FAST_ELEMENTS: |
1317 case FAST_HOLEY_ELEMENTS: | 1278 case FAST_HOLEY_ELEMENTS: |
1318 CopyObjectToDoubleElements(from, from_start, to, to_start, copy_size); | 1279 CopyObjectToDoubleElements(from, from_start, to, to_start, copy_size); |
1319 break; | 1280 break; |
1320 case DICTIONARY_ELEMENTS: | 1281 case DICTIONARY_ELEMENTS: |
1321 CopyDictionaryToDoubleElements( | 1282 CopyDictionaryToDoubleElements( |
1322 from, from_start, to, to_start, copy_size); | 1283 from, from_start, to, to_start, copy_size); |
1323 break; | 1284 break; |
1324 case NON_STRICT_ARGUMENTS_ELEMENTS: | 1285 case NON_STRICT_ARGUMENTS_ELEMENTS: |
1325 case EXTERNAL_BYTE_ELEMENTS: | |
1326 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | |
1327 case EXTERNAL_SHORT_ELEMENTS: | |
1328 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
1329 case EXTERNAL_INT_ELEMENTS: | |
1330 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
1331 case EXTERNAL_FLOAT_ELEMENTS: | |
1332 case EXTERNAL_DOUBLE_ELEMENTS: | |
1333 case EXTERNAL_PIXEL_ELEMENTS: | |
1334 case UINT8_ELEMENTS: | |
1335 case INT8_ELEMENTS: | |
1336 case UINT16_ELEMENTS: | |
1337 case INT16_ELEMENTS: | |
1338 case UINT32_ELEMENTS: | |
1339 case INT32_ELEMENTS: | |
1340 case FLOAT32_ELEMENTS: | |
1341 case FLOAT64_ELEMENTS: | |
1342 case UINT8_CLAMPED_ELEMENTS: | |
1343 UNREACHABLE(); | 1286 UNREACHABLE(); |
| 1287 |
| 1288 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 1289 case EXTERNAL_##TYPE##_ELEMENTS: \ |
| 1290 case TYPE##_ELEMENTS: \ |
| 1291 UNREACHABLE(); |
| 1292 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 1293 #undef TYPED_ARRAY_CASE |
1344 } | 1294 } |
1345 return to->GetHeap()->undefined_value(); | 1295 return to->GetHeap()->undefined_value(); |
1346 } | 1296 } |
1347 }; | 1297 }; |
1348 | 1298 |
1349 | 1299 |
1350 class FastPackedDoubleElementsAccessor | 1300 class FastPackedDoubleElementsAccessor |
1351 : public FastDoubleElementsAccessor< | 1301 : public FastDoubleElementsAccessor< |
1352 FastPackedDoubleElementsAccessor, | 1302 FastPackedDoubleElementsAccessor, |
1353 ElementsKindTraits<FAST_DOUBLE_ELEMENTS> > { | 1303 ElementsKindTraits<FAST_DOUBLE_ELEMENTS> > { |
(...skipping 16 matching lines...) Expand all Loading... |
1370 FastHoleyDoubleElementsAccessor, | 1320 FastHoleyDoubleElementsAccessor, |
1371 ElementsKindTraits<FAST_HOLEY_DOUBLE_ELEMENTS> >; | 1321 ElementsKindTraits<FAST_HOLEY_DOUBLE_ELEMENTS> >; |
1372 explicit FastHoleyDoubleElementsAccessor(const char* name) | 1322 explicit FastHoleyDoubleElementsAccessor(const char* name) |
1373 : FastDoubleElementsAccessor< | 1323 : FastDoubleElementsAccessor< |
1374 FastHoleyDoubleElementsAccessor, | 1324 FastHoleyDoubleElementsAccessor, |
1375 ElementsKindTraits<FAST_HOLEY_DOUBLE_ELEMENTS> >(name) {} | 1325 ElementsKindTraits<FAST_HOLEY_DOUBLE_ELEMENTS> >(name) {} |
1376 }; | 1326 }; |
1377 | 1327 |
1378 | 1328 |
1379 // Super class for all external element arrays. | 1329 // Super class for all external element arrays. |
1380 template<typename AccessorSubclass, | 1330 template<ElementsKind Kind> |
1381 ElementsKind Kind> | |
1382 class TypedElementsAccessor | 1331 class TypedElementsAccessor |
1383 : public ElementsAccessorBase<AccessorSubclass, | 1332 : public ElementsAccessorBase<TypedElementsAccessor<Kind>, |
1384 ElementsKindTraits<Kind> > { | 1333 ElementsKindTraits<Kind> > { |
1385 public: | 1334 public: |
1386 explicit TypedElementsAccessor(const char* name) | 1335 explicit TypedElementsAccessor(const char* name) |
1387 : ElementsAccessorBase<AccessorSubclass, | 1336 : ElementsAccessorBase<AccessorClass, |
1388 ElementsKindTraits<Kind> >(name) {} | 1337 ElementsKindTraits<Kind> >(name) {} |
1389 | 1338 |
1390 protected: | 1339 protected: |
1391 typedef typename ElementsKindTraits<Kind>::BackingStore BackingStore; | 1340 typedef typename ElementsKindTraits<Kind>::BackingStore BackingStore; |
| 1341 typedef TypedElementsAccessor<Kind> AccessorClass; |
1392 | 1342 |
1393 friend class ElementsAccessorBase<AccessorSubclass, | 1343 friend class ElementsAccessorBase<AccessorClass, |
1394 ElementsKindTraits<Kind> >; | 1344 ElementsKindTraits<Kind> >; |
1395 | 1345 |
1396 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, | 1346 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, |
1397 JSObject* obj, | 1347 JSObject* obj, |
1398 uint32_t key, | 1348 uint32_t key, |
1399 FixedArrayBase* backing_store) { | 1349 FixedArrayBase* backing_store) { |
1400 return | 1350 return |
1401 key < AccessorSubclass::GetCapacityImpl(backing_store) | 1351 key < AccessorClass::GetCapacityImpl(backing_store) |
1402 ? BackingStore::cast(backing_store)->get(key) | 1352 ? BackingStore::cast(backing_store)->get(key) |
1403 : backing_store->GetHeap()->undefined_value(); | 1353 : backing_store->GetHeap()->undefined_value(); |
1404 } | 1354 } |
1405 | 1355 |
1406 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | 1356 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( |
1407 Object* receiver, | 1357 Object* receiver, |
1408 JSObject* obj, | 1358 JSObject* obj, |
1409 uint32_t key, | 1359 uint32_t key, |
1410 FixedArrayBase* backing_store) { | 1360 FixedArrayBase* backing_store) { |
1411 return | 1361 return |
1412 key < AccessorSubclass::GetCapacityImpl(backing_store) | 1362 key < AccessorClass::GetCapacityImpl(backing_store) |
1413 ? NONE : ABSENT; | 1363 ? NONE : ABSENT; |
1414 } | 1364 } |
1415 | 1365 |
1416 MUST_USE_RESULT static PropertyType GetTypeImpl( | 1366 MUST_USE_RESULT static PropertyType GetTypeImpl( |
1417 Object* receiver, | 1367 Object* receiver, |
1418 JSObject* obj, | 1368 JSObject* obj, |
1419 uint32_t key, | 1369 uint32_t key, |
1420 FixedArrayBase* backing_store) { | 1370 FixedArrayBase* backing_store) { |
1421 return | 1371 return |
1422 key < AccessorSubclass::GetCapacityImpl(backing_store) | 1372 key < AccessorClass::GetCapacityImpl(backing_store) |
1423 ? FIELD : NONEXISTENT; | 1373 ? FIELD : NONEXISTENT; |
1424 } | 1374 } |
1425 | 1375 |
1426 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 1376 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
1427 JSObject* obj, | 1377 JSObject* obj, |
1428 Object* length, | 1378 Object* length, |
1429 FixedArrayBase* backing_store) { | 1379 FixedArrayBase* backing_store) { |
1430 // External arrays do not support changing their length. | 1380 // External arrays do not support changing their length. |
1431 UNREACHABLE(); | 1381 UNREACHABLE(); |
1432 return obj; | 1382 return obj; |
1433 } | 1383 } |
1434 | 1384 |
1435 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj, | 1385 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj, |
1436 uint32_t key, | 1386 uint32_t key, |
1437 JSReceiver::DeleteMode mode) { | 1387 JSReceiver::DeleteMode mode) { |
1438 // External arrays always ignore deletes. | 1388 // External arrays always ignore deletes. |
1439 return obj->GetHeap()->true_value(); | 1389 return obj->GetHeap()->true_value(); |
1440 } | 1390 } |
1441 | 1391 |
1442 static bool HasElementImpl(Object* receiver, | 1392 static bool HasElementImpl(Object* receiver, |
1443 JSObject* holder, | 1393 JSObject* holder, |
1444 uint32_t key, | 1394 uint32_t key, |
1445 FixedArrayBase* backing_store) { | 1395 FixedArrayBase* backing_store) { |
1446 uint32_t capacity = | 1396 uint32_t capacity = |
1447 AccessorSubclass::GetCapacityImpl(backing_store); | 1397 AccessorClass::GetCapacityImpl(backing_store); |
1448 return key < capacity; | 1398 return key < capacity; |
1449 } | 1399 } |
1450 }; | 1400 }; |
1451 | 1401 |
1452 | 1402 |
1453 class ExternalByteElementsAccessor | 1403 |
1454 : public TypedElementsAccessor<ExternalByteElementsAccessor, | 1404 #define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ |
1455 EXTERNAL_BYTE_ELEMENTS> { | 1405 typedef TypedElementsAccessor<EXTERNAL_##TYPE##_ELEMENTS> \ |
1456 public: | 1406 External##Type##ElementsAccessor; |
1457 explicit ExternalByteElementsAccessor(const char* name) | 1407 |
1458 : TypedElementsAccessor<ExternalByteElementsAccessor, | 1408 TYPED_ARRAYS(EXTERNAL_ELEMENTS_ACCESSOR) |
1459 EXTERNAL_BYTE_ELEMENTS>(name) {} | 1409 #undef EXTERNAL_ELEMENTS_ACCESSOR |
1460 }; | 1410 |
| 1411 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ |
| 1412 typedef TypedElementsAccessor<TYPE##_ELEMENTS > \ |
| 1413 Fixed##Type##ElementsAccessor; |
| 1414 |
| 1415 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) |
| 1416 #undef FIXED_ELEMENTS_ACCESSOR |
1461 | 1417 |
1462 | 1418 |
1463 class ExternalUnsignedByteElementsAccessor | |
1464 : public TypedElementsAccessor<ExternalUnsignedByteElementsAccessor, | |
1465 EXTERNAL_UNSIGNED_BYTE_ELEMENTS> { | |
1466 public: | |
1467 explicit ExternalUnsignedByteElementsAccessor(const char* name) | |
1468 : TypedElementsAccessor<ExternalUnsignedByteElementsAccessor, | |
1469 EXTERNAL_UNSIGNED_BYTE_ELEMENTS>(name) {} | |
1470 }; | |
1471 | |
1472 | |
1473 class ExternalShortElementsAccessor | |
1474 : public TypedElementsAccessor<ExternalShortElementsAccessor, | |
1475 EXTERNAL_SHORT_ELEMENTS> { | |
1476 public: | |
1477 explicit ExternalShortElementsAccessor(const char* name) | |
1478 : TypedElementsAccessor<ExternalShortElementsAccessor, | |
1479 EXTERNAL_SHORT_ELEMENTS>(name) {} | |
1480 }; | |
1481 | |
1482 | |
1483 class ExternalUnsignedShortElementsAccessor | |
1484 : public TypedElementsAccessor<ExternalUnsignedShortElementsAccessor, | |
1485 EXTERNAL_UNSIGNED_SHORT_ELEMENTS> { | |
1486 public: | |
1487 explicit ExternalUnsignedShortElementsAccessor(const char* name) | |
1488 : TypedElementsAccessor<ExternalUnsignedShortElementsAccessor, | |
1489 EXTERNAL_UNSIGNED_SHORT_ELEMENTS>(name) {} | |
1490 }; | |
1491 | |
1492 | |
1493 class ExternalIntElementsAccessor | |
1494 : public TypedElementsAccessor<ExternalIntElementsAccessor, | |
1495 EXTERNAL_INT_ELEMENTS> { | |
1496 public: | |
1497 explicit ExternalIntElementsAccessor(const char* name) | |
1498 : TypedElementsAccessor<ExternalIntElementsAccessor, | |
1499 EXTERNAL_INT_ELEMENTS>(name) {} | |
1500 }; | |
1501 | |
1502 | |
1503 class ExternalUnsignedIntElementsAccessor | |
1504 : public TypedElementsAccessor<ExternalUnsignedIntElementsAccessor, | |
1505 EXTERNAL_UNSIGNED_INT_ELEMENTS> { | |
1506 public: | |
1507 explicit ExternalUnsignedIntElementsAccessor(const char* name) | |
1508 : TypedElementsAccessor<ExternalUnsignedIntElementsAccessor, | |
1509 EXTERNAL_UNSIGNED_INT_ELEMENTS>(name) {} | |
1510 }; | |
1511 | |
1512 | |
1513 class ExternalFloatElementsAccessor | |
1514 : public TypedElementsAccessor<ExternalFloatElementsAccessor, | |
1515 EXTERNAL_FLOAT_ELEMENTS> { | |
1516 public: | |
1517 explicit ExternalFloatElementsAccessor(const char* name) | |
1518 : TypedElementsAccessor<ExternalFloatElementsAccessor, | |
1519 EXTERNAL_FLOAT_ELEMENTS>(name) {} | |
1520 }; | |
1521 | |
1522 | |
1523 class ExternalDoubleElementsAccessor | |
1524 : public TypedElementsAccessor<ExternalDoubleElementsAccessor, | |
1525 EXTERNAL_DOUBLE_ELEMENTS> { | |
1526 public: | |
1527 explicit ExternalDoubleElementsAccessor(const char* name) | |
1528 : TypedElementsAccessor<ExternalDoubleElementsAccessor, | |
1529 EXTERNAL_DOUBLE_ELEMENTS>(name) {} | |
1530 }; | |
1531 | |
1532 | |
1533 class PixelElementsAccessor | |
1534 : public TypedElementsAccessor<PixelElementsAccessor, | |
1535 EXTERNAL_PIXEL_ELEMENTS> { | |
1536 public: | |
1537 explicit PixelElementsAccessor(const char* name) | |
1538 : TypedElementsAccessor<PixelElementsAccessor, | |
1539 EXTERNAL_PIXEL_ELEMENTS>(name) {} | |
1540 }; | |
1541 | |
1542 | |
1543 class FixedUint8ArrayAccessor | |
1544 : public TypedElementsAccessor<FixedUint8ArrayAccessor, | |
1545 UINT8_ELEMENTS> { | |
1546 public: | |
1547 explicit FixedUint8ArrayAccessor(const char* name) | |
1548 : TypedElementsAccessor<FixedUint8ArrayAccessor, | |
1549 UINT8_ELEMENTS>(name) {} | |
1550 }; | |
1551 class FixedUint8ClampedArrayAccessor | |
1552 : public TypedElementsAccessor<FixedUint8ClampedArrayAccessor, | |
1553 UINT8_CLAMPED_ELEMENTS> { | |
1554 public: | |
1555 explicit FixedUint8ClampedArrayAccessor(const char* name) | |
1556 : TypedElementsAccessor<FixedUint8ClampedArrayAccessor, | |
1557 UINT8_CLAMPED_ELEMENTS>(name) {} | |
1558 }; | |
1559 class FixedInt8ArrayAccessor | |
1560 : public TypedElementsAccessor<FixedInt8ArrayAccessor, | |
1561 INT8_ELEMENTS> { | |
1562 public: | |
1563 explicit FixedInt8ArrayAccessor(const char* name) | |
1564 : TypedElementsAccessor<FixedInt8ArrayAccessor, | |
1565 INT8_ELEMENTS>(name) {} | |
1566 }; | |
1567 class FixedUint16ArrayAccessor | |
1568 : public TypedElementsAccessor<FixedUint16ArrayAccessor, | |
1569 UINT16_ELEMENTS> { | |
1570 public: | |
1571 explicit FixedUint16ArrayAccessor(const char* name) | |
1572 : TypedElementsAccessor<FixedUint16ArrayAccessor, | |
1573 UINT16_ELEMENTS>(name) {} | |
1574 }; | |
1575 class FixedInt16ArrayAccessor | |
1576 : public TypedElementsAccessor<FixedInt16ArrayAccessor, | |
1577 INT16_ELEMENTS> { | |
1578 public: | |
1579 explicit FixedInt16ArrayAccessor(const char* name) | |
1580 : TypedElementsAccessor<FixedInt16ArrayAccessor, | |
1581 INT16_ELEMENTS>(name) {} | |
1582 }; | |
1583 class FixedUint32ArrayAccessor | |
1584 : public TypedElementsAccessor<FixedUint32ArrayAccessor, | |
1585 UINT32_ELEMENTS> { | |
1586 public: | |
1587 explicit FixedUint32ArrayAccessor(const char* name) | |
1588 : TypedElementsAccessor<FixedUint32ArrayAccessor, | |
1589 UINT32_ELEMENTS>(name) {} | |
1590 }; | |
1591 class FixedInt32ArrayAccessor | |
1592 : public TypedElementsAccessor<FixedInt32ArrayAccessor, | |
1593 INT32_ELEMENTS> { | |
1594 public: | |
1595 explicit FixedInt32ArrayAccessor(const char* name) | |
1596 : TypedElementsAccessor<FixedInt32ArrayAccessor, | |
1597 INT32_ELEMENTS>(name) {} | |
1598 }; | |
1599 | |
1600 class FixedFloat32ArrayAccessor | |
1601 : public TypedElementsAccessor<FixedFloat32ArrayAccessor, | |
1602 FLOAT32_ELEMENTS> { | |
1603 public: | |
1604 explicit FixedFloat32ArrayAccessor(const char* name) | |
1605 : TypedElementsAccessor<FixedFloat32ArrayAccessor, | |
1606 FLOAT32_ELEMENTS>(name) {} | |
1607 }; | |
1608 class FixedFloat64ArrayAccessor | |
1609 : public TypedElementsAccessor<FixedFloat64ArrayAccessor, | |
1610 FLOAT64_ELEMENTS> { | |
1611 public: | |
1612 explicit FixedFloat64ArrayAccessor(const char* name) | |
1613 : TypedElementsAccessor<FixedFloat64ArrayAccessor, | |
1614 FLOAT64_ELEMENTS>(name) {} | |
1615 }; | |
1616 | 1419 |
1617 class DictionaryElementsAccessor | 1420 class DictionaryElementsAccessor |
1618 : public ElementsAccessorBase<DictionaryElementsAccessor, | 1421 : public ElementsAccessorBase<DictionaryElementsAccessor, |
1619 ElementsKindTraits<DICTIONARY_ELEMENTS> > { | 1422 ElementsKindTraits<DICTIONARY_ELEMENTS> > { |
1620 public: | 1423 public: |
1621 explicit DictionaryElementsAccessor(const char* name) | 1424 explicit DictionaryElementsAccessor(const char* name) |
1622 : ElementsAccessorBase<DictionaryElementsAccessor, | 1425 : ElementsAccessorBase<DictionaryElementsAccessor, |
1623 ElementsKindTraits<DICTIONARY_ELEMENTS> >(name) {} | 1426 ElementsKindTraits<DICTIONARY_ELEMENTS> >(name) {} |
1624 | 1427 |
1625 // Adjusts the length of the dictionary backing store and returns the new | 1428 // Adjusts the length of the dictionary backing store and returns the new |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 UNREACHABLE(); | 1992 UNREACHABLE(); |
2190 break; | 1993 break; |
2191 } | 1994 } |
2192 | 1995 |
2193 array->set_elements(elms); | 1996 array->set_elements(elms); |
2194 array->set_length(Smi::FromInt(number_of_elements)); | 1997 array->set_length(Smi::FromInt(number_of_elements)); |
2195 return array; | 1998 return array; |
2196 } | 1999 } |
2197 | 2000 |
2198 } } // namespace v8::internal | 2001 } } // namespace v8::internal |
OLD | NEW |