Skip to content

Commit 78e5763

Browse files
camillobruniCommit Bot
authored andcommitted
[CloneObjectIC] Avoid FieldType confusions
Do not propagate FieldTypes for kField properties. Bug: chromium:881247 Change-Id: Ia6af451cd6f3ba22a9ced1f3b43fc4cfc8f7084e Reviewed-on: https://chromium-review.googlesource.com/c/1288637 Commit-Queue: Camillo Bruni <[email protected]> Reviewed-by: Toon Verwaest <[email protected]> Cr-Commit-Position: refs/heads/master@{#56813}
1 parent 9c00157 commit 78e5763

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

src/objects.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10180,15 +10180,22 @@ Handle<DescriptorArray> DescriptorArray::CopyForFastObjectClone(
1018010180
Name* key = src->GetKey(i);
1018110181
PropertyDetails details = src->GetDetails(i);
1018210182

10183-
SLOW_DCHECK(!key->IsPrivateField() && details.IsEnumerable() &&
10184-
details.kind() == kData);
10183+
DCHECK(!key->IsPrivateField());
10184+
DCHECK(details.IsEnumerable());
10185+
DCHECK_EQ(details.kind(), kData);
1018510186

1018610187
// Ensure the ObjectClone property details are NONE, and that all source
1018710188
// details did not contain DONT_ENUM.
1018810189
PropertyDetails new_details(kData, NONE, details.location(),
1018910190
details.constness(), details.representation(),
1019010191
details.field_index());
10191-
descriptors->Set(i, key, src->GetValue(i), new_details);
10192+
// Do not propagate the field type of normal object fields from the
10193+
// original descriptors since FieldType changes don't create new maps.
10194+
MaybeObject* type = src->GetValue(i);
10195+
if (details.location() == PropertyLocation::kField) {
10196+
type = MaybeObject::FromObject(FieldType::Any());
10197+
}
10198+
descriptors->Set(i, key, type, new_details);
1019210199
}
1019310200

1019410201
descriptors->Sort();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2018 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax
6+
7+
const resolvedPromise = Promise.resolve();
8+
9+
function spread() {
10+
const result = { ...resolvedPromise };
11+
%HeapObjectVerify(result);
12+
return result;
13+
}
14+
15+
resolvedPromise[undefined] = {a:1};
16+
%HeapObjectVerify(resolvedPromise);
17+
18+
spread();
19+
20+
resolvedPromise[undefined] = undefined;
21+
%HeapObjectVerify(resolvedPromise);
22+
23+
spread();
24+
%HeapObjectVerify(resolvedPromise);

0 commit comments

Comments
 (0)