Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: test/cctest/test-migrations.cc

Issue 1099473004: Reland "Refactor compilation dependency handling." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 expectations.SetDataField(detach_property_at_index, 584 expectations.SetDataField(detach_property_at_index,
585 Representation::Tagged(), any_type); 585 Representation::Tagged(), any_type);
586 CHECK(map->is_deprecated()); 586 CHECK(map->is_deprecated());
587 CHECK(expectations.Check(*detach_point_map, 587 CHECK(expectations.Check(*detach_point_map,
588 detach_point_map->NumberOfOwnDescriptors())); 588 detach_point_map->NumberOfOwnDescriptors()));
589 } 589 }
590 590
591 // Create new maps by generalizing representation of propX field. 591 // Create new maps by generalizing representation of propX field.
592 Handle<Map> field_owner(map->FindFieldOwner(property_index), isolate); 592 Handle<Map> field_owner(map->FindFieldOwner(property_index), isolate);
593 CompilationInfo info(&stub, isolate, &zone); 593 CompilationInfo info(&stub, isolate, &zone);
594 CHECK(!info.HasAbortedDueToDependencyChange()); 594 CHECK(!info.dependencies()->HasAborted());
595 595
596 Map::AddDependentCompilationInfo(field_owner, DependentCode::kFieldTypeGroup, 596 info.dependencies()->AssumeFieldType(field_owner);
597 &info);
598 597
599 Handle<Map> new_map = 598 Handle<Map> new_map =
600 Map::ReconfigureProperty(map, property_index, kData, NONE, 599 Map::ReconfigureProperty(map, property_index, kData, NONE,
601 to_representation, to_type, FORCE_FIELD); 600 to_representation, to_type, FORCE_FIELD);
602 601
603 expectations.SetDataField(property_index, expected_representation, 602 expectations.SetDataField(property_index, expected_representation,
604 expected_type); 603 expected_type);
605 604
606 CHECK(!new_map->is_deprecated()); 605 CHECK(!new_map->is_deprecated());
607 CHECK(expectations.Check(*new_map)); 606 CHECK(expectations.Check(*new_map));
608 607
609 if (is_detached_map) { 608 if (is_detached_map) {
610 CHECK(map->is_deprecated()); 609 CHECK(map->is_deprecated());
611 CHECK_NE(*map, *new_map); 610 CHECK_NE(*map, *new_map);
612 CHECK_EQ(expected_field_type_dependency && !field_owner->is_deprecated(), 611 CHECK_EQ(expected_field_type_dependency && !field_owner->is_deprecated(),
613 info.HasAbortedDueToDependencyChange()); 612 info.dependencies()->HasAborted());
614 613
615 } else if (expected_deprecation) { 614 } else if (expected_deprecation) {
616 CHECK(map->is_deprecated()); 615 CHECK(map->is_deprecated());
617 CHECK(field_owner->is_deprecated()); 616 CHECK(field_owner->is_deprecated());
618 CHECK_NE(*map, *new_map); 617 CHECK_NE(*map, *new_map);
619 CHECK(!info.HasAbortedDueToDependencyChange()); 618 CHECK(!info.dependencies()->HasAborted());
620 619
621 } else { 620 } else {
622 CHECK(!field_owner->is_deprecated()); 621 CHECK(!field_owner->is_deprecated());
623 CHECK_EQ(*map, *new_map); 622 CHECK_EQ(*map, *new_map);
624 623
625 CHECK_EQ(expected_field_type_dependency, 624 CHECK_EQ(expected_field_type_dependency, info.dependencies()->HasAborted());
626 info.HasAbortedDueToDependencyChange());
627 } 625 }
628 626
629 info.RollbackDependencies(); // Properly cleanup compilation info. 627 info.dependencies()->Rollback(); // Properly cleanup compilation info.
630 628
631 // Update all deprecated maps and check that they are now the same. 629 // Update all deprecated maps and check that they are now the same.
632 Handle<Map> updated_map = Map::Update(map); 630 Handle<Map> updated_map = Map::Update(map);
633 CHECK_EQ(*new_map, *updated_map); 631 CHECK_EQ(*new_map, *updated_map);
634 } 632 }
635 633
636 634
637 static void TestGeneralizeRepresentation( 635 static void TestGeneralizeRepresentation(
638 Representation from_representation, Handle<HeapType> from_type, 636 Representation from_representation, Handle<HeapType> from_type,
639 Representation to_representation, Handle<HeapType> to_type, 637 Representation to_representation, Handle<HeapType> to_type,
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 map2 = expectations2.AddDataField(map2, NONE, to_representation, to_type); 952 map2 = expectations2.AddDataField(map2, NONE, to_representation, to_type);
955 } 953 }
956 CHECK(!map2->is_deprecated()); 954 CHECK(!map2->is_deprecated());
957 CHECK(map2->is_stable()); 955 CHECK(map2->is_stable());
958 CHECK(expectations2.Check(*map2)); 956 CHECK(expectations2.Check(*map2));
959 957
960 Zone zone; 958 Zone zone;
961 FakeStubForTesting stub(isolate); 959 FakeStubForTesting stub(isolate);
962 Handle<Map> field_owner(map->FindFieldOwner(kSplitProp), isolate); 960 Handle<Map> field_owner(map->FindFieldOwner(kSplitProp), isolate);
963 CompilationInfo info(&stub, isolate, &zone); 961 CompilationInfo info(&stub, isolate, &zone);
964 CHECK(!info.HasAbortedDueToDependencyChange()); 962 CHECK(!info.dependencies()->HasAborted());
965 Map::AddDependentCompilationInfo(field_owner, DependentCode::kFieldTypeGroup, 963 info.dependencies()->AssumeFieldType(field_owner);
966 &info);
967 964
968 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which 965 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which
969 // should generalize representations in |map1|. 966 // should generalize representations in |map1|.
970 Handle<Map> new_map = 967 Handle<Map> new_map =
971 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); 968 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE);
972 969
973 // |map2| should be left unchanged. 970 // |map2| should be left unchanged.
974 CHECK(!map2->is_deprecated()); 971 CHECK(!map2->is_deprecated());
975 CHECK_NE(*map2, *new_map); 972 CHECK_NE(*map2, *new_map);
976 CHECK(expectations2.Check(*map2)); 973 CHECK(expectations2.Check(*map2));
977 974
978 // |map| should be deprecated and |new_map| should match new expectations. 975 // |map| should be deprecated and |new_map| should match new expectations.
979 for (int i = kSplitProp; i < kPropCount; i++) { 976 for (int i = kSplitProp; i < kPropCount; i++) {
980 expectations.SetDataField(i, expected_representation, expected_type); 977 expectations.SetDataField(i, expected_representation, expected_type);
981 } 978 }
982 CHECK(map->is_deprecated()); 979 CHECK(map->is_deprecated());
983 CHECK(!info.HasAbortedDueToDependencyChange()); 980 CHECK(!info.dependencies()->HasAborted());
984 info.RollbackDependencies(); // Properly cleanup compilation info. 981 info.dependencies()->Rollback(); // Properly cleanup compilation info.
985 CHECK_NE(*map, *new_map); 982 CHECK_NE(*map, *new_map);
986 983
987 CHECK(!new_map->is_deprecated()); 984 CHECK(!new_map->is_deprecated());
988 CHECK(expectations.Check(*new_map)); 985 CHECK(expectations.Check(*new_map));
989 986
990 // Update deprecated |map|, it should become |new_map|. 987 // Update deprecated |map|, it should become |new_map|.
991 Handle<Map> updated_map = Map::Update(map); 988 Handle<Map> updated_map = Map::Update(map);
992 CHECK_EQ(*new_map, *updated_map); 989 CHECK_EQ(*new_map, *updated_map);
993 } 990 }
994 991
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 map2 = expectations2.AddDataField(map2, NONE, to_representation, to_type); 1037 map2 = expectations2.AddDataField(map2, NONE, to_representation, to_type);
1041 } 1038 }
1042 CHECK(!map2->is_deprecated()); 1039 CHECK(!map2->is_deprecated());
1043 CHECK(map2->is_stable()); 1040 CHECK(map2->is_stable());
1044 CHECK(expectations2.Check(*map2)); 1041 CHECK(expectations2.Check(*map2));
1045 1042
1046 Zone zone; 1043 Zone zone;
1047 FakeStubForTesting stub(isolate); 1044 FakeStubForTesting stub(isolate);
1048 Handle<Map> field_owner(map->FindFieldOwner(kSplitProp), isolate); 1045 Handle<Map> field_owner(map->FindFieldOwner(kSplitProp), isolate);
1049 CompilationInfo info(&stub, isolate, &zone); 1046 CompilationInfo info(&stub, isolate, &zone);
1050 CHECK(!info.HasAbortedDueToDependencyChange()); 1047 CHECK(!info.dependencies()->HasAborted());
1051 Map::AddDependentCompilationInfo(field_owner, DependentCode::kFieldTypeGroup, 1048 info.dependencies()->AssumeFieldType(field_owner);
1052 &info);
1053 1049
1054 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which 1050 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which
1055 // should generalize representations in |map1|. 1051 // should generalize representations in |map1|.
1056 Handle<Map> new_map = 1052 Handle<Map> new_map =
1057 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); 1053 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE);
1058 1054
1059 // |map2| should be left unchanged. 1055 // |map2| should be left unchanged.
1060 CHECK(!map2->is_deprecated()); 1056 CHECK(!map2->is_deprecated());
1061 CHECK_NE(*map2, *new_map); 1057 CHECK_NE(*map2, *new_map);
1062 CHECK(expectations2.Check(*map2)); 1058 CHECK(expectations2.Check(*map2));
1063 1059
1064 // In trivial case |map| should be returned as a result of the property 1060 // In trivial case |map| should be returned as a result of the property
1065 // reconfiguration, respective field types should be generalized and 1061 // reconfiguration, respective field types should be generalized and
1066 // respective code dependencies should be invalidated. |map| should be NOT 1062 // respective code dependencies should be invalidated. |map| should be NOT
1067 // deprecated and it should match new expectations. 1063 // deprecated and it should match new expectations.
1068 for (int i = kSplitProp; i < kPropCount; i++) { 1064 for (int i = kSplitProp; i < kPropCount; i++) {
1069 expectations.SetDataField(i, expected_representation, expected_type); 1065 expectations.SetDataField(i, expected_representation, expected_type);
1070 } 1066 }
1071 CHECK(!map->is_deprecated()); 1067 CHECK(!map->is_deprecated());
1072 CHECK_EQ(*map, *new_map); 1068 CHECK_EQ(*map, *new_map);
1073 CHECK_EQ(expected_field_type_dependency, 1069 CHECK_EQ(expected_field_type_dependency, info.dependencies()->HasAborted());
1074 info.HasAbortedDueToDependencyChange()); 1070 info.dependencies()->Rollback(); // Properly cleanup compilation info.
1075 info.RollbackDependencies(); // Properly cleanup compilation info.
1076 1071
1077 CHECK(!new_map->is_deprecated()); 1072 CHECK(!new_map->is_deprecated());
1078 CHECK(expectations.Check(*new_map)); 1073 CHECK(expectations.Check(*new_map));
1079 1074
1080 Handle<Map> updated_map = Map::Update(map); 1075 Handle<Map> updated_map = Map::Update(map);
1081 CHECK_EQ(*new_map, *updated_map); 1076 CHECK_EQ(*new_map, *updated_map);
1082 } 1077 }
1083 1078
1084 1079
1085 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) { 1080 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) {
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 Handle<AccessorPair> pair = CreateAccessorPair(true, true); 2074 Handle<AccessorPair> pair = CreateAccessorPair(true, true);
2080 TransitionToAccessorConstantOperator transition_op(pair); 2075 TransitionToAccessorConstantOperator transition_op(pair);
2081 2076
2082 SameMapChecker checker; 2077 SameMapChecker checker;
2083 TestTransitionTo(transition_op, transition_op, checker); 2078 TestTransitionTo(transition_op, transition_op, checker);
2084 } 2079 }
2085 2080
2086 2081
2087 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. 2082 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported.
2088 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) 2083 // TEST(TransitionAccessorConstantToAnotherAccessorConstant)
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698