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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 Handle<Map> containing_map); | 91 Handle<Map> containing_map); |
92 | 92 |
93 // Return a transition array, using the array from the owning map if it | 93 // Return a transition array, using the array from the owning map if it |
94 // already has one (copying into a larger array if necessary), otherwise | 94 // already has one (copying into a larger array if necessary), otherwise |
95 // creating a new one according to flag. | 95 // creating a new one according to flag. |
96 // TODO(verwaest): This should not cause an existing transition to be | 96 // TODO(verwaest): This should not cause an existing transition to be |
97 // overwritten. | 97 // overwritten. |
98 static Handle<TransitionArray> Insert(Handle<Map> map, Handle<Name> name, | 98 static Handle<TransitionArray> Insert(Handle<Map> map, Handle<Name> name, |
99 Handle<Map> target, | 99 Handle<Map> target, |
100 SimpleTransitionFlag flag); | 100 SimpleTransitionFlag flag); |
101 // Search a transition for a given type, property name and attributes. | |
102 int Search(PropertyType type, Name* name, PropertyAttributes attributes, | |
103 int* out_insertion_index = NULL); | |
101 | 104 |
102 // Search a transition for a given property name. | 105 // Search a non-property transition (like elements kind, observe or frozen |
103 inline int Search(Name* name, int* out_insertion_index = NULL); | 106 // transitions). |
107 inline int SearchSpecial(Symbol* symbol, int* out_insertion_index = NULL) { | |
108 return SearchName(symbol, out_insertion_index); | |
109 } | |
110 | |
111 static inline PropertyDetails GetTargetDetails(Name* name, Map* target); | |
104 | 112 |
105 // Allocates a TransitionArray. | 113 // Allocates a TransitionArray. |
106 static Handle<TransitionArray> Allocate(Isolate* isolate, | 114 static Handle<TransitionArray> Allocate(Isolate* isolate, |
107 int number_of_transitions, | 115 int number_of_transitions, |
108 int slack = 0); | 116 int slack = 0); |
109 | 117 |
110 bool IsSimpleTransition() { | 118 bool IsSimpleTransition() { |
111 return length() == kSimpleTransitionSize && | 119 return length() == kSimpleTransitionSize && |
112 get(kSimpleTransitionTarget)->IsHeapObject() && | 120 get(kSimpleTransitionTarget)->IsHeapObject() && |
113 // The IntrusivePrototypeTransitionIterator may have set the map of the | 121 // The IntrusivePrototypeTransitionIterator may have set the map of the |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 void Print(); | 168 void Print(); |
161 | 169 |
162 // Print all the transitions. | 170 // Print all the transitions. |
163 void PrintTransitions(std::ostream& os, bool print_header = true); // NOLINT | 171 void PrintTransitions(std::ostream& os, bool print_header = true); // NOLINT |
164 #endif | 172 #endif |
165 | 173 |
166 #ifdef DEBUG | 174 #ifdef DEBUG |
167 bool IsSortedNoDuplicates(int valid_entries = -1); | 175 bool IsSortedNoDuplicates(int valid_entries = -1); |
168 bool IsConsistentWithBackPointers(Map* current_map); | 176 bool IsConsistentWithBackPointers(Map* current_map); |
169 bool IsEqualTo(TransitionArray* other); | 177 bool IsEqualTo(TransitionArray* other); |
178 | |
179 // Returns true for a non-property transitions like elements kind, observed | |
180 // or frozen transitions. | |
181 static inline bool IsSpecialTransition(Name* name); | |
170 #endif | 182 #endif |
171 | 183 |
172 // The maximum number of transitions we want in a transition array (should | 184 // The maximum number of transitions we want in a transition array (should |
173 // fit in a page). | 185 // fit in a page). |
174 static const int kMaxNumberOfTransitions = 1024 + 512; | 186 static const int kMaxNumberOfTransitions = 1024 + 512; |
175 | 187 |
176 // Returns the fixed array length required to hold number_of_transitions | 188 // Returns the fixed array length required to hold number_of_transitions |
177 // transitions. | 189 // transitions. |
178 static int LengthFor(int number_of_transitions) { | 190 static int LengthFor(int number_of_transitions) { |
179 return ToKeyIndex(number_of_transitions); | 191 return ToKeyIndex(number_of_transitions); |
(...skipping 15 matching lines...) Expand all Loading... | |
195 | 207 |
196 static Handle<TransitionArray> AllocateSimple( | 208 static Handle<TransitionArray> AllocateSimple( |
197 Isolate* isolate, Handle<Map> target); | 209 Isolate* isolate, Handle<Map> target); |
198 | 210 |
199 // Allocate a new transition array with a single entry. | 211 // Allocate a new transition array with a single entry. |
200 static Handle<TransitionArray> NewWith(Handle<Map> map, | 212 static Handle<TransitionArray> NewWith(Handle<Map> map, |
201 Handle<Name> name, | 213 Handle<Name> name, |
202 Handle<Map> target, | 214 Handle<Map> target, |
203 SimpleTransitionFlag flag); | 215 SimpleTransitionFlag flag); |
204 | 216 |
217 // Search a first transition for a given property name. | |
218 inline int SearchName(Name* name, int* out_insertion_index = NULL); | |
219 int SearchDetails(int transition, PropertyType type, | |
220 PropertyAttributes attributes, int* out_insertion_index); | |
221 | |
222 // Compares two sets of keys, returns -1 if set1 is "less" than set2, | |
223 // 0 if set1 equal to set2 and 1 otherwise. | |
Toon Verwaest
2014/11/04 10:50:50
Sets? It just compares 2 keys with extra info than
Igor Sheludko
2014/11/04 16:44:16
Done.
| |
224 static inline int CompareKeys(Name* key1, uint32_t hash1, | |
225 bool is_data_property1, | |
226 PropertyAttributes attributes1, Name* key2, | |
227 uint32_t hash2, bool is_data_property2, | |
228 PropertyAttributes attributes2); | |
229 | |
230 // Compares keys, returns -1 if key1 is "less" than key2, | |
231 // 0 if key1 equal to key2 and 1 otherwise. | |
232 static inline int CompareNames(Name* key1, uint32_t hash1, Name* key2, | |
233 uint32_t hash2); | |
234 | |
235 // Compares two sets of details, returns -1 if set1 is "less" than set2, | |
236 // 0 if set1 equal to set2 and 1 otherwise. | |
237 static inline int CompareDetails(bool is_data_property1, | |
238 PropertyAttributes attributes1, | |
239 bool is_data_property2, | |
240 PropertyAttributes attributes2); | |
241 | |
205 inline void NoIncrementalWriteBarrierSet(int transition_number, | 242 inline void NoIncrementalWriteBarrierSet(int transition_number, |
206 Name* key, | 243 Name* key, |
207 Map* target); | 244 Map* target); |
208 | 245 |
209 // Copy a single transition from the origin array. | 246 // Copy a single transition from the origin array. |
210 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, | 247 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, |
211 int origin_transition, | 248 int origin_transition, |
212 int target_transition); | 249 int target_transition); |
213 | 250 |
214 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); | 251 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); |
215 }; | 252 }; |
216 | 253 |
217 | 254 |
218 } } // namespace v8::internal | 255 } } // namespace v8::internal |
219 | 256 |
220 #endif // V8_TRANSITIONS_H_ | 257 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |