| 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 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2252 deprecate(); | 2252 deprecate(); |
| 2253 dependent_code()->DeoptimizeDependentCodeGroup( | 2253 dependent_code()->DeoptimizeDependentCodeGroup( |
| 2254 GetIsolate(), DependentCode::kTransitionGroup); | 2254 GetIsolate(), DependentCode::kTransitionGroup); |
| 2255 NotifyLeafMapLayoutChange(); | 2255 NotifyLeafMapLayoutChange(); |
| 2256 } | 2256 } |
| 2257 | 2257 |
| 2258 | 2258 |
| 2259 // Invalidates a transition target at |key|, and installs |new_descriptors| over | 2259 // Invalidates a transition target at |key|, and installs |new_descriptors| over |
| 2260 // the current instance_descriptors to ensure proper sharing of descriptor | 2260 // the current instance_descriptors to ensure proper sharing of descriptor |
| 2261 // arrays. | 2261 // arrays. |
| 2262 void Map::DeprecateTarget(Name* key, DescriptorArray* new_descriptors, | 2262 // Returns true if the transition target at given key was deprecated. |
| 2263 bool Map::DeprecateTarget(Name* key, DescriptorArray* new_descriptors, |
| 2263 LayoutDescriptor* new_layout_descriptor) { | 2264 LayoutDescriptor* new_layout_descriptor) { |
| 2265 bool transition_target_deprecated = false; |
| 2264 if (HasTransitionArray()) { | 2266 if (HasTransitionArray()) { |
| 2265 TransitionArray* transitions = this->transitions(); | 2267 TransitionArray* transitions = this->transitions(); |
| 2266 int transition = transitions->Search(key); | 2268 int transition = transitions->Search(key); |
| 2267 if (transition != TransitionArray::kNotFound) { | 2269 if (transition != TransitionArray::kNotFound) { |
| 2268 transitions->GetTarget(transition)->DeprecateTransitionTree(); | 2270 transitions->GetTarget(transition)->DeprecateTransitionTree(); |
| 2271 transition_target_deprecated = true; |
| 2269 } | 2272 } |
| 2270 } | 2273 } |
| 2271 | 2274 |
| 2272 // Don't overwrite the empty descriptor array. | 2275 // Don't overwrite the empty descriptor array. |
| 2273 if (NumberOfOwnDescriptors() == 0) return; | 2276 if (NumberOfOwnDescriptors() == 0) return transition_target_deprecated; |
| 2274 | 2277 |
| 2275 DescriptorArray* to_replace = instance_descriptors(); | 2278 DescriptorArray* to_replace = instance_descriptors(); |
| 2276 Map* current = this; | 2279 Map* current = this; |
| 2277 GetHeap()->incremental_marking()->RecordWrites(to_replace); | 2280 GetHeap()->incremental_marking()->RecordWrites(to_replace); |
| 2278 while (current->instance_descriptors() == to_replace) { | 2281 while (current->instance_descriptors() == to_replace) { |
| 2279 current->SetEnumLength(kInvalidEnumCacheSentinel); | 2282 current->SetEnumLength(kInvalidEnumCacheSentinel); |
| 2280 current->UpdateDescriptors(new_descriptors, new_layout_descriptor); | 2283 current->UpdateDescriptors(new_descriptors, new_layout_descriptor); |
| 2281 Object* next = current->GetBackPointer(); | 2284 Object* next = current->GetBackPointer(); |
| 2282 if (next->IsUndefined()) break; | 2285 if (next->IsUndefined()) break; |
| 2283 current = Map::cast(next); | 2286 current = Map::cast(next); |
| 2284 } | 2287 } |
| 2285 | 2288 |
| 2286 set_owns_descriptors(false); | 2289 set_owns_descriptors(false); |
| 2290 return transition_target_deprecated; |
| 2287 } | 2291 } |
| 2288 | 2292 |
| 2289 | 2293 |
| 2290 Map* Map::FindRootMap() { | 2294 Map* Map::FindRootMap() { |
| 2291 Map* result = this; | 2295 Map* result = this; |
| 2292 while (true) { | 2296 while (true) { |
| 2293 Object* back = result->GetBackPointer(); | 2297 Object* back = result->GetBackPointer(); |
| 2294 if (back->IsUndefined()) return result; | 2298 if (back->IsUndefined()) return result; |
| 2295 result = Map::cast(back); | 2299 result = Map::cast(back); |
| 2296 } | 2300 } |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2724 DCHECK(store_mode != FORCE_FIELD || | 2728 DCHECK(store_mode != FORCE_FIELD || |
| 2725 new_descriptors->GetDetails(modify_index).type() == FIELD); | 2729 new_descriptors->GetDetails(modify_index).type() == FIELD); |
| 2726 | 2730 |
| 2727 Handle<Map> split_map(root_map->FindLastMatchMap( | 2731 Handle<Map> split_map(root_map->FindLastMatchMap( |
| 2728 root_nof, old_nof, *new_descriptors), isolate); | 2732 root_nof, old_nof, *new_descriptors), isolate); |
| 2729 int split_nof = split_map->NumberOfOwnDescriptors(); | 2733 int split_nof = split_map->NumberOfOwnDescriptors(); |
| 2730 DCHECK_NE(old_nof, split_nof); | 2734 DCHECK_NE(old_nof, split_nof); |
| 2731 | 2735 |
| 2732 Handle<LayoutDescriptor> new_layout_descriptor = | 2736 Handle<LayoutDescriptor> new_layout_descriptor = |
| 2733 LayoutDescriptor::New(split_map, new_descriptors, old_nof); | 2737 LayoutDescriptor::New(split_map, new_descriptors, old_nof); |
| 2734 split_map->DeprecateTarget(old_descriptors->GetKey(split_nof), | 2738 bool transition_target_deprecated = |
| 2735 *new_descriptors, *new_layout_descriptor); | 2739 split_map->DeprecateTarget(old_descriptors->GetKey(split_nof), |
| 2740 *new_descriptors, *new_layout_descriptor); |
| 2741 |
| 2742 // If |transition_target_deprecated| is true then the transition array |
| 2743 // already contains entry for given descriptor. This means that the transition |
| 2744 // could be inserted regardless of whether transitions array is full or not. |
| 2745 if (!transition_target_deprecated && !split_map->CanHaveMoreTransitions()) { |
| 2746 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, |
| 2747 "GenAll_CantHaveMoreTransitions"); |
| 2748 } |
| 2736 | 2749 |
| 2737 if (FLAG_trace_generalization) { | 2750 if (FLAG_trace_generalization) { |
| 2738 PropertyDetails old_details = old_descriptors->GetDetails(modify_index); | 2751 PropertyDetails old_details = old_descriptors->GetDetails(modify_index); |
| 2739 PropertyDetails new_details = new_descriptors->GetDetails(modify_index); | 2752 PropertyDetails new_details = new_descriptors->GetDetails(modify_index); |
| 2740 Handle<HeapType> old_field_type = (old_details.type() == FIELD) | 2753 Handle<HeapType> old_field_type = (old_details.type() == FIELD) |
| 2741 ? handle(old_descriptors->GetFieldType(modify_index), isolate) | 2754 ? handle(old_descriptors->GetFieldType(modify_index), isolate) |
| 2742 : HeapType::Constant(handle(old_descriptors->GetValue(modify_index), | 2755 : HeapType::Constant(handle(old_descriptors->GetValue(modify_index), |
| 2743 isolate), isolate); | 2756 isolate), isolate); |
| 2744 Handle<HeapType> new_field_type = (new_details.type() == FIELD) | 2757 Handle<HeapType> new_field_type = (new_details.type() == FIELD) |
| 2745 ? handle(new_descriptors->GetFieldType(modify_index), isolate) | 2758 ? handle(new_descriptors->GetFieldType(modify_index), isolate) |
| 2746 : HeapType::Constant(handle(new_descriptors->GetValue(modify_index), | 2759 : HeapType::Constant(handle(new_descriptors->GetValue(modify_index), |
| 2747 isolate), isolate); | 2760 isolate), isolate); |
| 2748 old_map->PrintGeneralization( | 2761 old_map->PrintGeneralization( |
| 2749 stdout, "", modify_index, split_nof, old_nof, | 2762 stdout, "", modify_index, split_nof, old_nof, |
| 2750 old_details.type() == CONSTANT && store_mode == FORCE_FIELD, | 2763 old_details.type() == CONSTANT && store_mode == FORCE_FIELD, |
| 2751 old_details.representation(), new_details.representation(), | 2764 old_details.representation(), new_details.representation(), |
| 2752 *old_field_type, *new_field_type); | 2765 *old_field_type, *new_field_type); |
| 2753 } | 2766 } |
| 2754 | 2767 |
| 2755 // Add missing transitions. | 2768 // Add missing transitions. |
| 2756 Handle<Map> new_map = split_map; | 2769 Handle<Map> new_map = split_map; |
| 2757 for (int i = split_nof; i < old_nof; ++i) { | 2770 for (int i = split_nof; i < old_nof; ++i) { |
| 2758 if (!new_map->CanHaveMoreTransitions()) { | |
| 2759 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, | |
| 2760 "can't have more transitions"); | |
| 2761 } | |
| 2762 new_map = CopyInstallDescriptors(new_map, i, new_descriptors, | 2771 new_map = CopyInstallDescriptors(new_map, i, new_descriptors, |
| 2763 new_layout_descriptor); | 2772 new_layout_descriptor); |
| 2764 } | 2773 } |
| 2765 new_map->set_owns_descriptors(true); | 2774 new_map->set_owns_descriptors(true); |
| 2766 return new_map; | 2775 return new_map; |
| 2767 } | 2776 } |
| 2768 | 2777 |
| 2769 | 2778 |
| 2770 // Generalize the representation of all FIELD descriptors. | 2779 // Generalize the representation of all FIELD descriptors. |
| 2771 Handle<Map> Map::GeneralizeAllFieldRepresentations( | 2780 Handle<Map> Map::GeneralizeAllFieldRepresentations( |
| (...skipping 14043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16815 Handle<DependentCode> codes = | 16824 Handle<DependentCode> codes = |
| 16816 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16825 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
| 16817 DependentCode::kPropertyCellChangedGroup, | 16826 DependentCode::kPropertyCellChangedGroup, |
| 16818 info->object_wrapper()); | 16827 info->object_wrapper()); |
| 16819 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16828 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
| 16820 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16829 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 16821 cell, info->zone()); | 16830 cell, info->zone()); |
| 16822 } | 16831 } |
| 16823 | 16832 |
| 16824 } } // namespace v8::internal | 16833 } } // namespace v8::internal |
| OLD | NEW |