1// Copyright 2019 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 5bitfield struct FinalizationRegistryFlags extends uint31 { 6 scheduled_for_cleanup: bool: 1 bit; 7} 8 9extern class JSFinalizationRegistry extends JSObject { 10 native_context: NativeContext; 11 cleanup: Callable; 12 active_cells: Undefined|WeakCell; 13 cleared_cells: Undefined|WeakCell; 14 key_map: Object; 15 // For the linked list of FinalizationRegistries that need cleanup. This 16 // link is weak. 17 next_dirty: Undefined|JSFinalizationRegistry; 18 flags: SmiTagged<FinalizationRegistryFlags>; 19} 20 21@generateCppClass 22extern class WeakCell extends HeapObject { 23 finalization_registry: Undefined|JSFinalizationRegistry; 24 target: Undefined|JSReceiver; 25 unregister_token: JSAny; 26 holdings: JSAny; 27 28 // For storing doubly linked lists of WeakCells in JSFinalizationRegistry's 29 // "active_cells" and "cleared_cells" lists. 30 prev: Undefined|WeakCell; 31 next: Undefined|WeakCell; 32 33 // For storing doubly linked lists of WeakCells per key in 34 // JSFinalizationRegistry's key-based hashmap. The key is the identity hash 35 // of unregister_token. WeakCell also needs to know its token, so that we 36 // can remove its corresponding key from the key_map when we remove the last 37 // WeakCell associated with it or when the unregister_token dies. The 38 // unregister token is stored above, after target, as both are weak. 39 key_list_prev: Undefined|WeakCell; 40 key_list_next: Undefined|WeakCell; 41} 42 43@generateCppClass 44extern class JSWeakRef extends JSObject { 45 target: Undefined|JSReceiver; 46} 47