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