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

Side by Side Diff: src/elements-kind.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/elements-kind.h ('k') | src/factory.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/elements-kind.h" 5 #include "src/elements-kind.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/base/lazy-instance.h" 8 #include "src/base/lazy-instance.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 15
16 int ElementsKindToShiftSize(ElementsKind elements_kind) { 16 int ElementsKindToShiftSize(ElementsKind elements_kind) {
17 switch (elements_kind) { 17 switch (elements_kind) {
18 case EXTERNAL_INT8_ELEMENTS:
19 case EXTERNAL_UINT8_CLAMPED_ELEMENTS:
20 case EXTERNAL_UINT8_ELEMENTS:
18 case UINT8_ELEMENTS: 21 case UINT8_ELEMENTS:
19 case INT8_ELEMENTS: 22 case INT8_ELEMENTS:
20 case UINT8_CLAMPED_ELEMENTS: 23 case UINT8_CLAMPED_ELEMENTS:
21 return 0; 24 return 0;
25 case EXTERNAL_INT16_ELEMENTS:
26 case EXTERNAL_UINT16_ELEMENTS:
22 case UINT16_ELEMENTS: 27 case UINT16_ELEMENTS:
23 case INT16_ELEMENTS: 28 case INT16_ELEMENTS:
24 return 1; 29 return 1;
30 case EXTERNAL_INT32_ELEMENTS:
31 case EXTERNAL_UINT32_ELEMENTS:
32 case EXTERNAL_FLOAT32_ELEMENTS:
25 case UINT32_ELEMENTS: 33 case UINT32_ELEMENTS:
26 case INT32_ELEMENTS: 34 case INT32_ELEMENTS:
27 case FLOAT32_ELEMENTS: 35 case FLOAT32_ELEMENTS:
28 return 2; 36 return 2;
37 case EXTERNAL_FLOAT64_ELEMENTS:
29 case FAST_DOUBLE_ELEMENTS: 38 case FAST_DOUBLE_ELEMENTS:
30 case FAST_HOLEY_DOUBLE_ELEMENTS: 39 case FAST_HOLEY_DOUBLE_ELEMENTS:
31 case FLOAT64_ELEMENTS: 40 case FLOAT64_ELEMENTS:
32 return 3; 41 return 3;
33 case FAST_SMI_ELEMENTS: 42 case FAST_SMI_ELEMENTS:
34 case FAST_ELEMENTS: 43 case FAST_ELEMENTS:
35 case FAST_HOLEY_SMI_ELEMENTS: 44 case FAST_HOLEY_SMI_ELEMENTS:
36 case FAST_HOLEY_ELEMENTS: 45 case FAST_HOLEY_ELEMENTS:
37 case DICTIONARY_ELEMENTS: 46 case DICTIONARY_ELEMENTS:
38 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: 47 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
39 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: 48 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
40 return kPointerSizeLog2; 49 return kPointerSizeLog2;
41 } 50 }
42 UNREACHABLE(); 51 UNREACHABLE();
43 return 0; 52 return 0;
44 } 53 }
45 54
46 55
56 static bool IsTypedArrayElementsKind(ElementsKind elements_kind) {
57 return IsFixedTypedArrayElementsKind(elements_kind) ||
58 IsExternalArrayElementsKind(elements_kind);
59 }
60
61
47 int GetDefaultHeaderSizeForElementsKind(ElementsKind elements_kind) { 62 int GetDefaultHeaderSizeForElementsKind(ElementsKind elements_kind) {
48 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); 63 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize);
49 64
50 if (IsFixedTypedArrayElementsKind(elements_kind)) { 65 if (IsTypedArrayElementsKind(elements_kind)) {
51 return 0; 66 return 0;
52 } else { 67 } else {
53 return FixedArray::kHeaderSize - kHeapObjectTag; 68 return FixedArray::kHeaderSize - kHeapObjectTag;
54 } 69 }
55 } 70 }
56 71
57 72
58 const char* ElementsKindToString(ElementsKind kind) { 73 const char* ElementsKindToString(ElementsKind kind) {
59 ElementsAccessor* accessor = ElementsAccessor::ForKind(kind); 74 ElementsAccessor* accessor = ElementsAccessor::ForKind(kind);
60 return accessor->name(); 75 return accessor->name();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if (fast_elements_kind_sequence.Get()[i] == elements_kind) { 118 if (fast_elements_kind_sequence.Get()[i] == elements_kind) {
104 return i; 119 return i;
105 } 120 }
106 } 121 }
107 UNREACHABLE(); 122 UNREACHABLE();
108 return 0; 123 return 0;
109 } 124 }
110 125
111 126
112 ElementsKind GetNextTransitionElementsKind(ElementsKind kind) { 127 ElementsKind GetNextTransitionElementsKind(ElementsKind kind) {
113 int index = GetSequenceIndexFromFastElementsKind(kind); 128 switch (kind) {
114 return GetFastElementsKindFromSequenceIndex(index + 1); 129 #define FIXED_TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
130 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS;
131
132 TYPED_ARRAYS(FIXED_TYPED_ARRAY_CASE)
133 #undef FIXED_TYPED_ARRAY_CASE
134 default: {
135 int index = GetSequenceIndexFromFastElementsKind(kind);
136 return GetFastElementsKindFromSequenceIndex(index + 1);
137 }
138 }
115 } 139 }
116 140
117 141
118 static inline bool IsFastTransitionTarget(ElementsKind elements_kind) { 142 static inline bool IsFastTransitionTarget(ElementsKind elements_kind) {
119 return IsFastElementsKind(elements_kind) || 143 return IsFastElementsKind(elements_kind) ||
120 elements_kind == DICTIONARY_ELEMENTS; 144 elements_kind == DICTIONARY_ELEMENTS;
121 } 145 }
122 146
123 bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, 147 bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind,
124 ElementsKind to_kind) { 148 ElementsKind to_kind) {
125 if (IsFixedTypedArrayElementsKind(from_kind) || 149 if (IsTypedArrayElementsKind(from_kind) ||
126 IsFixedTypedArrayElementsKind(to_kind)) { 150 IsTypedArrayElementsKind(to_kind)) {
127 return false; 151 switch (from_kind) {
152 #define FIXED_TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
153 case TYPE##_ELEMENTS: \
154 return to_kind == EXTERNAL_##TYPE##_ELEMENTS;
155
156 TYPED_ARRAYS(FIXED_TYPED_ARRAY_CASE);
157 #undef FIXED_TYPED_ARRAY_CASE
158 default:
159 return false;
160 }
128 } 161 }
129 if (IsFastElementsKind(from_kind) && IsFastTransitionTarget(to_kind)) { 162 if (IsFastElementsKind(from_kind) && IsFastTransitionTarget(to_kind)) {
130 switch (from_kind) { 163 switch (from_kind) {
131 case FAST_SMI_ELEMENTS: 164 case FAST_SMI_ELEMENTS:
132 return to_kind != FAST_SMI_ELEMENTS; 165 return to_kind != FAST_SMI_ELEMENTS;
133 case FAST_HOLEY_SMI_ELEMENTS: 166 case FAST_HOLEY_SMI_ELEMENTS:
134 return to_kind != FAST_SMI_ELEMENTS && 167 return to_kind != FAST_SMI_ELEMENTS &&
135 to_kind != FAST_HOLEY_SMI_ELEMENTS; 168 to_kind != FAST_HOLEY_SMI_ELEMENTS;
136 case FAST_DOUBLE_ELEMENTS: 169 case FAST_DOUBLE_ELEMENTS:
137 return to_kind != FAST_SMI_ELEMENTS && 170 return to_kind != FAST_SMI_ELEMENTS &&
138 to_kind != FAST_HOLEY_SMI_ELEMENTS && 171 to_kind != FAST_HOLEY_SMI_ELEMENTS &&
139 to_kind != FAST_DOUBLE_ELEMENTS; 172 to_kind != FAST_DOUBLE_ELEMENTS;
140 case FAST_HOLEY_DOUBLE_ELEMENTS: 173 case FAST_HOLEY_DOUBLE_ELEMENTS:
141 return to_kind == FAST_ELEMENTS || 174 return to_kind == FAST_ELEMENTS ||
142 to_kind == FAST_HOLEY_ELEMENTS; 175 to_kind == FAST_HOLEY_ELEMENTS;
143 case FAST_ELEMENTS: 176 case FAST_ELEMENTS:
144 return to_kind == FAST_HOLEY_ELEMENTS; 177 return to_kind == FAST_HOLEY_ELEMENTS;
145 case FAST_HOLEY_ELEMENTS: 178 case FAST_HOLEY_ELEMENTS:
146 return false; 179 return false;
147 default: 180 default:
148 return false; 181 return false;
149 } 182 }
150 } 183 }
151 return false; 184 return false;
152 } 185 }
153 186
154 187
155 } // namespace internal 188 } // namespace internal
156 } // namespace v8 189 } // namespace v8
OLDNEW
« no previous file with comments | « src/elements-kind.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698