OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 dependent_code()->DeoptimizeDependentCodeGroup( | 2271 dependent_code()->DeoptimizeDependentCodeGroup( |
2272 GetIsolate(), DependentCode::kTransitionGroup); | 2272 GetIsolate(), DependentCode::kTransitionGroup); |
2273 NotifyLeafMapLayoutChange(); | 2273 NotifyLeafMapLayoutChange(); |
2274 } | 2274 } |
2275 | 2275 |
2276 | 2276 |
2277 // Invalidates a transition target at |key|, and installs |new_descriptors| over | 2277 // Invalidates a transition target at |key|, and installs |new_descriptors| over |
2278 // the current instance_descriptors to ensure proper sharing of descriptor | 2278 // the current instance_descriptors to ensure proper sharing of descriptor |
2279 // arrays. | 2279 // arrays. |
2280 // Returns true if the transition target at given key was deprecated. | 2280 // Returns true if the transition target at given key was deprecated. |
2281 bool Map::DeprecateTarget(PropertyType type, Name* key, | 2281 bool Map::DeprecateTarget(PropertyKind kind, Name* key, |
2282 PropertyAttributes attributes, | 2282 PropertyAttributes attributes, |
2283 DescriptorArray* new_descriptors, | 2283 DescriptorArray* new_descriptors, |
2284 LayoutDescriptor* new_layout_descriptor) { | 2284 LayoutDescriptor* new_layout_descriptor) { |
2285 bool transition_target_deprecated = false; | 2285 bool transition_target_deprecated = false; |
2286 if (HasTransitionArray()) { | 2286 if (HasTransitionArray()) { |
2287 TransitionArray* transitions = this->transitions(); | 2287 TransitionArray* transitions = this->transitions(); |
2288 int transition = transitions->Search(type, key, attributes); | 2288 int transition = transitions->Search(kind, key, attributes); |
2289 if (transition != TransitionArray::kNotFound) { | 2289 if (transition != TransitionArray::kNotFound) { |
2290 transitions->GetTarget(transition)->DeprecateTransitionTree(); | 2290 transitions->GetTarget(transition)->DeprecateTransitionTree(); |
2291 transition_target_deprecated = true; | 2291 transition_target_deprecated = true; |
2292 } | 2292 } |
2293 } | 2293 } |
2294 | 2294 |
2295 // Don't overwrite the empty descriptor array. | 2295 // Don't overwrite the empty descriptor array. |
2296 if (NumberOfOwnDescriptors() == 0) return transition_target_deprecated; | 2296 if (NumberOfOwnDescriptors() == 0) return transition_target_deprecated; |
2297 | 2297 |
2298 DescriptorArray* to_replace = instance_descriptors(); | 2298 DescriptorArray* to_replace = instance_descriptors(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 DCHECK(GetBackPointer()->IsUndefined()); | 2330 DCHECK(GetBackPointer()->IsUndefined()); |
2331 | 2331 |
2332 Map* current = this; | 2332 Map* current = this; |
2333 | 2333 |
2334 for (int i = verbatim; i < length; i++) { | 2334 for (int i = verbatim; i < length; i++) { |
2335 if (!current->HasTransitionArray()) break; | 2335 if (!current->HasTransitionArray()) break; |
2336 Name* name = descriptors->GetKey(i); | 2336 Name* name = descriptors->GetKey(i); |
2337 PropertyDetails details = descriptors->GetDetails(i); | 2337 PropertyDetails details = descriptors->GetDetails(i); |
2338 TransitionArray* transitions = current->transitions(); | 2338 TransitionArray* transitions = current->transitions(); |
2339 int transition = | 2339 int transition = |
2340 transitions->Search(details.type(), name, details.attributes()); | 2340 transitions->Search(details.kind(), name, details.attributes()); |
2341 if (transition == TransitionArray::kNotFound) break; | 2341 if (transition == TransitionArray::kNotFound) break; |
2342 | 2342 |
2343 Map* next = transitions->GetTarget(transition); | 2343 Map* next = transitions->GetTarget(transition); |
2344 DescriptorArray* next_descriptors = next->instance_descriptors(); | 2344 DescriptorArray* next_descriptors = next->instance_descriptors(); |
2345 | 2345 |
2346 PropertyDetails next_details = next_descriptors->GetDetails(i); | 2346 PropertyDetails next_details = next_descriptors->GetDetails(i); |
2347 if (details.type() != next_details.type()) break; | 2347 if (details.type() != next_details.type()) break; |
2348 if (details.attributes() != next_details.attributes()) break; | 2348 if (details.attributes() != next_details.attributes()) break; |
2349 if (!details.representation().Equals(next_details.representation())) break; | 2349 if (!details.representation().Equals(next_details.representation())) break; |
2350 if (next_details.type() == FIELD) { | 2350 if (next_details.type() == FIELD) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 (!new_field_type->NowIs(old_descriptors->GetFieldType(modify_index)) || | 2540 (!new_field_type->NowIs(old_descriptors->GetFieldType(modify_index)) || |
2541 !new_representation.fits_into(old_details.representation())))) { | 2541 !new_representation.fits_into(old_details.representation())))) { |
2542 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, | 2542 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, |
2543 "GenAll_RootModification"); | 2543 "GenAll_RootModification"); |
2544 } | 2544 } |
2545 } | 2545 } |
2546 | 2546 |
2547 Handle<Map> target_map = root_map; | 2547 Handle<Map> target_map = root_map; |
2548 for (int i = root_nof; i < old_nof; ++i) { | 2548 for (int i = root_nof; i < old_nof; ++i) { |
2549 PropertyDetails old_details = old_descriptors->GetDetails(i); | 2549 PropertyDetails old_details = old_descriptors->GetDetails(i); |
2550 int j = target_map->SearchTransition(old_details.type(), | 2550 int j = target_map->SearchTransition(old_details.kind(), |
2551 old_descriptors->GetKey(i), | 2551 old_descriptors->GetKey(i), |
2552 old_details.attributes()); | 2552 old_details.attributes()); |
2553 if (j == TransitionArray::kNotFound) break; | 2553 if (j == TransitionArray::kNotFound) break; |
2554 Handle<Map> tmp_map(target_map->GetTransition(j), isolate); | 2554 Handle<Map> tmp_map(target_map->GetTransition(j), isolate); |
2555 Handle<DescriptorArray> tmp_descriptors = handle( | 2555 Handle<DescriptorArray> tmp_descriptors = handle( |
2556 tmp_map->instance_descriptors(), isolate); | 2556 tmp_map->instance_descriptors(), isolate); |
2557 | 2557 |
2558 // Check if target map is incompatible. | 2558 // Check if target map is incompatible. |
2559 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); | 2559 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); |
2560 PropertyType old_type = old_details.type(); | 2560 PropertyType old_type = old_details.type(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 target_descriptors->GetDetails(modify_index).representation())); | 2608 target_descriptors->GetDetails(modify_index).representation())); |
2609 DCHECK(target_descriptors->GetDetails(modify_index).type() != FIELD || | 2609 DCHECK(target_descriptors->GetDetails(modify_index).type() != FIELD || |
2610 new_field_type->NowIs( | 2610 new_field_type->NowIs( |
2611 target_descriptors->GetFieldType(modify_index))); | 2611 target_descriptors->GetFieldType(modify_index))); |
2612 return target_map; | 2612 return target_map; |
2613 } | 2613 } |
2614 | 2614 |
2615 // Find the last compatible target map in the transition tree. | 2615 // Find the last compatible target map in the transition tree. |
2616 for (int i = target_nof; i < old_nof; ++i) { | 2616 for (int i = target_nof; i < old_nof; ++i) { |
2617 PropertyDetails old_details = old_descriptors->GetDetails(i); | 2617 PropertyDetails old_details = old_descriptors->GetDetails(i); |
2618 int j = target_map->SearchTransition(old_details.type(), | 2618 int j = target_map->SearchTransition(old_details.kind(), |
2619 old_descriptors->GetKey(i), | 2619 old_descriptors->GetKey(i), |
2620 old_details.attributes()); | 2620 old_details.attributes()); |
2621 if (j == TransitionArray::kNotFound) break; | 2621 if (j == TransitionArray::kNotFound) break; |
2622 Handle<Map> tmp_map(target_map->GetTransition(j), isolate); | 2622 Handle<Map> tmp_map(target_map->GetTransition(j), isolate); |
2623 Handle<DescriptorArray> tmp_descriptors( | 2623 Handle<DescriptorArray> tmp_descriptors( |
2624 tmp_map->instance_descriptors(), isolate); | 2624 tmp_map->instance_descriptors(), isolate); |
2625 | 2625 |
2626 // Check if target map is compatible. | 2626 // Check if target map is compatible. |
2627 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); | 2627 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); |
2628 DCHECK_EQ(old_details.attributes(), tmp_details.attributes()); | 2628 DCHECK_EQ(old_details.attributes(), tmp_details.attributes()); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2755 | 2755 |
2756 Handle<Map> split_map(root_map->FindLastMatchMap( | 2756 Handle<Map> split_map(root_map->FindLastMatchMap( |
2757 root_nof, old_nof, *new_descriptors), isolate); | 2757 root_nof, old_nof, *new_descriptors), isolate); |
2758 int split_nof = split_map->NumberOfOwnDescriptors(); | 2758 int split_nof = split_map->NumberOfOwnDescriptors(); |
2759 DCHECK_NE(old_nof, split_nof); | 2759 DCHECK_NE(old_nof, split_nof); |
2760 | 2760 |
2761 Handle<LayoutDescriptor> new_layout_descriptor = | 2761 Handle<LayoutDescriptor> new_layout_descriptor = |
2762 LayoutDescriptor::New(split_map, new_descriptors, old_nof); | 2762 LayoutDescriptor::New(split_map, new_descriptors, old_nof); |
2763 PropertyDetails split_prop_details = old_descriptors->GetDetails(split_nof); | 2763 PropertyDetails split_prop_details = old_descriptors->GetDetails(split_nof); |
2764 bool transition_target_deprecated = split_map->DeprecateTarget( | 2764 bool transition_target_deprecated = split_map->DeprecateTarget( |
2765 split_prop_details.type(), old_descriptors->GetKey(split_nof), | 2765 split_prop_details.kind(), old_descriptors->GetKey(split_nof), |
2766 split_prop_details.attributes(), *new_descriptors, | 2766 split_prop_details.attributes(), *new_descriptors, |
2767 *new_layout_descriptor); | 2767 *new_layout_descriptor); |
2768 | 2768 |
2769 // If |transition_target_deprecated| is true then the transition array | 2769 // If |transition_target_deprecated| is true then the transition array |
2770 // already contains entry for given descriptor. This means that the transition | 2770 // already contains entry for given descriptor. This means that the transition |
2771 // could be inserted regardless of whether transitions array is full or not. | 2771 // could be inserted regardless of whether transitions array is full or not. |
2772 if (!transition_target_deprecated && !split_map->CanHaveMoreTransitions()) { | 2772 if (!transition_target_deprecated && !split_map->CanHaveMoreTransitions()) { |
2773 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, | 2773 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, |
2774 "GenAll_CantHaveMoreTransitions"); | 2774 "GenAll_CantHaveMoreTransitions"); |
2775 } | 2775 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2852 Map* root_map = old_map->FindRootMap(); | 2852 Map* root_map = old_map->FindRootMap(); |
2853 if (!old_map->EquivalentToForTransition(root_map)) return MaybeHandle<Map>(); | 2853 if (!old_map->EquivalentToForTransition(root_map)) return MaybeHandle<Map>(); |
2854 int root_nof = root_map->NumberOfOwnDescriptors(); | 2854 int root_nof = root_map->NumberOfOwnDescriptors(); |
2855 | 2855 |
2856 int old_nof = old_map->NumberOfOwnDescriptors(); | 2856 int old_nof = old_map->NumberOfOwnDescriptors(); |
2857 DescriptorArray* old_descriptors = old_map->instance_descriptors(); | 2857 DescriptorArray* old_descriptors = old_map->instance_descriptors(); |
2858 | 2858 |
2859 Map* new_map = root_map; | 2859 Map* new_map = root_map; |
2860 for (int i = root_nof; i < old_nof; ++i) { | 2860 for (int i = root_nof; i < old_nof; ++i) { |
2861 PropertyDetails old_details = old_descriptors->GetDetails(i); | 2861 PropertyDetails old_details = old_descriptors->GetDetails(i); |
2862 int j = new_map->SearchTransition(old_details.type(), | 2862 int j = new_map->SearchTransition(old_details.kind(), |
2863 old_descriptors->GetKey(i), | 2863 old_descriptors->GetKey(i), |
2864 old_details.attributes()); | 2864 old_details.attributes()); |
2865 if (j == TransitionArray::kNotFound) return MaybeHandle<Map>(); | 2865 if (j == TransitionArray::kNotFound) return MaybeHandle<Map>(); |
2866 new_map = new_map->GetTransition(j); | 2866 new_map = new_map->GetTransition(j); |
2867 DescriptorArray* new_descriptors = new_map->instance_descriptors(); | 2867 DescriptorArray* new_descriptors = new_map->instance_descriptors(); |
2868 | 2868 |
2869 PropertyDetails new_details = new_descriptors->GetDetails(i); | 2869 PropertyDetails new_details = new_descriptors->GetDetails(i); |
2870 if (old_details.attributes() != new_details.attributes() || | 2870 if (old_details.attributes() != new_details.attributes() || |
2871 !old_details.representation().fits_into(new_details.representation())) { | 2871 !old_details.representation().fits_into(new_details.representation())) { |
2872 return MaybeHandle<Map>(); | 2872 return MaybeHandle<Map>(); |
(...skipping 4253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7126 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, | 7126 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, |
7127 Handle<Object> value, | 7127 Handle<Object> value, |
7128 PropertyAttributes attributes, | 7128 PropertyAttributes attributes, |
7129 StoreFromKeyed store_mode) { | 7129 StoreFromKeyed store_mode) { |
7130 // Dictionary maps can always have additional data properties. | 7130 // Dictionary maps can always have additional data properties. |
7131 if (map->is_dictionary_map()) return map; | 7131 if (map->is_dictionary_map()) return map; |
7132 | 7132 |
7133 // Migrate to the newest map before storing the property. | 7133 // Migrate to the newest map before storing the property. |
7134 map = Update(map); | 7134 map = Update(map); |
7135 | 7135 |
7136 int index = map->SearchTransition(FIELD, *name, attributes); | 7136 int index = map->SearchTransition(DATA, *name, attributes); |
7137 if (index != TransitionArray::kNotFound) { | 7137 if (index != TransitionArray::kNotFound) { |
7138 Handle<Map> transition(map->GetTransition(index)); | 7138 Handle<Map> transition(map->GetTransition(index)); |
7139 int descriptor = transition->LastAdded(); | 7139 int descriptor = transition->LastAdded(); |
7140 | 7140 |
7141 DCHECK_EQ(attributes, transition->instance_descriptors() | 7141 DCHECK_EQ(attributes, transition->instance_descriptors() |
7142 ->GetDetails(descriptor) | 7142 ->GetDetails(descriptor) |
7143 .attributes()); | 7143 .attributes()); |
7144 | 7144 |
7145 return Map::PrepareForDataProperty(transition, descriptor, value); | 7145 return Map::PrepareForDataProperty(transition, descriptor, value); |
7146 } | 7146 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7203 return map; | 7203 return map; |
7204 } | 7204 } |
7205 | 7205 |
7206 // Migrate to the newest map before transitioning to the new property. | 7206 // Migrate to the newest map before transitioning to the new property. |
7207 map = Update(map); | 7207 map = Update(map); |
7208 | 7208 |
7209 PropertyNormalizationMode mode = map->is_prototype_map() | 7209 PropertyNormalizationMode mode = map->is_prototype_map() |
7210 ? KEEP_INOBJECT_PROPERTIES | 7210 ? KEEP_INOBJECT_PROPERTIES |
7211 : CLEAR_INOBJECT_PROPERTIES; | 7211 : CLEAR_INOBJECT_PROPERTIES; |
7212 | 7212 |
7213 int index = map->SearchTransition(CALLBACKS, *name, attributes); | 7213 int index = map->SearchTransition(ACCESSOR, *name, attributes); |
7214 if (index != TransitionArray::kNotFound) { | 7214 if (index != TransitionArray::kNotFound) { |
7215 Handle<Map> transition(map->GetTransition(index)); | 7215 Handle<Map> transition(map->GetTransition(index)); |
7216 DescriptorArray* descriptors = transition->instance_descriptors(); | 7216 DescriptorArray* descriptors = transition->instance_descriptors(); |
7217 int descriptor = transition->LastAdded(); | 7217 int descriptor = transition->LastAdded(); |
7218 DCHECK(descriptors->GetKey(descriptor)->Equals(*name)); | 7218 DCHECK(descriptors->GetKey(descriptor)->Equals(*name)); |
7219 | 7219 |
7220 DCHECK_EQ(CALLBACKS, descriptors->GetDetails(descriptor).type()); | 7220 DCHECK_EQ(CALLBACKS, descriptors->GetDetails(descriptor).type()); |
7221 DCHECK_EQ(attributes, descriptors->GetDetails(descriptor).attributes()); | 7221 DCHECK_EQ(attributes, descriptors->GetDetails(descriptor).attributes()); |
7222 | 7222 |
7223 Handle<Object> maybe_pair(descriptors->GetValue(descriptor), isolate); | 7223 Handle<Object> maybe_pair(descriptors->GetValue(descriptor), isolate); |
(...skipping 9707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16931 Handle<DependentCode> codes = | 16931 Handle<DependentCode> codes = |
16932 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16932 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
16933 DependentCode::kPropertyCellChangedGroup, | 16933 DependentCode::kPropertyCellChangedGroup, |
16934 info->object_wrapper()); | 16934 info->object_wrapper()); |
16935 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16935 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
16936 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16936 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
16937 cell, info->zone()); | 16937 cell, info->zone()); |
16938 } | 16938 } |
16939 | 16939 |
16940 } } // namespace v8::internal | 16940 } } // namespace v8::internal |
OLD | NEW |