deps: V8: cherry-pick 3ba21a17ce2f · nodejs/node@18a4cbf · GitHub
Skip to content

Commit 18a4cbf

Browse files
committed
deps: V8: cherry-pick 3ba21a17ce2f
Original commit message: Merged: [map] Try to in-place transition during map update When searching for a target map during map update, attempt to update field representations in-place to the more general representation, where possible. Bug: chromium:1143772 No-Try: true No-Presubmit: true No-Tree-Checks: true TBR=leszeks@chromium.org, fgm@chromium.org (cherry picked from commit 8e3ae62d294818733a0322d8e8abd53d4e410f19) Change-Id: I659890c2f08c14d1cf94242fb875c19837df2dbb Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2509599 Reviewed-by: Francis McCabe <fgm@chromium.org> Reviewed-by: Michael Hablich <hablich@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/branch-heads/8.6@{#44} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@3ba21a1 PR-URL: #38275 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
1 parent 70f622b commit 18a4cbf

5 files changed

Lines changed: 125 additions & 28 deletions

File tree

common.gypi

Lines changed: 1 addition & 1 deletion

deps/v8/src/objects/map-updater.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,17 @@ MapUpdater::State MapUpdater::FindTargetMap() {
401401
}
402402
Representation tmp_representation = tmp_details.representation();
403403
if (!old_details.representation().fits_into(tmp_representation)) {
404-
break;
404+
// Try updating the field in-place to a generalized type.
405+
Representation generalized =
406+
tmp_representation.generalize(old_details.representation());
407+
if (!tmp_representation.CanBeInPlaceChangedTo(generalized)) {
408+
break;
409+
}
410+
Handle<Map> field_owner(tmp_map->FindFieldOwner(isolate_, i), isolate_);
411+
tmp_representation = generalized;
412+
GeneralizeField(field_owner, i, tmp_details.constness(),
413+
tmp_representation,
414+
handle(tmp_descriptors->GetFieldType(i), isolate_));
405415
}
406416

407417
if (tmp_details.location() == kField) {

deps/v8/src/objects/map.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ void Map::DeprecateTransitionTree(Isolate* isolate) {
610610
transitions.GetTarget(i).DeprecateTransitionTree(isolate);
611611
}
612612
DCHECK(!constructor_or_backpointer().IsFunctionTemplateInfo());
613+
DCHECK(CanBeDeprecated());
613614
set_is_deprecated(true);
614615
if (FLAG_trace_maps) {
615616
LOG(isolate, MapEvent("Deprecate", handle(*this, isolate), Handle<Map>()));

deps/v8/test/cctest/test-field-type-tracking.cc

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,8 @@ namespace {
10521052
// where "p2A" and "p2B" differ only in the attributes.
10531053
//
10541054
void TestReconfigureDataFieldAttribute_GeneralizeField(
1055-
const CRFTData& from, const CRFTData& to, const CRFTData& expected) {
1055+
const CRFTData& from, const CRFTData& to, const CRFTData& expected,
1056+
bool expected_deprecation) {
10561057
Isolate* isolate = CcTest::i_isolate();
10571058

10581059
Expectations expectations(isolate);
@@ -1121,24 +1122,29 @@ void TestReconfigureDataFieldAttribute_GeneralizeField(
11211122
CHECK_NE(*map2, *new_map);
11221123
CHECK(expectations2.Check(*map2));
11231124

1124-
// |map| should be deprecated and |new_map| should match new expectations.
11251125
for (int i = kSplitProp; i < kPropCount; i++) {
11261126
expectations.SetDataField(i, expected.constness, expected.representation,
11271127
expected.type);
11281128
}
1129-
CHECK(map->is_deprecated());
1130-
CHECK(!code_field_type->marked_for_deoptimization());
1131-
CHECK(!code_field_repr->marked_for_deoptimization());
1132-
CHECK(!code_field_const->marked_for_deoptimization());
1133-
CHECK_NE(*map, *new_map);
1129+
if (expected_deprecation) {
1130+
// |map| should be deprecated and |new_map| should match new expectations.
1131+
CHECK(map->is_deprecated());
1132+
CHECK(!code_field_type->marked_for_deoptimization());
1133+
CHECK(!code_field_repr->marked_for_deoptimization());
1134+
CHECK(!code_field_const->marked_for_deoptimization());
1135+
CHECK_NE(*map, *new_map);
11341136

1135-
CHECK(!new_map->is_deprecated());
1136-
CHECK(expectations.Check(*new_map));
1137+
CHECK(!new_map->is_deprecated());
1138+
CHECK(expectations.Check(*new_map));
11371139

1138-
// Update deprecated |map|, it should become |new_map|.
1139-
Handle<Map> updated_map = Map::Update(isolate, map);
1140-
CHECK_EQ(*new_map, *updated_map);
1141-
CheckMigrationTarget(isolate, *map, *updated_map);
1140+
// Update deprecated |map|, it should become |new_map|.
1141+
Handle<Map> updated_map = Map::Update(isolate, map);
1142+
CHECK_EQ(*new_map, *updated_map);
1143+
CheckMigrationTarget(isolate, *map, *updated_map);
1144+
} else {
1145+
CHECK(!map->is_deprecated());
1146+
CHECK(expectations.Check(*map));
1147+
}
11421148
}
11431149

11441150
// This test ensures that trivial field generalization (from HeapObject to
@@ -1254,22 +1260,22 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToDouble) {
12541260
TestReconfigureDataFieldAttribute_GeneralizeField(
12551261
{PropertyConstness::kConst, Representation::Smi(), any_type},
12561262
{PropertyConstness::kConst, Representation::Double(), any_type},
1257-
{PropertyConstness::kConst, Representation::Double(), any_type});
1263+
{PropertyConstness::kConst, Representation::Double(), any_type}, true);
12581264

12591265
TestReconfigureDataFieldAttribute_GeneralizeField(
12601266
{PropertyConstness::kConst, Representation::Smi(), any_type},
12611267
{PropertyConstness::kMutable, Representation::Double(), any_type},
1262-
{PropertyConstness::kMutable, Representation::Double(), any_type});
1268+
{PropertyConstness::kMutable, Representation::Double(), any_type}, true);
12631269

12641270
TestReconfigureDataFieldAttribute_GeneralizeField(
12651271
{PropertyConstness::kMutable, Representation::Smi(), any_type},
12661272
{PropertyConstness::kConst, Representation::Double(), any_type},
1267-
{PropertyConstness::kMutable, Representation::Double(), any_type});
1273+
{PropertyConstness::kMutable, Representation::Double(), any_type}, true);
12681274

12691275
TestReconfigureDataFieldAttribute_GeneralizeField(
12701276
{PropertyConstness::kMutable, Representation::Smi(), any_type},
12711277
{PropertyConstness::kMutable, Representation::Double(), any_type},
1272-
{PropertyConstness::kMutable, Representation::Double(), any_type});
1278+
{PropertyConstness::kMutable, Representation::Double(), any_type}, true);
12731279
}
12741280

12751281
TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToTagged) {
@@ -1284,22 +1290,26 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToTagged) {
12841290
TestReconfigureDataFieldAttribute_GeneralizeField(
12851291
{PropertyConstness::kConst, Representation::Smi(), any_type},
12861292
{PropertyConstness::kConst, Representation::HeapObject(), value_type},
1287-
{PropertyConstness::kConst, Representation::Tagged(), any_type});
1293+
{PropertyConstness::kConst, Representation::Tagged(), any_type},
1294+
!FLAG_modify_field_representation_inplace);
12881295

12891296
TestReconfigureDataFieldAttribute_GeneralizeField(
12901297
{PropertyConstness::kConst, Representation::Smi(), any_type},
12911298
{PropertyConstness::kMutable, Representation::HeapObject(), value_type},
1292-
{PropertyConstness::kMutable, Representation::Tagged(), any_type});
1299+
{PropertyConstness::kMutable, Representation::Tagged(), any_type},
1300+
!FLAG_modify_field_representation_inplace);
12931301

12941302
TestReconfigureDataFieldAttribute_GeneralizeField(
12951303
{PropertyConstness::kMutable, Representation::Smi(), any_type},
12961304
{PropertyConstness::kConst, Representation::HeapObject(), value_type},
1297-
{PropertyConstness::kMutable, Representation::Tagged(), any_type});
1305+
{PropertyConstness::kMutable, Representation::Tagged(), any_type},
1306+
!FLAG_modify_field_representation_inplace);
12981307

12991308
TestReconfigureDataFieldAttribute_GeneralizeField(
13001309
{PropertyConstness::kMutable, Representation::Smi(), any_type},
13011310
{PropertyConstness::kMutable, Representation::HeapObject(), value_type},
1302-
{PropertyConstness::kMutable, Representation::Tagged(), any_type});
1311+
{PropertyConstness::kMutable, Representation::Tagged(), any_type},
1312+
!FLAG_modify_field_representation_inplace);
13031313
}
13041314

13051315
TEST(ReconfigureDataFieldAttribute_GeneralizeDoubleFieldToTagged) {
@@ -1314,22 +1324,26 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeDoubleFieldToTagged) {
13141324
TestReconfigureDataFieldAttribute_GeneralizeField(
13151325
{PropertyConstness::kConst, Representation::Double(), any_type},
13161326
{PropertyConstness::kConst, Representation::HeapObject(), value_type},
1317-
{PropertyConstness::kConst, Representation::Tagged(), any_type});
1327+
{PropertyConstness::kConst, Representation::Tagged(), any_type},
1328+
FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace);
13181329

13191330
TestReconfigureDataFieldAttribute_GeneralizeField(
13201331
{PropertyConstness::kConst, Representation::Double(), any_type},
13211332
{PropertyConstness::kMutable, Representation::HeapObject(), value_type},
1322-
{PropertyConstness::kMutable, Representation::Tagged(), any_type});
1333+
{PropertyConstness::kMutable, Representation::Tagged(), any_type},
1334+
FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace);
13231335

13241336
TestReconfigureDataFieldAttribute_GeneralizeField(
13251337
{PropertyConstness::kMutable, Representation::Double(), any_type},
13261338
{PropertyConstness::kConst, Representation::HeapObject(), value_type},
1327-
{PropertyConstness::kMutable, Representation::Tagged(), any_type});
1339+
{PropertyConstness::kMutable, Representation::Tagged(), any_type},
1340+
FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace);
13281341

13291342
TestReconfigureDataFieldAttribute_GeneralizeField(
13301343
{PropertyConstness::kMutable, Representation::Double(), any_type},
13311344
{PropertyConstness::kMutable, Representation::HeapObject(), value_type},
1332-
{PropertyConstness::kMutable, Representation::Tagged(), any_type});
1345+
{PropertyConstness::kMutable, Representation::Tagged(), any_type},
1346+
FLAG_unbox_double_fields || !FLAG_modify_field_representation_inplace);
13331347
}
13341348

13351349
TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjFieldToHeapObj) {
@@ -1415,7 +1429,8 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjectFieldToTagged) {
14151429
TestReconfigureDataFieldAttribute_GeneralizeField(
14161430
{PropertyConstness::kMutable, Representation::HeapObject(), value_type},
14171431
{PropertyConstness::kMutable, Representation::Smi(), any_type},
1418-
{PropertyConstness::kMutable, Representation::Tagged(), any_type});
1432+
{PropertyConstness::kMutable, Representation::Tagged(), any_type},
1433+
!FLAG_modify_field_representation_inplace);
14191434
}
14201435

14211436
// Checks that given |map| is deprecated and that it updates to given |new_map|
Lines changed: 71 additions & 0 deletions

0 commit comments

Comments
 (0)