| 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2409 new_map->NumberOfOwnDescriptors(), | 2409 new_map->NumberOfOwnDescriptors(), |
| 2410 new_map->NumberOfOwnDescriptors(), | 2410 new_map->NumberOfOwnDescriptors(), |
| 2411 details.type() == CONSTANT && store_mode == FORCE_FIELD, | 2411 details.type() == CONSTANT && store_mode == FORCE_FIELD, |
| 2412 details.representation(), Representation::Tagged(), | 2412 details.representation(), Representation::Tagged(), |
| 2413 field_type, HeapType::Any()); | 2413 field_type, HeapType::Any()); |
| 2414 } | 2414 } |
| 2415 return new_map; | 2415 return new_map; |
| 2416 } | 2416 } |
| 2417 | 2417 |
| 2418 | 2418 |
| 2419 // static |
| 2420 Handle<Map> Map::CopyGeneralizeAllRepresentations(Handle<Map> map, |
| 2421 int modify_index, |
| 2422 StoreMode store_mode, |
| 2423 const char* reason) { |
| 2424 PropertyDetails details = |
| 2425 map->instance_descriptors()->GetDetails(modify_index); |
| 2426 return CopyGeneralizeAllRepresentations(map, modify_index, store_mode, |
| 2427 details.attributes(), reason); |
| 2428 } |
| 2429 |
| 2430 |
| 2419 void Map::DeprecateTransitionTree() { | 2431 void Map::DeprecateTransitionTree() { |
| 2420 if (is_deprecated()) return; | 2432 if (is_deprecated()) return; |
| 2421 if (HasTransitionArray()) { | 2433 if (HasTransitionArray()) { |
| 2422 TransitionArray* transitions = this->transitions(); | 2434 TransitionArray* transitions = this->transitions(); |
| 2423 for (int i = 0; i < transitions->number_of_transitions(); i++) { | 2435 for (int i = 0; i < transitions->number_of_transitions(); i++) { |
| 2424 transitions->GetTarget(i)->DeprecateTransitionTree(); | 2436 transitions->GetTarget(i)->DeprecateTransitionTree(); |
| 2425 } | 2437 } |
| 2426 } | 2438 } |
| 2427 deprecate(); | 2439 deprecate(); |
| 2428 dependent_code()->DeoptimizeDependentCodeGroup( | 2440 dependent_code()->DeoptimizeDependentCodeGroup( |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 old_descriptors->GetFieldType(modify_index), *new_field_type); | 2666 old_descriptors->GetFieldType(modify_index), *new_field_type); |
| 2655 } | 2667 } |
| 2656 old_descriptors->SetRepresentation(modify_index, new_representation); | 2668 old_descriptors->SetRepresentation(modify_index, new_representation); |
| 2657 old_descriptors->SetValue(modify_index, *new_field_type); | 2669 old_descriptors->SetValue(modify_index, *new_field_type); |
| 2658 return old_map; | 2670 return old_map; |
| 2659 } | 2671 } |
| 2660 | 2672 |
| 2661 // Check the state of the root map. | 2673 // Check the state of the root map. |
| 2662 Handle<Map> root_map(old_map->FindRootMap(), isolate); | 2674 Handle<Map> root_map(old_map->FindRootMap(), isolate); |
| 2663 if (!old_map->EquivalentToForTransition(*root_map)) { | 2675 if (!old_map->EquivalentToForTransition(*root_map)) { |
| 2664 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, | 2676 return CopyGeneralizeAllRepresentations( |
| 2665 old_details.attributes(), "not equivalent"); | 2677 old_map, modify_index, store_mode, "not equivalent"); |
| 2666 } | 2678 } |
| 2667 int root_nof = root_map->NumberOfOwnDescriptors(); | 2679 int root_nof = root_map->NumberOfOwnDescriptors(); |
| 2668 if (modify_index < root_nof) { | 2680 if (modify_index < root_nof) { |
| 2669 PropertyDetails old_details = old_descriptors->GetDetails(modify_index); | 2681 PropertyDetails old_details = old_descriptors->GetDetails(modify_index); |
| 2670 if ((old_details.type() != FIELD && store_mode == FORCE_FIELD) || | 2682 if ((old_details.type() != FIELD && store_mode == FORCE_FIELD) || |
| 2671 (old_details.type() == FIELD && | 2683 (old_details.type() == FIELD && |
| 2672 (!new_field_type->NowIs(old_descriptors->GetFieldType(modify_index)) || | 2684 (!new_field_type->NowIs(old_descriptors->GetFieldType(modify_index)) || |
| 2673 !new_representation.fits_into(old_details.representation())))) { | 2685 !new_representation.fits_into(old_details.representation())))) { |
| 2674 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, | 2686 return CopyGeneralizeAllRepresentations( |
| 2675 old_details.attributes(), "root modification"); | 2687 old_map, modify_index, store_mode, "root modification"); |
| 2676 } | 2688 } |
| 2677 } | 2689 } |
| 2678 | 2690 |
| 2679 Handle<Map> target_map = root_map; | 2691 Handle<Map> target_map = root_map; |
| 2680 for (int i = root_nof; i < old_nof; ++i) { | 2692 for (int i = root_nof; i < old_nof; ++i) { |
| 2681 int j = target_map->SearchTransition(old_descriptors->GetKey(i)); | 2693 int j = target_map->SearchTransition(old_descriptors->GetKey(i)); |
| 2682 if (j == TransitionArray::kNotFound) break; | 2694 if (j == TransitionArray::kNotFound) break; |
| 2683 Handle<Map> tmp_map(target_map->GetTransition(j), isolate); | 2695 Handle<Map> tmp_map(target_map->GetTransition(j), isolate); |
| 2684 Handle<DescriptorArray> tmp_descriptors = handle( | 2696 Handle<DescriptorArray> tmp_descriptors = handle( |
| 2685 tmp_map->instance_descriptors(), isolate); | 2697 tmp_map->instance_descriptors(), isolate); |
| 2686 | 2698 |
| 2687 // Check if target map is incompatible. | 2699 // Check if target map is incompatible. |
| 2688 PropertyDetails old_details = old_descriptors->GetDetails(i); | 2700 PropertyDetails old_details = old_descriptors->GetDetails(i); |
| 2689 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); | 2701 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); |
| 2690 PropertyType old_type = old_details.type(); | 2702 PropertyType old_type = old_details.type(); |
| 2691 PropertyType tmp_type = tmp_details.type(); | 2703 PropertyType tmp_type = tmp_details.type(); |
| 2692 if (tmp_details.attributes() != old_details.attributes() || | 2704 if (tmp_details.attributes() != old_details.attributes() || |
| 2693 ((tmp_type == CALLBACKS || old_type == CALLBACKS) && | 2705 ((tmp_type == CALLBACKS || old_type == CALLBACKS) && |
| 2694 (tmp_type != old_type || | 2706 (tmp_type != old_type || |
| 2695 tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i)))) { | 2707 tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i)))) { |
| 2696 return CopyGeneralizeAllRepresentations( | 2708 return CopyGeneralizeAllRepresentations( |
| 2697 old_map, modify_index, store_mode, | 2709 old_map, modify_index, store_mode, "incompatible"); |
| 2698 old_details.attributes(), "incompatible"); | |
| 2699 } | 2710 } |
| 2700 Representation old_representation = old_details.representation(); | 2711 Representation old_representation = old_details.representation(); |
| 2701 Representation tmp_representation = tmp_details.representation(); | 2712 Representation tmp_representation = tmp_details.representation(); |
| 2702 if (!old_representation.fits_into(tmp_representation) || | 2713 if (!old_representation.fits_into(tmp_representation) || |
| 2703 (!new_representation.fits_into(tmp_representation) && | 2714 (!new_representation.fits_into(tmp_representation) && |
| 2704 modify_index == i)) { | 2715 modify_index == i)) { |
| 2705 break; | 2716 break; |
| 2706 } | 2717 } |
| 2707 if (tmp_type == FIELD) { | 2718 if (tmp_type == FIELD) { |
| 2708 // Generalize the field type as necessary. | 2719 // Generalize the field type as necessary. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2752 tmp_map->instance_descriptors(), isolate); | 2763 tmp_map->instance_descriptors(), isolate); |
| 2753 | 2764 |
| 2754 // Check if target map is compatible. | 2765 // Check if target map is compatible. |
| 2755 PropertyDetails old_details = old_descriptors->GetDetails(i); | 2766 PropertyDetails old_details = old_descriptors->GetDetails(i); |
| 2756 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); | 2767 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); |
| 2757 if (tmp_details.attributes() != old_details.attributes() || | 2768 if (tmp_details.attributes() != old_details.attributes() || |
| 2758 ((tmp_details.type() == CALLBACKS || old_details.type() == CALLBACKS) && | 2769 ((tmp_details.type() == CALLBACKS || old_details.type() == CALLBACKS) && |
| 2759 (tmp_details.type() != old_details.type() || | 2770 (tmp_details.type() != old_details.type() || |
| 2760 tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i)))) { | 2771 tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i)))) { |
| 2761 return CopyGeneralizeAllRepresentations( | 2772 return CopyGeneralizeAllRepresentations( |
| 2762 old_map, modify_index, store_mode, | 2773 old_map, modify_index, store_mode, "incompatible"); |
| 2763 old_details.attributes(), "incompatible"); | |
| 2764 } | 2774 } |
| 2765 target_map = tmp_map; | 2775 target_map = tmp_map; |
| 2766 } | 2776 } |
| 2767 target_nof = target_map->NumberOfOwnDescriptors(); | 2777 target_nof = target_map->NumberOfOwnDescriptors(); |
| 2768 target_descriptors = handle(target_map->instance_descriptors(), isolate); | 2778 target_descriptors = handle(target_map->instance_descriptors(), isolate); |
| 2769 | 2779 |
| 2770 // Allocate a new descriptor array large enough to hold the required | 2780 // Allocate a new descriptor array large enough to hold the required |
| 2771 // descriptors, with minimally the exact same size as the old descriptor | 2781 // descriptors, with minimally the exact same size as the old descriptor |
| 2772 // array. | 2782 // array. |
| 2773 int new_slack = Max( | 2783 int new_slack = Max( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2796 Handle<Name> target_key(target_descriptors->GetKey(i), isolate); | 2806 Handle<Name> target_key(target_descriptors->GetKey(i), isolate); |
| 2797 PropertyDetails old_details = old_descriptors->GetDetails(i); | 2807 PropertyDetails old_details = old_descriptors->GetDetails(i); |
| 2798 PropertyDetails target_details = target_descriptors->GetDetails(i); | 2808 PropertyDetails target_details = target_descriptors->GetDetails(i); |
| 2799 target_details = target_details.CopyWithRepresentation( | 2809 target_details = target_details.CopyWithRepresentation( |
| 2800 old_details.representation().generalize( | 2810 old_details.representation().generalize( |
| 2801 target_details.representation())); | 2811 target_details.representation())); |
| 2802 if (modify_index == i) { | 2812 if (modify_index == i) { |
| 2803 target_details = target_details.CopyWithRepresentation( | 2813 target_details = target_details.CopyWithRepresentation( |
| 2804 new_representation.generalize(target_details.representation())); | 2814 new_representation.generalize(target_details.representation())); |
| 2805 } | 2815 } |
| 2816 ASSERT_EQ(old_details.attributes(), target_details.attributes()); |
| 2806 if (old_details.type() == FIELD || | 2817 if (old_details.type() == FIELD || |
| 2807 target_details.type() == FIELD || | 2818 target_details.type() == FIELD || |
| 2808 (modify_index == i && store_mode == FORCE_FIELD) || | 2819 (modify_index == i && store_mode == FORCE_FIELD) || |
| 2809 (target_descriptors->GetValue(i) != old_descriptors->GetValue(i))) { | 2820 (target_descriptors->GetValue(i) != old_descriptors->GetValue(i))) { |
| 2810 Handle<HeapType> old_field_type = (old_details.type() == FIELD) | 2821 Handle<HeapType> old_field_type = (old_details.type() == FIELD) |
| 2811 ? handle(old_descriptors->GetFieldType(i), isolate) | 2822 ? handle(old_descriptors->GetFieldType(i), isolate) |
| 2812 : old_descriptors->GetValue(i)->OptimalType( | 2823 : old_descriptors->GetValue(i)->OptimalType( |
| 2813 isolate, target_details.representation()); | 2824 isolate, target_details.representation()); |
| 2814 Handle<HeapType> target_field_type = (target_details.type() == FIELD) | 2825 Handle<HeapType> target_field_type = (target_details.type() == FIELD) |
| 2815 ? handle(target_descriptors->GetFieldType(i), isolate) | 2826 ? handle(target_descriptors->GetFieldType(i), isolate) |
| (...skipping 14374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17190 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17201 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 17191 static const char* error_messages_[] = { | 17202 static const char* error_messages_[] = { |
| 17192 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17203 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 17193 }; | 17204 }; |
| 17194 #undef ERROR_MESSAGES_TEXTS | 17205 #undef ERROR_MESSAGES_TEXTS |
| 17195 return error_messages_[reason]; | 17206 return error_messages_[reason]; |
| 17196 } | 17207 } |
| 17197 | 17208 |
| 17198 | 17209 |
| 17199 } } // namespace v8::internal | 17210 } } // namespace v8::internal |
| OLD | NEW |