v8  3.14.5(node0.10.28)
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  // Derived constants from ElementsKind
74 };
75 
79 
80 void PrintElementsKind(FILE* out, ElementsKind kind);
81 
83 
85 
87 
88 
90  return kind == DICTIONARY_ELEMENTS;
91 }
92 
93 
95  return kind >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND &&
97 }
98 
99 
100 inline bool IsFastElementsKind(ElementsKind kind) {
102  return kind <= FAST_HOLEY_DOUBLE_ELEMENTS;
103 }
104 
105 
107  return kind == FAST_DOUBLE_ELEMENTS ||
109 }
110 
111 
113  return kind == FAST_SMI_ELEMENTS ||
114  kind == FAST_HOLEY_SMI_ELEMENTS ||
115  kind == FAST_ELEMENTS ||
116  kind == FAST_HOLEY_ELEMENTS;
117 }
118 
119 
121  return kind == FAST_SMI_ELEMENTS ||
122  kind == FAST_HOLEY_SMI_ELEMENTS;
123 }
124 
125 
127  return kind == FAST_ELEMENTS ||
128  kind == FAST_HOLEY_ELEMENTS;
129 }
130 
131 
133  return kind == FAST_HOLEY_SMI_ELEMENTS ||
134  kind == FAST_HOLEY_DOUBLE_ELEMENTS ||
135  kind == FAST_HOLEY_ELEMENTS;
136 }
137 
138 
140  return IsFastHoleyElementsKind(kind) ||
141  kind == DICTIONARY_ELEMENTS;
142 }
143 
144 
146  return kind == FAST_SMI_ELEMENTS ||
147  kind == FAST_DOUBLE_ELEMENTS ||
148  kind == FAST_ELEMENTS;
149 }
150 
151 
153  if (holey_kind == FAST_HOLEY_SMI_ELEMENTS) {
154  return FAST_SMI_ELEMENTS;
155  }
156  if (holey_kind == FAST_HOLEY_DOUBLE_ELEMENTS) {
157  return FAST_DOUBLE_ELEMENTS;
158  }
159  if (holey_kind == FAST_HOLEY_ELEMENTS) {
160  return FAST_ELEMENTS;
161  }
162  return holey_kind;
163 }
164 
165 
167  if (packed_kind == FAST_SMI_ELEMENTS) {
169  }
170  if (packed_kind == FAST_DOUBLE_ELEMENTS) {
172  }
173  if (packed_kind == FAST_ELEMENTS) {
174  return FAST_HOLEY_ELEMENTS;
175  }
176  return packed_kind;
177 }
178 
179 
181  ASSERT(IsFastSmiElementsKind(from_kind));
182  return (from_kind == FAST_SMI_ELEMENTS)
183  ? FAST_ELEMENTS
185 }
186 
187 
189  ElementsKind to_kind) {
190  return (GetHoleyElementsKind(from_kind) == to_kind) ||
191  (IsFastSmiElementsKind(from_kind) &&
192  IsFastObjectElementsKind(to_kind));
193 }
194 
195 
197  ElementsKind to_kind);
198 
199 
201  return IsFastElementsKind(from_kind) &&
202  from_kind != TERMINAL_FAST_ELEMENTS_KIND;
203 }
204 
205 
207  bool allow_only_packed);
208 
209 
211  ElementsKind elements_kind,
212  bool allow_only_packed) {
213  return IsFastElementsKind(elements_kind) &&
214  (elements_kind != TERMINAL_FAST_ELEMENTS_KIND &&
215  (!allow_only_packed || elements_kind != FAST_ELEMENTS));
216 }
217 
218 
219 } } // namespace v8::internal
220 
221 #endif // V8_ELEMENTS_KIND_H_
bool IsExternalArrayElementsKind(ElementsKind kind)
Definition: elements-kind.h:94
bool IsHoleyElementsKind(ElementsKind kind)
ElementsKind GetPackedElementsKind(ElementsKind holey_kind)
bool IsFastObjectElementsKind(ElementsKind kind)
#define ASSERT(condition)
Definition: checks.h:270
bool CanTransitionToMoreGeneralFastElementsKind(ElementsKind elements_kind, bool allow_only_packed)
const int kFastElementsKindCount
Definition: elements-kind.h:77
bool IsFastElementsKind(ElementsKind kind)
bool IsSimpleMapChangeTransition(ElementsKind from_kind, ElementsKind to_kind)
int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind)
bool IsFastPackedElementsKind(ElementsKind kind)
ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_number)
bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, ElementsKind to_kind)
bool IsFastSmiElementsKind(ElementsKind kind)
ElementsKind FastSmiToObjectElementsKind(ElementsKind from_kind)
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
const int kElementsKindCount
Definition: elements-kind.h:76
bool IsTransitionableFastElementsKind(ElementsKind from_kind)
void PrintElementsKind(FILE *out, ElementsKind kind)
ElementsKind GetInitialFastElementsKind()
ElementsKind GetNextMoreGeneralFastElementsKind(ElementsKind elements_kind, bool allow_only_packed)
bool IsFastHoleyElementsKind(ElementsKind kind)
ElementsKind GetHoleyElementsKind(ElementsKind packed_kind)
bool IsDictionaryElementsKind(ElementsKind kind)
Definition: elements-kind.h:89
bool IsFastDoubleElementsKind(ElementsKind kind)