Skip to content

Commit d4a530e

Browse files
joyeecheungrichardlau
authored andcommitted
deps: V8: cherry-pick 7f5daed62d47
Original commit message: [symbol-as-weakmap-key] Add tests to check weak collection size ... after gc. This CL also adds a runtime test function GetWeakCollectionSize to get the weak collection size. Bug: v8:12947 Change-Id: I4aff39165a54b63b3d690bfea71c2a439da01d00 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3905071 Reviewed-by: Marja Hölttä <marja@chromium.org> Commit-Queue: 王澳 <wangao.james@bytedance.com> Cr-Commit-Position: refs/heads/main@{#83464} Refs: v8/v8@7f5daed PR-URL: #51004 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 1ce901b commit d4a530e

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.29',
39+
'v8_embedder_string': '-node.30',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/runtime/runtime-test.cc

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "src/logging/counters.h"
2828
#include "src/objects/heap-object-inl.h"
2929
#include "src/objects/js-array-inl.h"
30+
#include "src/objects/js-collection-inl.h"
3031
#include "src/objects/js-function-inl.h"
3132
#include "src/objects/js-regexp-inl.h"
3233
#include "src/objects/managed-inl.h"
@@ -1730,5 +1731,14 @@ RUNTIME_FUNCTION(Runtime_SharedGC) {
17301731
return ReadOnlyRoots(isolate).undefined_value();
17311732
}
17321733

1734+
RUNTIME_FUNCTION(Runtime_GetWeakCollectionSize) {
1735+
HandleScope scope(isolate);
1736+
DCHECK_EQ(1, args.length());
1737+
Handle<JSWeakCollection> collection = args.at<JSWeakCollection>(0);
1738+
1739+
return Smi::FromInt(
1740+
EphemeronHashTable::cast(collection->table()).NumberOfElements());
1741+
}
1742+
17331743
} // namespace internal
17341744
} // namespace v8

deps/v8/src/runtime/runtime.h

+1
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ namespace internal {
498498
F(GetInitializerFunction, 1, 1) \
499499
F(GetOptimizationStatus, 1, 1) \
500500
F(GetUndetectable, 0, 1) \
501+
F(GetWeakCollectionSize, 1, 1) \
501502
F(GlobalPrint, 1, 1) \
502503
F(HasDictionaryElements, 1, 1) \
503504
F(HasDoubleElements, 1, 1) \

deps/v8/test/mjsunit/harmony/symbol-as-weakmap-key.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// Flags: --harmony-symbol-as-weakmap-key --expose-gc
5+
// Flags: --harmony-symbol-as-weakmap-key --expose-gc --allow-natives-syntax --noincremental-marking
66

77
(function TestWeakMapWithNonRegisteredSymbolKey() {
88
const key = Symbol('123');
@@ -28,16 +28,17 @@
2828
const outerKey = Symbol('234');
2929
const outerValue = 1;
3030
map.set(outerKey, outerValue);
31-
{
31+
(function () {
3232
const innerKey = Symbol('123');
3333
const innerValue = 1;
3434
map.set(innerKey, innerValue);
3535
assertTrue(map.has(innerKey));
3636
assertSame(innerValue, map.get(innerKey));
37-
}
37+
})();
3838
gc();
3939
assertTrue(map.has(outerKey));
4040
assertSame(outerValue, map.get(outerKey));
41+
assertEquals(1, %GetWeakCollectionSize(map));
4142
})();
4243

4344
(function TestWeakMapWithRegisteredSymbolKey() {
@@ -74,13 +75,14 @@
7475
const set = new WeakSet();
7576
const outerKey = Symbol('234');
7677
set.add(outerKey);
77-
{
78+
(function () {
7879
const innerKey = Symbol('123');
7980
set.add(innerKey);
8081
assertTrue(set.has(innerKey));
81-
}
82-
gc();
82+
})();
8383
assertTrue(set.has(outerKey));
84+
gc();
85+
assertEquals(1, %GetWeakCollectionSize(set));
8486
})();
8587

8688
(function TestWeakSetWithRegisteredSymbolKey() {

0 commit comments

Comments
 (0)