Skip to content

Commit 7bb79b9

Browse files
camillobruniCommit Bot
authored andcommitted
[keys] Don't keep chain of OrderedHashSets in KeyAccumulator
Bug: chromium:831984 Change-Id: Ie13b22bc2491acc255557ba0325d8d53c22d6acb Reviewed-on: https://chromium-review.googlesource.com/1012874 Reviewed-by: Igor Sheludko <[email protected]> Commit-Queue: Camillo Bruni <[email protected]> Cr-Commit-Position: refs/heads/master@{#52630}
1 parent c536ea2 commit 7bb79b9

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/keys.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ void KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) {
7777
Handle<String>::cast(key)->AsArrayIndex(&index)) {
7878
key = isolate_->factory()->NewNumberFromUint(index);
7979
}
80-
keys_ = OrderedHashSet::Add(keys(), key);
80+
Handle<OrderedHashSet> new_set = OrderedHashSet::Add(keys(), key);
81+
if (*new_set != *keys_) {
82+
// The keys_ Set is converted directly to a FixedArray in GetKeys which can
83+
// be left-trimmer. Hence the previous Set should not keep a pointer to the
84+
// new one.
85+
keys_->set(OrderedHashTableBase::kNextTableIndex, Smi::kZero);
86+
keys_ = new_set;
87+
}
8188
}
8289

8390
void KeyAccumulator::AddKeys(Handle<FixedArray> array,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
6+
let arr = [...Array(9000)];
7+
for (let j = 0; j < 40; j++) {
8+
Reflect.ownKeys(arr).shift();
9+
Array(64386);
10+
}

0 commit comments

Comments
 (0)