tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit af28e09fe8cff67fcf8298d81295b3626ce9c3a9
parent 37af6778fbbb266668965578d72ccddebc46f7f7
Author: Chris Peterson <cpeterson@mozilla.com>
Date:   Tue,  9 Dec 2025 00:01:29 +0000

Bug 2002864 - Replace MOZ_CONSTINIT with C++20 constinit in mozjemalloc. r=pbone

Differential Revision: https://phabricator.services.mozilla.com/D274505

Diffstat:
Mmemory/build/BaseAlloc.cpp | 2+-
Mmemory/build/Chunk.cpp | 3+--
Mmemory/build/Mutex.h | 2+-
Mmemory/build/mozjemalloc.cpp | 6+++---
4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/memory/build/BaseAlloc.cpp b/memory/build/BaseAlloc.cpp @@ -10,7 +10,7 @@ using namespace mozilla; -MOZ_CONSTINIT BaseAlloc sBaseAlloc; +constinit BaseAlloc sBaseAlloc; // Initialize base allocation data structures. void BaseAlloc::Init() MOZ_REQUIRES(gInitLock) { mMutex.Init(); } diff --git a/memory/build/Chunk.cpp b/memory/build/Chunk.cpp @@ -494,8 +494,7 @@ void* pages_mmap_aligned(size_t size, size_t alignment, return ret; } -MOZ_CONSTINIT AddressRadixTree<(sizeof(void*) << 3) - LOG2(kChunkSize)> - gChunkRTree; +constinit AddressRadixTree<(sizeof(void*) << 3) - LOG2(kChunkSize)> gChunkRTree; // Protects chunk-related data structures. static Mutex chunks_mtx; diff --git a/memory/build/Mutex.h b/memory/build/Mutex.h @@ -44,7 +44,7 @@ OS_EXPORT OS_NOTHROW OS_NONNULL_ALL void os_unfair_lock_lock_with_options( // locks. // // A constexpr constructor is provided so that Mutex can be part of something -// that is MOZ_CONSTINIT, but the mutex won't be initialised, you must still +// that is constinit, but the mutex won't be initialised, you must still // call Init() before the mutex can be used. struct MOZ_CAPABILITY("mutex") Mutex { #if defined(XP_WIN) diff --git a/memory/build/mozjemalloc.cpp b/memory/build/mozjemalloc.cpp @@ -175,7 +175,7 @@ using namespace mozilla; // while another thread accesses it. This means that clearing this value or // otherwise dropping a reference to it must not be done while holding an // arena's lock. -MOZ_CONSTINIT static RefPtr<MallocProfilerCallbacks> sCallbacks; +constinit static RefPtr<MallocProfilerCallbacks> sCallbacks; #endif // *************************************************************************** @@ -203,7 +203,7 @@ static Atomic<bool, MemoryOrdering::Relaxed> malloc_initialized; #endif // This lock must be held while bootstrapping us. -MOZ_CONSTINIT StaticMutex gInitLock MOZ_UNANNOTATED; +constinit StaticMutex gInitLock MOZ_UNANNOTATED; // *************************************************************************** // Statistics data structures. @@ -1219,7 +1219,7 @@ class ArenaCollection { Atomic<bool> mIsDeferredPurgeEnabled; }; -MOZ_CONSTINIT static ArenaCollection gArenas; +constinit static ArenaCollection gArenas; // Protects huge allocation-related data structures. static Mutex huge_mtx;