no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / js / src / gc / StableCellHasher.h
blob45cefd76e968b2fd8d2f62ce56ff6744181fd571
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/. */
7 #ifndef gc_StableCellHasher_h
8 #define gc_StableCellHasher_h
10 #include "js/RootingAPI.h"
11 #include "js/TypeDecls.h"
13 // StableCellHasher itself is defined in js/public/RootingAPI.h.
15 namespace js::gc {
17 struct Cell;
19 // Gets an existing UID in |uidp| if one exists.
20 [[nodiscard]] bool MaybeGetUniqueId(Cell* cell, uint64_t* uidp);
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);
26 uint64_t GetUniqueIdInfallible(Cell* cell);
28 // Return true if this cell has a UID associated with it.
29 [[nodiscard]] bool HasUniqueId(Cell* cell);
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);
35 // Remove any unique id associated with this Cell.
36 void RemoveUniqueId(Cell* cell);
38 // Used to restore unique ID after JSObject::swap.
39 bool SetOrUpdateUniqueId(JSContext* cx, Cell* cell, uint64_t uid);
41 } // namespace js::gc
43 #endif // gc_StableCellHasher_h