OLD | NEW |
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 #ifndef V8_ELEMENTS_KIND_H_ | 5 #ifndef V8_ELEMENTS_KIND_H_ |
6 #define V8_ELEMENTS_KIND_H_ | 6 #define V8_ELEMENTS_KIND_H_ |
7 | 7 |
8 #include "src/base/macros.h" | 8 #include "src/base/macros.h" |
9 #include "src/checks.h" | 9 #include "src/checks.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // The "fast" kind for unwrapped, non-tagged double values. | 26 // The "fast" kind for unwrapped, non-tagged double values. |
27 FAST_DOUBLE_ELEMENTS, | 27 FAST_DOUBLE_ELEMENTS, |
28 FAST_HOLEY_DOUBLE_ELEMENTS, | 28 FAST_HOLEY_DOUBLE_ELEMENTS, |
29 | 29 |
30 // The "slow" kind. | 30 // The "slow" kind. |
31 DICTIONARY_ELEMENTS, | 31 DICTIONARY_ELEMENTS, |
32 | 32 |
33 FAST_SLOPPY_ARGUMENTS_ELEMENTS, | 33 FAST_SLOPPY_ARGUMENTS_ELEMENTS, |
34 SLOW_SLOPPY_ARGUMENTS_ELEMENTS, | 34 SLOW_SLOPPY_ARGUMENTS_ELEMENTS, |
35 | 35 |
36 // The "fast" kind for external arrays | |
37 EXTERNAL_INT8_ELEMENTS, | |
38 EXTERNAL_UINT8_ELEMENTS, | |
39 EXTERNAL_INT16_ELEMENTS, | |
40 EXTERNAL_UINT16_ELEMENTS, | |
41 EXTERNAL_INT32_ELEMENTS, | |
42 EXTERNAL_UINT32_ELEMENTS, | |
43 EXTERNAL_FLOAT32_ELEMENTS, | |
44 EXTERNAL_FLOAT64_ELEMENTS, | |
45 EXTERNAL_UINT8_CLAMPED_ELEMENTS, | |
46 | |
47 // Fixed typed arrays | 36 // Fixed typed arrays |
48 UINT8_ELEMENTS, | 37 UINT8_ELEMENTS, |
49 INT8_ELEMENTS, | 38 INT8_ELEMENTS, |
50 UINT16_ELEMENTS, | 39 UINT16_ELEMENTS, |
51 INT16_ELEMENTS, | 40 INT16_ELEMENTS, |
52 UINT32_ELEMENTS, | 41 UINT32_ELEMENTS, |
53 INT32_ELEMENTS, | 42 INT32_ELEMENTS, |
54 FLOAT32_ELEMENTS, | 43 FLOAT32_ELEMENTS, |
55 FLOAT64_ELEMENTS, | 44 FLOAT64_ELEMENTS, |
56 UINT8_CLAMPED_ELEMENTS, | 45 UINT8_CLAMPED_ELEMENTS, |
57 | 46 |
58 // Derived constants from ElementsKind | 47 // Derived constants from ElementsKind |
59 FIRST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, | 48 FIRST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, |
60 LAST_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, | 49 LAST_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, |
61 FIRST_FAST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, | 50 FIRST_FAST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, |
62 LAST_FAST_ELEMENTS_KIND = FAST_HOLEY_DOUBLE_ELEMENTS, | 51 LAST_FAST_ELEMENTS_KIND = FAST_HOLEY_DOUBLE_ELEMENTS, |
63 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_INT8_ELEMENTS, | |
64 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_UINT8_CLAMPED_ELEMENTS, | |
65 FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_ELEMENTS, | 52 FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_ELEMENTS, |
66 LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, | 53 LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, |
67 TERMINAL_FAST_ELEMENTS_KIND = FAST_HOLEY_ELEMENTS | 54 TERMINAL_FAST_ELEMENTS_KIND = FAST_HOLEY_ELEMENTS |
68 }; | 55 }; |
69 | 56 |
70 const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; | 57 const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; |
71 const int kFastElementsKindCount = LAST_FAST_ELEMENTS_KIND - | 58 const int kFastElementsKindCount = LAST_FAST_ELEMENTS_KIND - |
72 FIRST_FAST_ELEMENTS_KIND + 1; | 59 FIRST_FAST_ELEMENTS_KIND + 1; |
73 | 60 |
74 // The number to add to a packed elements kind to reach a holey elements kind | 61 // The number to add to a packed elements kind to reach a holey elements kind |
(...skipping 15 matching lines...) Expand all Loading... |
90 return kind == DICTIONARY_ELEMENTS; | 77 return kind == DICTIONARY_ELEMENTS; |
91 } | 78 } |
92 | 79 |
93 | 80 |
94 inline bool IsSloppyArgumentsElements(ElementsKind kind) { | 81 inline bool IsSloppyArgumentsElements(ElementsKind kind) { |
95 return kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS || | 82 return kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS || |
96 kind == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; | 83 kind == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; |
97 } | 84 } |
98 | 85 |
99 | 86 |
100 inline bool IsExternalArrayElementsKind(ElementsKind kind) { | 87 inline bool IsFixedTypedArrayElementsKind(ElementsKind kind) { |
101 return kind >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && | 88 return kind >= FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND && |
102 kind <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND; | 89 kind <= LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND; |
103 } | 90 } |
104 | 91 |
105 | 92 |
106 inline bool IsTerminalElementsKind(ElementsKind kind) { | 93 inline bool IsTerminalElementsKind(ElementsKind kind) { |
107 return kind == TERMINAL_FAST_ELEMENTS_KIND || | 94 return kind == TERMINAL_FAST_ELEMENTS_KIND || |
108 IsExternalArrayElementsKind(kind); | 95 IsFixedTypedArrayElementsKind(kind); |
109 } | 96 } |
110 | 97 |
111 | 98 |
112 inline bool IsFixedTypedArrayElementsKind(ElementsKind kind) { | |
113 return kind >= FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND && | |
114 kind <= LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND; | |
115 } | |
116 | |
117 | |
118 inline bool IsFastElementsKind(ElementsKind kind) { | 99 inline bool IsFastElementsKind(ElementsKind kind) { |
119 STATIC_ASSERT(FIRST_FAST_ELEMENTS_KIND == 0); | 100 STATIC_ASSERT(FIRST_FAST_ELEMENTS_KIND == 0); |
120 return kind <= FAST_HOLEY_DOUBLE_ELEMENTS; | 101 return kind <= FAST_HOLEY_DOUBLE_ELEMENTS; |
121 } | 102 } |
122 | 103 |
123 | 104 |
124 inline bool IsTransitionElementsKind(ElementsKind kind) { | 105 inline bool IsTransitionElementsKind(ElementsKind kind) { |
125 return IsFastElementsKind(kind) || IsFixedTypedArrayElementsKind(kind) || | 106 return IsFastElementsKind(kind) || IsFixedTypedArrayElementsKind(kind) || |
126 kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS; | 107 kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS; |
127 } | 108 } |
128 | 109 |
129 | 110 |
130 inline bool IsFastDoubleElementsKind(ElementsKind kind) { | 111 inline bool IsFastDoubleElementsKind(ElementsKind kind) { |
131 return kind == FAST_DOUBLE_ELEMENTS || | 112 return kind == FAST_DOUBLE_ELEMENTS || |
132 kind == FAST_HOLEY_DOUBLE_ELEMENTS; | 113 kind == FAST_HOLEY_DOUBLE_ELEMENTS; |
133 } | 114 } |
134 | 115 |
135 | 116 |
136 inline bool IsExternalFloatOrDoubleElementsKind(ElementsKind kind) { | |
137 return kind == EXTERNAL_FLOAT64_ELEMENTS || | |
138 kind == EXTERNAL_FLOAT32_ELEMENTS; | |
139 } | |
140 | |
141 | |
142 inline bool IsFixedFloatElementsKind(ElementsKind kind) { | 117 inline bool IsFixedFloatElementsKind(ElementsKind kind) { |
143 return kind == FLOAT32_ELEMENTS || kind == FLOAT64_ELEMENTS; | 118 return kind == FLOAT32_ELEMENTS || kind == FLOAT64_ELEMENTS; |
144 } | 119 } |
145 | 120 |
146 | 121 |
147 inline bool IsDoubleOrFloatElementsKind(ElementsKind kind) { | 122 inline bool IsDoubleOrFloatElementsKind(ElementsKind kind) { |
148 return IsFastDoubleElementsKind(kind) || | 123 return IsFastDoubleElementsKind(kind) || IsFixedFloatElementsKind(kind); |
149 IsExternalFloatOrDoubleElementsKind(kind) || | |
150 IsFixedFloatElementsKind(kind); | |
151 } | 124 } |
152 | 125 |
153 | 126 |
154 inline bool IsFastSmiOrObjectElementsKind(ElementsKind kind) { | 127 inline bool IsFastSmiOrObjectElementsKind(ElementsKind kind) { |
155 return kind == FAST_SMI_ELEMENTS || | 128 return kind == FAST_SMI_ELEMENTS || |
156 kind == FAST_HOLEY_SMI_ELEMENTS || | 129 kind == FAST_HOLEY_SMI_ELEMENTS || |
157 kind == FAST_ELEMENTS || | 130 kind == FAST_ELEMENTS || |
158 kind == FAST_HOLEY_ELEMENTS; | 131 kind == FAST_HOLEY_ELEMENTS; |
159 } | 132 } |
160 | 133 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 214 |
242 inline bool IsTransitionableFastElementsKind(ElementsKind from_kind) { | 215 inline bool IsTransitionableFastElementsKind(ElementsKind from_kind) { |
243 return IsFastElementsKind(from_kind) && | 216 return IsFastElementsKind(from_kind) && |
244 from_kind != TERMINAL_FAST_ELEMENTS_KIND; | 217 from_kind != TERMINAL_FAST_ELEMENTS_KIND; |
245 } | 218 } |
246 | 219 |
247 | 220 |
248 } } // namespace v8::internal | 221 } } // namespace v8::internal |
249 | 222 |
250 #endif // V8_ELEMENTS_KIND_H_ | 223 #endif // V8_ELEMENTS_KIND_H_ |
OLD | NEW |