| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/objects.h" | 7 #include "src/objects.h" |
| 8 #include "src/transitions-inl.h" | 8 #include "src/transitions-inl.h" |
| 9 #include "src/utils.h" | 9 #include "src/utils.h" |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 DCHECK_EQ(is_special_transition, IsSpecialTransition(*name)); | 98 DCHECK_EQ(is_special_transition, IsSpecialTransition(*name)); |
| 99 PropertyDetails details = is_special_transition | 99 PropertyDetails details = is_special_transition |
| 100 ? PropertyDetails(NONE, FIELD, 0) | 100 ? PropertyDetails(NONE, FIELD, 0) |
| 101 : GetTargetDetails(*name, *target); | 101 : GetTargetDetails(*name, *target); |
| 102 | 102 |
| 103 int insertion_index = kNotFound; | 103 int insertion_index = kNotFound; |
| 104 int index = | 104 int index = |
| 105 is_special_transition | 105 is_special_transition |
| 106 ? map->transitions()->SearchSpecial(Symbol::cast(*name), | 106 ? map->transitions()->SearchSpecial(Symbol::cast(*name), |
| 107 &insertion_index) | 107 &insertion_index) |
| 108 : map->transitions()->Search(details.type(), *name, | 108 : map->transitions()->Search(details.kind(), *name, |
| 109 details.attributes(), &insertion_index); | 109 details.attributes(), &insertion_index); |
| 110 if (index == kNotFound) { | 110 if (index == kNotFound) { |
| 111 ++new_nof; | 111 ++new_nof; |
| 112 } else { | 112 } else { |
| 113 insertion_index = index; | 113 insertion_index = index; |
| 114 } | 114 } |
| 115 DCHECK(insertion_index >= 0 && insertion_index <= number_of_transitions); | 115 DCHECK(insertion_index >= 0 && insertion_index <= number_of_transitions); |
| 116 | 116 |
| 117 CHECK(new_nof <= kMaxNumberOfTransitions); | 117 CHECK(new_nof <= kMaxNumberOfTransitions); |
| 118 | 118 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 if (array->number_of_transitions() != number_of_transitions) { | 150 if (array->number_of_transitions() != number_of_transitions) { |
| 151 DCHECK(array->number_of_transitions() < number_of_transitions); | 151 DCHECK(array->number_of_transitions() < number_of_transitions); |
| 152 | 152 |
| 153 number_of_transitions = array->number_of_transitions(); | 153 number_of_transitions = array->number_of_transitions(); |
| 154 new_nof = number_of_transitions; | 154 new_nof = number_of_transitions; |
| 155 | 155 |
| 156 insertion_index = kNotFound; | 156 insertion_index = kNotFound; |
| 157 index = is_special_transition ? map->transitions()->SearchSpecial( | 157 index = is_special_transition ? map->transitions()->SearchSpecial( |
| 158 Symbol::cast(*name), &insertion_index) | 158 Symbol::cast(*name), &insertion_index) |
| 159 : map->transitions()->Search( | 159 : map->transitions()->Search( |
| 160 details.type(), *name, | 160 details.kind(), *name, |
| 161 details.attributes(), &insertion_index); | 161 details.attributes(), &insertion_index); |
| 162 if (index == kNotFound) { | 162 if (index == kNotFound) { |
| 163 ++new_nof; | 163 ++new_nof; |
| 164 } else { | 164 } else { |
| 165 insertion_index = index; | 165 insertion_index = index; |
| 166 } | 166 } |
| 167 DCHECK(insertion_index >= 0 && insertion_index <= number_of_transitions); | 167 DCHECK(insertion_index >= 0 && insertion_index <= number_of_transitions); |
| 168 | 168 |
| 169 result->Shrink(ToKeyIndex(new_nof)); | 169 result->Shrink(ToKeyIndex(new_nof)); |
| 170 result->SetNumberOfTransitions(new_nof); | 170 result->SetNumberOfTransitions(new_nof); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 182 for (int i = insertion_index; i < number_of_transitions; ++i) { | 182 for (int i = insertion_index; i < number_of_transitions; ++i) { |
| 183 result->NoIncrementalWriteBarrierCopyFrom(array, i, i + 1); | 183 result->NoIncrementalWriteBarrierCopyFrom(array, i, i + 1); |
| 184 } | 184 } |
| 185 | 185 |
| 186 result->set_back_pointer_storage(array->back_pointer_storage()); | 186 result->set_back_pointer_storage(array->back_pointer_storage()); |
| 187 SLOW_DCHECK(result->IsSortedNoDuplicates()); | 187 SLOW_DCHECK(result->IsSortedNoDuplicates()); |
| 188 return result; | 188 return result; |
| 189 } | 189 } |
| 190 | 190 |
| 191 | 191 |
| 192 int TransitionArray::SearchDetails(int transition, PropertyType type, | 192 int TransitionArray::SearchDetails(int transition, PropertyKind kind, |
| 193 PropertyAttributes attributes, | 193 PropertyAttributes attributes, |
| 194 int* out_insertion_index) { | 194 int* out_insertion_index) { |
| 195 int nof_transitions = number_of_transitions(); | 195 int nof_transitions = number_of_transitions(); |
| 196 DCHECK(transition < nof_transitions); | 196 DCHECK(transition < nof_transitions); |
| 197 Name* key = GetKey(transition); | 197 Name* key = GetKey(transition); |
| 198 bool is_data = type == FIELD || type == CONSTANT; | |
| 199 for (; transition < nof_transitions && GetKey(transition) == key; | 198 for (; transition < nof_transitions && GetKey(transition) == key; |
| 200 transition++) { | 199 transition++) { |
| 201 Map* target = GetTarget(transition); | 200 Map* target = GetTarget(transition); |
| 202 PropertyDetails target_details = GetTargetDetails(key, target); | 201 PropertyDetails target_details = GetTargetDetails(key, target); |
| 203 | 202 |
| 204 bool target_is_data = | 203 int cmp = CompareDetails(kind, attributes, target_details.kind(), |
| 205 target_details.type() == FIELD || target_details.type() == CONSTANT; | |
| 206 | |
| 207 int cmp = CompareDetails(is_data, attributes, target_is_data, | |
| 208 target_details.attributes()); | 204 target_details.attributes()); |
| 209 if (cmp == 0) { | 205 if (cmp == 0) { |
| 210 return transition; | 206 return transition; |
| 211 } else if (cmp < 0) { | 207 } else if (cmp < 0) { |
| 212 break; | 208 break; |
| 213 } | 209 } |
| 214 } | 210 } |
| 215 if (out_insertion_index != NULL) *out_insertion_index = transition; | 211 if (out_insertion_index != NULL) *out_insertion_index = transition; |
| 216 return kNotFound; | 212 return kNotFound; |
| 217 } | 213 } |
| 218 | 214 |
| 219 | 215 |
| 220 int TransitionArray::Search(PropertyType type, Name* name, | 216 int TransitionArray::Search(PropertyKind kind, Name* name, |
| 221 PropertyAttributes attributes, | 217 PropertyAttributes attributes, |
| 222 int* out_insertion_index) { | 218 int* out_insertion_index) { |
| 223 int transition = SearchName(name, out_insertion_index); | 219 int transition = SearchName(name, out_insertion_index); |
| 224 if (transition == kNotFound) { | 220 if (transition == kNotFound) { |
| 225 return kNotFound; | 221 return kNotFound; |
| 226 } | 222 } |
| 227 return SearchDetails(transition, type, attributes, out_insertion_index); | 223 return SearchDetails(transition, kind, attributes, out_insertion_index); |
| 228 } | 224 } |
| 229 } } // namespace v8::internal | 225 } } // namespace v8::internal |
| OLD | NEW |