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

Side by Side Diff: src/elements.cc

Issue 1257223002: Revert of Remove ExternalArray, derived types, and element kinds (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
30 // - FixedUint8ElementsAccessor 39 // - FixedUint8ElementsAccessor
31 // - FixedInt8ElementsAccessor 40 // - FixedInt8ElementsAccessor
32 // - FixedUint16ElementsAccessor 41 // - FixedUint16ElementsAccessor
33 // - FixedInt16ElementsAccessor 42 // - FixedInt16ElementsAccessor
34 // - FixedUint32ElementsAccessor 43 // - FixedUint32ElementsAccessor
35 // - FixedInt32ElementsAccessor 44 // - FixedInt32ElementsAccessor
36 // - FixedFloat32ElementsAccessor 45 // - FixedFloat32ElementsAccessor
37 // - FixedFloat64ElementsAccessor 46 // - FixedFloat64ElementsAccessor
38 // - FixedUint8ClampedElementsAccessor 47 // - FixedUint8ClampedElementsAccessor
39 // - DictionaryElementsAccessor 48 // - DictionaryElementsAccessor
(...skipping 23 matching lines...) Expand all
63 V(FastPackedObjectElementsAccessor, FAST_ELEMENTS, FixedArray) \ 72 V(FastPackedObjectElementsAccessor, FAST_ELEMENTS, FixedArray) \
64 V(FastHoleyObjectElementsAccessor, FAST_HOLEY_ELEMENTS, FixedArray) \ 73 V(FastHoleyObjectElementsAccessor, FAST_HOLEY_ELEMENTS, FixedArray) \
65 V(FastPackedDoubleElementsAccessor, FAST_DOUBLE_ELEMENTS, FixedDoubleArray) \ 74 V(FastPackedDoubleElementsAccessor, FAST_DOUBLE_ELEMENTS, FixedDoubleArray) \
66 V(FastHoleyDoubleElementsAccessor, FAST_HOLEY_DOUBLE_ELEMENTS, \ 75 V(FastHoleyDoubleElementsAccessor, FAST_HOLEY_DOUBLE_ELEMENTS, \
67 FixedDoubleArray) \ 76 FixedDoubleArray) \
68 V(DictionaryElementsAccessor, DICTIONARY_ELEMENTS, SeededNumberDictionary) \ 77 V(DictionaryElementsAccessor, DICTIONARY_ELEMENTS, SeededNumberDictionary) \
69 V(FastSloppyArgumentsElementsAccessor, FAST_SLOPPY_ARGUMENTS_ELEMENTS, \ 78 V(FastSloppyArgumentsElementsAccessor, FAST_SLOPPY_ARGUMENTS_ELEMENTS, \
70 FixedArray) \ 79 FixedArray) \
71 V(SlowSloppyArgumentsElementsAccessor, SLOW_SLOPPY_ARGUMENTS_ELEMENTS, \ 80 V(SlowSloppyArgumentsElementsAccessor, SLOW_SLOPPY_ARGUMENTS_ELEMENTS, \
72 FixedArray) \ 81 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) \
73 V(FixedUint8ElementsAccessor, UINT8_ELEMENTS, FixedUint8Array) \ 99 V(FixedUint8ElementsAccessor, UINT8_ELEMENTS, FixedUint8Array) \
74 V(FixedInt8ElementsAccessor, INT8_ELEMENTS, FixedInt8Array) \ 100 V(FixedInt8ElementsAccessor, INT8_ELEMENTS, FixedInt8Array) \
75 V(FixedUint16ElementsAccessor, UINT16_ELEMENTS, FixedUint16Array) \ 101 V(FixedUint16ElementsAccessor, UINT16_ELEMENTS, FixedUint16Array) \
76 V(FixedInt16ElementsAccessor, INT16_ELEMENTS, FixedInt16Array) \ 102 V(FixedInt16ElementsAccessor, INT16_ELEMENTS, FixedInt16Array) \
77 V(FixedUint32ElementsAccessor, UINT32_ELEMENTS, FixedUint32Array) \ 103 V(FixedUint32ElementsAccessor, UINT32_ELEMENTS, FixedUint32Array) \
78 V(FixedInt32ElementsAccessor, INT32_ELEMENTS, FixedInt32Array) \ 104 V(FixedInt32ElementsAccessor, INT32_ELEMENTS, FixedInt32Array) \
79 V(FixedFloat32ElementsAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \ 105 V(FixedFloat32ElementsAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \
80 V(FixedFloat64ElementsAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \ 106 V(FixedFloat64ElementsAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \
81 V(FixedUint8ClampedElementsAccessor, UINT8_CLAMPED_ELEMENTS, \ 107 V(FixedUint8ClampedElementsAccessor, UINT8_CLAMPED_ELEMENTS, \
82 FixedUint8ClampedArray) 108 FixedUint8ClampedArray)
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 break; 1211 break;
1186 } 1212 }
1187 case DICTIONARY_ELEMENTS: 1213 case DICTIONARY_ELEMENTS:
1188 CopyDictionaryToObjectElements(from, from_start, to, to_kind, to_start, 1214 CopyDictionaryToObjectElements(from, from_start, to, to_kind, to_start,
1189 copy_size); 1215 copy_size);
1190 break; 1216 break;
1191 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: 1217 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
1192 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: 1218 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
1193 UNREACHABLE(); 1219 UNREACHABLE();
1194 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1220 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1221 case EXTERNAL_##TYPE##_ELEMENTS: \
1195 case TYPE##_ELEMENTS: \ 1222 case TYPE##_ELEMENTS: \
1196 UNREACHABLE(); 1223 UNREACHABLE();
1197 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1224 TYPED_ARRAYS(TYPED_ARRAY_CASE)
1198 #undef TYPED_ARRAY_CASE 1225 #undef TYPED_ARRAY_CASE
1199 } 1226 }
1200 } 1227 }
1201 }; 1228 };
1202 1229
1203 1230
1204 class FastPackedSmiElementsAccessor 1231 class FastPackedSmiElementsAccessor
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 break; 1308 break;
1282 case DICTIONARY_ELEMENTS: 1309 case DICTIONARY_ELEMENTS:
1283 CopyDictionaryToDoubleElements(from, from_start, to, to_start, 1310 CopyDictionaryToDoubleElements(from, from_start, to, to_start,
1284 copy_size); 1311 copy_size);
1285 break; 1312 break;
1286 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: 1313 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
1287 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: 1314 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
1288 UNREACHABLE(); 1315 UNREACHABLE();
1289 1316
1290 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1317 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1318 case EXTERNAL_##TYPE##_ELEMENTS: \
1291 case TYPE##_ELEMENTS: \ 1319 case TYPE##_ELEMENTS: \
1292 UNREACHABLE(); 1320 UNREACHABLE();
1293 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1321 TYPED_ARRAYS(TYPED_ARRAY_CASE)
1294 #undef TYPED_ARRAY_CASE 1322 #undef TYPED_ARRAY_CASE
1295 } 1323 }
1296 } 1324 }
1297 }; 1325 };
1298 1326
1299 1327
1300 class FastPackedDoubleElementsAccessor 1328 class FastPackedDoubleElementsAccessor
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 static uint32_t GetCapacityImpl(JSObject* holder, 1399 static uint32_t GetCapacityImpl(JSObject* holder,
1372 FixedArrayBase* backing_store) { 1400 FixedArrayBase* backing_store) {
1373 JSArrayBufferView* view = JSArrayBufferView::cast(holder); 1401 JSArrayBufferView* view = JSArrayBufferView::cast(holder);
1374 if (view->WasNeutered()) return 0; 1402 if (view->WasNeutered()) return 0;
1375 return backing_store->length(); 1403 return backing_store->length();
1376 } 1404 }
1377 }; 1405 };
1378 1406
1379 1407
1380 1408
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
1381 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ 1416 #define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
1382 typedef TypedElementsAccessor<TYPE##_ELEMENTS > \ 1417 typedef TypedElementsAccessor<TYPE##_ELEMENTS > \
1383 Fixed##Type##ElementsAccessor; 1418 Fixed##Type##ElementsAccessor;
1384 1419
1385 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) 1420 TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR)
1386 #undef FIXED_ELEMENTS_ACCESSOR 1421 #undef FIXED_ELEMENTS_ACCESSOR
1387 1422
1388 1423
1389 template <typename SloppyArgumentsElementsAccessorSubclass, 1424 template <typename SloppyArgumentsElementsAccessorSubclass,
1390 typename ArgumentsAccessor, typename KindTraits> 1425 typename ArgumentsAccessor, typename KindTraits>
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; 1945 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
1911 ELEMENTS_LIST(ACCESSOR_DELETE) 1946 ELEMENTS_LIST(ACCESSOR_DELETE)
1912 #undef ACCESSOR_DELETE 1947 #undef ACCESSOR_DELETE
1913 elements_accessors_ = NULL; 1948 elements_accessors_ = NULL;
1914 } 1949 }
1915 1950
1916 1951
1917 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 1952 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
1918 } // namespace internal 1953 } // namespace internal
1919 } // namespace v8 1954 } // 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