v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
elements-kind.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_ELEMENTS_KIND_H_
29 #define V8_ELEMENTS_KIND_H_
30 
31 #include "v8checks.h"
32 
33 namespace v8 {
34 namespace internal {
35 
37  // The "fast" kind for elements that only contain SMI values. Must be first
38  // to make it possible to efficiently check maps for this kind.
41 
42  // The "fast" kind for tagged values. Must be second to make it possible to
43  // efficiently check maps for this and the FAST_SMI_ONLY_ELEMENTS kind
44  // together at once.
47 
48  // The "fast" kind for unwrapped, non-tagged double values.
51 
52  // The "slow" kind.
55  // The "fast" kind for external arrays
65 
66  // Fixed typed arrays
76 
77  // Derived constants from ElementsKind
87 };
88 
92 
93 // The number to add to a packed elements kind to reach a holey elements kind
96 
97 int ElementsKindToShiftSize(ElementsKind elements_kind);
98 const char* ElementsKindToString(ElementsKind kind);
99 void PrintElementsKind(FILE* out, ElementsKind kind);
100 
102 
105 
107 
109  return kind == DICTIONARY_ELEMENTS;
110 }
111 
112 
114  return kind >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND &&
116 }
117 
118 
120  return kind == TERMINAL_FAST_ELEMENTS_KIND ||
122 }
123 
124 
126  return kind >= FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND &&
128 }
129 
130 
131 inline bool IsFastElementsKind(ElementsKind kind) {
133  return kind <= FAST_HOLEY_DOUBLE_ELEMENTS;
134 }
135 
136 
139 }
140 
141 
143  return kind == FAST_DOUBLE_ELEMENTS ||
145 }
146 
147 
149  return kind == EXTERNAL_FLOAT64_ELEMENTS ||
151 }
152 
153 
155  return kind == FLOAT32_ELEMENTS || kind == FLOAT64_ELEMENTS;
156 }
157 
158 
160  return IsFastDoubleElementsKind(kind) ||
163 }
164 
165 
167  return kind == FAST_SMI_ELEMENTS ||
168  kind == FAST_HOLEY_SMI_ELEMENTS ||
169  kind == FAST_ELEMENTS ||
170  kind == FAST_HOLEY_ELEMENTS;
171 }
172 
173 
175  return kind == FAST_SMI_ELEMENTS ||
176  kind == FAST_HOLEY_SMI_ELEMENTS;
177 }
178 
179 
181  return kind == FAST_ELEMENTS ||
182  kind == FAST_HOLEY_ELEMENTS;
183 }
184 
185 
187  return kind == FAST_HOLEY_SMI_ELEMENTS ||
188  kind == FAST_HOLEY_DOUBLE_ELEMENTS ||
189  kind == FAST_HOLEY_ELEMENTS;
190 }
191 
192 
194  return IsFastHoleyElementsKind(kind) ||
195  kind == DICTIONARY_ELEMENTS;
196 }
197 
198 
200  return kind == FAST_SMI_ELEMENTS ||
201  kind == FAST_DOUBLE_ELEMENTS ||
202  kind == FAST_ELEMENTS;
203 }
204 
205 
207  if (holey_kind == FAST_HOLEY_SMI_ELEMENTS) {
208  return FAST_SMI_ELEMENTS;
209  }
210  if (holey_kind == FAST_HOLEY_DOUBLE_ELEMENTS) {
211  return FAST_DOUBLE_ELEMENTS;
212  }
213  if (holey_kind == FAST_HOLEY_ELEMENTS) {
214  return FAST_ELEMENTS;
215  }
216  return holey_kind;
217 }
218 
219 
221  if (packed_kind == FAST_SMI_ELEMENTS) {
223  }
224  if (packed_kind == FAST_DOUBLE_ELEMENTS) {
226  }
227  if (packed_kind == FAST_ELEMENTS) {
228  return FAST_HOLEY_ELEMENTS;
229  }
230  return packed_kind;
231 }
232 
233 
235  ASSERT(IsFastSmiElementsKind(from_kind));
236  return (from_kind == FAST_SMI_ELEMENTS)
237  ? FAST_ELEMENTS
239 }
240 
241 
243  ElementsKind to_kind) {
244  return (GetHoleyElementsKind(from_kind) == to_kind) ||
245  (IsFastSmiElementsKind(from_kind) &&
246  IsFastObjectElementsKind(to_kind));
247 }
248 
249 
251  ElementsKind to_kind);
252 
253 
255  return IsFastElementsKind(from_kind) &&
256  from_kind != TERMINAL_FAST_ELEMENTS_KIND;
257 }
258 
259 
261  bool allow_only_packed);
262 
263 
265  ElementsKind elements_kind,
266  bool allow_only_packed) {
267  return IsFastElementsKind(elements_kind) &&
268  (elements_kind != TERMINAL_FAST_ELEMENTS_KIND &&
269  (!allow_only_packed || elements_kind != FAST_ELEMENTS));
270 }
271 
272 
273 } } // namespace v8::internal
274 
275 #endif // V8_ELEMENTS_KIND_H_
bool IsExternalArrayElementsKind(ElementsKind kind)
bool IsHoleyElementsKind(ElementsKind kind)
ElementsKind GetPackedElementsKind(ElementsKind holey_kind)
bool IsFastObjectElementsKind(ElementsKind kind)
bool IsExternalFloatOrDoubleElementsKind(ElementsKind kind)
#define ASSERT(condition)
Definition: checks.h:329
bool CanTransitionToMoreGeneralFastElementsKind(ElementsKind elements_kind, bool allow_only_packed)
const int kFastElementsKindCount
Definition: elements-kind.h:90
bool IsFastElementsKind(ElementsKind kind)
bool IsSimpleMapChangeTransition(ElementsKind from_kind, ElementsKind to_kind)
int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind)
const int kFastElementsKindPackedToHoley
Definition: elements-kind.h:94
bool IsTransitionElementsKind(ElementsKind kind)
bool IsFastPackedElementsKind(ElementsKind kind)
ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_number)
bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, ElementsKind to_kind)
bool IsFixedTypedArrayElementsKind(ElementsKind kind)
bool IsFastSmiElementsKind(ElementsKind kind)
ElementsKind FastSmiToObjectElementsKind(ElementsKind from_kind)
int ElementsKindToShiftSize(ElementsKind elements_kind)
bool IsTerminalElementsKind(ElementsKind kind)
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
const int kElementsKindCount
Definition: elements-kind.h:89
bool IsTransitionableFastElementsKind(ElementsKind from_kind)
void PrintElementsKind(FILE *out, ElementsKind kind)
bool IsFixedFloatElementsKind(ElementsKind kind)
const char * ElementsKindToString(ElementsKind kind)
ElementsKind GetInitialFastElementsKind()
ElementsKind GetNextMoreGeneralFastElementsKind(ElementsKind elements_kind, bool allow_only_packed)
bool IsDoubleOrFloatElementsKind(ElementsKind kind)
bool IsFastHoleyElementsKind(ElementsKind kind)
ElementsKind GetHoleyElementsKind(ElementsKind packed_kind)
ElementsKind GetNextTransitionElementsKind(ElementsKind kind)
bool IsDictionaryElementsKind(ElementsKind kind)
bool IsFastDoubleElementsKind(ElementsKind kind)