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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Allocate a new transition array with a single entry. |
99 static MUST_USE_RESULT MaybeObject* NewWith( | 99 static Handle<TransitionArray> NewWith(SimpleTransitionFlag flag, |
100 SimpleTransitionFlag flag, | 100 Handle<Name> key, |
101 Name* key, | 101 Handle<Map> target, |
102 Map* target, | 102 Handle<Object> back_pointer); |
103 Object* back_pointer); | |
104 | 103 |
105 MUST_USE_RESULT MaybeObject* ExtendToFullTransitionArray(); | 104 MUST_USE_RESULT MaybeObject* ExtendToFullTransitionArray(); |
106 | 105 |
107 // Copy the transition array, inserting a new transition. | 106 // Copy the transition array, inserting a new transition. |
108 // TODO(verwaest): This should not cause an existing transition to be | 107 // TODO(verwaest): This should not cause an existing transition to be |
109 // overwritten. | 108 // overwritten. |
110 MUST_USE_RESULT MaybeObject* CopyInsert(Name* name, Map* target); | 109 static Handle<TransitionArray> CopyInsert(Handle<Map> map, |
| 110 Handle<Name> name, |
| 111 Handle<Map> target); |
111 | 112 |
112 // Copy a single transition from the origin array. | 113 // Copy a single transition from the origin array. |
113 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, | 114 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, |
114 int origin_transition, | 115 int origin_transition, |
115 int target_transition); | 116 int target_transition); |
116 | 117 |
117 // Search a transition for a given property name. | 118 // Search a transition for a given property name. |
118 inline int Search(Name* name); | 119 inline int Search(Name* name); |
119 | 120 |
120 // Allocates a TransitionArray. | 121 // Allocates a TransitionArray. |
121 MUST_USE_RESULT static MaybeObject* Allocate( | 122 MUST_USE_RESULT static MaybeObject* Allocate( |
122 Isolate* isolate, int number_of_transitions); | 123 Isolate* isolate, int number_of_transitions); |
123 | 124 |
| 125 MUST_USE_RESULT static MaybeObject* AllocateSimple( |
| 126 Isolate* isolate, Map* target); |
| 127 |
124 bool IsSimpleTransition() { | 128 bool IsSimpleTransition() { |
125 return length() == kSimpleTransitionSize && | 129 return length() == kSimpleTransitionSize && |
126 get(kSimpleTransitionTarget)->IsHeapObject() && | 130 get(kSimpleTransitionTarget)->IsHeapObject() && |
127 // The IntrusivePrototypeTransitionIterator may have set the map of the | 131 // The IntrusivePrototypeTransitionIterator may have set the map of the |
128 // prototype transitions array to a smi. In that case, there are | 132 // prototype transitions array to a smi. In that case, there are |
129 // prototype transitions, hence this transition array is a full | 133 // prototype transitions, hence this transition array is a full |
130 // transition array. | 134 // transition array. |
131 HeapObject::cast(get(kSimpleTransitionTarget))->map()->IsMap() && | 135 HeapObject::cast(get(kSimpleTransitionTarget))->map()->IsMap() && |
132 get(kSimpleTransitionTarget)->IsMap(); | 136 get(kSimpleTransitionTarget)->IsMap(); |
133 } | 137 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 Name* key, | 206 Name* key, |
203 Map* target); | 207 Map* target); |
204 | 208 |
205 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); | 209 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); |
206 }; | 210 }; |
207 | 211 |
208 | 212 |
209 } } // namespace v8::internal | 213 } } // namespace v8::internal |
210 | 214 |
211 #endif // V8_TRANSITIONS_H_ | 215 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |