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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 inline PropertyDetails GetTargetDetails(int transition_number); | 65 inline PropertyDetails GetTargetDetails(int transition_number); |
66 | 66 |
67 inline Map* elements_transition(); | 67 inline Map* elements_transition(); |
68 inline void set_elements_transition( | 68 inline void set_elements_transition( |
69 Map* target, | 69 Map* target, |
70 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 70 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
71 inline bool HasElementsTransition(); | 71 inline bool HasElementsTransition(); |
72 inline void ClearElementsTransition(); | 72 inline void ClearElementsTransition(); |
73 | 73 |
| 74 inline Object** GetDescriptorsSlot(); |
74 inline DescriptorArray* descriptors(); | 75 inline DescriptorArray* descriptors(); |
75 inline void set_descriptors(DescriptorArray* descriptors); | 76 inline void set_descriptors(DescriptorArray* descriptors); |
76 inline JSGlobalPropertyCell* descriptors_pointer(); | |
77 inline void set_descriptors_pointer(JSGlobalPropertyCell* pointer); | |
78 | 77 |
79 inline Object* back_pointer_storage(); | 78 inline Object* back_pointer_storage(); |
80 inline void set_back_pointer_storage( | 79 inline void set_back_pointer_storage( |
81 Object* back_pointer, | 80 Object* back_pointer, |
82 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 81 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
83 | 82 |
84 inline FixedArray* GetPrototypeTransitions(); | 83 inline FixedArray* GetPrototypeTransitions(); |
85 inline void SetPrototypeTransitions( | 84 inline void SetPrototypeTransitions( |
86 FixedArray* prototype_transitions, | 85 FixedArray* prototype_transitions, |
87 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 86 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
88 inline Object** GetPrototypeTransitionsSlot(); | 87 inline Object** GetPrototypeTransitionsSlot(); |
89 inline bool HasPrototypeTransitions(); | 88 inline bool HasPrototypeTransitions(); |
90 inline HeapObject* UncheckedPrototypeTransitions(); | 89 inline HeapObject* UncheckedPrototypeTransitions(); |
91 | 90 |
92 // Returns the number of transitions in the array. | 91 // Returns the number of transitions in the array. |
93 int number_of_transitions() { | 92 int number_of_transitions() { |
94 if (IsSimpleTransition()) return 1; | 93 if (IsSimpleTransition()) return 1; |
95 int len = length(); | 94 int len = length(); |
96 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kTransitionSize; | 95 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kTransitionSize; |
97 } | 96 } |
98 | 97 |
99 inline int number_of_entries() { return number_of_transitions(); } | 98 inline int number_of_entries() { return number_of_transitions(); } |
100 | 99 |
101 // Allocate a new transition array with a single entry. | 100 // Allocate a new transition array with a single entry. |
102 static MUST_USE_RESULT MaybeObject* NewWith( | 101 static MUST_USE_RESULT MaybeObject* NewWith( |
103 SimpleTransitionFlag flag, | 102 SimpleTransitionFlag flag, |
104 String* key, | 103 String* key, |
105 Map* target, | 104 Map* target, |
106 JSGlobalPropertyCell* descriptor_pointer, | 105 DescriptorArray* descriptors, |
107 Object* back_pointer); | 106 Object* back_pointer); |
108 | 107 |
109 static MUST_USE_RESULT MaybeObject* AllocateDescriptorsHolder( | 108 static MUST_USE_RESULT MaybeObject* AllocateDescriptorsHolder(); |
110 JSGlobalPropertyCell* descriptor_pointer); | |
111 | 109 |
112 MUST_USE_RESULT MaybeObject* ExtendToFullTransitionArray(); | 110 MUST_USE_RESULT MaybeObject* ExtendToFullTransitionArray(); |
113 | 111 |
114 // Copy the transition array, inserting a new transition. | 112 // Copy the transition array, inserting a new transition. |
115 // TODO(verwaest): This should not cause an existing transition to be | 113 // TODO(verwaest): This should not cause an existing transition to be |
116 // overwritten. | 114 // overwritten. |
117 MUST_USE_RESULT MaybeObject* CopyInsert(String* name, Map* target); | 115 MUST_USE_RESULT MaybeObject* CopyInsert(String* name, Map* target); |
118 | 116 |
119 // Copy a single transition from the origin array. | 117 // Copy a single transition from the origin array. |
120 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, | 118 inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, |
121 int origin_transition, | 119 int origin_transition, |
122 int target_transition); | 120 int target_transition); |
123 | 121 |
124 // Search a transition for a given property name. | 122 // Search a transition for a given property name. |
125 inline int Search(String* name); | 123 inline int Search(String* name); |
126 | 124 |
127 // Allocates a TransitionArray. | 125 // Allocates a TransitionArray. |
128 MUST_USE_RESULT static MaybeObject* Allocate( | 126 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_transitions); |
129 int number_of_transitions, | |
130 JSGlobalPropertyCell* descriptors_cell); | |
131 | 127 |
132 bool IsDescriptorsHolder() { return length() == kDescriptorsHolderSize; } | 128 bool IsDescriptorsHolder() { return length() == kDescriptorsHolderSize; } |
133 bool IsSimpleTransition() { return length() == kSimpleTransitionSize; } | 129 bool IsSimpleTransition() { return length() == kSimpleTransitionSize; } |
134 bool IsFullTransitionArray() { return length() >= kFirstIndex; } | 130 bool IsFullTransitionArray() { return length() >= kFirstIndex; } |
135 | 131 |
136 // Casting. | 132 // Casting. |
137 static inline TransitionArray* cast(Object* obj); | 133 static inline TransitionArray* cast(Object* obj); |
138 | 134 |
139 // Constant for denoting key was not found. | 135 // Constant for denoting key was not found. |
140 static const int kNotFound = -1; | 136 static const int kNotFound = -1; |
141 | 137 |
142 static const int kDescriptorsPointerIndex = 0; | 138 static const int kDescriptorsIndex = 0; |
143 static const int kBackPointerStorageIndex = 1; | 139 static const int kBackPointerStorageIndex = 1; |
144 static const int kDescriptorsHolderSize = 2; | 140 static const int kDescriptorsHolderSize = 2; |
145 | 141 |
146 // Layout for full transition arrays. | 142 // Layout for full transition arrays. |
147 static const int kElementsTransitionIndex = 2; | 143 static const int kElementsTransitionIndex = 2; |
148 static const int kPrototypeTransitionsIndex = 3; | 144 static const int kPrototypeTransitionsIndex = 3; |
149 static const int kFirstIndex = 4; | 145 static const int kFirstIndex = 4; |
150 | 146 |
151 // Layout for simple transition arrays. | 147 // Layout for simple transition arrays. |
152 static const int kSimpleTransitionTarget = 2; | 148 static const int kSimpleTransitionTarget = 2; |
153 static const int kSimpleTransitionSize = 3; | 149 static const int kSimpleTransitionSize = 3; |
154 static const int kSimpleTransitionIndex = 0; | 150 static const int kSimpleTransitionIndex = 0; |
155 STATIC_ASSERT(kSimpleTransitionIndex != kNotFound); | 151 STATIC_ASSERT(kSimpleTransitionIndex != kNotFound); |
156 | 152 |
157 static const int kDescriptorsPointerOffset = FixedArray::kHeaderSize; | 153 static const int kDescriptorsOffset = FixedArray::kHeaderSize; |
158 static const int kBackPointerStorageOffset = kDescriptorsPointerOffset + | 154 static const int kBackPointerStorageOffset = kDescriptorsOffset + |
159 kPointerSize; | 155 kPointerSize; |
160 | 156 |
161 // Layout for the full transition array header. | 157 // Layout for the full transition array header. |
162 static const int kElementsTransitionOffset = kBackPointerStorageOffset + | 158 static const int kElementsTransitionOffset = kBackPointerStorageOffset + |
163 kPointerSize; | 159 kPointerSize; |
164 static const int kPrototypeTransitionsOffset = kElementsTransitionOffset + | 160 static const int kPrototypeTransitionsOffset = kElementsTransitionOffset + |
165 kPointerSize; | 161 kPointerSize; |
166 | 162 |
167 // Layout of map transition entries in full transition arrays. | 163 // Layout of map transition entries in full transition arrays. |
168 static const int kTransitionKey = 0; | 164 static const int kTransitionKey = 0; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 String* key, | 201 String* key, |
206 Map* target); | 202 Map* target); |
207 | 203 |
208 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); | 204 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); |
209 }; | 205 }; |
210 | 206 |
211 | 207 |
212 } } // namespace v8::internal | 208 } } // namespace v8::internal |
213 | 209 |
214 #endif // V8_TRANSITIONS_H_ | 210 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |