Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_TRANSITIONS_INL_H_ | 5 #ifndef V8_TRANSITIONS_INL_H_ |
| 6 #define V8_TRANSITIONS_INL_H_ | 6 #define V8_TRANSITIONS_INL_H_ |
| 7 | 7 |
| 8 #include "src/transitions.h" | 8 #include "src/transitions.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 TransitionArray* TransitionArray::cast(Object* object) { | 30 TransitionArray* TransitionArray::cast(Object* object) { |
| 31 DCHECK(object->IsTransitionArray()); | 31 DCHECK(object->IsTransitionArray()); |
| 32 return reinterpret_cast<TransitionArray*>(object); | 32 return reinterpret_cast<TransitionArray*>(object); |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 bool TransitionArray::HasElementsTransition() { | 36 bool TransitionArray::HasElementsTransition() { |
| 37 return Search(GetHeap()->elements_transition_symbol()) != kNotFound; | 37 return SearchSpecial(GetHeap()->elements_transition_symbol()) != kNotFound; |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 Object* TransitionArray::back_pointer_storage() { | 41 Object* TransitionArray::back_pointer_storage() { |
| 42 return get(kBackPointerStorageIndex); | 42 return get(kBackPointerStorageIndex); |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 void TransitionArray::set_back_pointer_storage(Object* back_pointer, | 46 void TransitionArray::set_back_pointer_storage(Object* back_pointer, |
| 47 WriteBarrierMode mode) { | 47 WriteBarrierMode mode) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 return map->GetLastDescriptorDetails(); | 133 return map->GetLastDescriptorDetails(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 Object* TransitionArray::GetTargetValue(int transition_number) { | 137 Object* TransitionArray::GetTargetValue(int transition_number) { |
| 138 Map* map = GetTarget(transition_number); | 138 Map* map = GetTarget(transition_number); |
| 139 return map->instance_descriptors()->GetValue(map->LastAdded()); | 139 return map->instance_descriptors()->GetValue(map->LastAdded()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 | 142 |
| 143 int TransitionArray::Search(Name* name, int* out_insertion_index) { | 143 int TransitionArray::SearchName(Name* name, int* out_insertion_index) { |
| 144 if (IsSimpleTransition()) { | 144 if (IsSimpleTransition()) { |
| 145 Name* key = GetKey(kSimpleTransitionIndex); | 145 Name* key = GetKey(kSimpleTransitionIndex); |
| 146 if (key->Equals(name)) return kSimpleTransitionIndex; | 146 if (key->Equals(name)) return kSimpleTransitionIndex; |
| 147 if (out_insertion_index != NULL) { | 147 if (out_insertion_index != NULL) { |
| 148 *out_insertion_index = key->Hash() > name->Hash() ? 0 : 1; | 148 *out_insertion_index = key->Hash() > name->Hash() ? 0 : 1; |
| 149 } | 149 } |
| 150 return kNotFound; | 150 return kNotFound; |
| 151 } | 151 } |
| 152 return internal::Search<ALL_ENTRIES>(this, name, 0, out_insertion_index); | 152 return internal::Search<ALL_ENTRIES>(this, name, 0, out_insertion_index); |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| 156 #ifdef DEBUG | |
| 157 bool TransitionArray::IsSpecialTransition(Name* name) { | |
| 158 if (!name->IsSymbol()) return false; | |
| 159 Heap* heap = name->GetHeap(); | |
| 160 return name == heap->frozen_symbol() || | |
| 161 name == heap->elements_transition_symbol() || | |
| 162 name == heap->observed_symbol(); | |
| 163 } | |
| 164 #endif | |
| 165 | |
| 166 | |
| 167 int TransitionArray::CompareKeys(Name* key1, uint32_t hash1, | |
| 168 bool is_data_property1, | |
| 169 PropertyAttributes attributes1, Name* key2, | |
| 170 uint32_t hash2, bool is_data_property2, | |
| 171 PropertyAttributes attributes2) { | |
| 172 int cmp = CompareNames(key1, hash1, key2, hash2); | |
| 173 if (cmp != 0) return cmp; | |
| 174 | |
| 175 return CompareDetails(is_data_property1, attributes1, is_data_property2, | |
| 176 attributes2); | |
| 177 } | |
| 178 | |
| 179 | |
| 180 int TransitionArray::CompareNames(Name* key1, uint32_t hash1, Name* key2, | |
| 181 uint32_t hash2) { | |
| 182 if (key1 != key2) { | |
| 183 // In case of hash collisions key1 is always "less" than key2. | |
| 184 return hash1 <= hash2 ? -1 : 1; | |
| 185 } | |
| 186 | |
| 187 return 0; | |
| 188 } | |
| 189 | |
| 190 | |
| 191 int TransitionArray::CompareDetails(bool is_data_property1, | |
| 192 PropertyAttributes attributes1, | |
| 193 bool is_data_property2, | |
| 194 PropertyAttributes attributes2) { | |
| 195 if (is_data_property1 != is_data_property2) { | |
| 196 return static_cast<int>(is_data_property1) < | |
| 197 static_cast<int>(is_data_property2) | |
| 198 ? -1 | |
| 199 : 1; | |
| 200 } | |
| 201 | |
| 202 if (attributes1 != attributes2) { | |
| 203 return static_cast<int>(attributes1) < static_cast<int>(attributes2) ? -1 | |
| 204 : 1; | |
| 205 } | |
| 206 | |
| 207 return 0; | |
| 208 } | |
| 209 | |
| 210 | |
| 211 PropertyDetails TransitionArray::GetTargetDetails(Name* name, Map* target) { | |
| 212 DCHECK(!IsSpecialTransition(name)); | |
| 213 int descriptor = target->LastAdded(); | |
| 214 DescriptorArray* descriptors = target->instance_descriptors(); | |
| 215 if (!descriptors->GetKey(descriptor)->Equals(name)) { | |
| 216 descriptor = descriptors->SearchWithCache(name, target); | |
| 217 DCHECK_NE(kNotFound, descriptor); | |
|
Toon Verwaest
2014/11/04 10:50:50
Mmh, this doesn't seem necessary. We shouldn't nee
Igor Sheludko
2014/11/04 16:44:16
Done. Now transitions always created for last adde
| |
| 218 } | |
| 219 return descriptors->GetDetails(descriptor); | |
| 220 } | |
| 221 | |
| 222 | |
| 156 void TransitionArray::NoIncrementalWriteBarrierSet(int transition_number, | 223 void TransitionArray::NoIncrementalWriteBarrierSet(int transition_number, |
| 157 Name* key, | 224 Name* key, |
| 158 Map* target) { | 225 Map* target) { |
| 159 FixedArray::NoIncrementalWriteBarrierSet( | 226 FixedArray::NoIncrementalWriteBarrierSet( |
| 160 this, ToKeyIndex(transition_number), key); | 227 this, ToKeyIndex(transition_number), key); |
| 161 FixedArray::NoIncrementalWriteBarrierSet( | 228 FixedArray::NoIncrementalWriteBarrierSet( |
| 162 this, ToTargetIndex(transition_number), target); | 229 this, ToTargetIndex(transition_number), target); |
| 163 } | 230 } |
| 164 | 231 |
| 165 | 232 |
| 166 void TransitionArray::SetNumberOfTransitions(int number_of_transitions) { | 233 void TransitionArray::SetNumberOfTransitions(int number_of_transitions) { |
| 167 if (IsFullTransitionArray()) { | 234 if (IsFullTransitionArray()) { |
| 168 DCHECK(number_of_transitions <= number_of_transitions_storage()); | 235 DCHECK(number_of_transitions <= number_of_transitions_storage()); |
| 169 WRITE_FIELD(this, kTransitionLengthOffset, | 236 WRITE_FIELD(this, kTransitionLengthOffset, |
| 170 Smi::FromInt(number_of_transitions)); | 237 Smi::FromInt(number_of_transitions)); |
| 171 } | 238 } |
| 172 } | 239 } |
| 173 | 240 |
| 174 | 241 |
| 175 #undef FIELD_ADDR | 242 #undef FIELD_ADDR |
| 176 #undef WRITE_FIELD | 243 #undef WRITE_FIELD |
| 177 #undef CONDITIONAL_WRITE_BARRIER | 244 #undef CONDITIONAL_WRITE_BARRIER |
| 178 | 245 |
| 179 | 246 |
| 180 } } // namespace v8::internal | 247 } } // namespace v8::internal |
| 181 | 248 |
| 182 #endif // V8_TRANSITIONS_INL_H_ | 249 #endif // V8_TRANSITIONS_INL_H_ |
| OLD | NEW |