tor-browser

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

commit 5eff2e1b632dc1c6bec60e6032bf7690acea8d2b
parent 08382f067af085ff0c3e7e597bb49df771b4e1ad
Author: Jan de Mooij <jdemooij@mozilla.com>
Date:   Tue, 18 Nov 2025 12:03:02 +0000

Bug 1992990 part 1 - Add default constructor for OffthreadGCPtr. r=iain

It's already possible to pass `nullptr` to the other constructor (and then call `init()` later),
but having this constructor without arguments simplifies later patches where we have an array of
`OffthreadGCPtr`s.

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

Diffstat:
Mjs/src/jit/OffthreadSnapshot.h | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/js/src/jit/OffthreadSnapshot.h b/js/src/jit/OffthreadSnapshot.h @@ -15,12 +15,14 @@ // These pointers must be traced using TraceOffthreadGCPtr. template <typename T> class OffthreadGCPtr { - // Note: no pre-barrier is needed because after being initialized - // this is a constant. No post-barrier is needed because the value - // is always tenured. - T ptr_; + // Note: no pre-barrier is needed because after being initialized to a + // non-empty OffthreadGCPtr this is a constant. No post-barrier is needed + // because the value is always tenured. + T ptr_ = JS::SafelyInitialized<T>::create(); public: + constexpr OffthreadGCPtr() = default; + explicit OffthreadGCPtr(const T& ptr) : ptr_(ptr) { MOZ_ASSERT(JS::GCPolicy<T>::isTenured(ptr), "OffthreadSnapshot pointers must be tenured"); @@ -39,7 +41,6 @@ class OffthreadGCPtr { } private: - OffthreadGCPtr() = delete; void operator=(OffthreadGCPtr<T>& other) = delete; };