OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 // Returns the number of transitions in the array. | 89 // Returns the number of transitions in the array. |
90 int number_of_transitions() { | 90 int number_of_transitions() { |
91 if (IsSimpleTransition()) return 1; | 91 if (IsSimpleTransition()) return 1; |
92 int len = length(); | 92 int len = length(); |
93 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kTransitionSize; | 93 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kTransitionSize; |
94 } | 94 } |
95 | 95 |
96 inline int number_of_entries() { return number_of_transitions(); } | 96 inline int number_of_entries() { return number_of_transitions(); } |
97 | 97 |
98 // Allocate a new transition array with a single entry. | 98 static Handle<TransitionArray> ExtendToFullTransitionArray( |
99 static Handle<TransitionArray> NewWith(Handle<Map> map, | 99 Handle<TransitionArray> array); |
100 Handle<Name> name, | |
101 Handle<Map> target, | |
102 SimpleTransitionFlag flag); | |
103 | |
104 MUST_USE_RESULT MaybeObject* ExtendToFullTransitionArray(); | |
105 | 100 |
106 // Create a transition array, copying from the owning map if it already has | 101 // Create a transition array, copying from the owning map if it already has |
107 // one, otherwise creating a new one according to flag. | 102 // one, otherwise creating a new one according to flag. |
108 // TODO(verwaest): This should not cause an existing transition to be | 103 // TODO(verwaest): This should not cause an existing transition to be |
109 // overwritten. | 104 // overwritten. |
110 static Handle<TransitionArray> CopyInsert(Handle<Map> map, | 105 static Handle<TransitionArray> CopyInsert(Handle<Map> map, |
111 Handle<Name> name, | 106 Handle<Name> name, |
112 Handle<Map> target, | 107 Handle<Map> target, |
113 SimpleTransitionFlag flag); | 108 SimpleTransitionFlag flag); |
114 | 109 |
115 // Copy a single transition from the origin array. | |
116 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, | |
117 int origin_transition, | |
118 int target_transition); | |
119 | |
120 // Search a transition for a given property name. | 110 // Search a transition for a given property name. |
121 inline int Search(Name* name); | 111 inline int Search(Name* name); |
122 | 112 |
123 // Allocates a TransitionArray. | 113 // Allocates a TransitionArray. |
124 MUST_USE_RESULT static MaybeObject* Allocate( | 114 static Handle<TransitionArray> Allocate( |
125 Isolate* isolate, int number_of_transitions); | 115 Isolate* isolate, int number_of_transitions); |
126 | 116 |
127 MUST_USE_RESULT static MaybeObject* AllocateSimple( | |
128 Isolate* isolate, Map* target); | |
129 | |
130 bool IsSimpleTransition() { | 117 bool IsSimpleTransition() { |
131 return length() == kSimpleTransitionSize && | 118 return length() == kSimpleTransitionSize && |
132 get(kSimpleTransitionTarget)->IsHeapObject() && | 119 get(kSimpleTransitionTarget)->IsHeapObject() && |
133 // The IntrusivePrototypeTransitionIterator may have set the map of the | 120 // The IntrusivePrototypeTransitionIterator may have set the map of the |
134 // prototype transitions array to a smi. In that case, there are | 121 // prototype transitions array to a smi. In that case, there are |
135 // prototype transitions, hence this transition array is a full | 122 // prototype transitions, hence this transition array is a full |
136 // transition array. | 123 // transition array. |
137 HeapObject::cast(get(kSimpleTransitionTarget))->map()->IsMap() && | 124 HeapObject::cast(get(kSimpleTransitionTarget))->map()->IsMap() && |
138 get(kSimpleTransitionTarget)->IsMap(); | 125 get(kSimpleTransitionTarget)->IsMap(); |
139 } | 126 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 (transition_number * kTransitionSize) + | 184 (transition_number * kTransitionSize) + |
198 kTransitionKey; | 185 kTransitionKey; |
199 } | 186 } |
200 | 187 |
201 static int ToTargetIndex(int transition_number) { | 188 static int ToTargetIndex(int transition_number) { |
202 return kFirstIndex + | 189 return kFirstIndex + |
203 (transition_number * kTransitionSize) + | 190 (transition_number * kTransitionSize) + |
204 kTransitionTarget; | 191 kTransitionTarget; |
205 } | 192 } |
206 | 193 |
| 194 static Handle<TransitionArray> AllocateSimple( |
| 195 Isolate* isolate, Handle<Map> target); |
| 196 |
| 197 // Allocate a new transition array with a single entry. |
| 198 static Handle<TransitionArray> NewWith(Handle<Map> map, |
| 199 Handle<Name> name, |
| 200 Handle<Map> target, |
| 201 SimpleTransitionFlag flag); |
| 202 |
207 inline void NoIncrementalWriteBarrierSet(int transition_number, | 203 inline void NoIncrementalWriteBarrierSet(int transition_number, |
208 Name* key, | 204 Name* key, |
209 Map* target); | 205 Map* target); |
210 | 206 |
| 207 // Copy a single transition from the origin array. |
| 208 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, |
| 209 int origin_transition, |
| 210 int target_transition); |
| 211 |
211 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); | 212 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); |
212 }; | 213 }; |
213 | 214 |
214 | 215 |
215 } } // namespace v8::internal | 216 } } // namespace v8::internal |
216 | 217 |
217 #endif // V8_TRANSITIONS_H_ | 218 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |