Skip to content

Commit 25d1657

Browse files
sethbrenithCommit Bot
authored andcommitted
[runtime] Improve handling of enumeration index on global dictionary
Bug: chromium:1056054 Change-Id: Ie1f2da98bc54a2ad5189cbe2ee1686fe1ef7019a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2079035 Reviewed-by: Toon Verwaest <[email protected]> Reviewed-by: Jakob Kummerow <[email protected]> Commit-Queue: Seth Brenith <[email protected]> Cr-Commit-Position: refs/heads/master@{#66504}
1 parent da900ff commit 25d1657

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

src/objects/objects.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7287,10 +7287,9 @@ int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex(
72877287
// Check whether the next enumeration index is valid.
72887288
if (!PropertyDetails::IsValidIndex(index)) {
72897289
// If not, we generate new indices for the properties.
7290-
int length = dictionary->NumberOfElements();
7291-
72927290
Handle<FixedArray> iteration_order = IterationIndices(isolate, dictionary);
7293-
DCHECK_EQ(length, iteration_order->length());
7291+
int length = iteration_order->length();
7292+
DCHECK_LE(length, dictionary->NumberOfElements());
72947293

72957294
// Iterate over the dictionary using the enumeration order and update
72967295
// the dictionary with new enumeration indices.
@@ -7534,8 +7533,8 @@ void BaseNameDictionary<Derived, Shape>::CopyEnumKeysTo(
75347533
template <typename Derived, typename Shape>
75357534
Handle<FixedArray> BaseNameDictionary<Derived, Shape>::IterationIndices(
75367535
Isolate* isolate, Handle<Derived> dictionary) {
7537-
int length = dictionary->NumberOfElements();
7538-
Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
7536+
Handle<FixedArray> array =
7537+
isolate->factory()->NewFixedArray(dictionary->NumberOfElements());
75397538
ReadOnlyRoots roots(isolate);
75407539
int array_size = 0;
75417540
{
@@ -7547,7 +7546,13 @@ Handle<FixedArray> BaseNameDictionary<Derived, Shape>::IterationIndices(
75477546
array->set(array_size++, Smi::FromInt(i.as_int()));
75487547
}
75497548

7550-
DCHECK_EQ(array_size, length);
7549+
// The global dictionary doesn't track its deletion count, so we may iterate
7550+
// fewer entries than the count of elements claimed by the dictionary.
7551+
if (std::is_same<Derived, GlobalDictionary>::value) {
7552+
DCHECK_LE(array_size, dictionary->NumberOfElements());
7553+
} else {
7554+
DCHECK_EQ(array_size, dictionary->NumberOfElements());
7555+
}
75517556

75527557
EnumIndexComparator<Derived> cmp(raw_dictionary);
75537558
// Use AtomicSlot wrapper to ensure that std::sort uses atomic load and

test/mjsunit/mjsunit.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
'regress/regress-crbug-217858': [SKIP],
178178
'regress/regress-crbug-808192': [SKIP],
179179
'regress/regress-crbug-941743': [SKIP],
180+
'regress/regress-crbug-1056054': [SKIP],
180181
'regress/regress-create-exception': [SKIP],
181182

182183
# These tests run out of stack space in debug mode.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2020 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+
(function (global) {
6+
var e = [];
7+
for (var i = 0; i < 1e5; ++i) {
8+
e.push('a' + i);
9+
}
10+
for (var j = 0; j < 900; ++j) {
11+
for(var i = 0; i < 1e4; ++i) {
12+
global[e[i]] = j;
13+
delete global[e[i]];
14+
}
15+
}
16+
})(this);

0 commit comments

Comments
 (0)