| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return String::cast(get(ToKeyIndex(transition_number))); | 131 return String::cast(get(ToKeyIndex(transition_number))); |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 void TransitionArray::SetKey(int transition_number, String* key) { | 135 void TransitionArray::SetKey(int transition_number, String* key) { |
| 136 ASSERT(transition_number < number_of_transitions()); | 136 ASSERT(transition_number < number_of_transitions()); |
| 137 set(ToKeyIndex(transition_number), key); | 137 set(ToKeyIndex(transition_number), key); |
| 138 } | 138 } |
| 139 | 139 |
| 140 | 140 |
| 141 Object* TransitionArray::GetValue(int transition_number) { | 141 Map* TransitionArray::GetTarget(int transition_number) { |
| 142 ASSERT(transition_number < number_of_transitions()); | 142 ASSERT(transition_number < number_of_transitions()); |
| 143 return get(ToValueIndex(transition_number)); | 143 return Map::cast(get(ToTargetIndex(transition_number))); |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 Object** TransitionArray::GetValueSlot(int transition_number) { | 147 Object** TransitionArray::GetTargetSlot(int transition_number) { |
| 148 ASSERT(transition_number < number_of_transitions()); | 148 ASSERT(transition_number < number_of_transitions()); |
| 149 return HeapObject::RawField( | 149 return HeapObject::RawField( |
| 150 reinterpret_cast<HeapObject*>(this), | 150 reinterpret_cast<HeapObject*>(this), |
| 151 OffsetOfElementAt(ToValueIndex(transition_number))); | 151 OffsetOfElementAt(ToTargetIndex(transition_number))); |
| 152 } | 152 } |
| 153 | 153 |
| 154 | 154 |
| 155 void TransitionArray::SetValue(int transition_number, Object* value) { | 155 void TransitionArray::SetTarget(int transition_number, Map* value) { |
| 156 ASSERT(transition_number < number_of_transitions()); | 156 ASSERT(transition_number < number_of_transitions()); |
| 157 set(ToValueIndex(transition_number), value); | 157 set(ToTargetIndex(transition_number), value); |
| 158 } | |
| 159 | |
| 160 | |
| 161 Map* TransitionArray::GetTargetMap(int transition_number) { | |
| 162 Object* value = GetValue(transition_number); | |
| 163 if (value->IsAccessorPair()) { | |
| 164 // TODO(verwaest): Currently details are always taken from the getter if it | |
| 165 // is a transition, otherwise from the setter which in that case has to be a | |
| 166 // transition. Details should be dependent on which component is requested. | |
| 167 AccessorPair* accessors = AccessorPair::cast(value); | |
| 168 if (accessors->getter()->IsMap()) { | |
| 169 return Map::cast(accessors->getter()); | |
| 170 } | |
| 171 return Map::cast(accessors->setter()); | |
| 172 } | |
| 173 return Map::cast(value); | |
| 174 } | 158 } |
| 175 | 159 |
| 176 | 160 |
| 177 PropertyDetails TransitionArray::GetTargetDetails(int transition_number) { | 161 PropertyDetails TransitionArray::GetTargetDetails(int transition_number) { |
| 178 Map* map = GetTargetMap(transition_number); | 162 Map* map = GetTarget(transition_number); |
| 179 DescriptorArray* descriptors = map->instance_descriptors(); | 163 DescriptorArray* descriptors = map->instance_descriptors(); |
| 180 int descriptor = descriptors->LastAdded(); | 164 int descriptor = descriptors->LastAdded(); |
| 181 ASSERT(descriptor != DescriptorArray::kNotFound); | 165 ASSERT(descriptor != DescriptorArray::kNotFound); |
| 182 return descriptors->GetDetails(descriptor); | 166 return descriptors->GetDetails(descriptor); |
| 183 } | 167 } |
| 184 | 168 |
| 185 | 169 |
| 186 Object** TransitionArray::GetElementsTransitionSlot() { | 170 Object** TransitionArray::GetElementsTransitionSlot() { |
| 187 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), | 171 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), |
| 188 kElementsTransitionOffset); | 172 kElementsTransitionOffset); |
| 189 } | 173 } |
| 190 | 174 |
| 191 | 175 |
| 192 int TransitionArray::Search(String* name) { | 176 int TransitionArray::Search(String* name) { |
| 193 return internal::Search(this, name); | 177 return internal::Search(this, name); |
| 194 } | 178 } |
| 195 | 179 |
| 196 | 180 |
| 197 void TransitionArray::Set(int transition_number, | 181 void TransitionArray::Set(int transition_number, |
| 198 String* key, | 182 String* key, |
| 199 Object* value, | 183 Map* target, |
| 200 const WhitenessWitness&) { | 184 const WhitenessWitness&) { |
| 201 NoIncrementalWriteBarrierSet(this, | 185 NoIncrementalWriteBarrierSet(this, |
| 202 ToKeyIndex(transition_number), | 186 ToKeyIndex(transition_number), |
| 203 key); | 187 key); |
| 204 NoIncrementalWriteBarrierSet(this, | 188 NoIncrementalWriteBarrierSet(this, |
| 205 ToValueIndex(transition_number), | 189 ToTargetIndex(transition_number), |
| 206 value); | 190 target); |
| 207 } | 191 } |
| 208 | 192 |
| 209 | 193 |
| 210 #undef FIELD_ADDR | 194 #undef FIELD_ADDR |
| 211 #undef WRITE_FIELD | 195 #undef WRITE_FIELD |
| 212 #undef CONDITIONAL_WRITE_BARRIER | 196 #undef CONDITIONAL_WRITE_BARRIER |
| 213 | 197 |
| 214 | 198 |
| 215 } } // namespace v8::internal | 199 } } // namespace v8::internal |
| 216 | 200 |
| 217 #endif // V8_TRANSITIONS_INL_H_ | 201 #endif // V8_TRANSITIONS_INL_H_ |
| OLD | NEW |