@@ -3479,7 +3479,7 @@ void MarkCompactCollector::ClearJSWeakRefs() {
3479
3479
};
3480
3480
HeapObject target = HeapObject::cast (weak_cell.target ());
3481
3481
if (!non_atomic_marking_state ()->IsBlackOrGrey (target)) {
3482
- DCHECK (! target.IsUndefined ());
3482
+ DCHECK (target.CanBeHeldWeakly ());
3483
3483
// The value of the WeakCell is dead.
3484
3484
JSFinalizationRegistry finalization_registry =
3485
3485
JSFinalizationRegistry::cast (weak_cell.finalization_registry ());
@@ -3501,6 +3501,7 @@ void MarkCompactCollector::ClearJSWeakRefs() {
3501
3501
3502
3502
HeapObject unregister_token = weak_cell.unregister_token ();
3503
3503
if (!non_atomic_marking_state ()->IsBlackOrGrey (unregister_token)) {
3504
+ DCHECK (unregister_token.CanBeHeldWeakly ());
3504
3505
// The unregister token is dead. Remove any corresponding entries in the
3505
3506
// key map. Multiple WeakCell with the same token will have all their
3506
3507
// unregister_token field set to undefined when processing the first
@@ -3509,7 +3510,7 @@ void MarkCompactCollector::ClearJSWeakRefs() {
3509
3510
JSFinalizationRegistry finalization_registry =
3510
3511
JSFinalizationRegistry::cast (weak_cell.finalization_registry ());
3511
3512
finalization_registry.RemoveUnregisterToken (
3512
- JSReceiver::cast ( unregister_token) , isolate (),
3513
+ unregister_token, isolate (),
3513
3514
JSFinalizationRegistry::kKeepMatchedCellsInRegistry ,
3514
3515
gc_notify_updated_slot);
3515
3516
} else {
0 commit comments