Skip to content

Commit cbd847c

Browse files
LeszekSwirskiV8 LUCI CQ
authored andcommitted
[map] Don't update maps in PrepareForDataProperty
... because we might update to a dictionary map. Instead, DCHECK that the map isn't deprecated, and fix callers to first update the map. Bug: 342456991 Change-Id: I8a966437d816c8e0200333c4068854432caf5729 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5588058 Reviewed-by: Igor Sheludko <[email protected]> Auto-Submit: Leszek Swirski <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#94175}
1 parent 5e7895a commit cbd847c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/objects/js-objects.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3547,7 +3547,12 @@ bool TryFastAddDataProperty(Isolate* isolate, Handle<JSObject> object,
35473547
DCHECK(!map->is_dictionary_map());
35483548

35493549
Handle<Map> new_map = handle(map, isolate);
3550-
InternalIndex descriptor = map->LastAdded();
3550+
if (map->is_deprecated()) {
3551+
new_map = Map::Update(isolate, new_map);
3552+
if (new_map->is_dictionary_map()) return false;
3553+
}
3554+
3555+
InternalIndex descriptor = new_map->LastAdded();
35513556
new_map = Map::PrepareForDataProperty(isolate, new_map, descriptor,
35523557
PropertyConstness::kConst, value);
35533558
JSObject::MigrateToMap(isolate, object, new_map);

src/objects/map.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,8 +1928,8 @@ Handle<Map> Map::PrepareForDataProperty(Isolate* isolate, Handle<Map> map,
19281928
InternalIndex descriptor,
19291929
PropertyConstness constness,
19301930
Handle<Object> value) {
1931-
// Update to the newest map before storing the property.
1932-
map = Update(isolate, map);
1931+
// The map should already be fully updated before storing the property.
1932+
DCHECK(!map->is_deprecated());
19331933
// Dictionaries can store any property value.
19341934
DCHECK(!map->is_dictionary_map());
19351935
return UpdateDescriptorForValue(isolate, map, descriptor, constness, value);

0 commit comments

Comments
 (0)