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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 DescriptorArray* descriptors(); | 74 inline DescriptorArray* descriptors(); |
75 inline void set_descriptors(DescriptorArray* descriptors, | 75 inline void set_descriptors(DescriptorArray* descriptors); |
76 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 76 inline JSGlobalPropertyCell* descriptors_pointer(); |
77 inline Object** GetDescriptorsSlot(); | |
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 ASSERT(length() >= kFirstIndex); | 93 ASSERT(length() >= kFirstIndex); |
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(String* name, Map* target); | 101 static MUST_USE_RESULT MaybeObject* NewWith( |
| 102 String* name, |
| 103 Map* target, |
| 104 JSGlobalPropertyCell* descriptor_pointer, |
| 105 Object* back_pointer); |
103 | 106 |
104 // Copy the transition array, inserting a new transition. | 107 // Copy the transition array, inserting a new transition. |
105 // TODO(verwaest): This should not cause an existing transition to be | 108 // TODO(verwaest): This should not cause an existing transition to be |
106 // overwritten. | 109 // overwritten. |
107 MUST_USE_RESULT MaybeObject* CopyInsert(String* name, Map* target); | 110 MUST_USE_RESULT MaybeObject* CopyInsert(String* name, Map* target); |
108 | 111 |
109 // Copy a single transition from the origin array. | 112 // Copy a single transition from the origin array. |
110 inline void CopyFrom(TransitionArray* origin, | 113 inline void CopyFrom(TransitionArray* origin, |
111 int origin_transition, | 114 int origin_transition, |
112 int target_transition, | 115 int target_transition, |
113 const WhitenessWitness& witness); | 116 const WhitenessWitness& witness); |
114 | 117 |
115 // Search a transition for a given property name. | 118 // Search a transition for a given property name. |
116 inline int Search(String* name); | 119 inline int Search(String* name); |
117 | 120 |
118 // Allocates a TransitionArray. | 121 // Allocates a TransitionArray. |
119 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_transitions); | 122 MUST_USE_RESULT static MaybeObject* Allocate( |
| 123 int number_of_transitions, |
| 124 JSGlobalPropertyCell* descriptors_cell); |
120 | 125 |
121 // Casting. | 126 // Casting. |
122 static inline TransitionArray* cast(Object* obj); | 127 static inline TransitionArray* cast(Object* obj); |
123 | 128 |
124 // Constant for denoting key was not found. | 129 // Constant for denoting key was not found. |
125 static const int kNotFound = -1; | 130 static const int kNotFound = -1; |
126 | 131 |
127 static const int kDescriptorsIndex = 0; | 132 static const int kDescriptorsPointerIndex = 0; |
128 static const int kBackPointerStorageIndex = 1; | 133 static const int kBackPointerStorageIndex = 1; |
129 static const int kElementsTransitionIndex = 2; | 134 static const int kElementsTransitionIndex = 2; |
130 static const int kPrototypeTransitionsIndex = 3; | 135 static const int kPrototypeTransitionsIndex = 3; |
131 static const int kFirstIndex = 4; | 136 static const int kFirstIndex = 4; |
132 | 137 |
133 // Layout transition array header. | 138 // Layout transition array header. |
134 static const int kDescriptorsOffset = FixedArray::kHeaderSize; | 139 static const int kDescriptorsPointerOffset = FixedArray::kHeaderSize; |
135 static const int kBackPointerStorageOffset = kDescriptorsOffset + | 140 static const int kBackPointerStorageOffset = kDescriptorsPointerOffset + |
136 kPointerSize; | 141 kPointerSize; |
137 static const int kElementsTransitionOffset = kBackPointerStorageOffset + | 142 static const int kElementsTransitionOffset = kBackPointerStorageOffset + |
138 kPointerSize; | 143 kPointerSize; |
139 static const int kPrototypeTransitionsOffset = kElementsTransitionOffset + | 144 static const int kPrototypeTransitionsOffset = kElementsTransitionOffset + |
140 kPointerSize; | 145 kPointerSize; |
141 | 146 |
142 // Layout of map transition. | 147 // Layout of map transition. |
143 static const int kTransitionKey = 0; | 148 static const int kTransitionKey = 0; |
144 static const int kTransitionTarget = 1; | 149 static const int kTransitionTarget = 1; |
145 static const int kTransitionSize = 2; | 150 static const int kTransitionSize = 2; |
146 | 151 |
147 #ifdef OBJECT_PRINT | 152 #ifdef OBJECT_PRINT |
148 // Print all the transitions. | 153 // Print all the transitions. |
149 inline void PrintTransitions() { | 154 inline void PrintTransitions() { |
150 PrintTransitions(stdout); | 155 PrintTransitions(stdout); |
151 } | 156 } |
152 void PrintTransitions(FILE* out); | 157 void PrintTransitions(FILE* out); |
153 #endif | 158 #endif |
154 | 159 |
155 #ifdef DEBUG | 160 #ifdef DEBUG |
156 bool IsSortedNoDuplicates(); | 161 bool IsSortedNoDuplicates(int valid_entries = -1); |
157 bool IsConsistentWithBackPointers(Map* current_map); | 162 bool IsConsistentWithBackPointers(Map* current_map); |
158 bool IsEqualTo(TransitionArray* other); | 163 bool IsEqualTo(TransitionArray* other); |
159 #endif | 164 #endif |
160 | 165 |
161 // The maximum number of transitions we want in a transition array (should | 166 // The maximum number of transitions we want in a transition array (should |
162 // fit in a page). | 167 // fit in a page). |
163 static const int kMaxNumberOfTransitions = 1024 + 512; | 168 static const int kMaxNumberOfTransitions = 1024 + 512; |
164 | 169 |
165 private: | 170 private: |
166 // Conversion from transition number to array indices. | 171 // Conversion from transition number to array indices. |
(...skipping 14 matching lines...) Expand all Loading... |
181 Map* target, | 186 Map* target, |
182 const WhitenessWitness&); | 187 const WhitenessWitness&); |
183 | 188 |
184 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); | 189 DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray); |
185 }; | 190 }; |
186 | 191 |
187 | 192 |
188 } } // namespace v8::internal | 193 } } // namespace v8::internal |
189 | 194 |
190 #endif // V8_TRANSITIONS_H_ | 195 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |