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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 return Map::cast(transition_map); | 62 return Map::cast(transition_map); |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 void TransitionArray::ClearElementsTransition() { | 66 void TransitionArray::ClearElementsTransition() { |
67 WRITE_FIELD(this, kElementsTransitionOffset, Smi::FromInt(0)); | 67 WRITE_FIELD(this, kElementsTransitionOffset, Smi::FromInt(0)); |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 bool TransitionArray::HasElementsTransition() { | 71 bool TransitionArray::HasElementsTransition() { |
72 if (!IsFullTransitionArray()) return false; | |
72 return get(kElementsTransitionIndex) != Smi::FromInt(0); | 73 return get(kElementsTransitionIndex) != Smi::FromInt(0); |
Michael Starzinger
2012/09/19 09:34:55
Can we turn that into ...
return IsFullTransition
Toon Verwaest
2012/09/19 09:53:23
Done.
| |
73 } | 74 } |
74 | 75 |
75 | 76 |
76 void TransitionArray::set_elements_transition(Map* transition_map, | 77 void TransitionArray::set_elements_transition(Map* transition_map, |
77 WriteBarrierMode mode) { | 78 WriteBarrierMode mode) { |
79 ASSERT(IsFullTransitionArray()); | |
78 Heap* heap = GetHeap(); | 80 Heap* heap = GetHeap(); |
79 WRITE_FIELD(this, kElementsTransitionOffset, transition_map); | 81 WRITE_FIELD(this, kElementsTransitionOffset, transition_map); |
80 CONDITIONAL_WRITE_BARRIER( | 82 CONDITIONAL_WRITE_BARRIER( |
81 heap, this, kElementsTransitionOffset, transition_map, mode); | 83 heap, this, kElementsTransitionOffset, transition_map, mode); |
82 } | 84 } |
83 | 85 |
84 | 86 |
85 DescriptorArray* TransitionArray::descriptors() { | 87 DescriptorArray* TransitionArray::descriptors() { |
86 return DescriptorArray::cast(descriptors_pointer()->value()); | 88 return DescriptorArray::cast(descriptors_pointer()->value()); |
87 } | 89 } |
(...skipping 26 matching lines...) Expand all Loading... | |
114 void TransitionArray::set_back_pointer_storage(Object* back_pointer, | 116 void TransitionArray::set_back_pointer_storage(Object* back_pointer, |
115 WriteBarrierMode mode) { | 117 WriteBarrierMode mode) { |
116 Heap* heap = GetHeap(); | 118 Heap* heap = GetHeap(); |
117 WRITE_FIELD(this, kBackPointerStorageOffset, back_pointer); | 119 WRITE_FIELD(this, kBackPointerStorageOffset, back_pointer); |
118 CONDITIONAL_WRITE_BARRIER( | 120 CONDITIONAL_WRITE_BARRIER( |
119 heap, this, kBackPointerStorageOffset, back_pointer, mode); | 121 heap, this, kBackPointerStorageOffset, back_pointer, mode); |
120 } | 122 } |
121 | 123 |
122 | 124 |
123 bool TransitionArray::HasPrototypeTransitions() { | 125 bool TransitionArray::HasPrototypeTransitions() { |
126 if (!IsFullTransitionArray()) return false; | |
124 Object* prototype_transitions = get(kPrototypeTransitionsIndex); | 127 Object* prototype_transitions = get(kPrototypeTransitionsIndex); |
125 return prototype_transitions != Smi::FromInt(0); | 128 return prototype_transitions != Smi::FromInt(0); |
Michael Starzinger
2012/09/19 09:34:55
Can we turn that into ...
return IsFullTransition
Toon Verwaest
2012/09/19 09:53:23
Done.
| |
126 } | 129 } |
127 | 130 |
128 | 131 |
129 FixedArray* TransitionArray::GetPrototypeTransitions() { | 132 FixedArray* TransitionArray::GetPrototypeTransitions() { |
133 ASSERT(IsFullTransitionArray()); | |
130 Object* prototype_transitions = get(kPrototypeTransitionsIndex); | 134 Object* prototype_transitions = get(kPrototypeTransitionsIndex); |
131 return FixedArray::cast(prototype_transitions); | 135 return FixedArray::cast(prototype_transitions); |
132 } | 136 } |
133 | 137 |
134 | 138 |
135 HeapObject* TransitionArray::UncheckedPrototypeTransitions() { | 139 HeapObject* TransitionArray::UncheckedPrototypeTransitions() { |
136 ASSERT(HasPrototypeTransitions()); | 140 ASSERT(HasPrototypeTransitions()); |
137 return reinterpret_cast<HeapObject*>(get(kPrototypeTransitionsIndex)); | 141 return reinterpret_cast<HeapObject*>(get(kPrototypeTransitionsIndex)); |
138 } | 142 } |
139 | 143 |
140 | 144 |
141 void TransitionArray::SetPrototypeTransitions(FixedArray* transitions, | 145 void TransitionArray::SetPrototypeTransitions(FixedArray* transitions, |
142 WriteBarrierMode mode) { | 146 WriteBarrierMode mode) { |
143 ASSERT(this != NULL); | 147 ASSERT(IsFullTransitionArray()); |
144 ASSERT(transitions->IsFixedArray()); | 148 ASSERT(transitions->IsFixedArray()); |
145 Heap* heap = GetHeap(); | 149 Heap* heap = GetHeap(); |
146 WRITE_FIELD(this, kPrototypeTransitionsOffset, transitions); | 150 WRITE_FIELD(this, kPrototypeTransitionsOffset, transitions); |
147 CONDITIONAL_WRITE_BARRIER( | 151 CONDITIONAL_WRITE_BARRIER( |
148 heap, this, kPrototypeTransitionsOffset, transitions, mode); | 152 heap, this, kPrototypeTransitionsOffset, transitions, mode); |
149 } | 153 } |
150 | 154 |
151 | 155 |
152 Object** TransitionArray::GetPrototypeTransitionsSlot() { | 156 Object** TransitionArray::GetPrototypeTransitionsSlot() { |
153 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), | 157 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), |
154 kPrototypeTransitionsOffset); | 158 kPrototypeTransitionsOffset); |
155 } | 159 } |
156 | 160 |
157 | 161 |
158 Object** TransitionArray::GetKeySlot(int transition_number) { | 162 Object** TransitionArray::GetKeySlot(int transition_number) { |
163 ASSERT(!IsSimpleTransition()); | |
159 ASSERT(transition_number < number_of_transitions()); | 164 ASSERT(transition_number < number_of_transitions()); |
160 return HeapObject::RawField( | 165 return HeapObject::RawField( |
161 reinterpret_cast<HeapObject*>(this), | 166 reinterpret_cast<HeapObject*>(this), |
162 OffsetOfElementAt(ToKeyIndex(transition_number))); | 167 OffsetOfElementAt(ToKeyIndex(transition_number))); |
163 } | 168 } |
164 | 169 |
165 | 170 |
166 String* TransitionArray::GetKey(int transition_number) { | 171 String* TransitionArray::GetKey(int transition_number) { |
172 if (IsSimpleTransition()) { | |
173 Map* target = GetTarget(kSimpleTransitionIndex); | |
174 int descriptor = target->LastAdded(); | |
175 String* key = target->instance_descriptors()->GetKey(descriptor); | |
176 return key; | |
177 } | |
167 ASSERT(transition_number < number_of_transitions()); | 178 ASSERT(transition_number < number_of_transitions()); |
168 return String::cast(get(ToKeyIndex(transition_number))); | 179 return String::cast(get(ToKeyIndex(transition_number))); |
169 } | 180 } |
170 | 181 |
171 | 182 |
172 void TransitionArray::SetKey(int transition_number, String* key) { | 183 void TransitionArray::SetKey(int transition_number, String* key) { |
184 ASSERT(!IsSimpleTransition()); | |
173 ASSERT(transition_number < number_of_transitions()); | 185 ASSERT(transition_number < number_of_transitions()); |
174 set(ToKeyIndex(transition_number), key); | 186 set(ToKeyIndex(transition_number), key); |
175 } | 187 } |
176 | 188 |
177 | 189 |
178 Map* TransitionArray::GetTarget(int transition_number) { | 190 Map* TransitionArray::GetTarget(int transition_number) { |
191 if (IsSimpleTransition()) { | |
192 ASSERT(transition_number == kSimpleTransitionIndex); | |
193 return Map::cast(get(kSimpleTransitionTarget)); | |
194 } | |
179 ASSERT(transition_number < number_of_transitions()); | 195 ASSERT(transition_number < number_of_transitions()); |
180 return Map::cast(get(ToTargetIndex(transition_number))); | 196 return Map::cast(get(ToTargetIndex(transition_number))); |
181 } | 197 } |
182 | 198 |
183 | 199 |
184 void TransitionArray::SetTarget(int transition_number, Map* value) { | 200 void TransitionArray::SetTarget(int transition_number, Map* value) { |
201 if (IsSimpleTransition()) { | |
202 ASSERT(transition_number == kSimpleTransitionIndex); | |
203 return set(kSimpleTransitionTarget, value); | |
204 } | |
185 ASSERT(transition_number < number_of_transitions()); | 205 ASSERT(transition_number < number_of_transitions()); |
186 set(ToTargetIndex(transition_number), value); | 206 set(ToTargetIndex(transition_number), value); |
187 } | 207 } |
188 | 208 |
189 | 209 |
190 PropertyDetails TransitionArray::GetTargetDetails(int transition_number) { | 210 PropertyDetails TransitionArray::GetTargetDetails(int transition_number) { |
191 Map* map = GetTarget(transition_number); | 211 Map* map = GetTarget(transition_number); |
192 DescriptorArray* descriptors = map->instance_descriptors(); | 212 DescriptorArray* descriptors = map->instance_descriptors(); |
193 int descriptor = map->LastAdded(); | 213 int descriptor = map->LastAdded(); |
194 return descriptors->GetDetails(descriptor); | 214 return descriptors->GetDetails(descriptor); |
(...skipping 16 matching lines...) Expand all Loading... | |
211 | 231 |
212 | 232 |
213 #undef FIELD_ADDR | 233 #undef FIELD_ADDR |
214 #undef WRITE_FIELD | 234 #undef WRITE_FIELD |
215 #undef CONDITIONAL_WRITE_BARRIER | 235 #undef CONDITIONAL_WRITE_BARRIER |
216 | 236 |
217 | 237 |
218 } } // namespace v8::internal | 238 } } // namespace v8::internal |
219 | 239 |
220 #endif // V8_TRANSITIONS_INL_H_ | 240 #endif // V8_TRANSITIONS_INL_H_ |
OLD | NEW |