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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 Map::ReconfigureProperty(map, property_index, kData, NONE, | 593 Map::ReconfigureProperty(map, property_index, kData, NONE, |
594 to_representation, to_type, FORCE_FIELD); | 594 to_representation, to_type, FORCE_FIELD); |
595 | 595 |
596 expectations.SetDataField(property_index, expected_representation, | 596 expectations.SetDataField(property_index, expected_representation, |
597 expected_type); | 597 expected_type); |
598 | 598 |
599 CHECK(!new_map->is_deprecated()); | 599 CHECK(!new_map->is_deprecated()); |
600 CHECK(expectations.Check(*new_map)); | 600 CHECK(expectations.Check(*new_map)); |
601 | 601 |
602 if (is_detached_map) { | 602 if (is_detached_map) { |
| 603 CHECK(!map->is_stable()); |
603 CHECK(map->is_deprecated()); | 604 CHECK(map->is_deprecated()); |
604 CHECK_NE(*map, *new_map); | 605 CHECK_NE(*map, *new_map); |
605 CHECK_EQ(expected_field_type_dependency && !field_owner->is_deprecated(), | 606 CHECK_EQ(expected_field_type_dependency && !field_owner->is_deprecated(), |
606 info.dependencies()->HasAborted()); | 607 info.dependencies()->HasAborted()); |
607 | 608 |
608 } else if (expected_deprecation) { | 609 } else if (expected_deprecation) { |
| 610 CHECK(!map->is_stable()); |
609 CHECK(map->is_deprecated()); | 611 CHECK(map->is_deprecated()); |
610 CHECK(field_owner->is_deprecated()); | 612 CHECK(field_owner->is_deprecated()); |
611 CHECK_NE(*map, *new_map); | 613 CHECK_NE(*map, *new_map); |
612 CHECK(!info.dependencies()->HasAborted()); | 614 CHECK(!info.dependencies()->HasAborted()); |
613 | 615 |
614 } else { | 616 } else { |
615 CHECK(!field_owner->is_deprecated()); | 617 CHECK(!field_owner->is_deprecated()); |
| 618 CHECK(map->is_stable()); // Map did not change, must be left stable. |
616 CHECK_EQ(*map, *new_map); | 619 CHECK_EQ(*map, *new_map); |
617 | 620 |
618 CHECK_EQ(expected_field_type_dependency, info.dependencies()->HasAborted()); | 621 CHECK_EQ(expected_field_type_dependency, info.dependencies()->HasAborted()); |
619 } | 622 } |
620 | 623 |
621 info.dependencies()->Rollback(); // Properly cleanup compilation info. | 624 info.dependencies()->Rollback(); // Properly cleanup compilation info. |
622 | 625 |
623 // Update all deprecated maps and check that they are now the same. | 626 // Update all deprecated maps and check that they are now the same. |
624 Handle<Map> updated_map = Map::Update(map); | 627 Handle<Map> updated_map = Map::Update(map); |
625 CHECK_EQ(*new_map, *updated_map); | 628 CHECK_EQ(*new_map, *updated_map); |
(...skipping 20 matching lines...) Expand all Loading... |
646 // Check the cases when the map being reconfigured is NOT a part of the | 649 // Check the cases when the map being reconfigured is NOT a part of the |
647 // transition tree. "None -> anything" representation changes make sense | 650 // transition tree. "None -> anything" representation changes make sense |
648 // only for "attached" maps. | 651 // only for "attached" maps. |
649 int indices[] = {0, kPropCount - 1}; | 652 int indices[] = {0, kPropCount - 1}; |
650 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { | 653 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { |
651 TestGeneralizeRepresentation( | 654 TestGeneralizeRepresentation( |
652 indices[i], 2, from_representation, from_type, to_representation, | 655 indices[i], 2, from_representation, from_type, to_representation, |
653 to_type, expected_representation, expected_type, expected_deprecation, | 656 to_type, expected_representation, expected_type, expected_deprecation, |
654 expected_field_type_dependency); | 657 expected_field_type_dependency); |
655 } | 658 } |
| 659 |
| 660 // Check that reconfiguration to the very same field works correctly. |
| 661 Representation representation = from_representation; |
| 662 Handle<HeapType> type = from_type; |
| 663 TestGeneralizeRepresentation(-1, 2, representation, type, representation, |
| 664 type, representation, type, false, false); |
656 } | 665 } |
657 } | 666 } |
658 | 667 |
659 | 668 |
660 static void TestGeneralizeRepresentation(Representation from_representation, | 669 static void TestGeneralizeRepresentation(Representation from_representation, |
661 Handle<HeapType> from_type, | 670 Handle<HeapType> from_type, |
662 Representation to_representation, | 671 Representation to_representation, |
663 Handle<HeapType> to_type, | 672 Handle<HeapType> to_type, |
664 Representation expected_representation, | 673 Representation expected_representation, |
665 Handle<HeapType> expected_type) { | 674 Handle<HeapType> expected_type) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 // Skip accessor property reconfiguration. | 878 // Skip accessor property reconfiguration. |
870 maps[i] = maps[i - 1]; | 879 maps[i] = maps[i - 1]; |
871 continue; | 880 continue; |
872 } | 881 } |
873 Handle<Map> new_map = Map::ReconfigureProperty( | 882 Handle<Map> new_map = Map::ReconfigureProperty( |
874 map, i, kData, NONE, Representation::Double(), any_type, FORCE_FIELD); | 883 map, i, kData, NONE, Representation::Double(), any_type, FORCE_FIELD); |
875 maps[i] = new_map; | 884 maps[i] = new_map; |
876 | 885 |
877 expectations.SetDataField(i, Representation::Double(), any_type); | 886 expectations.SetDataField(i, Representation::Double(), any_type); |
878 | 887 |
| 888 CHECK(!map->is_stable()); |
879 CHECK(map->is_deprecated()); | 889 CHECK(map->is_deprecated()); |
880 CHECK_NE(*map, *new_map); | 890 CHECK_NE(*map, *new_map); |
881 CHECK(i == 0 || maps[i - 1]->is_deprecated()); | 891 CHECK(i == 0 || maps[i - 1]->is_deprecated()); |
882 | 892 |
883 CHECK(!new_map->is_deprecated()); | 893 CHECK(!new_map->is_deprecated()); |
884 CHECK(expectations.Check(*new_map)); | 894 CHECK(expectations.Check(*new_map)); |
885 } | 895 } |
886 | 896 |
887 Handle<Map> active_map = maps[kPropCount - 1]; | 897 Handle<Map> active_map = maps[kPropCount - 1]; |
888 CHECK(!active_map->is_deprecated()); | 898 CHECK(!active_map->is_deprecated()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 Handle<Map> field_owner(map->FindFieldOwner(kSplitProp), isolate); | 964 Handle<Map> field_owner(map->FindFieldOwner(kSplitProp), isolate); |
955 CompilationInfo info(&stub, isolate, &zone); | 965 CompilationInfo info(&stub, isolate, &zone); |
956 CHECK(!info.dependencies()->HasAborted()); | 966 CHECK(!info.dependencies()->HasAborted()); |
957 info.dependencies()->AssumeFieldType(field_owner); | 967 info.dependencies()->AssumeFieldType(field_owner); |
958 | 968 |
959 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which | 969 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which |
960 // should generalize representations in |map1|. | 970 // should generalize representations in |map1|. |
961 Handle<Map> new_map = | 971 Handle<Map> new_map = |
962 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); | 972 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); |
963 | 973 |
964 // |map2| should be left unchanged. | 974 // |map2| should be left unchanged but marked unstable. |
| 975 CHECK(!map2->is_stable()); |
965 CHECK(!map2->is_deprecated()); | 976 CHECK(!map2->is_deprecated()); |
966 CHECK_NE(*map2, *new_map); | 977 CHECK_NE(*map2, *new_map); |
967 CHECK(expectations2.Check(*map2)); | 978 CHECK(expectations2.Check(*map2)); |
968 | 979 |
969 // |map| should be deprecated and |new_map| should match new expectations. | 980 // |map| should be deprecated and |new_map| should match new expectations. |
970 for (int i = kSplitProp; i < kPropCount; i++) { | 981 for (int i = kSplitProp; i < kPropCount; i++) { |
971 expectations.SetDataField(i, expected_representation, expected_type); | 982 expectations.SetDataField(i, expected_representation, expected_type); |
972 } | 983 } |
973 CHECK(map->is_deprecated()); | 984 CHECK(map->is_deprecated()); |
974 CHECK(!info.dependencies()->HasAborted()); | 985 CHECK(!info.dependencies()->HasAborted()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 Handle<Map> field_owner(map->FindFieldOwner(kSplitProp), isolate); | 1050 Handle<Map> field_owner(map->FindFieldOwner(kSplitProp), isolate); |
1040 CompilationInfo info(&stub, isolate, &zone); | 1051 CompilationInfo info(&stub, isolate, &zone); |
1041 CHECK(!info.dependencies()->HasAborted()); | 1052 CHECK(!info.dependencies()->HasAborted()); |
1042 info.dependencies()->AssumeFieldType(field_owner); | 1053 info.dependencies()->AssumeFieldType(field_owner); |
1043 | 1054 |
1044 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which | 1055 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which |
1045 // should generalize representations in |map1|. | 1056 // should generalize representations in |map1|. |
1046 Handle<Map> new_map = | 1057 Handle<Map> new_map = |
1047 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); | 1058 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); |
1048 | 1059 |
1049 // |map2| should be left unchanged. | 1060 // |map2| should be left unchanged but marked unstable. |
| 1061 CHECK(!map2->is_stable()); |
1050 CHECK(!map2->is_deprecated()); | 1062 CHECK(!map2->is_deprecated()); |
1051 CHECK_NE(*map2, *new_map); | 1063 CHECK_NE(*map2, *new_map); |
1052 CHECK(expectations2.Check(*map2)); | 1064 CHECK(expectations2.Check(*map2)); |
1053 | 1065 |
1054 // In trivial case |map| should be returned as a result of the property | 1066 // In trivial case |map| should be returned as a result of the property |
1055 // reconfiguration, respective field types should be generalized and | 1067 // reconfiguration, respective field types should be generalized and |
1056 // respective code dependencies should be invalidated. |map| should be NOT | 1068 // respective code dependencies should be invalidated. |map| should be NOT |
1057 // deprecated and it should match new expectations. | 1069 // deprecated and it should match new expectations. |
1058 for (int i = kSplitProp; i < kPropCount; i++) { | 1070 for (int i = kSplitProp; i < kPropCount; i++) { |
1059 expectations.SetDataField(i, expected_representation, expected_type); | 1071 expectations.SetDataField(i, expected_representation, expected_type); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 CHECK_EQ(*new_map, *updated_map); | 1187 CHECK_EQ(*new_map, *updated_map); |
1176 } | 1188 } |
1177 }; | 1189 }; |
1178 | 1190 |
1179 | 1191 |
1180 // Checks that given |map| is NOT deprecated, equals to given |new_map| and | 1192 // Checks that given |map| is NOT deprecated, equals to given |new_map| and |
1181 // matches expectations. | 1193 // matches expectations. |
1182 struct CheckSameMap { | 1194 struct CheckSameMap { |
1183 void Check(Handle<Map> map, Handle<Map> new_map, | 1195 void Check(Handle<Map> map, Handle<Map> new_map, |
1184 const Expectations& expectations) { | 1196 const Expectations& expectations) { |
| 1197 // |map| was not reconfigured, therefore it should stay stable. |
| 1198 CHECK(map->is_stable()); |
1185 CHECK(!map->is_deprecated()); | 1199 CHECK(!map->is_deprecated()); |
1186 CHECK_EQ(*map, *new_map); | 1200 CHECK_EQ(*map, *new_map); |
1187 | 1201 |
1188 CHECK(!new_map->is_deprecated()); | 1202 CHECK(!new_map->is_deprecated()); |
1189 CHECK(expectations.Check(*new_map)); | 1203 CHECK(expectations.Check(*new_map)); |
1190 | 1204 |
1191 // Update deprecated |map|, it should become |new_map|. | 1205 // Update deprecated |map|, it should become |new_map|. |
1192 Handle<Map> updated_map = Map::Update(map); | 1206 Handle<Map> updated_map = Map::Update(map); |
1193 CHECK_EQ(*new_map, *updated_map); | 1207 CHECK_EQ(*new_map, *updated_map); |
1194 } | 1208 } |
1195 }; | 1209 }; |
1196 | 1210 |
1197 | 1211 |
| 1212 // Checks that given |map| is NOT deprecated and matches expectations. |
| 1213 // |new_map| is unrelated to |map|. |
| 1214 struct CheckUnrelated { |
| 1215 void Check(Handle<Map> map, Handle<Map> new_map, |
| 1216 const Expectations& expectations) { |
| 1217 CHECK(!map->is_deprecated()); |
| 1218 CHECK_NE(*map, *new_map); |
| 1219 CHECK(expectations.Check(*map)); |
| 1220 |
| 1221 CHECK(new_map->is_stable()); |
| 1222 CHECK(!new_map->is_deprecated()); |
| 1223 } |
| 1224 }; |
| 1225 |
| 1226 |
1198 // Checks that given |map| is NOT deprecated, and |new_map| is a result of | 1227 // Checks that given |map| is NOT deprecated, and |new_map| is a result of |
1199 // copy-generalize-all-representations. | 1228 // copy-generalize-all-representations. |
1200 struct CheckCopyGeneralizeAllRepresentations { | 1229 struct CheckCopyGeneralizeAllRepresentations { |
1201 void Check(Handle<Map> map, Handle<Map> new_map, Expectations& expectations) { | 1230 void Check(Handle<Map> map, Handle<Map> new_map, Expectations& expectations) { |
1202 CHECK(!map->is_deprecated()); | 1231 CHECK(!map->is_deprecated()); |
1203 CHECK_NE(*map, *new_map); | 1232 CHECK_NE(*map, *new_map); |
1204 | 1233 |
1205 CHECK(new_map->GetBackPointer()->IsUndefined()); | 1234 CHECK(new_map->GetBackPointer()->IsUndefined()); |
1206 for (int i = 0; i < kPropCount; i++) { | 1235 for (int i = 0; i < kPropCount; i++) { |
1207 expectations.GeneralizeRepresentation(i); | 1236 expectations.GeneralizeRepresentation(i); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 CHECK(!map2->is_deprecated()); | 1310 CHECK(!map2->is_deprecated()); |
1282 CHECK(map2->is_stable()); | 1311 CHECK(map2->is_stable()); |
1283 CHECK(expectations2.Check(*map2)); | 1312 CHECK(expectations2.Check(*map2)); |
1284 | 1313 |
1285 | 1314 |
1286 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which | 1315 // Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which |
1287 // should generalize representations in |map1|. | 1316 // should generalize representations in |map1|. |
1288 Handle<Map> new_map = | 1317 Handle<Map> new_map = |
1289 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); | 1318 Map::ReconfigureExistingProperty(map2, kSplitProp, kData, NONE); |
1290 | 1319 |
1291 // |map2| should be left unchanged. | 1320 // |map2| should be left unchanged but marked unstable. |
| 1321 CHECK(!map2->is_stable()); |
1292 CHECK(!map2->is_deprecated()); | 1322 CHECK(!map2->is_deprecated()); |
1293 CHECK_NE(*map2, *new_map); | 1323 CHECK_NE(*map2, *new_map); |
1294 CHECK(expectations2.Check(*map2)); | 1324 CHECK(expectations2.Check(*map2)); |
1295 | 1325 |
1296 config.UpdateExpectations(kCustomPropIndex, expectations1); | 1326 config.UpdateExpectations(kCustomPropIndex, expectations1); |
1297 checker.Check(map1, new_map, expectations1); | 1327 checker.Check(map1, new_map, expectations1); |
1298 } | 1328 } |
1299 | 1329 |
1300 | 1330 |
1301 TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { | 1331 TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 } | 1388 } |
1359 }; | 1389 }; |
1360 | 1390 |
1361 TestConfig config; | 1391 TestConfig config; |
1362 // Two branches are "incompatible" so the |map1| should be deprecated. | 1392 // Two branches are "incompatible" so the |map1| should be deprecated. |
1363 CheckDeprecated checker; | 1393 CheckDeprecated checker; |
1364 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1394 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
1365 } | 1395 } |
1366 | 1396 |
1367 | 1397 |
| 1398 TEST(ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) { |
| 1399 CcTest::InitializeVM(); |
| 1400 v8::HandleScope scope(CcTest::isolate()); |
| 1401 |
| 1402 struct TestConfig { |
| 1403 Handle<JSFunction> js_func_; |
| 1404 Handle<AccessorPair> pair_; |
| 1405 TestConfig() { |
| 1406 Isolate* isolate = CcTest::i_isolate(); |
| 1407 Factory* factory = isolate->factory(); |
| 1408 js_func_ = factory->NewFunction(factory->empty_string()); |
| 1409 pair_ = CreateAccessorPair(true, true); |
| 1410 } |
| 1411 |
| 1412 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
| 1413 Handle<Map> map) { |
| 1414 CHECK(branch_id == 1 || branch_id == 2); |
| 1415 if (branch_id == 1) { |
| 1416 return expectations.AddDataConstant(map, NONE, js_func_); |
| 1417 } else { |
| 1418 return expectations.AddAccessorConstant(map, NONE, pair_); |
| 1419 } |
| 1420 } |
| 1421 |
| 1422 void UpdateExpectations(int property_index, Expectations& expectations) {} |
| 1423 }; |
| 1424 |
| 1425 TestConfig config; |
| 1426 // These are completely separate branches in transition tree. |
| 1427 CheckUnrelated checker; |
| 1428 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1429 } |
| 1430 |
| 1431 |
1368 TEST(ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) { | 1432 TEST(ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) { |
1369 CcTest::InitializeVM(); | 1433 CcTest::InitializeVM(); |
1370 v8::HandleScope scope(CcTest::isolate()); | 1434 v8::HandleScope scope(CcTest::isolate()); |
1371 | 1435 |
1372 struct TestConfig { | 1436 struct TestConfig { |
1373 Handle<AccessorPair> pair_; | 1437 Handle<AccessorPair> pair_; |
1374 TestConfig() { pair_ = CreateAccessorPair(true, true); } | 1438 TestConfig() { pair_ = CreateAccessorPair(true, true); } |
1375 | 1439 |
1376 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, | 1440 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
1377 Handle<Map> map) { | 1441 Handle<Map> map) { |
1378 CHECK(branch_id == 1 || branch_id == 2); | 1442 CHECK(branch_id == 1 || branch_id == 2); |
1379 // Add the same accessor constant property at both transition tree | 1443 // Add the same accessor constant property at both transition tree |
1380 // branches. | 1444 // branches. |
1381 return expectations.AddAccessorConstant(map, NONE, pair_); | 1445 return expectations.AddAccessorConstant(map, NONE, pair_); |
1382 } | 1446 } |
1383 | 1447 |
1384 bool UpdateExpectations(int property_index, Expectations& expectations) { | 1448 void UpdateExpectations(int property_index, Expectations& expectations) { |
1385 // Two branches are "compatible" so the |map1| should NOT be deprecated. | 1449 // Two branches are "compatible" so the |map1| should NOT be deprecated. |
1386 return false; | |
1387 } | 1450 } |
1388 }; | 1451 }; |
1389 | 1452 |
1390 TestConfig config; | 1453 TestConfig config; |
1391 CheckSameMap checker; | 1454 CheckSameMap checker; |
1392 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1455 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
1393 } | 1456 } |
1394 | 1457 |
1395 | 1458 |
1396 TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) { | 1459 TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 CheckCopyGeneralizeAllRepresentations checker; | 1491 CheckCopyGeneralizeAllRepresentations checker; |
1429 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1492 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
1430 } else { | 1493 } else { |
1431 // Currently we have a copy-generalize-all-representations case. | 1494 // Currently we have a copy-generalize-all-representations case. |
1432 CheckCopyGeneralizeAllRepresentations checker; | 1495 CheckCopyGeneralizeAllRepresentations checker; |
1433 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1496 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
1434 } | 1497 } |
1435 } | 1498 } |
1436 | 1499 |
1437 | 1500 |
| 1501 TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { |
| 1502 CcTest::InitializeVM(); |
| 1503 v8::HandleScope scope(CcTest::isolate()); |
| 1504 |
| 1505 struct TestConfig { |
| 1506 Handle<AccessorPair> pair_; |
| 1507 TestConfig() { pair_ = CreateAccessorPair(true, true); } |
| 1508 |
| 1509 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
| 1510 Handle<Map> map) { |
| 1511 CHECK(branch_id == 1 || branch_id == 2); |
| 1512 if (branch_id == 1) { |
| 1513 return expectations.AddAccessorConstant(map, NONE, pair_); |
| 1514 } else { |
| 1515 Isolate* isolate = CcTest::i_isolate(); |
| 1516 Handle<HeapType> any_type = HeapType::Any(isolate); |
| 1517 return expectations.AddDataField(map, NONE, Representation::Smi(), |
| 1518 any_type); |
| 1519 } |
| 1520 } |
| 1521 |
| 1522 void UpdateExpectations(int property_index, Expectations& expectations) {} |
| 1523 }; |
| 1524 |
| 1525 TestConfig config; |
| 1526 // These are completely separate branches in transition tree. |
| 1527 CheckUnrelated checker; |
| 1528 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1529 } |
| 1530 |
| 1531 |
1438 //////////////////////////////////////////////////////////////////////////////// | 1532 //////////////////////////////////////////////////////////////////////////////// |
1439 // A set of tests checking split map deprecation. | 1533 // A set of tests checking split map deprecation. |
1440 // | 1534 // |
1441 | 1535 |
1442 TEST(ReconfigurePropertySplitMapTransitionsOverflow) { | 1536 TEST(ReconfigurePropertySplitMapTransitionsOverflow) { |
1443 CcTest::InitializeVM(); | 1537 CcTest::InitializeVM(); |
1444 v8::HandleScope scope(CcTest::isolate()); | 1538 v8::HandleScope scope(CcTest::isolate()); |
1445 Isolate* isolate = CcTest::i_isolate(); | 1539 Isolate* isolate = CcTest::i_isolate(); |
1446 Handle<HeapType> any_type = HeapType::Any(isolate); | 1540 Handle<HeapType> any_type = HeapType::Any(isolate); |
1447 | 1541 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 expectations.SetDataField(kSplitProp, Representation::Double(), any_type); | 1573 expectations.SetDataField(kSplitProp, Representation::Double(), any_type); |
1480 | 1574 |
1481 CHECK(expectations.Check(*split_map, kSplitProp)); | 1575 CHECK(expectations.Check(*split_map, kSplitProp)); |
1482 CHECK(expectations.Check(*map2, kSplitProp + 1)); | 1576 CHECK(expectations.Check(*map2, kSplitProp + 1)); |
1483 } | 1577 } |
1484 | 1578 |
1485 // At this point |map| should be deprecated and disconnected from the | 1579 // At this point |map| should be deprecated and disconnected from the |
1486 // transition tree. | 1580 // transition tree. |
1487 CHECK(map->is_deprecated()); | 1581 CHECK(map->is_deprecated()); |
1488 CHECK(!split_map->is_deprecated()); | 1582 CHECK(!split_map->is_deprecated()); |
| 1583 CHECK(map2->is_stable()); |
1489 CHECK(!map2->is_deprecated()); | 1584 CHECK(!map2->is_deprecated()); |
1490 | 1585 |
1491 // Fill in transition tree of |map2| so that it can't have more transitions. | 1586 // Fill in transition tree of |map2| so that it can't have more transitions. |
1492 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { | 1587 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { |
1493 CHECK(TransitionArray::CanHaveMoreTransitions(map2)); | 1588 CHECK(TransitionArray::CanHaveMoreTransitions(map2)); |
1494 Handle<String> name = MakeName("foo", i); | 1589 Handle<String> name = MakeName("foo", i); |
1495 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), | 1590 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), |
1496 INSERT_TRANSITION).ToHandleChecked(); | 1591 INSERT_TRANSITION).ToHandleChecked(); |
1497 } | 1592 } |
1498 CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); | 1593 CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 heap_type_(heap_type) {} | 2019 heap_type_(heap_type) {} |
1925 | 2020 |
1926 void Check(Expectations& expectations2, Handle<Map> map1, Handle<Map> map2) { | 2021 void Check(Expectations& expectations2, Handle<Map> map1, Handle<Map> map2) { |
1927 CHECK(!map2->is_deprecated()); | 2022 CHECK(!map2->is_deprecated()); |
1928 | 2023 |
1929 CHECK(map1->is_deprecated()); | 2024 CHECK(map1->is_deprecated()); |
1930 CHECK_NE(*map1, *map2); | 2025 CHECK_NE(*map1, *map2); |
1931 Handle<Map> updated_map = Map::Update(map1); | 2026 Handle<Map> updated_map = Map::Update(map1); |
1932 CHECK_EQ(*map2, *updated_map); | 2027 CHECK_EQ(*map2, *updated_map); |
1933 | 2028 |
1934 expectations2.SetDataField(descriptor_, representation_, heap_type_); | 2029 expectations2.SetDataField(descriptor_, attributes_, representation_, |
| 2030 heap_type_); |
1935 CHECK(expectations2.Check(*map2)); | 2031 CHECK(expectations2.Check(*map2)); |
1936 } | 2032 } |
1937 }; | 2033 }; |
1938 | 2034 |
1939 | 2035 |
1940 // Checks that existing transition was taken as is. | 2036 // Checks that existing transition was taken as is. |
1941 struct SameMapChecker { | 2037 struct SameMapChecker { |
1942 void Check(Expectations& expectations, Handle<Map> map1, Handle<Map> map2) { | 2038 void Check(Expectations& expectations, Handle<Map> map1, Handle<Map> map2) { |
1943 CHECK(!map2->is_deprecated()); | 2039 CHECK(!map2->is_deprecated()); |
1944 CHECK_EQ(*map1, *map2); | 2040 CHECK_EQ(*map1, *map2); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2082 Handle<AccessorPair> pair = CreateAccessorPair(true, true); | 2178 Handle<AccessorPair> pair = CreateAccessorPair(true, true); |
2083 TransitionToAccessorConstantOperator transition_op(pair); | 2179 TransitionToAccessorConstantOperator transition_op(pair); |
2084 | 2180 |
2085 SameMapChecker checker; | 2181 SameMapChecker checker; |
2086 TestTransitionTo(transition_op, transition_op, checker); | 2182 TestTransitionTo(transition_op, transition_op, checker); |
2087 } | 2183 } |
2088 | 2184 |
2089 | 2185 |
2090 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. | 2186 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. |
2091 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) | 2187 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) |
OLD | NEW |