◐ Shell
clean mode source ↗

deps: V8: cherry-pick 1fada6b36f8d · nodejs/node@b0e8889

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
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();