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 12 matching lines...) Expand all Loading... |
23 FAST_ELEMENTS, | 23 FAST_ELEMENTS, |
24 FAST_HOLEY_ELEMENTS, | 24 FAST_HOLEY_ELEMENTS, |
25 | 25 |
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 // Elements kind of the "arguments" object (only in sloppy mode). |
33 FAST_SLOPPY_ARGUMENTS_ELEMENTS, | 34 FAST_SLOPPY_ARGUMENTS_ELEMENTS, |
34 SLOW_SLOPPY_ARGUMENTS_ELEMENTS, | 35 SLOW_SLOPPY_ARGUMENTS_ELEMENTS, |
35 | 36 |
36 // Fixed typed arrays | 37 // For string wrapper objects ("new String('...')"), the string's characters |
| 38 // are overlaid onto a regular elements backing store. |
| 39 FAST_STRING_WRAPPER_ELEMENTS, |
| 40 SLOW_STRING_WRAPPER_ELEMENTS, |
| 41 |
| 42 // Fixed typed arrays. |
37 UINT8_ELEMENTS, | 43 UINT8_ELEMENTS, |
38 INT8_ELEMENTS, | 44 INT8_ELEMENTS, |
39 UINT16_ELEMENTS, | 45 UINT16_ELEMENTS, |
40 INT16_ELEMENTS, | 46 INT16_ELEMENTS, |
41 UINT32_ELEMENTS, | 47 UINT32_ELEMENTS, |
42 INT32_ELEMENTS, | 48 INT32_ELEMENTS, |
43 FLOAT32_ELEMENTS, | 49 FLOAT32_ELEMENTS, |
44 FLOAT64_ELEMENTS, | 50 FLOAT64_ELEMENTS, |
45 UINT8_CLAMPED_ELEMENTS, | 51 UINT8_CLAMPED_ELEMENTS, |
46 | 52 |
47 // Derived constants from ElementsKind | 53 // Sentinel ElementsKind for objects with no elements. |
| 54 NO_ELEMENTS, |
| 55 |
| 56 // Derived constants from ElementsKind. |
48 FIRST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, | 57 FIRST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, |
49 LAST_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, | 58 LAST_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, |
50 FIRST_FAST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, | 59 FIRST_FAST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, |
51 LAST_FAST_ELEMENTS_KIND = FAST_HOLEY_DOUBLE_ELEMENTS, | 60 LAST_FAST_ELEMENTS_KIND = FAST_HOLEY_DOUBLE_ELEMENTS, |
52 FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_ELEMENTS, | 61 FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_ELEMENTS, |
53 LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, | 62 LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, |
54 TERMINAL_FAST_ELEMENTS_KIND = FAST_HOLEY_ELEMENTS | 63 TERMINAL_FAST_ELEMENTS_KIND = FAST_HOLEY_ELEMENTS |
55 }; | 64 }; |
56 | 65 |
57 const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; | 66 const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; |
(...skipping 18 matching lines...) Expand all Loading... |
76 inline bool IsDictionaryElementsKind(ElementsKind kind) { | 85 inline bool IsDictionaryElementsKind(ElementsKind kind) { |
77 return kind == DICTIONARY_ELEMENTS; | 86 return kind == DICTIONARY_ELEMENTS; |
78 } | 87 } |
79 | 88 |
80 | 89 |
81 inline bool IsSloppyArgumentsElements(ElementsKind kind) { | 90 inline bool IsSloppyArgumentsElements(ElementsKind kind) { |
82 return kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS || | 91 return kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS || |
83 kind == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; | 92 kind == SLOW_SLOPPY_ARGUMENTS_ELEMENTS; |
84 } | 93 } |
85 | 94 |
| 95 inline bool IsStringWrapperElementsKind(ElementsKind kind) { |
| 96 return kind == FAST_STRING_WRAPPER_ELEMENTS || |
| 97 kind == SLOW_STRING_WRAPPER_ELEMENTS; |
| 98 } |
86 | 99 |
87 inline bool IsFixedTypedArrayElementsKind(ElementsKind kind) { | 100 inline bool IsFixedTypedArrayElementsKind(ElementsKind kind) { |
88 return kind >= FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND && | 101 return kind >= FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND && |
89 kind <= LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND; | 102 kind <= LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND; |
90 } | 103 } |
91 | 104 |
92 | 105 |
93 inline bool IsTerminalElementsKind(ElementsKind kind) { | 106 inline bool IsTerminalElementsKind(ElementsKind kind) { |
94 return kind == TERMINAL_FAST_ELEMENTS_KIND || | 107 return kind == TERMINAL_FAST_ELEMENTS_KIND || |
95 IsFixedTypedArrayElementsKind(kind); | 108 IsFixedTypedArrayElementsKind(kind); |
96 } | 109 } |
97 | 110 |
98 | 111 |
99 inline bool IsFastElementsKind(ElementsKind kind) { | 112 inline bool IsFastElementsKind(ElementsKind kind) { |
100 STATIC_ASSERT(FIRST_FAST_ELEMENTS_KIND == 0); | 113 STATIC_ASSERT(FIRST_FAST_ELEMENTS_KIND == 0); |
101 return kind <= FAST_HOLEY_DOUBLE_ELEMENTS; | 114 return kind <= FAST_HOLEY_DOUBLE_ELEMENTS; |
102 } | 115 } |
103 | 116 |
104 | 117 |
105 inline bool IsTransitionElementsKind(ElementsKind kind) { | 118 inline bool IsTransitionElementsKind(ElementsKind kind) { |
106 return IsFastElementsKind(kind) || IsFixedTypedArrayElementsKind(kind) || | 119 return IsFastElementsKind(kind) || IsFixedTypedArrayElementsKind(kind) || |
107 kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS; | 120 kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS || |
| 121 kind == FAST_STRING_WRAPPER_ELEMENTS; |
108 } | 122 } |
109 | 123 |
110 | 124 |
111 inline bool IsFastDoubleElementsKind(ElementsKind kind) { | 125 inline bool IsFastDoubleElementsKind(ElementsKind kind) { |
112 return kind == FAST_DOUBLE_ELEMENTS || | 126 return kind == FAST_DOUBLE_ELEMENTS || |
113 kind == FAST_HOLEY_DOUBLE_ELEMENTS; | 127 kind == FAST_HOLEY_DOUBLE_ELEMENTS; |
114 } | 128 } |
115 | 129 |
116 | 130 |
117 inline bool IsFixedFloatElementsKind(ElementsKind kind) { | 131 inline bool IsFixedFloatElementsKind(ElementsKind kind) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 inline bool IsTransitionableFastElementsKind(ElementsKind from_kind) { | 237 inline bool IsTransitionableFastElementsKind(ElementsKind from_kind) { |
224 return IsFastElementsKind(from_kind) && | 238 return IsFastElementsKind(from_kind) && |
225 from_kind != TERMINAL_FAST_ELEMENTS_KIND; | 239 from_kind != TERMINAL_FAST_ELEMENTS_KIND; |
226 } | 240 } |
227 | 241 |
228 | 242 |
229 } // namespace internal | 243 } // namespace internal |
230 } // namespace v8 | 244 } // namespace v8 |
231 | 245 |
232 #endif // V8_ELEMENTS_KIND_H_ | 246 #endif // V8_ELEMENTS_KIND_H_ |
OLD | NEW |