| OLD | NEW |
| 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 Handle<Map> initial_map = Map::Create(isolate, 0); | 430 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 431 Handle<Map> map = initial_map; | 431 Handle<Map> map = initial_map; |
| 432 map = expectations.AddAccessorConstant(map, NONE, pair); | 432 map = expectations.AddAccessorConstant(map, NONE, pair); |
| 433 | 433 |
| 434 CHECK(!map->is_deprecated()); | 434 CHECK(!map->is_deprecated()); |
| 435 CHECK(map->is_stable()); | 435 CHECK(map->is_stable()); |
| 436 CHECK(expectations.Check(*map)); | 436 CHECK(expectations.Check(*map)); |
| 437 | 437 |
| 438 Handle<Map> new_map = Map::ReconfigureProperty( | 438 Handle<Map> new_map = Map::ReconfigureProperty( |
| 439 map, 0, kData, NONE, Representation::None(), none_type, FORCE_FIELD); | 439 map, 0, kData, NONE, Representation::None(), none_type, FORCE_FIELD); |
| 440 // |map| did not change. | 440 // |map| did not change except marked unstable. |
| 441 CHECK(!map->is_deprecated()); | 441 CHECK(!map->is_deprecated()); |
| 442 CHECK(map->is_stable()); | 442 CHECK(!map->is_stable()); |
| 443 CHECK(expectations.Check(*map)); | 443 CHECK(expectations.Check(*map)); |
| 444 | 444 |
| 445 expectations.SetDataField(0, NONE, Representation::None(), none_type); | 445 expectations.SetDataField(0, NONE, Representation::None(), none_type); |
| 446 | 446 |
| 447 CHECK(!new_map->is_deprecated()); | 447 CHECK(!new_map->is_deprecated()); |
| 448 CHECK(new_map->is_stable()); | 448 CHECK(new_map->is_stable()); |
| 449 CHECK(expectations.Check(*new_map)); | 449 CHECK(expectations.Check(*new_map)); |
| 450 | 450 |
| 451 Handle<Map> new_map2 = Map::ReconfigureProperty( | 451 Handle<Map> new_map2 = Map::ReconfigureProperty( |
| 452 map, 0, kData, NONE, Representation::None(), none_type, FORCE_FIELD); | 452 map, 0, kData, NONE, Representation::None(), none_type, FORCE_FIELD); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 Map::ReconfigureProperty(map, property_index, kData, NONE, | 595 Map::ReconfigureProperty(map, property_index, kData, NONE, |
| 596 to_representation, to_type, FORCE_FIELD); | 596 to_representation, to_type, FORCE_FIELD); |
| 597 | 597 |
| 598 expectations.SetDataField(property_index, expected_representation, | 598 expectations.SetDataField(property_index, expected_representation, |
| 599 expected_type); | 599 expected_type); |
| 600 | 600 |
| 601 CHECK(!new_map->is_deprecated()); | 601 CHECK(!new_map->is_deprecated()); |
| 602 CHECK(expectations.Check(*new_map)); | 602 CHECK(expectations.Check(*new_map)); |
| 603 | 603 |
| 604 if (is_detached_map) { | 604 if (is_detached_map) { |
| 605 CHECK(!map->is_stable()); |
| 605 CHECK(map->is_deprecated()); | 606 CHECK(map->is_deprecated()); |
| 606 CHECK_NE(*map, *new_map); | 607 CHECK_NE(*map, *new_map); |
| 607 CHECK_EQ(expected_field_type_dependency && !field_owner->is_deprecated(), | 608 CHECK_EQ(expected_field_type_dependency && !field_owner->is_deprecated(), |
| 608 info.HasAbortedDueToDependencyChange()); | 609 info.HasAbortedDueToDependencyChange()); |
| 609 | 610 |
| 610 } else if (expected_deprecation) { | 611 } else if (expected_deprecation) { |
| 612 CHECK(!map->is_stable()); |
| 611 CHECK(map->is_deprecated()); | 613 CHECK(map->is_deprecated()); |
| 612 CHECK(field_owner->is_deprecated()); | 614 CHECK(field_owner->is_deprecated()); |
| 613 CHECK_NE(*map, *new_map); | 615 CHECK_NE(*map, *new_map); |
| 614 CHECK(!info.HasAbortedDueToDependencyChange()); | 616 CHECK(!info.HasAbortedDueToDependencyChange()); |
| 615 | 617 |
| 616 } else { | 618 } else { |
| 617 CHECK(!field_owner->is_deprecated()); | 619 CHECK(!field_owner->is_deprecated()); |
| 620 CHECK(map->is_stable()); // Map did not change, must be left stable. |
| 618 CHECK_EQ(*map, *new_map); | 621 CHECK_EQ(*map, *new_map); |
| 619 | 622 |
| 620 CHECK_EQ(expected_field_type_dependency, | 623 CHECK_EQ(expected_field_type_dependency, |
| 621 info.HasAbortedDueToDependencyChange()); | 624 info.HasAbortedDueToDependencyChange()); |
| 622 } | 625 } |
| 623 | 626 |
| 624 info.RollbackDependencies(); // Properly cleanup compilation info. | 627 info.RollbackDependencies(); // Properly cleanup compilation info. |
| 625 | 628 |
| 626 // 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. |
| 627 Handle<Map> updated_map = Map::Update(map); | 630 Handle<Map> updated_map = Map::Update(map); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 649 // Check the cases when the map being reconfigured is NOT a part of the | 652 // Check the cases when the map being reconfigured is NOT a part of the |
| 650 // transition tree. "None -> anything" representation changes make sense | 653 // transition tree. "None -> anything" representation changes make sense |
| 651 // only for "attached" maps. | 654 // only for "attached" maps. |
| 652 int indices[] = {0, kPropCount - 1}; | 655 int indices[] = {0, kPropCount - 1}; |
| 653 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { | 656 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { |
| 654 TestGeneralizeRepresentation( | 657 TestGeneralizeRepresentation( |
| 655 indices[i], 2, from_representation, from_type, to_representation, | 658 indices[i], 2, from_representation, from_type, to_representation, |
| 656 to_type, expected_representation, expected_type, expected_deprecation, | 659 to_type, expected_representation, expected_type, expected_deprecation, |
| 657 expected_field_type_dependency); | 660 expected_field_type_dependency); |
| 658 } | 661 } |
| 662 |
| 663 // Check that reconfiguration to the very same field works correctly. |
| 664 Representation representation = from_representation; |
| 665 Handle<HeapType> type = from_type; |
| 666 TestGeneralizeRepresentation(-1, 2, representation, type, representation, |
| 667 type, representation, type, false, false); |
| 659 } | 668 } |
| 660 } | 669 } |
| 661 | 670 |
| 662 | 671 |
| 663 static void TestGeneralizeRepresentation(Representation from_representation, | 672 static void TestGeneralizeRepresentation(Representation from_representation, |
| 664 Handle<HeapType> from_type, | 673 Handle<HeapType> from_type, |
| 665 Representation to_representation, | 674 Representation to_representation, |
| 666 Handle<HeapType> to_type, | 675 Handle<HeapType> to_type, |
| 667 Representation expected_representation, | 676 Representation expected_representation, |
| 668 Handle<HeapType> expected_type) { | 677 Handle<HeapType> expected_type) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 // Skip accessor property reconfiguration. | 881 // Skip accessor property reconfiguration. |
| 873 maps[i] = maps[i - 1]; | 882 maps[i] = maps[i - 1]; |
| 874 continue; | 883 continue; |
| 875 } | 884 } |
| 876 Handle<Map> new_map = Map::ReconfigureProperty( | 885 Handle<Map> new_map = Map::ReconfigureProperty( |
| 877 map, i, kData, NONE, Representation::Double(), any_type, FORCE_FIELD); | 886 map, i, kData, NONE, Representation::Double(), any_type, FORCE_FIELD); |
| 878 maps[i] = new_map; | 887 maps[i] = new_map; |
| 879 | 888 |
| 880 expectations.SetDataField(i, Representation::Double(), any_type); | 889 expectations.SetDataField(i, Representation::Double(), any_type); |
| 881 | 890 |
| 891 CHECK(!map->is_stable()); |
| 882 CHECK(map->is_deprecated()); | 892 CHECK(map->is_deprecated()); |
| 883 CHECK_NE(*map, *new_map); | 893 CHECK_NE(*map, *new_map); |
| 884 CHECK(i == 0 || maps[i - 1]->is_deprecated()); | 894 CHECK(i == 0 || maps[i - 1]->is_deprecated()); |
| 885 | 895 |
| 886 CHECK(!new_map->is_deprecated()); | 896 CHECK(!new_map->is_deprecated()); |
| 887 CHECK(expectations.Check(*new_map)); | 897 CHECK(expectations.Check(*new_map)); |
| 888 } | 898 } |
| 889 | 899 |
| 890 Handle<Map> active_map = maps[kPropCount - 1]; | 900 Handle<Map> active_map = maps[kPropCount - 1]; |
| 891 CHECK(!active_map->is_deprecated()); | 901 CHECK(!active_map->is_deprecated()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 CompilationInfo info(&stub, isolate, &zone); | 968 CompilationInfo info(&stub, isolate, &zone); |
| 959 CHECK(!info.HasAbortedDueToDependencyChange()); | 969 CHECK(!info.HasAbortedDueToDependencyChange()); |
| 960 Map::AddDependentCompilationInfo(field_owner, DependentCode::kFieldTypeGroup, | 970 Map::AddDependentCompilationInfo(field_owner, DependentCode::kFieldTypeGroup, |
| 961 &info); | 971 &info); |
| 962 | 972 |
| 963 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which | 973 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which |
| 964 // should generalize representations in |map1|. | 974 // should generalize representations in |map1|. |
| 965 Handle<Map> new_map = | 975 Handle<Map> new_map = |
| 966 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); | 976 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); |
| 967 | 977 |
| 968 // |map2| should be left unchanged. | 978 // |map2| should be left unchanged but marked unstable. |
| 979 CHECK(!map2->is_stable()); |
| 969 CHECK(!map2->is_deprecated()); | 980 CHECK(!map2->is_deprecated()); |
| 970 CHECK_NE(*map2, *new_map); | 981 CHECK_NE(*map2, *new_map); |
| 971 CHECK(expectations2.Check(*map2)); | 982 CHECK(expectations2.Check(*map2)); |
| 972 | 983 |
| 973 // |map| should be deprecated and |new_map| should match new expectations. | 984 // |map| should be deprecated and |new_map| should match new expectations. |
| 974 for (int i = kSplitProp; i < kPropCount; i++) { | 985 for (int i = kSplitProp; i < kPropCount; i++) { |
| 975 expectations.SetDataField(i, expected_representation, expected_type); | 986 expectations.SetDataField(i, expected_representation, expected_type); |
| 976 } | 987 } |
| 977 CHECK(map->is_deprecated()); | 988 CHECK(map->is_deprecated()); |
| 978 CHECK(!info.HasAbortedDueToDependencyChange()); | 989 CHECK(!info.HasAbortedDueToDependencyChange()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 CompilationInfo info(&stub, isolate, &zone); | 1055 CompilationInfo info(&stub, isolate, &zone); |
| 1045 CHECK(!info.HasAbortedDueToDependencyChange()); | 1056 CHECK(!info.HasAbortedDueToDependencyChange()); |
| 1046 Map::AddDependentCompilationInfo(field_owner, DependentCode::kFieldTypeGroup, | 1057 Map::AddDependentCompilationInfo(field_owner, DependentCode::kFieldTypeGroup, |
| 1047 &info); | 1058 &info); |
| 1048 | 1059 |
| 1049 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which | 1060 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which |
| 1050 // should generalize representations in |map1|. | 1061 // should generalize representations in |map1|. |
| 1051 Handle<Map> new_map = | 1062 Handle<Map> new_map = |
| 1052 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); | 1063 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); |
| 1053 | 1064 |
| 1054 // |map2| should be left unchanged. | 1065 // |map2| should be left unchanged but marked unstable. |
| 1066 CHECK(!map2->is_stable()); |
| 1055 CHECK(!map2->is_deprecated()); | 1067 CHECK(!map2->is_deprecated()); |
| 1056 CHECK_NE(*map2, *new_map); | 1068 CHECK_NE(*map2, *new_map); |
| 1057 CHECK(expectations2.Check(*map2)); | 1069 CHECK(expectations2.Check(*map2)); |
| 1058 | 1070 |
| 1059 // In trivial case |map| should be returned as a result of the property | 1071 // In trivial case |map| should be returned as a result of the property |
| 1060 // reconfiguration, respective field types should be generalized and | 1072 // reconfiguration, respective field types should be generalized and |
| 1061 // respective code dependencies should be invalidated. |map| should be NOT | 1073 // respective code dependencies should be invalidated. |map| should be NOT |
| 1062 // deprecated and it should match new expectations. | 1074 // deprecated and it should match new expectations. |
| 1063 for (int i = kSplitProp; i < kPropCount; i++) { | 1075 for (int i = kSplitProp; i < kPropCount; i++) { |
| 1064 expectations.SetDataField(i, expected_representation, expected_type); | 1076 expectations.SetDataField(i, expected_representation, expected_type); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 CHECK_EQ(*new_map, *updated_map); | 1193 CHECK_EQ(*new_map, *updated_map); |
| 1182 } | 1194 } |
| 1183 }; | 1195 }; |
| 1184 | 1196 |
| 1185 | 1197 |
| 1186 // Checks that given |map| is NOT deprecated, equals to given |new_map| and | 1198 // Checks that given |map| is NOT deprecated, equals to given |new_map| and |
| 1187 // matches expectations. | 1199 // matches expectations. |
| 1188 struct CheckSameMap { | 1200 struct CheckSameMap { |
| 1189 void Check(Handle<Map> map, Handle<Map> new_map, | 1201 void Check(Handle<Map> map, Handle<Map> new_map, |
| 1190 const Expectations& expectations) { | 1202 const Expectations& expectations) { |
| 1203 // |map| was not reconfigured, therefore it should stay stable. |
| 1204 CHECK(map->is_stable()); |
| 1191 CHECK(!map->is_deprecated()); | 1205 CHECK(!map->is_deprecated()); |
| 1192 CHECK_EQ(*map, *new_map); | 1206 CHECK_EQ(*map, *new_map); |
| 1193 | 1207 |
| 1194 CHECK(!new_map->is_deprecated()); | 1208 CHECK(!new_map->is_deprecated()); |
| 1195 CHECK(expectations.Check(*new_map)); | 1209 CHECK(expectations.Check(*new_map)); |
| 1196 | 1210 |
| 1197 // Update deprecated |map|, it should become |new_map|. | 1211 // Update deprecated |map|, it should become |new_map|. |
| 1198 Handle<Map> updated_map = Map::Update(map); | 1212 Handle<Map> updated_map = Map::Update(map); |
| 1199 CHECK_EQ(*new_map, *updated_map); | 1213 CHECK_EQ(*new_map, *updated_map); |
| 1200 } | 1214 } |
| 1201 }; | 1215 }; |
| 1202 | 1216 |
| 1203 | 1217 |
| 1218 // Checks that given |map| is NOT deprecated and matches expectations. |
| 1219 // |new_map| is unrelated to |map|. |
| 1220 struct CheckUnrelated { |
| 1221 void Check(Handle<Map> map, Handle<Map> new_map, |
| 1222 const Expectations& expectations) { |
| 1223 CHECK(!map->is_deprecated()); |
| 1224 CHECK_NE(*map, *new_map); |
| 1225 CHECK(expectations.Check(*map)); |
| 1226 |
| 1227 CHECK(new_map->is_stable()); |
| 1228 CHECK(!new_map->is_deprecated()); |
| 1229 } |
| 1230 }; |
| 1231 |
| 1232 |
| 1204 // Checks that given |map| is NOT deprecated, and |new_map| is a result of | 1233 // Checks that given |map| is NOT deprecated, and |new_map| is a result of |
| 1205 // copy-generalize-all-representations. | 1234 // copy-generalize-all-representations. |
| 1206 struct CheckCopyGeneralizeAllRepresentations { | 1235 struct CheckCopyGeneralizeAllRepresentations { |
| 1207 void Check(Handle<Map> map, Handle<Map> new_map, Expectations& expectations) { | 1236 void Check(Handle<Map> map, Handle<Map> new_map, Expectations& expectations) { |
| 1208 CHECK(!map->is_deprecated()); | 1237 CHECK(!map->is_deprecated()); |
| 1209 CHECK_NE(*map, *new_map); | 1238 CHECK_NE(*map, *new_map); |
| 1210 | 1239 |
| 1211 CHECK(new_map->GetBackPointer()->IsUndefined()); | 1240 CHECK(new_map->GetBackPointer()->IsUndefined()); |
| 1212 for (int i = 0; i < kPropCount; i++) { | 1241 for (int i = 0; i < kPropCount; i++) { |
| 1213 expectations.GeneralizeRepresentation(i); | 1242 expectations.GeneralizeRepresentation(i); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 CHECK(!map2->is_deprecated()); | 1316 CHECK(!map2->is_deprecated()); |
| 1288 CHECK(map2->is_stable()); | 1317 CHECK(map2->is_stable()); |
| 1289 CHECK(expectations2.Check(*map2)); | 1318 CHECK(expectations2.Check(*map2)); |
| 1290 | 1319 |
| 1291 | 1320 |
| 1292 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which | 1321 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which |
| 1293 // should generalize representations in |map1|. | 1322 // should generalize representations in |map1|. |
| 1294 Handle<Map> new_map = | 1323 Handle<Map> new_map = |
| 1295 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); | 1324 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); |
| 1296 | 1325 |
| 1297 // |map2| should be left unchanged. | 1326 // |map2| should be left unchanged but marked unstable. |
| 1327 CHECK(!map2->is_stable()); |
| 1298 CHECK(!map2->is_deprecated()); | 1328 CHECK(!map2->is_deprecated()); |
| 1299 CHECK_NE(*map2, *new_map); | 1329 CHECK_NE(*map2, *new_map); |
| 1300 CHECK(expectations2.Check(*map2)); | 1330 CHECK(expectations2.Check(*map2)); |
| 1301 | 1331 |
| 1302 config.UpdateExpectations(kCustomPropIndex, expectations1); | 1332 config.UpdateExpectations(kCustomPropIndex, expectations1); |
| 1303 checker.Check(map1, new_map, expectations1); | 1333 checker.Check(map1, new_map, expectations1); |
| 1304 } | 1334 } |
| 1305 | 1335 |
| 1306 | 1336 |
| 1307 TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { | 1337 TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 } | 1394 } |
| 1365 }; | 1395 }; |
| 1366 | 1396 |
| 1367 TestConfig config; | 1397 TestConfig config; |
| 1368 // Two branches are "incompatible" so the |map1| should be deprecated. | 1398 // Two branches are "incompatible" so the |map1| should be deprecated. |
| 1369 CheckDeprecated checker; | 1399 CheckDeprecated checker; |
| 1370 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1400 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1371 } | 1401 } |
| 1372 | 1402 |
| 1373 | 1403 |
| 1404 TEST(ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) { |
| 1405 CcTest::InitializeVM(); |
| 1406 v8::HandleScope scope(CcTest::isolate()); |
| 1407 |
| 1408 struct TestConfig { |
| 1409 Handle<JSFunction> js_func_; |
| 1410 Handle<AccessorPair> pair_; |
| 1411 TestConfig() { |
| 1412 Isolate* isolate = CcTest::i_isolate(); |
| 1413 Factory* factory = isolate->factory(); |
| 1414 js_func_ = factory->NewFunction(factory->empty_string()); |
| 1415 pair_ = CreateAccessorPair(true, true); |
| 1416 } |
| 1417 |
| 1418 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
| 1419 Handle<Map> map) { |
| 1420 CHECK(branch_id == 1 || branch_id == 2); |
| 1421 if (branch_id == 1) { |
| 1422 return expectations.AddDataConstant(map, NONE, js_func_); |
| 1423 } else { |
| 1424 return expectations.AddAccessorConstant(map, NONE, pair_); |
| 1425 } |
| 1426 } |
| 1427 |
| 1428 void UpdateExpectations(int property_index, Expectations& expectations) {} |
| 1429 }; |
| 1430 |
| 1431 TestConfig config; |
| 1432 // These are completely separate branches in transition tree. |
| 1433 CheckUnrelated checker; |
| 1434 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1435 } |
| 1436 |
| 1437 |
| 1374 TEST(ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) { | 1438 TEST(ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) { |
| 1375 CcTest::InitializeVM(); | 1439 CcTest::InitializeVM(); |
| 1376 v8::HandleScope scope(CcTest::isolate()); | 1440 v8::HandleScope scope(CcTest::isolate()); |
| 1377 | 1441 |
| 1378 struct TestConfig { | 1442 struct TestConfig { |
| 1379 Handle<AccessorPair> pair_; | 1443 Handle<AccessorPair> pair_; |
| 1380 TestConfig() { pair_ = CreateAccessorPair(true, true); } | 1444 TestConfig() { pair_ = CreateAccessorPair(true, true); } |
| 1381 | 1445 |
| 1382 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, | 1446 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
| 1383 Handle<Map> map) { | 1447 Handle<Map> map) { |
| 1384 CHECK(branch_id == 1 || branch_id == 2); | 1448 CHECK(branch_id == 1 || branch_id == 2); |
| 1385 // Add the same accessor constant property at both transition tree | 1449 // Add the same accessor constant property at both transition tree |
| 1386 // branches. | 1450 // branches. |
| 1387 return expectations.AddAccessorConstant(map, NONE, pair_); | 1451 return expectations.AddAccessorConstant(map, NONE, pair_); |
| 1388 } | 1452 } |
| 1389 | 1453 |
| 1390 bool UpdateExpectations(int property_index, Expectations& expectations) { | 1454 void UpdateExpectations(int property_index, Expectations& expectations) { |
| 1391 // Two branches are "compatible" so the |map1| should NOT be deprecated. | 1455 // Two branches are "compatible" so the |map1| should NOT be deprecated. |
| 1392 return false; | |
| 1393 } | 1456 } |
| 1394 }; | 1457 }; |
| 1395 | 1458 |
| 1396 TestConfig config; | 1459 TestConfig config; |
| 1397 CheckSameMap checker; | 1460 CheckSameMap checker; |
| 1398 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1461 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1399 } | 1462 } |
| 1400 | 1463 |
| 1401 | 1464 |
| 1402 TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) { | 1465 TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1434 CheckCopyGeneralizeAllRepresentations checker; | 1497 CheckCopyGeneralizeAllRepresentations checker; |
| 1435 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1498 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1436 } else { | 1499 } else { |
| 1437 // Currently we have a copy-generalize-all-representations case. | 1500 // Currently we have a copy-generalize-all-representations case. |
| 1438 CheckCopyGeneralizeAllRepresentations checker; | 1501 CheckCopyGeneralizeAllRepresentations checker; |
| 1439 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1502 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1440 } | 1503 } |
| 1441 } | 1504 } |
| 1442 | 1505 |
| 1443 | 1506 |
| 1507 TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { |
| 1508 CcTest::InitializeVM(); |
| 1509 v8::HandleScope scope(CcTest::isolate()); |
| 1510 |
| 1511 struct TestConfig { |
| 1512 Handle<AccessorPair> pair_; |
| 1513 TestConfig() { pair_ = CreateAccessorPair(true, true); } |
| 1514 |
| 1515 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
| 1516 Handle<Map> map) { |
| 1517 CHECK(branch_id == 1 || branch_id == 2); |
| 1518 if (branch_id == 1) { |
| 1519 return expectations.AddAccessorConstant(map, NONE, pair_); |
| 1520 } else { |
| 1521 Isolate* isolate = CcTest::i_isolate(); |
| 1522 Handle<HeapType> any_type = HeapType::Any(isolate); |
| 1523 return expectations.AddDataField(map, NONE, Representation::Smi(), |
| 1524 any_type); |
| 1525 } |
| 1526 } |
| 1527 |
| 1528 void UpdateExpectations(int property_index, Expectations& expectations) {} |
| 1529 }; |
| 1530 |
| 1531 TestConfig config; |
| 1532 // These are completely separate branches in transition tree. |
| 1533 CheckUnrelated checker; |
| 1534 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1535 } |
| 1536 |
| 1537 |
| 1444 //////////////////////////////////////////////////////////////////////////////// | 1538 //////////////////////////////////////////////////////////////////////////////// |
| 1445 // A set of tests checking split map deprecation. | 1539 // A set of tests checking split map deprecation. |
| 1446 // | 1540 // |
| 1447 | 1541 |
| 1448 TEST(ReconfigurePropertySplitMapTransitionsOverflow) { | 1542 TEST(ReconfigurePropertySplitMapTransitionsOverflow) { |
| 1449 CcTest::InitializeVM(); | 1543 CcTest::InitializeVM(); |
| 1450 v8::HandleScope scope(CcTest::isolate()); | 1544 v8::HandleScope scope(CcTest::isolate()); |
| 1451 Isolate* isolate = CcTest::i_isolate(); | 1545 Isolate* isolate = CcTest::i_isolate(); |
| 1452 Handle<HeapType> any_type = HeapType::Any(isolate); | 1546 Handle<HeapType> any_type = HeapType::Any(isolate); |
| 1453 | 1547 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 expectations.SetDataField(kSplitProp, Representation::Double(), any_type); | 1579 expectations.SetDataField(kSplitProp, Representation::Double(), any_type); |
| 1486 | 1580 |
| 1487 CHECK(expectations.Check(*split_map, kSplitProp)); | 1581 CHECK(expectations.Check(*split_map, kSplitProp)); |
| 1488 CHECK(expectations.Check(*map2, kSplitProp + 1)); | 1582 CHECK(expectations.Check(*map2, kSplitProp + 1)); |
| 1489 } | 1583 } |
| 1490 | 1584 |
| 1491 // At this point |map| should be deprecated and disconnected from the | 1585 // At this point |map| should be deprecated and disconnected from the |
| 1492 // transition tree. | 1586 // transition tree. |
| 1493 CHECK(map->is_deprecated()); | 1587 CHECK(map->is_deprecated()); |
| 1494 CHECK(!split_map->is_deprecated()); | 1588 CHECK(!split_map->is_deprecated()); |
| 1589 CHECK(map2->is_stable()); |
| 1495 CHECK(!map2->is_deprecated()); | 1590 CHECK(!map2->is_deprecated()); |
| 1496 | 1591 |
| 1497 // Fill in transition tree of |map2| so that it can't have more transitions. | 1592 // Fill in transition tree of |map2| so that it can't have more transitions. |
| 1498 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { | 1593 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { |
| 1499 CHECK(TransitionArray::CanHaveMoreTransitions(map2)); | 1594 CHECK(TransitionArray::CanHaveMoreTransitions(map2)); |
| 1500 Handle<String> name = MakeName("foo", i); | 1595 Handle<String> name = MakeName("foo", i); |
| 1501 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), | 1596 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), |
| 1502 INSERT_TRANSITION).ToHandleChecked(); | 1597 INSERT_TRANSITION).ToHandleChecked(); |
| 1503 } | 1598 } |
| 1504 CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); | 1599 CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 heap_type_(heap_type) {} | 2025 heap_type_(heap_type) {} |
| 1931 | 2026 |
| 1932 void Check(Expectations& expectations2, Handle<Map> map1, Handle<Map> map2) { | 2027 void Check(Expectations& expectations2, Handle<Map> map1, Handle<Map> map2) { |
| 1933 CHECK(!map2->is_deprecated()); | 2028 CHECK(!map2->is_deprecated()); |
| 1934 | 2029 |
| 1935 CHECK(map1->is_deprecated()); | 2030 CHECK(map1->is_deprecated()); |
| 1936 CHECK_NE(*map1, *map2); | 2031 CHECK_NE(*map1, *map2); |
| 1937 Handle<Map> updated_map = Map::Update(map1); | 2032 Handle<Map> updated_map = Map::Update(map1); |
| 1938 CHECK_EQ(*map2, *updated_map); | 2033 CHECK_EQ(*map2, *updated_map); |
| 1939 | 2034 |
| 1940 expectations2.SetDataField(descriptor_, representation_, heap_type_); | 2035 expectations2.SetDataField(descriptor_, attributes_, representation_, |
| 2036 heap_type_); |
| 1941 CHECK(expectations2.Check(*map2)); | 2037 CHECK(expectations2.Check(*map2)); |
| 1942 } | 2038 } |
| 1943 }; | 2039 }; |
| 1944 | 2040 |
| 1945 | 2041 |
| 1946 // Checks that existing transition was taken as is. | 2042 // Checks that existing transition was taken as is. |
| 1947 struct SameMapChecker { | 2043 struct SameMapChecker { |
| 1948 void Check(Expectations& expectations, Handle<Map> map1, Handle<Map> map2) { | 2044 void Check(Expectations& expectations, Handle<Map> map1, Handle<Map> map2) { |
| 1949 CHECK(!map2->is_deprecated()); | 2045 CHECK(!map2->is_deprecated()); |
| 1950 CHECK_EQ(*map1, *map2); | 2046 CHECK_EQ(*map1, *map2); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 Handle<AccessorPair> pair = CreateAccessorPair(true, true); | 2184 Handle<AccessorPair> pair = CreateAccessorPair(true, true); |
| 2089 TransitionToAccessorConstantOperator transition_op(pair); | 2185 TransitionToAccessorConstantOperator transition_op(pair); |
| 2090 | 2186 |
| 2091 SameMapChecker checker; | 2187 SameMapChecker checker; |
| 2092 TestTransitionTo(transition_op, transition_op, checker); | 2188 TestTransitionTo(transition_op, transition_op, checker); |
| 2093 } | 2189 } |
| 2094 | 2190 |
| 2095 | 2191 |
| 2096 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. | 2192 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. |
| 2097 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) | 2193 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) |
| OLD | NEW |