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

Side by Side Diff: src/elements.cc

Issue 1254623002: Remove ExternalArray, derived types, and element kinds (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 4 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
« no previous file with comments | « src/contexts.h ('k') | src/elements-kind.h » ('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 // 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/messages.h" 10 #include "src/messages.h"
11 #include "src/objects.h" 11 #include "src/objects.h"
12 #include "src/utils.h" 12 #include "src/utils.h"
13 13
14 // Each concrete ElementsAccessor can handle exactly one ElementsKind, 14 // Each concrete ElementsAccessor can handle exactly one ElementsKind,
15 // several abstract ElementsAccessor classes are used to allow sharing 15 // several abstract ElementsAccessor classes are used to allow sharing
16 // common code. 16 // common code.
17 // 17 //
18 // Inheritance hierarchy: 18 // Inheritance hierarchy:
19 // - ElementsAccessorBase (abstract) 19 // - ElementsAccessorBase (abstract)
20 // - FastElementsAccessor (abstract) 20 // - FastElementsAccessor (abstract)
21 // - FastSmiOrObjectElementsAccessor 21 // - FastSmiOrObjectElementsAccessor
22 // - FastPackedSmiElementsAccessor 22 // - FastPackedSmiElementsAccessor
23 // - FastHoleySmiElementsAccessor 23 // - FastHoleySmiElementsAccessor
24 // - FastPackedObjectElementsAccessor 24 // - FastPackedObjectElementsAccessor
25 // - FastHoleyObjectElementsAccessor 25 // - FastHoleyObjectElementsAccessor
26 // - FastDoubleElementsAccessor 26 // - FastDoubleElementsAccessor
27 // - FastPackedDoubleElementsAccessor 27 // - FastPackedDoubleElementsAccessor
28 // - FastHoleyDoubleElementsAccessor 28 // - FastHoleyDoubleElementsAccessor
29 // - TypedElementsAccessor: template, with instantiations: 29 // - TypedElementsAccessor: template, with instantiations:
30 // - ExternalInt8ElementsAccessor
31 // - ExternalUint8ElementsAccessor
32 // - ExternalInt16ElementsAccessor
33 // - ExternalUint16ElementsAccessor
34 // - ExternalInt32ElementsAccessor
35 // - ExternalUint32ElementsAccessor
36 // - ExternalFloat32ElementsAccessor
37 // - ExternalFloat64ElementsAccessor
38 // - ExternalUint8ClampedElementsAccessor
39 // - FixedUint8ElementsAccessor 30 // - FixedUint8ElementsAccessor
40 // - FixedInt8ElementsAccessor 31 // - FixedInt8ElementsAccessor
41 // - FixedUint16ElementsAccessor 32 // - FixedUint16ElementsAccessor
42 // - FixedInt16ElementsAccessor 33 // - FixedInt16ElementsAccessor
43 // - FixedUint32ElementsAccessor 34 // - FixedUint32ElementsAccessor
44 // - FixedInt32ElementsAccessor 35 // - FixedInt32ElementsAccessor
45 // - FixedFloat32ElementsAccessor 36 // - FixedFloat32ElementsAccessor
46 // - FixedFloat64ElementsAccessor 37 // - FixedFloat64ElementsAccessor
47 // - FixedUint8ClampedElementsAccessor 38 // - FixedUint8ClampedElementsAccessor
48 // - DictionaryElementsAccessor 39 // - DictionaryElementsAccessor
(...skipping 23 matching lines...) Expand all
72 V(FastPackedObjectElementsAccessor, FAST_ELEMENTS, FixedArray) \ 63 V(FastPackedObjectElementsAccessor, FAST_ELEMENTS, FixedArray) \
73 V(FastHoleyObjectElementsAccessor, FAST_HOLEY_ELEMENTS, FixedArray) \ 64 V(FastHoleyObjectElementsAccessor, FAST_HOLEY_ELEMENTS, FixedArray) \
74 V(FastPackedDoubleElementsAccessor, FAST_DOUBLE_ELEMENTS, FixedDoubleArray) \ 65 V(FastPackedDoubleElementsAccessor, FAST_DOUBLE_ELEMENTS, FixedDoubleArray) \
75 V(FastHoleyDoubleElementsAccessor, FAST_HOLEY_DOUBLE_ELEMENTS, \ 66 V(FastHoleyDoubleElementsAccessor, FAST_HOLEY_DOUBLE_ELEMENTS, \
76 FixedDoubleArray) \ 67 FixedDoubleArray) \
77 V(DictionaryElementsAccessor, DICTIONARY_ELEMENTS, SeededNumberDictionary) \ 68 V(DictionaryElementsAccessor, DICTIONARY_ELEMENTS, SeededNumberDictionary) \
78 V(FastSloppyArgumentsElementsAccessor, FAST_SLOPPY_ARGUMENTS_ELEMENTS, \ 69 V(FastSloppyArgumentsElementsAccessor, FAST_SLOPPY_ARGUMENTS_ELEMENTS, \
79 FixedArray) \ 70 FixedArray) \
80 V(SlowSloppyArgumentsElementsAccessor, SLOW_SLOPPY_ARGUMENTS_ELEMENTS, \ 71 V(SlowSloppyArgumentsElementsAccessor, SLOW_SLOPPY_ARGUMENTS_ELEMENTS, \
81 FixedArray) \ 72 FixedArray) \
82 V(ExternalInt8ElementsAccessor, EXTERNAL_INT8_ELEMENTS, ExternalInt8Array) \
83 V(ExternalUint8ElementsAccessor, EXTERNAL_UINT8_ELEMENTS, \
84 ExternalUint8Array) \
85 V(ExternalInt16ElementsAccessor, EXTERNAL_INT16_ELEMENTS, \
86 ExternalInt16Array) \
87 V(ExternalUint16ElementsAccessor, EXTERNAL_UINT16_ELEMENTS, \
88 ExternalUint16Array) \
89 V(ExternalInt32ElementsAccessor, EXTERNAL_INT32_ELEMENTS, \
90 ExternalInt32Array) \
91 V(ExternalUint32ElementsAccessor, EXTERNAL_UINT32_ELEMENTS, \
92 ExternalUint32Array) \
93 V(ExternalFloat32ElementsAccessor, EXTERNAL_FLOAT32_ELEMENTS, \
94 ExternalFloat32Array) \
95 V(ExternalFloat64ElementsAccessor, EXTERNAL_FLOAT64_ELEMENTS, \
96 ExternalFloat64Array) \
97 V(ExternalUint8ClampedElementsAccessor, EXTERNAL_UINT8_CLAMPED_ELEMENTS, \
98 ExternalUint8ClampedArray) \
99 V(FixedUint8ElementsAccessor, UINT8_ELEMENTS, FixedUint8Array) \ 73 V(FixedUint8ElementsAccessor, UINT8_ELEMENTS, FixedUint8Array) \
100 V(FixedInt8ElementsAccessor, INT8_ELEMENTS, FixedInt8Array) \ 74 V(FixedInt8ElementsAccessor, INT8_ELEMENTS, FixedInt8Array) \
101 V(FixedUint16ElementsAccessor, UINT16_ELEMENTS, FixedUint16Array) \ 75 V(FixedUint16ElementsAccessor, UINT16_ELEMENTS, FixedUint16Array) \
102 V(FixedInt16ElementsAccessor, INT16_ELEMENTS, FixedInt16Array) \ 76 V(FixedInt16ElementsAccessor, INT16_ELEMENTS, FixedInt16Array) \
103 V(FixedUint32ElementsAccessor, UINT32_ELEMENTS, FixedUint32Array) \ 77 V(FixedUint32ElementsAccessor, UINT32_ELEMENTS, FixedUint32Array) \
104 V(FixedInt32ElementsAccessor, INT32_ELEMENTS, FixedInt32Array) \ 78 V(FixedInt32ElementsAccessor, INT32_ELEMENTS, FixedInt32Array) \
105 V(FixedFloat32ElementsAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \ 79 V(FixedFloat32ElementsAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \
106 V(FixedFloat64ElementsAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \ 80 V(FixedFloat64ElementsAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \
107 V(FixedUint8ClampedElementsAccessor, UINT8_CLAMPED_ELEMENTS, \ 81 V(FixedUint8ClampedElementsAccessor, UINT8_CLAMPED_ELEMENTS, \
108 FixedUint8ClampedArray) 82 FixedUint8ClampedArray)
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 break; 1185 break;
1212 } 1186 }
1213 case DICTIONARY_ELEMENTS: 1187 case DICTIONARY_ELEMENTS:
1214 CopyDictionaryToObjectElements(from, from_start, to, to_kind, to_start, 1188 CopyDictionaryToObjectElements(from, from_start, to, to_kind, to_start,
1215 copy_size); 1189 copy_size);
1216 break; 1190 break;
1217 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: 1191 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
1218 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: 1192 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
1219 UNREACHABLE(); 1193 UNREACHABLE();
1220 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1194 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1221 case EXTERNAL_##TYPE##_ELEMENTS: \
1222 case TYPE##_ELEMENTS: \ 1195 case TYPE##_ELEMENTS: \
1223 UNREACHABLE(); 1196 UNREACHABLE();
1224 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1197 TYPED_ARRAYS(TYPED_ARRAY_CASE)
1225 #undef TYPED_ARRAY_CASE 1198 #undef TYPED_ARRAY_CASE
1226 } 1199 }
1227 } 1200 }
1228 }; 1201 };
1229 1202
1230 1203
1231 class FastPackedSmiElementsAccessor 1204 class FastPackedSmiElementsAccessor
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 break; 1281 break;
1309 case DICTIONARY_ELEMENTS: 1282 case DICTIONARY_ELEMENTS:
1310 CopyDictionaryToDoubleElements(from, from_start, to, to_start, 1283 CopyDictionaryToDoubleElements(from, from_start, to, to_start,
1311 copy_size); 1284 copy_size);
1312 break; 1285 break;
1313 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: 1286 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
1314 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: 1287 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
1315 UNREACHABLE(); 1288 UNREACHABLE();
1316 1289
1317 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1290 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1318 case EXTERNAL_##TYPE##_ELEMENTS: \
1319 case TYPE##_ELEMENTS: \ 1291 case TYPE##_ELEMENTS: \
1320 UNREACHABLE(); 1292 UNREACHABLE();
1321 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1293 TYPED_ARRAYS(TYPED_ARRAY_CASE)
1322 #undef TYPED_ARRAY_CASE 1294 #undef TYPED_ARRAY_CASE
1323 } 1295 }
1324 } 1296 }
1325 }; 1297 };
1326 1298
1327 1299
1328 class FastPackedDoubleElementsAccessor 1300 class FastPackedDoubleElementsAccessor
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 static uint32_t GetCapacityImpl(JSObject* holder, 1371 static uint32_t GetCapacityImpl(JSObject* holder,
1400 FixedArrayBase* backing_store) { 1372 FixedArrayBase* backing_store) {
1401 JSArrayBufferView* view = JSArrayBufferView::cast(holder); 1373 JSArrayBufferView* view = JSArrayBufferView::cast(holder);
1402 if (view->WasNeutered()) return 0; 1374 if (view->WasNeutered()) return 0;
1403 return backing_store->length(); 1375 return backing_store->length();
1404 } 1376 }
1405 }; 1377 };
1406 1378
1407 1379
1408 1380
1409 #define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
1410 typedef TypedElementsAccessor<EXTERNAL_##TYPE##_ELEMENTS> \
1411 External##Type##ElementsAccessor;
1412
1413 TYPED_ARRAYS(EXTERNAL_ELEMENTS_ACCESSOR)
1414 #undef EXTERNAL_ELEMENTS_ACCESSOR
1415
1416 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ 1381 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
1417 typedef TypedElementsAccessor<TYPE##_ELEMENTS > \ 1382 typedef TypedElementsAccessor<TYPE##_ELEMENTS > \
1418 Fixed##Type##ElementsAccessor; 1383 Fixed##Type##ElementsAccessor;
1419 1384
1420 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) 1385 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR)
1421 #undef FIXED_ELEMENTS_ACCESSOR 1386 #undef FIXED_ELEMENTS_ACCESSOR
1422 1387
1423 1388
1424 template <typename SloppyArgumentsElementsAccessorSubclass, 1389 template <typename SloppyArgumentsElementsAccessorSubclass,
1425 typename ArgumentsAccessor, typename KindTraits> 1390 typename ArgumentsAccessor, typename KindTraits>
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; 1910 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
1946 ELEMENTS_LIST(ACCESSOR_DELETE) 1911 ELEMENTS_LIST(ACCESSOR_DELETE)
1947 #undef ACCESSOR_DELETE 1912 #undef ACCESSOR_DELETE
1948 elements_accessors_ = NULL; 1913 elements_accessors_ = NULL;
1949 } 1914 }
1950 1915
1951 1916
1952 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 1917 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
1953 } // namespace internal 1918 } // namespace internal
1954 } // namespace v8 1919 } // namespace v8
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/elements-kind.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698