@@ -437,9 +437,9 @@ TEST(ReconfigureAccessorToNonExistingDataField) {
437
437
438
438
Handle <Map> new_map = Map::ReconfigureProperty (
439
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
441
CHECK (!map->is_deprecated ());
442
- CHECK (map->is_stable ());
442
+ CHECK (! map->is_stable ());
443
443
CHECK (expectations.Check (*map));
444
444
445
445
expectations.SetDataField (0 , NONE, Representation::None (), none_type);
@@ -601,19 +601,22 @@ static void TestGeneralizeRepresentation(
601
601
CHECK (expectations.Check (*new_map));
602
602
603
603
if (is_detached_map) {
604
+ CHECK (!map->is_stable ());
604
605
CHECK (map->is_deprecated ());
605
606
CHECK_NE (*map, *new_map);
606
607
CHECK_EQ (expected_field_type_dependency && !field_owner->is_deprecated (),
607
608
info.dependencies ()->HasAborted ());
608
609
609
610
} else if (expected_deprecation) {
611
+ CHECK (!map->is_stable ());
610
612
CHECK (map->is_deprecated ());
611
613
CHECK (field_owner->is_deprecated ());
612
614
CHECK_NE (*map, *new_map);
613
615
CHECK (!info.dependencies ()->HasAborted ());
614
616
615
617
} else {
616
618
CHECK (!field_owner->is_deprecated ());
619
+ CHECK (map->is_stable ()); // Map did not change, must be left stable.
617
620
CHECK_EQ (*map, *new_map);
618
621
619
622
CHECK_EQ (expected_field_type_dependency, info.dependencies ()->HasAborted ());
@@ -654,6 +657,12 @@ static void TestGeneralizeRepresentation(
654
657
to_type, expected_representation, expected_type, expected_deprecation,
655
658
expected_field_type_dependency);
656
659
}
660
+
661
+ // Check that reconfiguration to the very same field works correctly.
662
+ Representation representation = from_representation;
663
+ Handle <HeapType> type = from_type;
664
+ TestGeneralizeRepresentation (-1 , 2 , representation, type, representation,
665
+ type, representation, type, false , false );
657
666
}
658
667
}
659
668
@@ -877,6 +886,7 @@ TEST(GeneralizeRepresentationWithAccessorProperties) {
877
886
878
887
expectations.SetDataField (i, Representation::Double (), any_type);
879
888
889
+ CHECK (!map->is_stable ());
880
890
CHECK (map->is_deprecated ());
881
891
CHECK_NE (*map, *new_map);
882
892
CHECK (i == 0 || maps[i - 1 ]->is_deprecated ());
@@ -962,7 +972,8 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation(
962
972
Handle <Map> new_map =
963
973
Map::ReconfigureExistingProperty (map2, kSplitProp , kData , NONE);
964
974
965
- // |map2| should be left unchanged.
975
+ // |map2| should be left unchanged but marked unstable.
976
+ CHECK (!map2->is_stable ());
966
977
CHECK (!map2->is_deprecated ());
967
978
CHECK_NE (*map2, *new_map);
968
979
CHECK (expectations2.Check (*map2));
@@ -1047,7 +1058,8 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial(
1047
1058
Handle <Map> new_map =
1048
1059
Map::ReconfigureExistingProperty (map2, kSplitProp , kData , NONE);
1049
1060
1050
- // |map2| should be left unchanged.
1061
+ // |map2| should be left unchanged but marked unstable.
1062
+ CHECK (!map2->is_stable ());
1051
1063
CHECK (!map2->is_deprecated ());
1052
1064
CHECK_NE (*map2, *new_map);
1053
1065
CHECK (expectations2.Check (*map2));
@@ -1183,6 +1195,8 @@ struct CheckDeprecated {
1183
1195
struct CheckSameMap {
1184
1196
void Check (Handle <Map> map, Handle <Map> new_map,
1185
1197
const Expectations& expectations) {
1198
+ // |map| was not reconfigured, therefore it should stay stable.
1199
+ CHECK (map->is_stable ());
1186
1200
CHECK (!map->is_deprecated ());
1187
1201
CHECK_EQ (*map, *new_map);
1188
1202
@@ -1196,6 +1210,21 @@ struct CheckSameMap {
1196
1210
};
1197
1211
1198
1212
1213
+ // Checks that given |map| is NOT deprecated and matches expectations.
1214
+ // |new_map| is unrelated to |map|.
1215
+ struct CheckUnrelated {
1216
+ void Check (Handle <Map> map, Handle <Map> new_map,
1217
+ const Expectations& expectations) {
1218
+ CHECK (!map->is_deprecated ());
1219
+ CHECK_NE (*map, *new_map);
1220
+ CHECK (expectations.Check (*map));
1221
+
1222
+ CHECK (new_map->is_stable ());
1223
+ CHECK (!new_map->is_deprecated ());
1224
+ }
1225
+ };
1226
+
1227
+
1199
1228
// Checks that given |map| is NOT deprecated, and |new_map| is a result of
1200
1229
// copy-generalize-all-representations.
1201
1230
struct CheckCopyGeneralizeAllRepresentations {
@@ -1289,7 +1318,8 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap(
1289
1318
Handle <Map> new_map =
1290
1319
Map::ReconfigureExistingProperty (map2, kSplitProp , kData , NONE);
1291
1320
1292
- // |map2| should be left unchanged.
1321
+ // |map2| should be left unchanged but marked unstable.
1322
+ CHECK (!map2->is_stable ());
1293
1323
CHECK (!map2->is_deprecated ());
1294
1324
CHECK_NE (*map2, *new_map);
1295
1325
CHECK (expectations2.Check (*map2));
@@ -1366,6 +1396,40 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) {
1366
1396
}
1367
1397
1368
1398
1399
+ TEST (ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) {
1400
+ CcTest::InitializeVM ();
1401
+ v8::HandleScope scope (CcTest::isolate ());
1402
+
1403
+ struct TestConfig {
1404
+ Handle <JSFunction> js_func_;
1405
+ Handle <AccessorPair> pair_;
1406
+ TestConfig () {
1407
+ Isolate* isolate = CcTest::i_isolate ();
1408
+ Factory* factory = isolate->factory ();
1409
+ js_func_ = factory->NewFunction (factory->empty_string ());
1410
+ pair_ = CreateAccessorPair (true , true );
1411
+ }
1412
+
1413
+ Handle <Map> AddPropertyAtBranch (int branch_id, Expectations& expectations,
1414
+ Handle <Map> map) {
1415
+ CHECK (branch_id == 1 || branch_id == 2 );
1416
+ if (branch_id == 1 ) {
1417
+ return expectations.AddDataConstant (map, NONE, js_func_);
1418
+ } else {
1419
+ return expectations.AddAccessorConstant (map, NONE, pair_);
1420
+ }
1421
+ }
1422
+
1423
+ void UpdateExpectations (int property_index, Expectations& expectations) {}
1424
+ };
1425
+
1426
+ TestConfig config;
1427
+ // These are completely separate branches in transition tree.
1428
+ CheckUnrelated checker;
1429
+ TestReconfigureProperty_CustomPropertyAfterTargetMap (config, checker);
1430
+ }
1431
+
1432
+
1369
1433
TEST (ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) {
1370
1434
CcTest::InitializeVM ();
1371
1435
v8::HandleScope scope (CcTest::isolate ());
@@ -1382,9 +1446,8 @@ TEST(ReconfigureDataFieldAttribute_SameAccessorConstantAfterTargetMap) {
1382
1446
return expectations.AddAccessorConstant (map, NONE, pair_);
1383
1447
}
1384
1448
1385
- bool UpdateExpectations (int property_index, Expectations& expectations) {
1449
+ void UpdateExpectations (int property_index, Expectations& expectations) {
1386
1450
// Two branches are "compatible" so the |map1| should NOT be deprecated.
1387
- return false ;
1388
1451
}
1389
1452
};
1390
1453
@@ -1436,6 +1499,37 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToAccFieldAfterTargetMap) {
1436
1499
}
1437
1500
1438
1501
1502
+ TEST (ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) {
1503
+ CcTest::InitializeVM ();
1504
+ v8::HandleScope scope (CcTest::isolate ());
1505
+
1506
+ struct TestConfig {
1507
+ Handle <AccessorPair> pair_;
1508
+ TestConfig () { pair_ = CreateAccessorPair (true , true ); }
1509
+
1510
+ Handle <Map> AddPropertyAtBranch (int branch_id, Expectations& expectations,
1511
+ Handle <Map> map) {
1512
+ CHECK (branch_id == 1 || branch_id == 2 );
1513
+ if (branch_id == 1 ) {
1514
+ return expectations.AddAccessorConstant (map, NONE, pair_);
1515
+ } else {
1516
+ Isolate* isolate = CcTest::i_isolate ();
1517
+ Handle <HeapType> any_type = HeapType::Any (isolate);
1518
+ return expectations.AddDataField (map, NONE, Representation::Smi (),
1519
+ any_type);
1520
+ }
1521
+ }
1522
+
1523
+ void UpdateExpectations (int property_index, Expectations& expectations) {}
1524
+ };
1525
+
1526
+ TestConfig config;
1527
+ // These are completely separate branches in transition tree.
1528
+ CheckUnrelated checker;
1529
+ TestReconfigureProperty_CustomPropertyAfterTargetMap (config, checker);
1530
+ }
1531
+
1532
+
1439
1533
// //////////////////////////////////////////////////////////////////////////////
1440
1534
// A set of tests checking split map deprecation.
1441
1535
//
@@ -1487,6 +1581,7 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
1487
1581
// transition tree.
1488
1582
CHECK (map->is_deprecated ());
1489
1583
CHECK (!split_map->is_deprecated ());
1584
+ CHECK (map2->is_stable ());
1490
1585
CHECK (!map2->is_deprecated ());
1491
1586
1492
1587
// Fill in transition tree of |map2| so that it can't have more transitions.
@@ -1932,7 +2027,8 @@ struct FieldGeneralizationChecker {
1932
2027
Handle <Map> updated_map = Map::Update (map1);
1933
2028
CHECK_EQ (*map2, *updated_map);
1934
2029
1935
- expectations2.SetDataField (descriptor_, representation_, heap_type_);
2030
+ expectations2.SetDataField (descriptor_, attributes_, representation_,
2031
+ heap_type_);
1936
2032
CHECK (expectations2.Check (*map2));
1937
2033
}
1938
2034
};
0 commit comments