Debian Codegraph @

js/src/gc/StableCellHasher.h

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef gc_StableCellHasher_h
8 #define gc_StableCellHasher_h
9
10 #include "js/RootingAPI.h"
11 #include "js/TypeDecls.h"
12
13 // StableCellHasher itself is defined in js/public/RootingAPI.h.
14
15 namespace js::gc {
16
17 struct Cell;
18
19 // Gets an existing UID in |uidp| if one exists.
20 [[nodiscard]] bool MaybeGetUniqueId(Cell* cell, uint64_t* uidp);
21
22 // Puts an existing UID in |uidp|, or creates a new UID for this Cell and
23 // puts that into |uidp|. Returns false on OOM.
24 [[nodiscard]] bool GetOrCreateUniqueId(Cell* cell, uint64_t* uidp);
25
26 uint64_t GetUniqueIdInfallible(Cell* cell);
27
28 // Return true if this cell has a UID associated with it.
29 [[nodiscard]] bool HasUniqueId(Cell* cell);
30
31 // Transfer an id from another cell. This must only be called on behalf of a
32 // moving GC. This method is infallible.
33 void TransferUniqueId(Cell* tgt, Cell* src);
34
35 // Remove any unique id associated with this Cell.
36 void RemoveUniqueId(Cell* cell);
37
38 // Used to restore unique ID after JSObject::swap.
39 bool SetOrUpdateUniqueId(JSContext* cx, Cell* cell, uint64_t uid);
40
41 } // namespace js::gc
42
43 #endif // gc_StableCellHasher_h