5 #ifndef V8_TRANSITIONS_H_ 6 #define V8_TRANSITIONS_H_ 8 #include "src/checks.h" 9 #include "src/elements-kind.h" 10 #include "src/objects.h" 11 #include "src/objects/descriptor-array.h" 12 #include "src/objects/map.h" 13 #include "src/objects/maybe-object.h" 14 #include "src/objects/name.h" 17 #include "src/objects/object-macros.h" 42 : isolate_(isolate), map_(map) {
47 : isolate_(isolate), map_handle_(map), map_(*map) {
57 Map SearchTransition(
Name name, PropertyKind kind,
58 PropertyAttributes attributes);
65 enum RequestedLocation { kAnyLocation, kFieldOnly };
67 Handle<Name> name, RequestedLocation requested_location = kAnyLocation);
70 return FindTransitionToDataProperty(name, kFieldOnly);
76 int NumberOfTransitions();
80 static const int kMaxNumberOfTransitions = 1024 + 512;
81 bool CanHaveMoreTransitions();
82 inline Name GetKey(
int transition_number);
83 inline Map GetTarget(
int transition_number);
86 static bool IsMatchingMap(
Map target,
Name name, PropertyKind kind,
87 PropertyAttributes attributes);
90 typedef void (*TraverseCallback)(
Map map,
void* data);
93 void TraverseTransitionTree(TraverseCallback callback,
void* data) {
96 TraverseTransitionTreeInternal(callback, data, &no_allocation);
115 void SetMigrationTarget(
Map migration_target);
116 Map GetMigrationTarget();
118 #if DEBUG || OBJECT_PRINT 119 void PrintTransitions(std::ostream& os);
120 static void PrintOneTransition(std::ostream& os,
Name key,
Map target);
121 void PrintTransitionTree();
122 void PrintTransitionTree(std::ostream& os,
int level,
126 void CheckNewTransitionsAreConsistent(
TransitionArray* old_transitions,
128 bool IsConsistentWithBackPointers();
129 bool IsSortedNoDuplicates();
139 kFullTransitionArray,
143 DCHECK(!map_handle_.is_null());
148 inline Encoding encoding() {
149 DCHECK(!needs_reload_);
159 static inline Name GetSimpleTransitionKey(
Map transition);
163 void MarkNeedsReload() {
165 needs_reload_ =
true;
171 inline Map GetSimpleTransition();
172 bool HasSimpleTransitionTo(
Map map);
174 void ReplaceTransitions(
MaybeObject new_transitions);
176 inline Map GetTargetMapFromWeakRef();
178 void EnsureHasFullTransitionArray();
182 void TraverseTransitionTreeInternal(TraverseCallback callback,
void* data,
216 inline bool HasPrototypeTransitions();
219 inline void SetKey(
int transition_number,
Name value);
220 inline Name GetKey(
int transition_number);
223 inline Map GetTarget(
int transition_number);
224 inline void SetRawTarget(
int transition_number,
MaybeObject target);
225 inline MaybeObject GetRawTarget(
int transition_number);
227 inline bool GetTargetIfExists(
int transition_number,
Isolate* isolate,
231 static constexpr
int kNotFound = -1;
233 inline Name GetSortedKey(
int transition_number);
234 int GetSortedKeyIndex(
int transition_number) {
return transition_number; }
235 inline int number_of_entries()
const;
237 bool IsSortedNoDuplicates(
int valid_entries = -1);
242 void PrintInternal(std::ostream& os);
248 static const int kPrototypeTransitionsIndex = 0;
249 static const int kTransitionLengthIndex = 1;
250 static const int kFirstIndex = 2;
253 static const int kEntryKeyIndex = 0;
254 static const int kEntryTargetIndex = 1;
255 static const int kEntrySize = 2;
258 static int ToKeyIndex(
int transition_number) {
259 return kFirstIndex + (transition_number * kEntrySize) + kEntryKeyIndex;
262 static int ToTargetIndex(
int transition_number) {
263 return kFirstIndex + (transition_number * kEntrySize) + kEntryTargetIndex;
266 inline int SearchNameForTesting(
Name name,
267 int* out_insertion_index =
nullptr);
274 inline void SetNumberOfTransitions(
int number_of_transitions);
276 inline int Capacity();
282 static const int kProtoTransitionHeaderSize = 1;
283 static const int kMaxCachedPrototypeTransitions = 256;
285 inline void SetPrototypeTransitions(
WeakFixedArray* prototype_transitions);
287 static inline int NumberOfPrototypeTransitions(
289 static void SetNumberOfPrototypeTransitions(
WeakFixedArray* proto_transitions,
292 static const int kProtoTransitionNumberOfEntriesOffset = 0;
293 STATIC_ASSERT(kProtoTransitionHeaderSize == 1);
297 static int LengthFor(
int number_of_transitions) {
298 return ToKeyIndex(number_of_transitions);
302 int Search(PropertyKind kind,
Name name, PropertyAttributes attributes,
303 int* out_insertion_index =
nullptr);
307 inline int SearchSpecial(
Symbol symbol,
int* out_insertion_index =
nullptr);
309 inline int SearchName(
Name name,
int* out_insertion_index =
nullptr);
310 int SearchDetails(
int transition, PropertyKind kind,
311 PropertyAttributes attributes,
int* out_insertion_index);
313 inline int number_of_transitions()
const;
315 static bool CompactPrototypeTransitionArray(
Isolate* isolate,
323 static inline int CompareKeys(
Name key1,
uint32_t hash1, PropertyKind kind1,
324 PropertyAttributes attributes1,
Name key2,
326 PropertyAttributes attributes2);
335 static inline int CompareDetails(PropertyKind kind1,
336 PropertyAttributes attributes1,
338 PropertyAttributes attributes2);
350 #include "src/objects/object-macros-undef.h" 352 #endif // V8_TRANSITIONS_H_