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_TRANSITIONS_H_ | 5 #ifndef V8_TRANSITIONS_H_ |
6 #define V8_TRANSITIONS_H_ | 6 #define V8_TRANSITIONS_H_ |
7 | 7 |
8 #include "src/checks.h" | 8 #include "src/checks.h" |
9 #include "src/elements-kind.h" | 9 #include "src/elements-kind.h" |
10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 // Returns the number of transitions in the array. | 159 // Returns the number of transitions in the array. |
160 static int NumberOfTransitions(Object* raw_transitions); | 160 static int NumberOfTransitions(Object* raw_transitions); |
161 // Required for templatized Search interface. | 161 // Required for templatized Search interface. |
162 inline int number_of_entries() { return number_of_transitions(); } | 162 inline int number_of_entries() { return number_of_transitions(); } |
163 | 163 |
164 inline void SetNumberOfTransitions(int number_of_transitions); | 164 inline void SetNumberOfTransitions(int number_of_transitions); |
165 | 165 |
166 static int Capacity(Object* raw_transitions); | 166 static int Capacity(Object* raw_transitions); |
167 | 167 |
168 inline static TransitionArray* cast(Object* object); | 168 // Casting. |
169 | 169 static inline TransitionArray* cast(Object* obj); |
170 // This field should be used only by GC. | |
171 inline void set_next_link(Object* next, WriteBarrierMode mode); | |
172 inline Object* next_link(); | |
173 | 170 |
174 static const int kTransitionSize = 2; | 171 static const int kTransitionSize = 2; |
175 static const int kProtoTransitionHeaderSize = 1; | 172 static const int kProtoTransitionHeaderSize = 1; |
176 | 173 |
177 #if defined(DEBUG) || defined(OBJECT_PRINT) | 174 #if defined(DEBUG) || defined(OBJECT_PRINT) |
178 // For our gdb macros, we should perhaps change these in the future. | 175 // For our gdb macros, we should perhaps change these in the future. |
179 void Print(); | 176 void Print(); |
180 | 177 |
181 // Print all the transitions. | 178 // Print all the transitions. |
182 static void PrintTransitions(std::ostream& os, Object* transitions, | 179 static void PrintTransitions(std::ostream& os, Object* transitions, |
183 bool print_header = true); // NOLINT | 180 bool print_header = true); // NOLINT |
184 #endif | 181 #endif |
185 | 182 |
186 #ifdef OBJECT_PRINT | |
187 void TransitionArrayPrint(std::ostream& os); // NOLINT | |
188 #endif | |
189 | |
190 #ifdef VERIFY_HEAP | |
191 void TransitionArrayVerify(); | |
192 #endif | |
193 | |
194 #ifdef DEBUG | 183 #ifdef DEBUG |
195 bool IsSortedNoDuplicates(int valid_entries = -1); | 184 bool IsSortedNoDuplicates(int valid_entries = -1); |
196 static bool IsSortedNoDuplicates(Map* map); | 185 static bool IsSortedNoDuplicates(Map* map); |
197 static bool IsConsistentWithBackPointers(Map* map); | 186 static bool IsConsistentWithBackPointers(Map* map); |
198 | 187 |
199 // Returns true for a non-property transitions like elements kind, observed | 188 // Returns true for a non-property transitions like elements kind, observed |
200 // or frozen transitions. | 189 // or frozen transitions. |
201 static inline bool IsSpecialTransition(Name* name); | 190 static inline bool IsSpecialTransition(Name* name); |
202 #endif | 191 #endif |
203 | 192 |
204 // Constant for denoting key was not found. | 193 // Constant for denoting key was not found. |
205 static const int kNotFound = -1; | 194 static const int kNotFound = -1; |
206 | 195 |
207 // The maximum number of transitions we want in a transition array (should | 196 // The maximum number of transitions we want in a transition array (should |
208 // fit in a page). | 197 // fit in a page). |
209 static const int kMaxNumberOfTransitions = 1024 + 512; | 198 static const int kMaxNumberOfTransitions = 1024 + 512; |
210 | 199 |
211 private: | 200 private: |
212 // Layout for full transition arrays. | 201 // Layout for full transition arrays. |
213 static const int kNextLinkIndex = 0; | 202 static const int kPrototypeTransitionsIndex = 0; |
214 static const int kPrototypeTransitionsIndex = 1; | 203 static const int kTransitionLengthIndex = 1; |
215 static const int kTransitionLengthIndex = 2; | 204 static const int kFirstIndex = 2; |
216 static const int kFirstIndex = 3; | |
217 | 205 |
218 // Layout of map transition entries in full transition arrays. | 206 // Layout of map transition entries in full transition arrays. |
219 static const int kTransitionKey = 0; | 207 static const int kTransitionKey = 0; |
220 static const int kTransitionTarget = 1; | 208 static const int kTransitionTarget = 1; |
221 STATIC_ASSERT(kTransitionSize == 2); | 209 STATIC_ASSERT(kTransitionSize == 2); |
222 | 210 |
223 static const int kProtoTransitionNumberOfEntriesOffset = 0; | 211 static const int kProtoTransitionNumberOfEntriesOffset = 0; |
224 STATIC_ASSERT(kProtoTransitionHeaderSize == 1); | 212 STATIC_ASSERT(kProtoTransitionHeaderSize == 1); |
225 | 213 |
226 // Conversion from transition number to array indices. | 214 // Conversion from transition number to array indices. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 PropertyKind kind2, | 297 PropertyKind kind2, |
310 PropertyAttributes attributes2); | 298 PropertyAttributes attributes2); |
311 | 299 |
312 inline void Set(int transition_number, Name* key, Map* target); | 300 inline void Set(int transition_number, Name* key, Map* target); |
313 | 301 |
314 #ifdef DEBUG | 302 #ifdef DEBUG |
315 static void CheckNewTransitionsAreConsistent(Handle<Map> map, | 303 static void CheckNewTransitionsAreConsistent(Handle<Map> map, |
316 TransitionArray* old_transitions, | 304 TransitionArray* old_transitions, |
317 Object* transitions); | 305 Object* transitions); |
318 #endif | 306 #endif |
319 static void ZapTransitionArray(TransitionArray* transitions); | |
320 | 307 |
321 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); | 308 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); |
322 }; | 309 }; |
323 | 310 |
324 | 311 |
325 } // namespace internal | 312 } // namespace internal |
326 } // namespace v8 | 313 } // namespace v8 |
327 | 314 |
328 #endif // V8_TRANSITIONS_H_ | 315 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |