Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(821)

Side by Side Diff: src/transitions.h

Issue 1157943003: Replace ad-hoc weakness in transition array with WeakCell. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove redundant dchecks Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 WeakCell::cast(raw_transition)->cleared() || 64 WeakCell::cast(raw_transition)->cleared() ||
65 WeakCell::cast(raw_transition)->value()->IsMap()); 65 WeakCell::cast(raw_transition)->value()->IsMap());
66 return raw_transition->IsWeakCell() && 66 return raw_transition->IsWeakCell() &&
67 !WeakCell::cast(raw_transition)->cleared(); 67 !WeakCell::cast(raw_transition)->cleared();
68 } 68 }
69 static inline Map* GetSimpleTransition(Object* raw_transition) { 69 static inline Map* GetSimpleTransition(Object* raw_transition) {
70 DCHECK(IsSimpleTransition(raw_transition)); 70 DCHECK(IsSimpleTransition(raw_transition));
71 DCHECK(raw_transition->IsWeakCell()); 71 DCHECK(raw_transition->IsWeakCell());
72 return Map::cast(WeakCell::cast(raw_transition)->value()); 72 return Map::cast(WeakCell::cast(raw_transition)->value());
73 } 73 }
74 static inline WeakCell* GetSimpleTransitionCell(Object* raw_transition) {
75 DCHECK(IsSimpleTransition(raw_transition));
76 DCHECK(raw_transition->IsWeakCell());
77 return WeakCell::cast(raw_transition);
78 }
74 static inline bool IsFullTransitionArray(Object* raw_transitions) { 79 static inline bool IsFullTransitionArray(Object* raw_transitions) {
75 return raw_transitions->IsTransitionArray(); 80 return raw_transitions->IsTransitionArray();
76 } 81 }
77 82
78 // The size of transition arrays are limited so they do not end up in large 83 // The size of transition arrays are limited so they do not end up in large
79 // object space. Otherwise ClearNonLiveReferences would leak memory while 84 // object space. Otherwise ClearNonLiveReferences would leak memory while
80 // applying in-place right trimming. 85 // applying in-place right trimming.
81 static bool CanHaveMoreTransitions(Handle<Map> map); 86 static bool CanHaveMoreTransitions(Handle<Map> map);
82 87
83 // ===== PROTOTYPE TRANSITIONS ===== 88 // ===== PROTOTYPE TRANSITIONS =====
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 TraverseTransitionTreeInternal(map, callback, data); 133 TraverseTransitionTreeInternal(map, callback, data);
129 } 134 }
130 135
131 // ===== LOW-LEVEL ACCESSORS ===== 136 // ===== LOW-LEVEL ACCESSORS =====
132 137
133 // Accessors for fetching instance transition at transition number. 138 // Accessors for fetching instance transition at transition number.
134 static inline Name* GetKey(Object* raw_transitions, int transition_number); 139 static inline Name* GetKey(Object* raw_transitions, int transition_number);
135 inline Name* GetKey(int transition_number); 140 inline Name* GetKey(int transition_number);
136 inline void SetKey(int transition_number, Name* value); 141 inline void SetKey(int transition_number, Name* value);
137 inline Object** GetKeySlot(int transition_number); 142 inline Object** GetKeySlot(int transition_number);
143 inline Object** GetTargetSlot(int transition_number);
138 int GetSortedKeyIndex(int transition_number) { return transition_number; } 144 int GetSortedKeyIndex(int transition_number) { return transition_number; }
139 145
140 Name* GetSortedKey(int transition_number) { 146 Name* GetSortedKey(int transition_number) {
141 return GetKey(transition_number); 147 return GetKey(transition_number);
142 } 148 }
143 149
144 static inline Map* GetTarget(Object* raw_transitions, int transition_number); 150 static inline Map* GetTarget(Object* raw_transitions, int transition_number);
145 inline Map* GetTarget(int transition_number); 151 inline Map* GetTarget(int transition_number);
146 inline void SetTarget(int transition_number, Map* target); 152
153 inline WeakCell* GetTargetCell(int transition_number);
154 inline void SetTargetCell(int transition_number, WeakCell* target);
147 155
148 static inline PropertyDetails GetTargetDetails(Name* name, Map* target); 156 static inline PropertyDetails GetTargetDetails(Name* name, Map* target);
149 157
150 // Returns the number of transitions in the array. 158 // Returns the number of transitions in the array.
151 static int NumberOfTransitions(Object* raw_transitions); 159 static int NumberOfTransitions(Object* raw_transitions);
152 // Required for templatized Search interface. 160 // Required for templatized Search interface.
153 inline int number_of_entries() { return number_of_transitions(); } 161 inline int number_of_entries() { return number_of_transitions(); }
154 162
155 inline void SetNumberOfTransitions(int number_of_transitions); 163 inline void SetNumberOfTransitions(int number_of_transitions);
156 164
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 static inline int CompareNames(Name* key1, uint32_t hash1, Name* key2, 284 static inline int CompareNames(Name* key1, uint32_t hash1, Name* key2,
277 uint32_t hash2); 285 uint32_t hash2);
278 286
279 // Compares two details, returns -1 if details1 is "less" than details2, 287 // Compares two details, returns -1 if details1 is "less" than details2,
280 // 0 if details1 equal to details2 and 1 otherwise. 288 // 0 if details1 equal to details2 and 1 otherwise.
281 static inline int CompareDetails(PropertyKind kind1, 289 static inline int CompareDetails(PropertyKind kind1,
282 PropertyAttributes attributes1, 290 PropertyAttributes attributes1,
283 PropertyKind kind2, 291 PropertyKind kind2,
284 PropertyAttributes attributes2); 292 PropertyAttributes attributes2);
285 293
286 inline void NoIncrementalWriteBarrierSet(int transition_number, 294 inline void Set(int transition_number, Name* key, WeakCell* target_cell);
287 Name* key,
288 Map* target);
289 295
290 // Copy a single transition from the origin array. 296 // Copy a single transition from the origin array.
291 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, 297 inline void CopyFrom(TransitionArray* origin, int origin_transition,
292 int origin_transition, 298 int target_transition);
293 int target_transition);
294 299
295 #ifdef DEBUG 300 #ifdef DEBUG
296 static void CheckNewTransitionsAreConsistent(Handle<Map> map, 301 static void CheckNewTransitionsAreConsistent(Handle<Map> map,
297 TransitionArray* old_transitions, 302 TransitionArray* old_transitions,
298 Object* transitions); 303 Object* transitions);
299 #endif 304 #endif
300 305
301 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); 306 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray);
302 }; 307 };
303 308
304 309
305 } } // namespace v8::internal 310 } } // namespace v8::internal
306 311
307 #endif // V8_TRANSITIONS_H_ 312 #endif // V8_TRANSITIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698