Skip to content

Commit b0e8889

Browse files
joyeecheungrichardlau
authored andcommitted
deps: V8: cherry-pick 1fada6b36f8d
Original commit message: [symbol-as-weakmap-key] Fix DCHECKs when clearing JS weakrefs Bug: chromium:1372500, v8:12947 Fixed: chromium:1372500 Change-Id: Id6330de5886e4ea72544b307c358e2190ea47d9c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3942586 Reviewed-by: Anton Bikineev <[email protected]> Commit-Queue: Shu-yu Guo <[email protected]> Cr-Commit-Position: refs/heads/main@{#83632} Refs: v8/v8@1fada6b PR-URL: #51004 Reviewed-By: Chengzhong Wu <[email protected]>
1 parent d87a810 commit b0e8889

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
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.33',
39+
'v8_embedder_string': '-node.34',
4040

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

deps/v8/src/heap/mark-compact.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -3027,7 +3027,7 @@ void MarkCompactCollector::ClearJSWeakRefs() {
30273027
};
30283028
HeapObject target = HeapObject::cast(weak_cell.target());
30293029
if (!non_atomic_marking_state()->IsBlackOrGrey(target)) {
3030-
DCHECK(!target.IsUndefined());
3030+
DCHECK(target.CanBeHeldWeakly());
30313031
// The value of the WeakCell is dead.
30323032
JSFinalizationRegistry finalization_registry =
30333033
JSFinalizationRegistry::cast(weak_cell.finalization_registry());
@@ -3049,6 +3049,7 @@ void MarkCompactCollector::ClearJSWeakRefs() {
30493049

30503050
HeapObject unregister_token = weak_cell.unregister_token();
30513051
if (!non_atomic_marking_state()->IsBlackOrGrey(unregister_token)) {
3052+
DCHECK(unregister_token.CanBeHeldWeakly());
30523053
// The unregister token is dead. Remove any corresponding entries in the
30533054
// key map. Multiple WeakCell with the same token will have all their
30543055
// unregister_token field set to undefined when processing the first
@@ -3057,7 +3058,7 @@ void MarkCompactCollector::ClearJSWeakRefs() {
30573058
JSFinalizationRegistry finalization_registry =
30583059
JSFinalizationRegistry::cast(weak_cell.finalization_registry());
30593060
finalization_registry.RemoveUnregisterToken(
3060-
JSReceiver::cast(unregister_token), isolate(),
3061+
unregister_token, isolate(),
30613062
JSFinalizationRegistry::kKeepMatchedCellsInRegistry,
30623063
gc_notify_updated_slot);
30633064
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2022 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: --harmony-symbol-as-weakmap-key --expose-gc
6+
7+
// Register an object in a FinalizationRegistry with a Symbol as the unregister
8+
// token.
9+
let fr = new FinalizationRegistry(function () {});
10+
(function register() {
11+
fr.register({}, "holdings", Symbol('unregisterToken'));
12+
})();
13+
// The unregister token should be dead, trigger its collection.
14+
gc();

0 commit comments

Comments
 (0)