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

Side by Side Diff: src/elements-kind.cc

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