diff --git a/accessible/android/Platform.cpp b/accessible/android/Platform.cpp index 15321ac06aea..968026f73228 100644 --- a/accessible/android/Platform.cpp +++ b/accessible/android/Platform.cpp @@ -19,7 +19,7 @@ using namespace mozilla; using namespace mozilla::a11y; -static nsTHashMap sLocalizedStrings; +MOZ_RUNINIT static nsTHashMap sLocalizedStrings; void a11y::PlatformInit() { nsresult rv = NS_OK; diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index f9bec41d2d32..4b8a1fce7e39 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -1498,7 +1498,7 @@ LocalAccessible* nsAccessibilityService::CreateAccessible( # include "mozilla/Monitor.h" # include "mozilla/Maybe.h" -static Maybe sAndroidMonitor; +MOZ_RUNINIT static Maybe sAndroidMonitor; mozilla::Monitor& nsAccessibilityService::GetAndroidMonitor() { if (!sAndroidMonitor.isSome()) { diff --git a/accessible/mac/MOXTextMarkerDelegate.mm b/accessible/mac/MOXTextMarkerDelegate.mm index 3e1e451ddd69..a2f6faf020ce 100644 --- a/accessible/mac/MOXTextMarkerDelegate.mm +++ b/accessible/mac/MOXTextMarkerDelegate.mm @@ -18,8 +18,8 @@ using namespace mozilla::a11y; #define PREF_ACCESSIBILITY_MAC_DEBUG "accessibility.mac.debug" -static nsTHashMap, - MOXTextMarkerDelegate*> +MOZ_RUNINIT static nsTHashMap, + MOXTextMarkerDelegate*> sDelegates; @implementation MOXTextMarkerDelegate diff --git a/accessible/mac/mozAccessible.mm b/accessible/mac/mozAccessible.mm index 4c27e771c0ae..42b5e6384ea7 100644 --- a/accessible/mac/mozAccessible.mm +++ b/accessible/mac/mozAccessible.mm @@ -411,7 +411,7 @@ struct RoleDescrMap { const nsString description; }; -static const RoleDescrMap sRoleDescrMap[] = { +MOZ_RUNINIT static const RoleDescrMap sRoleDescrMap[] = { {@"AXApplicationAlert", u"alert"_ns}, {@"AXApplicationAlertDialog", u"alertDialog"_ns}, {@"AXApplicationDialog", u"dialog"_ns}, diff --git a/accessible/windows/msaa/MsaaAccessible.cpp b/accessible/windows/msaa/MsaaAccessible.cpp index 294c12462a98..6da568e13bb7 100644 --- a/accessible/windows/msaa/MsaaAccessible.cpp +++ b/accessible/windows/msaa/MsaaAccessible.cpp @@ -45,7 +45,7 @@ static const GUID IID_MsaaAccessible = { 0x4afc, {0xa3, 0x2c, 0xd6, 0xb5, 0xc0, 0x10, 0x04, 0x6b}}; -MsaaIdGenerator MsaaAccessible::sIDGen; +MOZ_RUNINIT MsaaIdGenerator MsaaAccessible::sIDGen; ITypeInfo* MsaaAccessible::gTypeInfo = nullptr; /* static */ diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp index cae769cbb647..3ca37324b1bb 100644 --- a/browser/app/nsBrowserApp.cpp +++ b/browser/app/nsBrowserApp.cpp @@ -158,7 +158,7 @@ static bool IsArg(const char* arg, const char* s) { return false; } -Bootstrap::UniquePtr gBootstrap; +MOZ_RUNINIT Bootstrap::UniquePtr gBootstrap; static int do_main(int argc, char* argv[], char* envp[]) { // Allow firefox.exe to launch XULRunner apps via -app diff --git a/browser/app/winlauncher/freestanding/SafeThreadLocal.h b/browser/app/winlauncher/freestanding/SafeThreadLocal.h index e4b869f649d0..ac6fe9b7efc9 100644 --- a/browser/app/winlauncher/freestanding/SafeThreadLocal.h +++ b/browser/app/winlauncher/freestanding/SafeThreadLocal.h @@ -78,8 +78,7 @@ class SafeThreadLocal final { }; template -MOZ_THREAD_LOCAL(T) -SafeThreadLocal::sThreadLocal; +MOZ_GLOBINIT MOZ_THREAD_LOCAL(T) SafeThreadLocal::sThreadLocal; template T SafeThreadLocal::sGlobal = nullptr; diff --git a/browser/app/winlauncher/test/TestCrossProcessWin.cpp b/browser/app/winlauncher/test/TestCrossProcessWin.cpp index a129df721d6b..eaafb2f7f961 100644 --- a/browser/app/winlauncher/test/TestCrossProcessWin.cpp +++ b/browser/app/winlauncher/test/TestCrossProcessWin.cpp @@ -289,9 +289,9 @@ static DynamicBlockList ConvertStaticBlocklistToDynamic( return blockList; } -const DynamicBlockList gFullList = +MOZ_RUNINIT const DynamicBlockList gFullList = ConvertStaticBlocklistToDynamic(gWindowsDllBlocklist); -const DynamicBlockList gShortList = +MOZ_RUNINIT const DynamicBlockList gShortList = ConvertStaticBlocklistToDynamic(kDllBlocklistShort); static bool TestDependentModules() { diff --git a/caps/tests/gtest/TestPrincipalAttributes.cpp b/caps/tests/gtest/TestPrincipalAttributes.cpp index bc0bff90f6e2..9ed1f3199b67 100644 --- a/caps/tests/gtest/TestPrincipalAttributes.cpp +++ b/caps/tests/gtest/TestPrincipalAttributes.cpp @@ -29,7 +29,7 @@ TEST_P(PrincipalAttributesTest, PrincipalAttributesTest) { ASSERT_EQ(principal->GetIsIpAddress(), GetParam().expectIsIpAddress); } -static const PrincipalAttributesParam kAttributes[] = { +MOZ_RUNINIT static const PrincipalAttributesParam kAttributes[] = { {nsAutoCString("https://mozilla.com"), false}, {nsAutoCString("https://127.0.0.1"), true}, {nsAutoCString("https://[::1]"), true}, diff --git a/docs/code-quality/coding-style/coding_style_cpp.rst b/docs/code-quality/coding-style/coding_style_cpp.rst index eb47cdde17c3..06684e469c84 100644 --- a/docs/code-quality/coding-style/coding_style_cpp.rst +++ b/docs/code-quality/coding-style/coding_style_cpp.rst @@ -394,6 +394,11 @@ C/C++ practices - One-argument constructors, that are not copy or move constructors, should generally be marked explicit. Exceptions should be annotated with ``MOZ_IMPLICIT``. +- Global variables with runtimle initialization should be avoided. Flagging + them as ``constexpr`` or ``MOZ_CONSTINIT`` is a good way to make sure the + initialization happens at compile-time. If runtime initialization cannot be + avoided, use the attribute ``MOZ_RUNINIT`` to identify those and tell the + linter to ignore that variable. - Use ``char32_t`` as the return type or argument type of a method that returns or takes as argument a single Unicode scalar value. (Don't use UTF-32 strings, though.) diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index 3715938e0652..fa126d84f9b8 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -82,7 +82,7 @@ struct ListHelper { LinkedList mList; }; -static ListHelper gSHistoryList; +MOZ_RUNINIT static ListHelper gSHistoryList; // Max viewers allowed total, across all SHistory objects - negative default // means we will calculate how many viewers to cache based on total memory int32_t nsSHistory::sHistoryMaxTotalViewers = -1; diff --git a/dom/base/CCGCScheduler.cpp b/dom/base/CCGCScheduler.cpp index 88d8cb636215..dbb7db657859 100644 --- a/dom/base/CCGCScheduler.cpp +++ b/dom/base/CCGCScheduler.cpp @@ -15,20 +15,25 @@ /* Globally initialized constants */ namespace mozilla { -const TimeDuration kOneMinute = TimeDuration::FromSeconds(60.0f); -const TimeDuration kCCDelay = TimeDuration::FromSeconds(6); -const TimeDuration kCCSkippableDelay = TimeDuration::FromMilliseconds(250); -const TimeDuration kTimeBetweenForgetSkippableCycles = +MOZ_RUNINIT const TimeDuration kOneMinute = TimeDuration::FromSeconds(60.0f); +MOZ_RUNINIT const TimeDuration kCCDelay = TimeDuration::FromSeconds(6); +MOZ_RUNINIT const TimeDuration kCCSkippableDelay = + TimeDuration::FromMilliseconds(250); +MOZ_RUNINIT const TimeDuration kTimeBetweenForgetSkippableCycles = TimeDuration::FromSeconds(2); -const TimeDuration kForgetSkippableSliceDuration = +MOZ_RUNINIT const TimeDuration kForgetSkippableSliceDuration = TimeDuration::FromMilliseconds(2); -const TimeDuration kICCIntersliceDelay = TimeDuration::FromMilliseconds(250); -const TimeDuration kICCSliceBudget = TimeDuration::FromMilliseconds(3); -const TimeDuration kIdleICCSliceBudget = TimeDuration::FromMilliseconds(2); -const TimeDuration kMaxICCDuration = TimeDuration::FromSeconds(2); +MOZ_RUNINIT const TimeDuration kICCIntersliceDelay = + TimeDuration::FromMilliseconds(250); +MOZ_RUNINIT const TimeDuration kICCSliceBudget = + TimeDuration::FromMilliseconds(3); +MOZ_RUNINIT const TimeDuration kIdleICCSliceBudget = + TimeDuration::FromMilliseconds(2); +MOZ_RUNINIT const TimeDuration kMaxICCDuration = TimeDuration::FromSeconds(2); -const TimeDuration kCCForced = kOneMinute * 2; -const TimeDuration kMaxCCLockedoutTime = TimeDuration::FromSeconds(30); +MOZ_RUNINIT const TimeDuration kCCForced = kOneMinute * 2; +MOZ_RUNINIT const TimeDuration kMaxCCLockedoutTime = + TimeDuration::FromSeconds(30); } // namespace mozilla /* diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 168d0b63f24f..b97b7e8e280d 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -14785,7 +14785,7 @@ class PendingFullscreenChangeList { }; /* static */ -LinkedList PendingFullscreenChangeList::sList; +MOZ_RUNINIT LinkedList PendingFullscreenChangeList::sList; size_t Document::CountFullscreenElements() const { size_t count = 0; diff --git a/dom/base/FuzzingFunctions.cpp b/dom/base/FuzzingFunctions.cpp index c09e11e4c144..53b131e6d704 100644 --- a/dom/base/FuzzingFunctions.cpp +++ b/dom/base/FuzzingFunctions.cpp @@ -89,7 +89,7 @@ struct ModifierKey final { mLockable(aLockable) {} }; -static const ModifierKey kModifierKeys[] = { +MOZ_RUNINIT static const ModifierKey kModifierKeys[] = { ModifierKey(MODIFIER_ALT, KEY_NAME_INDEX_Alt, false), ModifierKey(MODIFIER_ALTGRAPH, KEY_NAME_INDEX_AltGraph, false), ModifierKey(MODIFIER_CONTROL, KEY_NAME_INDEX_Control, false), diff --git a/dom/base/PlacesObservers.cpp b/dom/base/PlacesObservers.cpp index b5211733ea05..54290fd63ee1 100644 --- a/dom/base/PlacesObservers.cpp +++ b/dom/base/PlacesObservers.cpp @@ -54,9 +54,10 @@ struct ListenerCollection { }; template -StaticAutoPtr> ListenerCollection::gListeners; +MOZ_GLOBINIT StaticAutoPtr> ListenerCollection::gListeners; template -StaticAutoPtr> ListenerCollection::gListenersToRemove; +MOZ_GLOBINIT StaticAutoPtr> + ListenerCollection::gListenersToRemove; using JSListeners = ListenerCollection>; using WeakJSListeners = ListenerCollection>; @@ -66,7 +67,8 @@ using WeakNativeListeners = // Even if NotifyListeners is called any timing, we mange the notifications with // adding to this queue, then sending in sequence. This avoids sending nested // notifications while previous ones are still being sent. -static nsTArray>> gNotificationQueue; +MOZ_RUNINIT static nsTArray>> + gNotificationQueue; uint32_t GetEventTypeFlag(PlacesEventType aEventType) { if (aEventType == PlacesEventType::None) { diff --git a/dom/base/PointerLockManager.cpp b/dom/base/PointerLockManager.cpp index f574ed26d83f..fa92858dbf23 100644 --- a/dom/base/PointerLockManager.cpp +++ b/dom/base/PointerLockManager.cpp @@ -34,10 +34,10 @@ using mozilla::dom::Element; using mozilla::dom::WindowContext; // Reference to the pointer locked element. -static nsWeakPtr sLockedElement; +MOZ_RUNINIT static nsWeakPtr sLockedElement; // Reference to the document which requested pointer lock. -static nsWeakPtr sLockedDoc; +MOZ_RUNINIT static nsWeakPtr sLockedDoc; // Reference to the BrowserParent requested pointer lock. static BrowserParent* sLockedRemoteTarget = nullptr; diff --git a/dom/base/ScrollingMetrics.cpp b/dom/base/ScrollingMetrics.cpp index 78dc6070235c..73b67a082bac 100644 --- a/dom/base/ScrollingMetrics.cpp +++ b/dom/base/ScrollingMetrics.cpp @@ -13,7 +13,7 @@ namespace mozilla { static TimeStamp gScrollingStartTime; static TimeStamp gScrollingEndTime; static uint32_t gScrollDistanceCSSPixels = 0; -static dom::InteractionData gScrollingInteraction = {}; +MOZ_RUNINIT static dom::InteractionData gScrollingInteraction = {}; void ScrollingMetrics::OnScrollingInteractionEnded() { // We are only interested in content process scrolling diff --git a/dom/base/fuzztest/FuzzStructuredClone.cpp b/dom/base/fuzztest/FuzzStructuredClone.cpp index 5473df2c8e84..d4088b18d8c0 100644 --- a/dom/base/fuzztest/FuzzStructuredClone.cpp +++ b/dom/base/fuzztest/FuzzStructuredClone.cpp @@ -22,7 +22,7 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::dom::ipc; -JS::PersistentRooted global; +MOZ_RUNINIT JS::PersistentRooted global; static int FuzzingInitDomSC(int* argc, char*** argv) { JSObject* simpleGlobal = diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index e92c3fcfe368..848b7d717711 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -219,7 +219,7 @@ already_AddRefed NativeInputRunnable::Create( } // unnamed namespace -LinkedList OldWindowSize::sList; +MOZ_RUNINIT LinkedList OldWindowSize::sList; NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWindowUtils) diff --git a/dom/base/test/gtest/TestScheduler.cpp b/dom/base/test/gtest/TestScheduler.cpp index 2e580cc0c156..75fa4b136801 100644 --- a/dom/base/test/gtest/TestScheduler.cpp +++ b/dom/base/test/gtest/TestScheduler.cpp @@ -11,11 +11,12 @@ using namespace mozilla; -static TimeDuration kOneSecond = TimeDuration::FromSeconds(1); -static TimeDuration kTenthSecond = TimeDuration::FromSeconds(0.1); -static TimeDuration kFrameDuration = TimeDuration::FromSeconds(1.0 / 60.0); +MOZ_RUNINIT static TimeDuration kOneSecond = TimeDuration::FromSeconds(1); +MOZ_RUNINIT static TimeDuration kTenthSecond = TimeDuration::FromSeconds(0.1); +MOZ_RUNINIT static TimeDuration kFrameDuration = + TimeDuration::FromSeconds(1.0 / 60.0); -static mozilla::TimeStamp sNow = TimeStamp::Now(); +MOZ_RUNINIT static mozilla::TimeStamp sNow = TimeStamp::Now(); static mozilla::TimeStamp AdvanceTime(TimeDuration aDuration) { sNow += aDuration; @@ -328,10 +329,10 @@ static bool BasicScenario(CCGCScheduler& aScheduler, TestGC* aTestGC, return true; } -static CCGCScheduler scheduler; -static TestGC gc(scheduler); -static TestIdleCC ccIdle(scheduler); -static TestNonIdleCC ccNonIdle(scheduler); +MOZ_RUNINIT static CCGCScheduler scheduler; +MOZ_RUNINIT static TestGC gc(scheduler); +MOZ_RUNINIT static TestIdleCC ccIdle(scheduler); +MOZ_RUNINIT static TestNonIdleCC ccNonIdle(scheduler); TEST(TestScheduler, Idle) { diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index f213869dedd8..bb48e2bd26bb 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -2618,7 +2618,7 @@ class PropertyDefiner: specType = "const " + specType arrays = fill( """ - static ${specType} ${name}_specs[] = { + MOZ_GLOBINIT static ${specType} ${name}_specs[] = { ${specs} }; diff --git a/dom/bindings/DOMJSProxyHandler.cpp b/dom/bindings/DOMJSProxyHandler.cpp index a0f93afcb937..49ace4cc9a60 100644 --- a/dom/bindings/DOMJSProxyHandler.cpp +++ b/dom/bindings/DOMJSProxyHandler.cpp @@ -71,7 +71,7 @@ struct SetDOMProxyInformation { } }; -SetDOMProxyInformation gSetDOMProxyInformation; +MOZ_RUNINIT SetDOMProxyInformation gSetDOMProxyInformation; static inline void CheckExpandoObject(JSObject* proxy, const JS::Value& expando) { diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 13ed8c1bc14d..da3a3cce91b7 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -102,7 +102,7 @@ WebGLContextOptions::WebGLContextOptions() { } StaticMutex WebGLContext::sLruMutex; -std::list WebGLContext::sLru; +MOZ_RUNINIT std::list WebGLContext::sLru; WebGLContext::LruPosition::LruPosition() { StaticMutexAutoLock lock(sLruMutex); diff --git a/dom/canvas/WebGLFormats.cpp b/dom/canvas/WebGLFormats.cpp index e27d9d133557..355ddfbe9706 100644 --- a/dom/canvas/WebGLFormats.cpp +++ b/dom/canvas/WebGLFormats.cpp @@ -85,8 +85,9 @@ static inline auto FindPtrOrNull(C& container, const K2& key) { ////////////////////////////////////////////////////////////////////////////////////////// -std::map gCompressedFormatInfoMap; -std::map gFormatInfoMap; +MOZ_RUNINIT std::map + gCompressedFormatInfoMap; +MOZ_RUNINIT std::map gFormatInfoMap; static inline const CompressedFormatInfo* GetCompressedFormatInfo( EffectiveFormat format) { diff --git a/dom/canvas/WebGLTexture.cpp b/dom/canvas/WebGLTexture.cpp index db8906f7f508..62ad89b51c0d 100644 --- a/dom/canvas/WebGLTexture.cpp +++ b/dom/canvas/WebGLTexture.cpp @@ -25,7 +25,7 @@ namespace mozilla { namespace webgl { -/*static*/ const ImageInfo ImageInfo::kUndefined; +MOZ_RUNINIT /*static*/ const ImageInfo ImageInfo::kUndefined; size_t ImageInfo::MemoryUsage() const { if (!IsDefined()) return 0; diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp index 892576f6dabc..9ad7554c006e 100644 --- a/dom/crypto/WebCryptoTask.cpp +++ b/dom/crypto/WebCryptoTask.cpp @@ -26,7 +26,7 @@ // Template taken from security/nss/lib/util/templates.c // This (or SGN_EncodeDigestInfo) would ideally be exported // by NSS and until that happens we have to keep our own copy. -const SEC_ASN1Template SGN_DigestInfoTemplate[] = { +MOZ_GLOBINIT const SEC_ASN1Template SGN_DigestInfoTemplate[] = { {SEC_ASN1_SEQUENCE, 0, NULL, sizeof(SGNDigestInfo)}, {SEC_ASN1_INLINE, offsetof(SGNDigestInfo, digestAlgorithm), SEC_ASN1_GET(SECOID_AlgorithmIDTemplate)}, diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 9fe5366469f5..632f1721ddba 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -142,12 +142,12 @@ static nsITimer* gUserInteractionTimer = nullptr; static nsITimerCallback* gUserInteractionTimerCallback = nullptr; static const double kCursorLoadingTimeout = 1000; // ms -static AutoWeakFrame gLastCursorSourceFrame; +MOZ_RUNINIT static AutoWeakFrame gLastCursorSourceFrame; static TimeStamp gLastCursorUpdateTime; static TimeStamp gTypingStartTime; static TimeStamp gTypingEndTime; static int32_t gTypingInteractionKeyPresses = 0; -static dom::InteractionData gTypingInteraction = {}; +MOZ_RUNINIT static dom::InteractionData gTypingInteraction = {}; static inline int32_t RoundDown(double aDouble) { return (aDouble > 0) ? static_cast(floor(aDouble)) @@ -559,14 +559,14 @@ bool EventStateManager::sNormalLMouseEventInProcess = false; int16_t EventStateManager::sCurrentMouseBtn = MouseButton::eNotPressed; EventStateManager* EventStateManager::sActiveESM = nullptr; EventStateManager* EventStateManager::sCursorSettingManager = nullptr; -AutoWeakFrame EventStateManager::sLastDragOverFrame = nullptr; +MOZ_RUNINIT AutoWeakFrame EventStateManager::sLastDragOverFrame = nullptr; LayoutDeviceIntPoint EventStateManager::sPreLockScreenPoint = LayoutDeviceIntPoint(0, 0); LayoutDeviceIntPoint EventStateManager::sLastRefPoint = kInvalidRefPoint; CSSIntPoint EventStateManager::sLastScreenPoint = CSSIntPoint(0, 0); LayoutDeviceIntPoint EventStateManager::sSynthCenteringPoint = kInvalidRefPoint; CSSIntPoint EventStateManager::sLastClientPoint = CSSIntPoint(0, 0); -nsCOMPtr EventStateManager::sDragOverContent = nullptr; +MOZ_RUNINIT nsCOMPtr EventStateManager::sDragOverContent = nullptr; EventStateManager::WheelPrefs* EventStateManager::WheelPrefs::sInstance = nullptr; diff --git a/dom/events/IMEStateManager.cpp b/dom/events/IMEStateManager.cpp index db8f5e8fcec2..2ca06d40923b 100644 --- a/dom/events/IMEStateManager.cpp +++ b/dom/events/IMEStateManager.cpp @@ -79,12 +79,12 @@ nsIWidget* IMEStateManager::sActiveInputContextWidget = nullptr; StaticRefPtr IMEStateManager::sActiveIMEContentObserver; TextCompositionArray* IMEStateManager::sTextCompositions = nullptr; InputContext::Origin IMEStateManager::sOrigin = InputContext::ORIGIN_MAIN; -InputContext IMEStateManager::sActiveChildInputContext; +MOZ_RUNINIT InputContext IMEStateManager::sActiveChildInputContext; bool IMEStateManager::sInstalledMenuKeyboardListener = false; bool IMEStateManager::sIsGettingNewIMEState = false; bool IMEStateManager::sCleaningUpForStoppingIMEStateManagement = false; bool IMEStateManager::sIsActive = false; -Maybe +MOZ_RUNINIT Maybe IMEStateManager::sPendingFocusedBrowserSwitchingData; class PseudoFocusChangeRunnable : public Runnable { diff --git a/dom/fetch/FetchParent.cpp b/dom/fetch/FetchParent.cpp index eabe44e8cc01..ac5e53da2279 100644 --- a/dom/fetch/FetchParent.cpp +++ b/dom/fetch/FetchParent.cpp @@ -49,7 +49,8 @@ NS_IMETHODIMP FetchParent::FetchParentCSPEventListener::OnCSPViolationEvent( return NS_OK; } -nsTHashMap> FetchParent::sActorTable; +MOZ_RUNINIT nsTHashMap> + FetchParent::sActorTable; /*static*/ RefPtr FetchParent::GetActorByID(const nsID& aID) { diff --git a/dom/fetch/FetchUtil.cpp b/dom/fetch/FetchUtil.cpp index 0b69306b2e84..2bcf6fcf2c68 100644 --- a/dom/fetch/FetchUtil.cpp +++ b/dom/fetch/FetchUtil.cpp @@ -655,7 +655,7 @@ class JSStreamConsumer final : public nsIInputStreamCallback, NS_IMPL_ISUPPORTS(JSStreamConsumer, nsIInputStreamCallback) // static -const nsCString FetchUtil::WasmAltDataType; +MOZ_RUNINIT const nsCString FetchUtil::WasmAltDataType; // static void FetchUtil::InitWasmAltDataType() { diff --git a/dom/fs/test/gtest/parent/TestFileSystemOriginInitialization.cpp b/dom/fs/test/gtest/parent/TestFileSystemOriginInitialization.cpp index f867086bc86d..5e7d389597aa 100644 --- a/dom/fs/test/gtest/parent/TestFileSystemOriginInitialization.cpp +++ b/dom/fs/test/gtest/parent/TestFileSystemOriginInitialization.cpp @@ -111,7 +111,7 @@ class TestFileSystemOriginInitialization : public FileSystemParentTest { FileSystemQuotaClientFactory::SetCustomFactory(nullptr); } - static inline RefPtr sQuotaClient; + MOZ_RUNINIT static inline RefPtr sQuotaClient; }; TEST_F(TestFileSystemOriginInitialization, EmptyOriginDirectory) { diff --git a/dom/gamepad/windows/WindowsGamepad.cpp b/dom/gamepad/windows/WindowsGamepad.cpp index fc7306bb745a..2bf76406fa5b 100644 --- a/dom/gamepad/windows/WindowsGamepad.cpp +++ b/dom/gamepad/windows/WindowsGamepad.cpp @@ -100,7 +100,7 @@ class WindowsGamepadService; // it will be created and destroyed by background thread and // used by gMonitorThread WindowsGamepadService* MOZ_NON_OWNING_REF gService = nullptr; -nsCOMPtr gMonitorThread = nullptr; +MOZ_RUNINIT nsCOMPtr gMonitorThread = nullptr; static bool sIsShutdown = false; class Gamepad { diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp index 6df1a568f3f5..eb65fe4730e1 100644 --- a/dom/ipc/BrowserParent.cpp +++ b/dom/ipc/BrowserParent.cpp @@ -255,7 +255,8 @@ class RequestingAccessKeyEventData { static int32_t sBrowserParentCount; }; int32_t RequestingAccessKeyEventData::sBrowserParentCount = 0; -Maybe RequestingAccessKeyEventData::sData; +MOZ_RUNINIT Maybe + RequestingAccessKeyEventData::sData; namespace dom { diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 23806da825e1..72d5d22a940d 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -369,7 +369,8 @@ namespace dom { LazyLogModule gProcessLog("Process"); -static std::map sCodecsSupported; +MOZ_RUNINIT static std::map + sCodecsSupported; /* static */ uint32_t ContentParent::sMaxContentProcesses = 0; diff --git a/dom/localstorage/ActorsParent.cpp b/dom/localstorage/ActorsParent.cpp index 600768cf955f..9364080bd8bb 100644 --- a/dom/localstorage/ActorsParent.cpp +++ b/dom/localstorage/ActorsParent.cpp @@ -2802,7 +2802,7 @@ using PrivateDatastoreHashtable = // event of an (unlikely) race where the private browsing windows are still // being torn down, will cause the Datastore to be discarded when the last // window actually goes away. -UniquePtr gPrivateDatastores; +MOZ_RUNINIT UniquePtr gPrivateDatastores; using DatabaseArray = nsTArray; diff --git a/dom/media/CubebUtils.cpp b/dom/media/CubebUtils.cpp index 0659dc5e7c00..bb662c974094 100644 --- a/dom/media/CubebUtils.cpp +++ b/dom/media/CubebUtils.cpp @@ -121,7 +121,7 @@ int sInCommunicationCount = 0; const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties"; -std::unordered_map +MOZ_RUNINIT std::unordered_map kTelemetryBackendLabel = { {"audiounit", LABELS_MEDIA_AUDIO_BACKEND::audiounit}, {"audiounit-rust", LABELS_MEDIA_AUDIO_BACKEND::audiounit_rust}, diff --git a/dom/media/ExternalEngineStateMachine.cpp b/dom/media/ExternalEngineStateMachine.cpp index 3a81a6816691..cb40d6b39873 100644 --- a/dom/media/ExternalEngineStateMachine.cpp +++ b/dom/media/ExternalEngineStateMachine.cpp @@ -130,7 +130,7 @@ class ProcessCrashMonitor final { } static inline StaticMutex sMutex; - static inline UniquePtr sCrashMonitor; + static inline MOZ_RUNINIT UniquePtr sCrashMonitor; static inline Atomic sIsShutdown{false}; uint32_t mCrashNums; diff --git a/dom/media/Tracing.cpp b/dom/media/Tracing.cpp index 2430ac9761f8..62a6e1b1177b 100644 --- a/dom/media/Tracing.cpp +++ b/dom/media/Tracing.cpp @@ -12,7 +12,7 @@ using namespace mozilla; using TracingPhase = mozilla::AsyncLogger::TracingPhase; -mozilla::AsyncLogger gAudioCallbackTraceLogger; +MOZ_RUNINIT mozilla::AsyncLogger gAudioCallbackTraceLogger; static std::atomic gTracingStarted(0); void StartAudioCallbackTracing() { diff --git a/dom/media/eme/clearkey/gtest/TestClearKeyUtils.cpp b/dom/media/eme/clearkey/gtest/TestClearKeyUtils.cpp index bff6d0f35660..0e2b2bd4581d 100644 --- a/dom/media/eme/clearkey/gtest/TestClearKeyUtils.cpp +++ b/dom/media/eme/clearkey/gtest/TestClearKeyUtils.cpp @@ -19,7 +19,7 @@ struct B64Test { bool shouldPass; }; -const B64Test tests[] = { +MOZ_RUNINIT const B64Test tests[] = { {"AAAAADk4AU4AAAAAAAAAAA", {0x0, 0x0, 0x0, 0x0, 0x39, 0x38, 0x1, 0x4e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, diff --git a/dom/media/gmp/ChromiumCDMAdapter.cpp b/dom/media/gmp/ChromiumCDMAdapter.cpp index a5e866f83edc..d1e5d34920d8 100644 --- a/dom/media/gmp/ChromiumCDMAdapter.cpp +++ b/dom/media/gmp/ChromiumCDMAdapter.cpp @@ -175,7 +175,7 @@ bool ChromiumCDMAdapter::Supports(int32_t aModuleVersion, #ifdef XP_WIN -static WindowsDllInterceptor sKernel32Intercept; +MOZ_RUNINIT static WindowsDllInterceptor sKernel32Intercept; typedef DWORD(WINAPI* QueryDosDeviceWFnPtr)(_In_opt_ LPCWSTR lpDeviceName, _Out_ LPWSTR lpTargetPath, diff --git a/dom/media/gtest/TestMediaDataEncoder.cpp b/dom/media/gtest/TestMediaDataEncoder.cpp index 4fd1dc4e74bf..4523c115520e 100644 --- a/dom/media/gtest/TestMediaDataEncoder.cpp +++ b/dom/media/gtest/TestMediaDataEncoder.cpp @@ -40,12 +40,12 @@ using namespace mozilla; static gfx::IntSize kImageSize(WIDTH, HEIGHT); // Set codec to avc1.42001E - Base profile, constraint 0, level 30. -const H264Specific kH264SpecificAnnexB(H264_PROFILE_BASE, - H264_LEVEL::H264_LEVEL_3, - H264BitStreamFormat::ANNEXB); -const H264Specific kH264SpecificAVCC(H264_PROFILE_BASE, - H264_LEVEL::H264_LEVEL_3, - H264BitStreamFormat::AVC); +MOZ_RUNINIT const H264Specific kH264SpecificAnnexB(H264_PROFILE_BASE, + H264_LEVEL::H264_LEVEL_3, + H264BitStreamFormat::ANNEXB); +MOZ_RUNINIT const H264Specific kH264SpecificAVCC(H264_PROFILE_BASE, + H264_LEVEL::H264_LEVEL_3, + H264BitStreamFormat::AVC); class MediaDataEncoderTest : public testing::Test { protected: diff --git a/dom/media/ipc/MFCDMParent.cpp b/dom/media/ipc/MFCDMParent.cpp index 52f0381cc6ce..42d4d48efb81 100644 --- a/dom/media/ipc/MFCDMParent.cpp +++ b/dom/media/ipc/MFCDMParent.cpp @@ -90,11 +90,12 @@ DEFINE_PROPERTYKEY(EME_CONTENTDECRYPTIONMODULE_ORIGIN_ID, 0x1218a3e2, 0xcfb0, } while (false) StaticMutex sFactoryMutex; -static nsTHashMap> +MOZ_RUNINIT static nsTHashMap> sFactoryMap; -static CopyableTArray sCapabilities; +MOZ_RUNINIT static CopyableTArray sCapabilities; StaticMutex sCapabilitesMutex; -static ComPtr sMediaEngineClassFactory; +MOZ_RUNINIT static ComPtr sMediaEngineClassFactory; // RAIIized PROPVARIANT. See // third_party/libwebrtc/modules/audio_device/win/core_audio_utility_win.h diff --git a/dom/media/ipc/MFCDMParent.h b/dom/media/ipc/MFCDMParent.h index 17cb49171573..542f0712fbd3 100644 --- a/dom/media/ipc/MFCDMParent.h +++ b/dom/media/ipc/MFCDMParent.h @@ -133,7 +133,8 @@ class MFCDMParent final : public PMFCDMParent { const RefPtr mManager; const RefPtr mManagerThread; - static inline nsTHashMap sRegisteredCDMs; + MOZ_RUNINIT static inline nsTHashMap + sRegisteredCDMs; static inline uint64_t sNextId = 1; const uint64_t mId; diff --git a/dom/media/ipc/RemoteDecoderManagerChild.cpp b/dom/media/ipc/RemoteDecoderManagerChild.cpp index 9ce14e65d679..002cdfd3e303 100644 --- a/dom/media/ipc/RemoteDecoderManagerChild.cpp +++ b/dom/media/ipc/RemoteDecoderManagerChild.cpp @@ -57,7 +57,7 @@ static EnumeratedArray, // Only modified on the main-thread, read on any thread. While it could be read // on the main thread directly, for clarity we force access via the DataMutex // wrapper. -static StaticDataMutex> +MOZ_RUNINIT static StaticDataMutex> sRemoteDecoderManagerChildThread("sRemoteDecoderManagerChildThread"); // Only accessed from sRemoteDecoderManagerChildThread @@ -70,11 +70,9 @@ static StaticAutoPtr>> sRecreateTasks; // Used for protecting codec support information collected from different remote // processes. StaticMutex sProcessSupportedMutex; -#ifndef MOZ_DEBUG -MOZ_CONSTINIT -#endif -static EnumeratedArray, - size_t(RemoteDecodeIn::SENTINEL)> +MOZ_GLOBINIT static EnumeratedArray, + size_t(RemoteDecodeIn::SENTINEL)> sProcessSupported MOZ_GUARDED_BY(sProcessSupportedMutex); class ShutdownObserver final : public nsIObserver { diff --git a/dom/media/mediasession/test/gtest/TestPositionState.cpp b/dom/media/mediasession/test/gtest/TestPositionState.cpp index 5fa38d02942e..0bf0d62180ef 100644 --- a/dom/media/mediasession/test/gtest/TestPositionState.cpp +++ b/dom/media/mediasession/test/gtest/TestPositionState.cpp @@ -20,97 +20,98 @@ struct CurrentPlaybackPositionFixture { class CurrentPlaybackPositionTest : public testing::TestWithParam {}; -static const std::initializer_list kFixtures = { - // position must be positive - { - 10.0, - 1.0, - 0.0, - TimeDuration::FromSeconds(-1.0), - 0.0, - }, - // no time elapsed - { - 10.0, - 1.0, - 0.0, - TimeDuration::FromSeconds(0.0), - 0.0, - }, - { - 10.0, - 1.0, - 0.0, - TimeDuration::FromSeconds(3.0), - 3.0, - }, - { - 10.0, - 1.0, - 0.0, - TimeDuration::FromSeconds(10.0), - 10.0, - }, - // position is clamped to the duration - { - 10.0, - 1.0, - 0.0, - TimeDuration::FromSeconds(20.0), - 10.0, - }, - { - 10.0, - 1.0, - 5.0, - TimeDuration::FromSeconds(-1.0), - 4.0, - }, - { - 10.0, - 1.0, - 5.0, - TimeDuration::FromSeconds(-6.0), - 0.0, - }, - { - 10.0, - 1.0, - 5.0, - TimeDuration::FromSeconds(6.0), - 10.0, - }, - // expected: 5s + 2 * 2s - { - 10.0, - 2.0, - 5.0, - TimeDuration::FromSeconds(2.0), - 9.0, - }, - // expected: 5s + 0.5 * 2s - { - 10.0, - 0.5, - 5.0, - TimeDuration::FromSeconds(2.0), - 6.0, - }, - { - 5.0, - 4.0, - 10.0, - TimeDuration::FromSeconds(20.0), - 5.0, - }, - // empty media (0s) - { - 0.0, - 4.0, - 5.0, - TimeDuration::FromSeconds(20.0), - 0.0, - }, +MOZ_RUNINIT static const std::initializer_list + kFixtures = { + // position must be positive + { + 10.0, + 1.0, + 0.0, + TimeDuration::FromSeconds(-1.0), + 0.0, + }, + // no time elapsed + { + 10.0, + 1.0, + 0.0, + TimeDuration::FromSeconds(0.0), + 0.0, + }, + { + 10.0, + 1.0, + 0.0, + TimeDuration::FromSeconds(3.0), + 3.0, + }, + { + 10.0, + 1.0, + 0.0, + TimeDuration::FromSeconds(10.0), + 10.0, + }, + // position is clamped to the duration + { + 10.0, + 1.0, + 0.0, + TimeDuration::FromSeconds(20.0), + 10.0, + }, + { + 10.0, + 1.0, + 5.0, + TimeDuration::FromSeconds(-1.0), + 4.0, + }, + { + 10.0, + 1.0, + 5.0, + TimeDuration::FromSeconds(-6.0), + 0.0, + }, + { + 10.0, + 1.0, + 5.0, + TimeDuration::FromSeconds(6.0), + 10.0, + }, + // expected: 5s + 2 * 2s + { + 10.0, + 2.0, + 5.0, + TimeDuration::FromSeconds(2.0), + 9.0, + }, + // expected: 5s + 0.5 * 2s + { + 10.0, + 0.5, + 5.0, + TimeDuration::FromSeconds(2.0), + 6.0, + }, + { + 5.0, + 4.0, + 10.0, + TimeDuration::FromSeconds(20.0), + 5.0, + }, + // empty media (0s) + { + 0.0, + 4.0, + 5.0, + TimeDuration::FromSeconds(20.0), + 0.0, + }, }; TEST_P(CurrentPlaybackPositionTest, Run) { diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp index 43dcb00409b7..442d191e284d 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -88,7 +88,8 @@ typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage; namespace mozilla { #ifdef MOZ_USE_HWDECODE -nsTArray FFmpegVideoDecoder::mAcceleratedFormats; +MOZ_RUNINIT nsTArray + FFmpegVideoDecoder::mAcceleratedFormats; #endif using media::TimeUnit; diff --git a/dom/media/platforms/wmf/WMF.h b/dom/media/platforms/wmf/WMF.h index 86afcb8e5c90..7c8c83da5c4d 100644 --- a/dom/media/platforms/wmf/WMF.h +++ b/dom/media/platforms/wmf/WMF.h @@ -139,7 +139,7 @@ class MediaFoundationInitializer final { // WMF from threads with the same COM compartment model. HRESULT MFShutdown(); - static inline UniquePtr sInitializer; + MOZ_RUNINIT static inline UniquePtr sInitializer; static inline StaticMutex sCreateMutex; static inline Atomic sIsShutdown{false}; const bool mHasInitialized; diff --git a/dom/media/systemservices/CamerasParent.cpp b/dom/media/systemservices/CamerasParent.cpp index 9eeada1301cd..ed103b6b1f5d 100644 --- a/dom/media/systemservices/CamerasParent.cpp +++ b/dom/media/systemservices/CamerasParent.cpp @@ -61,8 +61,9 @@ namespace mozilla { using media::ShutdownBlockingTicket; namespace camera { -std::map sDeviceUniqueIDs; -std::map sAllRequestedCapabilities; +MOZ_RUNINIT std::map sDeviceUniqueIDs; +MOZ_RUNINIT std::map + sAllRequestedCapabilities; uint32_t ResolutionFeasibilityDistance(int32_t candidate, int32_t requested) { // The purpose of this function is to find a smallest resolution diff --git a/dom/media/systemservices/objc_video_capture/device_info.mm b/dom/media/systemservices/objc_video_capture/device_info.mm index 74778da02f47..115c822a2493 100644 --- a/dom/media/systemservices/objc_video_capture/device_info.mm +++ b/dom/media/systemservices/objc_video_capture/device_info.mm @@ -27,7 +27,7 @@ using namespace mozilla; using namespace webrtc; using namespace videocapturemodule; -static NSArray* camera_presets = @[ +MOZ_RUNINIT static NSArray* camera_presets = @[ AVCaptureSessionPreset352x288, AVCaptureSessionPreset640x480, AVCaptureSessionPreset1280x720 ]; diff --git a/dom/media/webrtc/jsapi/PeerConnectionImpl.cpp b/dom/media/webrtc/jsapi/PeerConnectionImpl.cpp index e1155cec0c41..6d4d3dea49a8 100644 --- a/dom/media/webrtc/jsapi/PeerConnectionImpl.cpp +++ b/dom/media/webrtc/jsapi/PeerConnectionImpl.cpp @@ -4846,6 +4846,6 @@ std::unique_ptr PeerConnectionImpl::GetProxyConfig() net::WebrtcProxyConfig(id, alpn, loadInfoArgs, mForceProxy))); } -std::map +MOZ_RUNINIT std::map PeerConnectionImpl::sCallDurationTimers; } // namespace mozilla diff --git a/dom/media/webrtc/jsapi/WebrtcGlobalInformation.cpp b/dom/media/webrtc/jsapi/WebrtcGlobalInformation.cpp index eabf7ee3357f..d6dedd23a9fc 100644 --- a/dom/media/webrtc/jsapi/WebrtcGlobalInformation.cpp +++ b/dom/media/webrtc/jsapi/WebrtcGlobalInformation.cpp @@ -67,7 +67,8 @@ class WebrtcContentParents { static std::vector> sContentParents; }; -std::vector> WebrtcContentParents::sContentParents; +MOZ_RUNINIT std::vector> + WebrtcContentParents::sContentParents; WebrtcGlobalParent* WebrtcContentParents::Alloc() { RefPtr cp = new WebrtcGlobalParent; @@ -533,7 +534,7 @@ void WebrtcGlobalInformation::GetLogging( } static bool sLastAECDebug = false; -static Maybe sAecDebugLogDir; +MOZ_RUNINIT static Maybe sAecDebugLogDir; void WebrtcGlobalInformation::SetAecDebug(const GlobalObject& aGlobal, bool aEnable) { diff --git a/dom/media/webrtc/sdp/RsdparsaSdpAttributeList.cpp b/dom/media/webrtc/sdp/RsdparsaSdpAttributeList.cpp index 0b76757c444b..c1625922a325 100644 --- a/dom/media/webrtc/sdp/RsdparsaSdpAttributeList.cpp +++ b/dom/media/webrtc/sdp/RsdparsaSdpAttributeList.cpp @@ -17,7 +17,7 @@ namespace mozilla { -const std::string RsdparsaSdpAttributeList::kEmptyString = ""; +MOZ_RUNINIT const std::string RsdparsaSdpAttributeList::kEmptyString = ""; RsdparsaSdpAttributeList::~RsdparsaSdpAttributeList() { for (size_t i = 0; i < kNumAttributeTypes; ++i) { diff --git a/dom/media/webrtc/sdp/SipccSdpAttributeList.cpp b/dom/media/webrtc/sdp/SipccSdpAttributeList.cpp index 15572b6dd396..b05993f96d29 100644 --- a/dom/media/webrtc/sdp/SipccSdpAttributeList.cpp +++ b/dom/media/webrtc/sdp/SipccSdpAttributeList.cpp @@ -18,7 +18,7 @@ namespace mozilla { using InternalResults = SdpParser::InternalResults; /* static */ -const std::string SipccSdpAttributeList::kEmptyString = ""; +MOZ_RUNINIT const std::string SipccSdpAttributeList::kEmptyString = ""; SipccSdpAttributeList::SipccSdpAttributeList( const SipccSdpAttributeList* sessionLevel) diff --git a/dom/media/webrtc/tests/fuzztests/sdp_parser_libfuzz.cpp b/dom/media/webrtc/tests/fuzztests/sdp_parser_libfuzz.cpp index 3451d6fd2148..af93ef7bd61d 100644 --- a/dom/media/webrtc/tests/fuzztests/sdp_parser_libfuzz.cpp +++ b/dom/media/webrtc/tests/fuzztests/sdp_parser_libfuzz.cpp @@ -14,8 +14,8 @@ using namespace mozilla; -static mozilla::UniquePtr sdpPtr; -static SipccSdpParser mParser; +MOZ_RUNINIT static mozilla::UniquePtr sdpPtr; +MOZ_RUNINIT static SipccSdpParser mParser; int FuzzingInitSdpParser(int* argc, char*** argv) { return 0; } diff --git a/dom/media/webrtc/transport/test/ice_unittest.cpp b/dom/media/webrtc/transport/test/ice_unittest.cpp index 22e99b85b62e..eb7d2995d37e 100644 --- a/dom/media/webrtc/transport/test/ice_unittest.cpp +++ b/dom/media/webrtc/transport/test/ice_unittest.cpp @@ -61,14 +61,14 @@ static unsigned int kDefaultTimeout = 7000; // TODO: It would be nice to have a test STUN/TURN server that can run with // gtest. -const std::string kDefaultStunServerHostname((char*)""); -const std::string kBogusStunServerHostname( +MOZ_RUNINIT const std::string kDefaultStunServerHostname((char*)""); +MOZ_RUNINIT const std::string kBogusStunServerHostname( (char*)"stun-server-nonexistent.invalid"); const uint16_t kDefaultStunServerPort = 19305; -const std::string kBogusIceCandidate( +MOZ_RUNINIT const std::string kBogusIceCandidate( (char*)"candidate:0 2 UDP 2113601790 192.168.178.20 50769 typ"); -const std::string kUnreachableHostIceCandidate( +MOZ_RUNINIT const std::string kUnreachableHostIceCandidate( (char*)"candidate:0 1 UDP 2113601790 192.168.178.20 50769 typ host"); namespace { diff --git a/dom/media/webrtc/transport/test/proxy_tunnel_socket_unittest.cpp b/dom/media/webrtc/transport/test/proxy_tunnel_socket_unittest.cpp index aeac6788e39e..7a1715584e91 100644 --- a/dom/media/webrtc/transport/test/proxy_tunnel_socket_unittest.cpp +++ b/dom/media/webrtc/transport/test/proxy_tunnel_socket_unittest.cpp @@ -19,7 +19,8 @@ using namespace mozilla; // update TestReadMultipleSizes if you change this -const std::string kHelloMessage = "HELLO IS IT ME YOU'RE LOOKING FOR?"; +MOZ_RUNINIT const std::string kHelloMessage = + "HELLO IS IT ME YOU'RE LOOKING FOR?"; class NrTcpSocketTest : public MtransportTest { public: diff --git a/dom/media/webrtc/transport/test/turn_unittest.cpp b/dom/media/webrtc/transport/test/turn_unittest.cpp index 3b82db1a3294..512ae772c0ad 100644 --- a/dom/media/webrtc/transport/test/turn_unittest.cpp +++ b/dom/media/webrtc/transport/test/turn_unittest.cpp @@ -66,7 +66,7 @@ extern "C" { using namespace mozilla; -static std::string kDummyTurnServer("192.0.2.1"); // From RFC 5737 +MOZ_RUNINIT static std::string kDummyTurnServer("192.0.2.1"); // From RFC 5737 class TurnClient : public MtransportTest { public: diff --git a/dom/media/webrtc/transport/test/webrtcproxychannel_unittest.cpp b/dom/media/webrtc/transport/test/webrtcproxychannel_unittest.cpp index e5a8ba82cbdb..7c0f709d892c 100644 --- a/dom/media/webrtc/transport/test/webrtcproxychannel_unittest.cpp +++ b/dom/media/webrtc/transport/test/webrtcproxychannel_unittest.cpp @@ -19,7 +19,7 @@ static const uint32_t kDefaultTestTimeout = 2000; static const char kReadData[] = "Hello, World!"; static const size_t kReadDataLength = sizeof(kReadData) - 1; -static const std::string kReadDataString = +MOZ_RUNINIT static const std::string kReadDataString = std::string(kReadData, kReadDataLength); static int kDataLargeOuterLoopCount = 128; static int kDataLargeInnerLoopCount = 1024; diff --git a/dom/midi/midirMIDIPlatformService.cpp b/dom/midi/midirMIDIPlatformService.cpp index 842eb51dcddc..78c4624540b9 100644 --- a/dom/midi/midirMIDIPlatformService.cpp +++ b/dom/midi/midirMIDIPlatformService.cpp @@ -54,7 +54,8 @@ class SendRunnable : public MIDIBackgroundRunnable { StaticMutex midirMIDIPlatformService::gOwnerThreadMutex; // static -nsCOMPtr midirMIDIPlatformService::gOwnerThread; +MOZ_RUNINIT nsCOMPtr + midirMIDIPlatformService::gOwnerThread; midirMIDIPlatformService::midirMIDIPlatformService() : mImplementation(nullptr) { diff --git a/dom/promise/PromiseDebugging.cpp b/dom/promise/PromiseDebugging.cpp index b27661ef5e60..16969f301621 100644 --- a/dom/promise/PromiseDebugging.cpp +++ b/dom/promise/PromiseDebugging.cpp @@ -159,7 +159,7 @@ void PromiseDebugging::GetFullfillmentStack(GlobalObject& aGlobal, } /*static */ -nsString PromiseDebugging::sIDPrefix; +MOZ_RUNINIT nsString PromiseDebugging::sIDPrefix; /* static */ void PromiseDebugging::Init() { diff --git a/dom/quota/test/gtest/QuotaManagerDependencyFixture.cpp b/dom/quota/test/gtest/QuotaManagerDependencyFixture.cpp index c6d1b59e12ff..3b80940b210b 100644 --- a/dom/quota/test/gtest/QuotaManagerDependencyFixture.cpp +++ b/dom/quota/test/gtest/QuotaManagerDependencyFixture.cpp @@ -423,6 +423,7 @@ void QuotaManagerDependencyFixture::EnsureQuotaManager() { [&resolver]() { return resolver->IsDone(); }); } -nsCOMPtr QuotaManagerDependencyFixture::sBackgroundTarget; +MOZ_RUNINIT nsCOMPtr + QuotaManagerDependencyFixture::sBackgroundTarget; } // namespace mozilla::dom::quota::test diff --git a/dom/quota/test/gtest/TestEncryptedStream.cpp b/dom/quota/test/gtest/TestEncryptedStream.cpp index b172287e2bd8..bdbad09aa77f 100644 --- a/dom/quota/test/gtest/TestEncryptedStream.cpp +++ b/dom/quota/test/gtest/TestEncryptedStream.cpp @@ -266,7 +266,8 @@ class DOM_Quota_EncryptedStream : public ::testing::Test { struct NSSInitContextDeleter { void operator()(NSSInitContext* p) { NSS_ShutdownContext(p); } }; - inline static std::unique_ptr + MOZ_RUNINIT inline static std::unique_ptr sNssContext; }; diff --git a/dom/quota/test/gtest/TestStorageConnection.cpp b/dom/quota/test/gtest/TestStorageConnection.cpp index 02a7f2e1355c..05c4701eb6bf 100644 --- a/dom/quota/test/gtest/TestStorageConnection.cpp +++ b/dom/quota/test/gtest/TestStorageConnection.cpp @@ -183,7 +183,8 @@ class TestStorageConnection : public QuotaManagerDependencyFixture { struct NSSInitContextDeleter { void operator()(NSSInitContext* p) { NSS_ShutdownContext(p); } }; - inline static std::unique_ptr + MOZ_RUNINIT inline static std::unique_ptr sNssContext; }; diff --git a/dom/security/featurepolicy/fuzztest/fp_fuzzer.cpp b/dom/security/featurepolicy/fuzztest/fp_fuzzer.cpp index 25f7dc8d4104..6e03ef7b5682 100644 --- a/dom/security/featurepolicy/fuzztest/fp_fuzzer.cpp +++ b/dom/security/featurepolicy/fuzztest/fp_fuzzer.cpp @@ -15,8 +15,8 @@ using namespace mozilla; using namespace mozilla::dom; -static nsCOMPtr selfURIPrincipal; -static nsCOMPtr selfURI; +MOZ_RUNINIT static nsCOMPtr selfURIPrincipal; +MOZ_RUNINIT static nsCOMPtr selfURI; static int LVVMFuzzerInitTest(int* argc, char*** argv) { nsresult ret; diff --git a/dom/serviceworkers/ServiceWorkerRegistrar.cpp b/dom/serviceworkers/ServiceWorkerRegistrar.cpp index fb509b3beeb6..6e4353547c4b 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrar.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistrar.cpp @@ -138,8 +138,8 @@ nsresult CreatePrincipalInfo(nsILineInputStream* aStream, return NS_OK; } -const IPCNavigationPreloadState gDefaultNavigationPreloadState(false, - "true"_ns); +MOZ_RUNINIT const IPCNavigationPreloadState + gDefaultNavigationPreloadState(false, "true"_ns); } // namespace diff --git a/dom/svg/DOMSVGAnimatedTransformList.cpp b/dom/svg/DOMSVGAnimatedTransformList.cpp index ab09bab1fc82..374b7c045e60 100644 --- a/dom/svg/DOMSVGAnimatedTransformList.cpp +++ b/dom/svg/DOMSVGAnimatedTransformList.cpp @@ -13,8 +13,8 @@ namespace mozilla::dom { -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sSVGAnimatedTransformListTearoffTable; NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAnimatedTransformList, diff --git a/dom/svg/DOMSVGLength.cpp b/dom/svg/DOMSVGLength.cpp index 3146dfb58de9..e9081b638eac 100644 --- a/dom/svg/DOMSVGLength.cpp +++ b/dom/svg/DOMSVGLength.cpp @@ -22,7 +22,7 @@ namespace mozilla::dom { -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sBaseSVGLengthTearOffTable, sAnimSVGLengthTearOffTable; // We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to diff --git a/dom/svg/DOMSVGPoint.cpp b/dom/svg/DOMSVGPoint.cpp index 465f4e28a55b..1c9dbf45b8de 100644 --- a/dom/svg/DOMSVGPoint.cpp +++ b/dom/svg/DOMSVGPoint.cpp @@ -37,7 +37,8 @@ class MOZ_RAII AutoChangePointNotifier { DOMSVGPoint* const mValue; }; -static SVGAttrTearoffTable sSVGTranslateTearOffTable; +MOZ_CONSTINIT static SVGAttrTearoffTable + sSVGTranslateTearOffTable; // We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to // clear our list's weak ref to us to be safe. (The other option would be to diff --git a/dom/svg/SVGAnimatedClassOrString.cpp b/dom/svg/SVGAnimatedClassOrString.cpp index 25a89f15ae42..0fcfad7203fc 100644 --- a/dom/svg/SVGAnimatedClassOrString.cpp +++ b/dom/svg/SVGAnimatedClassOrString.cpp @@ -11,7 +11,8 @@ namespace mozilla { -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sSVGAnimatedClassOrStringTearoffTable; already_AddRefed diff --git a/dom/svg/SVGAnimatedEnumeration.cpp b/dom/svg/SVGAnimatedEnumeration.cpp index 52ea0f215fda..489a0d59b321 100644 --- a/dom/svg/SVGAnimatedEnumeration.cpp +++ b/dom/svg/SVGAnimatedEnumeration.cpp @@ -44,8 +44,8 @@ class MOZ_RAII AutoChangeEnumNotifier { bool mDoSetAttr; }; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable< + SVGAnimatedEnumeration, SVGAnimatedEnumeration::DOMAnimatedEnum> sSVGAnimatedEnumTearoffTable; const SVGEnumMapping* SVGAnimatedEnumeration::GetMapping( diff --git a/dom/svg/SVGAnimatedInteger.cpp b/dom/svg/SVGAnimatedInteger.cpp index b14a32ce1c8c..780dec4c2716 100644 --- a/dom/svg/SVGAnimatedInteger.cpp +++ b/dom/svg/SVGAnimatedInteger.cpp @@ -45,8 +45,8 @@ class MOZ_RAII AutoChangeIntegerNotifier { bool mDoSetAttr; }; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sSVGAnimatedIntegerTearoffTable; nsresult SVGAnimatedInteger::SetBaseValueString(const nsAString& aValueAsString, diff --git a/dom/svg/SVGAnimatedIntegerPair.cpp b/dom/svg/SVGAnimatedIntegerPair.cpp index cf13fdaf4b22..071adfe8a9e6 100644 --- a/dom/svg/SVGAnimatedIntegerPair.cpp +++ b/dom/svg/SVGAnimatedIntegerPair.cpp @@ -58,11 +58,11 @@ class MOZ_RAII AutoChangeIntegerPairNotifier { bool mDoSetAttr; }; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable< + SVGAnimatedIntegerPair, SVGAnimatedIntegerPair::DOMAnimatedInteger> sSVGFirstAnimatedIntegerTearoffTable; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable< + SVGAnimatedIntegerPair, SVGAnimatedIntegerPair::DOMAnimatedInteger> sSVGSecondAnimatedIntegerTearoffTable; /* Implementation */ diff --git a/dom/svg/SVGAnimatedLength.cpp b/dom/svg/SVGAnimatedLength.cpp index 9f2a4c161614..f36e7b0b8778 100644 --- a/dom/svg/SVGAnimatedLength.cpp +++ b/dom/svg/SVGAnimatedLength.cpp @@ -68,7 +68,8 @@ class MOZ_RAII AutoChangeLengthNotifier { bool mDoSetAttr; }; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sSVGAnimatedLengthTearoffTable; /* Helper functions */ diff --git a/dom/svg/SVGAnimatedNumber.cpp b/dom/svg/SVGAnimatedNumber.cpp index fa3f21af03d9..74049c2c3db0 100644 --- a/dom/svg/SVGAnimatedNumber.cpp +++ b/dom/svg/SVGAnimatedNumber.cpp @@ -42,8 +42,8 @@ class MOZ_RAII AutoChangeNumberNotifier { SVGElement* const mSVGElement; }; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sSVGAnimatedNumberTearoffTable; static bool GetValueFromString(const nsAString& aString, diff --git a/dom/svg/SVGAnimatedNumberPair.cpp b/dom/svg/SVGAnimatedNumberPair.cpp index 7bb09a966a21..579094e78bcb 100644 --- a/dom/svg/SVGAnimatedNumberPair.cpp +++ b/dom/svg/SVGAnimatedNumberPair.cpp @@ -54,11 +54,11 @@ class MOZ_RAII AutoChangeNumberPairNotifier { bool mDoSetAttr; }; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable< + SVGAnimatedNumberPair, SVGAnimatedNumberPair::DOMAnimatedNumber> sSVGFirstAnimatedNumberTearoffTable; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable< + SVGAnimatedNumberPair, SVGAnimatedNumberPair::DOMAnimatedNumber> sSVGSecondAnimatedNumberTearoffTable; static nsresult ParseNumberOptionalNumber(const nsAString& aValue, diff --git a/dom/svg/SVGAnimatedOrient.cpp b/dom/svg/SVGAnimatedOrient.cpp index 340ea98741ba..12dd857cc49d 100644 --- a/dom/svg/SVGAnimatedOrient.cpp +++ b/dom/svg/SVGAnimatedOrient.cpp @@ -27,13 +27,14 @@ using namespace mozilla::dom::SVGMarkerElement_Binding; namespace mozilla { -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sSVGAnimatedEnumTearoffTable; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sSVGAnimatedAngleTearoffTable; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sBaseSVGAngleTearoffTable; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sAnimSVGAngleTearoffTable; /* Helper functions */ diff --git a/dom/svg/SVGAnimatedPreserveAspectRatio.cpp b/dom/svg/SVGAnimatedPreserveAspectRatio.cpp index 7b9b2aa13676..420bb614838e 100644 --- a/dom/svg/SVGAnimatedPreserveAspectRatio.cpp +++ b/dom/svg/SVGAnimatedPreserveAspectRatio.cpp @@ -70,14 +70,14 @@ class MOZ_RAII AutoChangePreserveAspectRatioNotifier { bool mDoSetAttr; }; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sSVGAnimatedPAspectRatioTearoffTable; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sBaseSVGPAspectRatioTearoffTable; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sAnimSVGPAspectRatioTearoffTable; already_AddRefed diff --git a/dom/svg/SVGAnimatedViewBox.cpp b/dom/svg/SVGAnimatedViewBox.cpp index aa5d07990928..f2058bf99a68 100644 --- a/dom/svg/SVGAnimatedViewBox.cpp +++ b/dom/svg/SVGAnimatedViewBox.cpp @@ -66,11 +66,11 @@ nsresult SVGViewBox::FromString(const nsAString& aStr, SVGViewBox* aViewBox) { return NS_OK; } -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sBaseSVGViewBoxTearoffTable; -static SVGAttrTearoffTable +MOZ_CONSTINIT static SVGAttrTearoffTable sAnimSVGViewBoxTearoffTable; -SVGAttrTearoffTable +MOZ_CONSTINIT SVGAttrTearoffTable SVGAnimatedViewBox::sSVGAnimatedRectTearoffTable; //---------------------------------------------------------------------- diff --git a/dom/system/IOUtils.cpp b/dom/system/IOUtils.cpp index de320cb79d4c..ae227a85261d 100644 --- a/dom/system/IOUtils.cpp +++ b/dom/system/IOUtils.cpp @@ -301,7 +301,7 @@ static void AssertParentProcessWithCallerLocation(GlobalObject& aGlobal) { // IOUtils implementation /* static */ -IOUtils::StateMutex IOUtils::sState{"IOUtils::sState"}; +MOZ_RUNINIT IOUtils::StateMutex IOUtils::sState{"IOUtils::sState"}; /* static */ template diff --git a/dom/system/PathUtils.cpp b/dom/system/PathUtils.cpp index 24d7b648db8c..1d4fee8df163 100644 --- a/dom/system/PathUtils.cpp +++ b/dom/system/PathUtils.cpp @@ -90,8 +90,8 @@ nsresult PathUtils::InitFileWithPath(nsIFile* aFile, const nsAString& aPath) { return aFile->InitWithPath(aPath); } -StaticDataMutex> PathUtils::sDirCache{ - "sDirCache"}; +MOZ_RUNINIT StaticDataMutex> + PathUtils::sDirCache{"sDirCache"}; /** * Return the leaf name, including leading path separators in the case of diff --git a/dom/system/mac/CoreLocationLocationProvider.mm b/dom/system/mac/CoreLocationLocationProvider.mm index 1be9a8b1e47f..243eb568c4c3 100644 --- a/dom/system/mac/CoreLocationLocationProvider.mm +++ b/dom/system/mac/CoreLocationLocationProvider.mm @@ -29,8 +29,9 @@ using namespace mozilla; -static const CLLocationAccuracy kHIGH_ACCURACY = kCLLocationAccuracyBest; -static const CLLocationAccuracy kDEFAULT_ACCURACY = +MOZ_RUNINIT static const CLLocationAccuracy kHIGH_ACCURACY = + kCLLocationAccuracyBest; +MOZ_RUNINIT static const CLLocationAccuracy kDEFAULT_ACCURACY = kCLLocationAccuracyNearestTenMeters; @interface LocationDelegate : NSObject { diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 1442ef2b8cd8..4a11db9cceb4 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -135,25 +135,27 @@ HTMLEditor::InsertNodeIntoProperAncestorWithTransaction( Text& aContentToInsert, const EditorDOMPoint& aPointToInsert, SplitAtEdges aSplitAtEdges); -HTMLEditor::InitializeInsertingElement HTMLEditor::DoNothingForNewElement = - [](HTMLEditor&, Element&, const EditorDOMPoint&) { return NS_OK; }; +MOZ_RUNINIT HTMLEditor::InitializeInsertingElement + HTMLEditor::DoNothingForNewElement = + [](HTMLEditor&, Element&, const EditorDOMPoint&) { return NS_OK; }; -HTMLEditor::InitializeInsertingElement HTMLEditor::InsertNewBRElement = - [](HTMLEditor& aHTMLEditor, Element& aNewElement, const EditorDOMPoint&) - MOZ_CAN_RUN_SCRIPT_BOUNDARY { - MOZ_ASSERT(!aNewElement.IsInComposedDoc()); - Result createBRElementResult = - aHTMLEditor.InsertBRElement(WithTransaction::No, - EditorDOMPoint(&aNewElement, 0u)); - if (MOZ_UNLIKELY(createBRElementResult.isErr())) { - NS_WARNING_ASSERTION( - createBRElementResult.isOk(), - "HTMLEditor::InsertBRElement(WithTransaction::No) failed"); - return createBRElementResult.unwrapErr(); - } - createBRElementResult.unwrap().IgnoreCaretPointSuggestion(); - return NS_OK; - }; +MOZ_RUNINIT HTMLEditor::InitializeInsertingElement + HTMLEditor::InsertNewBRElement = + [](HTMLEditor& aHTMLEditor, Element& aNewElement, const EditorDOMPoint&) + MOZ_CAN_RUN_SCRIPT_BOUNDARY { + MOZ_ASSERT(!aNewElement.IsInComposedDoc()); + Result createBRElementResult = + aHTMLEditor.InsertBRElement(WithTransaction::No, + EditorDOMPoint(&aNewElement, 0u)); + if (MOZ_UNLIKELY(createBRElementResult.isErr())) { + NS_WARNING_ASSERTION( + createBRElementResult.isOk(), + "HTMLEditor::InsertBRElement(WithTransaction::No) failed"); + return createBRElementResult.unwrapErr(); + } + createBRElementResult.unwrap().IgnoreCaretPointSuggestion(); + return NS_OK; + }; // static Result @@ -186,25 +188,27 @@ HTMLEditor::AppendNewElementWithBRToInsertingElement( return createNewElementWithBRResult; } -HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributes = +MOZ_RUNINIT HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributes = [](HTMLEditor&, const Element&, const Element&, int32_t, const nsAtom&, nsString&) { return true; }; -HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptId = +MOZ_RUNINIT HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptId = [](HTMLEditor&, const Element&, const Element&, int32_t aNamespaceID, const nsAtom& aAttrName, nsString&) { return aNamespaceID != kNameSpaceID_None || &aAttrName != nsGkAtoms::id; }; -HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptDir = +MOZ_RUNINIT HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptDir = [](HTMLEditor&, const Element&, const Element&, int32_t aNamespaceID, const nsAtom& aAttrName, nsString&) { return aNamespaceID != kNameSpaceID_None || &aAttrName != nsGkAtoms::dir; }; -HTMLEditor::AttributeFilter HTMLEditor::CopyAllAttributesExceptIdAndDir = - [](HTMLEditor&, const Element&, const Element&, int32_t aNamespaceID, - const nsAtom& aAttrName, nsString&) { - return !(aNamespaceID == kNameSpaceID_None && - (&aAttrName == nsGkAtoms::id || &aAttrName == nsGkAtoms::dir)); - }; +MOZ_RUNINIT HTMLEditor::AttributeFilter + HTMLEditor::CopyAllAttributesExceptIdAndDir = + [](HTMLEditor&, const Element&, const Element&, int32_t aNamespaceID, + const nsAtom& aAttrName, nsString&) { + return !( + aNamespaceID == kNameSpaceID_None && + (&aAttrName == nsGkAtoms::id || &aAttrName == nsGkAtoms::dir)); + }; HTMLEditor::HTMLEditor(const Document& aDocument) : EditorBase(EditorBase::EditorType::HTML), diff --git a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp index 00813392f110..456e4fb23d62 100644 --- a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp +++ b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp @@ -30,8 +30,8 @@ using mozilla::dom::AutoJSAPI; //***************************************************************************** -static JS::PersistentRooted autoconfigSystemSb; -static JS::PersistentRooted autoconfigSb; +MOZ_RUNINIT static JS::PersistentRooted autoconfigSystemSb; +MOZ_RUNINIT static JS::PersistentRooted autoconfigSb; bool sandboxEnabled; nsresult CentralizedAdminPrefManagerInit(bool aSandboxEnabled) { diff --git a/extensions/spellcheck/hunspell/glue/mozHunspellRLBoxHost.cpp b/extensions/spellcheck/hunspell/glue/mozHunspellRLBoxHost.cpp index 61d2f50887ec..7397fbcafeaa 100644 --- a/extensions/spellcheck/hunspell/glue/mozHunspellRLBoxHost.cpp +++ b/extensions/spellcheck/hunspell/glue/mozHunspellRLBoxHost.cpp @@ -77,10 +77,10 @@ uint32_t mozHunspellCallbacks::sCurrentFreshId = 0; /* static */ mozilla::StaticRWLock mozHunspellCallbacks::sFileMgrMapLock; /* static */ -std::map> +MOZ_RUNINIT std::map> mozHunspellCallbacks::sFileMgrMap; /* static */ -std::set mozHunspellCallbacks::sFileMgrAllowList; +MOZ_RUNINIT std::set mozHunspellCallbacks::sFileMgrAllowList; /* static */ void mozHunspellCallbacks::AllowFile(const nsCString& aFilename) { diff --git a/gfx/2d/DWriteSettings.cpp b/gfx/2d/DWriteSettings.cpp index acd26b4e5b39..fc10bab29f60 100644 --- a/gfx/2d/DWriteSettings.cpp +++ b/gfx/2d/DWriteSettings.cpp @@ -21,10 +21,10 @@ static Atomic sPixelGeometry; static Atomic sRenderingMode; static Atomic sMeasuringMode; static std::atomic sGDIGamma{1.4f}; -StaticDataMutex> sStandardRenderingParams( - "StandardRenderingParams"); -StaticDataMutex> sGDIRenderingParams( - "GDIRenderingParams"); +MOZ_RUNINIT StaticDataMutex> + sStandardRenderingParams("StandardRenderingParams"); +MOZ_RUNINIT StaticDataMutex> + sGDIRenderingParams("GDIRenderingParams"); static void ClearStandardRenderingParams() { auto lockedParams = sStandardRenderingParams.Lock(); diff --git a/gfx/2d/DrawTargetD2D1.cpp b/gfx/2d/DrawTargetD2D1.cpp index e0bdd4d0553b..fe82d99c24ce 100644 --- a/gfx/2d/DrawTargetD2D1.cpp +++ b/gfx/2d/DrawTargetD2D1.cpp @@ -34,7 +34,7 @@ uint64_t DrawTargetD2D1::mVRAMUsageDT; uint64_t DrawTargetD2D1::mVRAMUsageSS; StaticRefPtr DrawTargetD2D1::mFactory; -const D2D1_MATRIX_5X4_F kLuminanceMatrix = +MOZ_RUNINIT const D2D1_MATRIX_5X4_F kLuminanceMatrix = D2D1::Matrix5x4F(0, 0, 0, 0.2125f, 0, 0, 0, 0.7154f, 0, 0, 0, 0.0721f, 0, 0, 0, 0, 0, 0, 0, 0); diff --git a/gfx/2d/NativeFontResourceDWrite.cpp b/gfx/2d/NativeFontResourceDWrite.cpp index e0b599fa767d..10abb9692f86 100644 --- a/gfx/2d/NativeFontResourceDWrite.cpp +++ b/gfx/2d/NativeFontResourceDWrite.cpp @@ -19,7 +19,8 @@ namespace gfx { static StaticMutex sFontFileStreamsMutex MOZ_UNANNOTATED; static uint64_t sNextFontFileKey = 0; -static std::unordered_map sFontFileStreams; +MOZ_RUNINIT static std::unordered_map + sFontFileStreams; class DWriteFontFileLoader : public IDWriteFontFileLoader { public: diff --git a/gfx/2d/NativeFontResourceMac.cpp b/gfx/2d/NativeFontResourceMac.cpp index 448db7672603..51e5afa4f57d 100644 --- a/gfx/2d/NativeFontResourceMac.cpp +++ b/gfx/2d/NativeFontResourceMac.cpp @@ -23,7 +23,8 @@ namespace mozilla { namespace gfx { #define FONT_NAME_MAX 32 -static StaticDataMutex>> +MOZ_RUNINIT static StaticDataMutex< + std::unordered_map>> sWeakFontDataMap("WeakFonts"); void FontDataDeallocate(void*, void* info) { diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index 2e205c1434fe..f5522410f35a 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -342,7 +342,7 @@ already_AddRefed GLContextProviderCGL::CreateHeadless( return gl.forget(); } -static RefPtr gGlobalContext; +MOZ_RUNINIT static RefPtr gGlobalContext; GLContext* GLContextProviderCGL::GetGlobalContext() { static bool triedToCreateContext = false; diff --git a/gfx/gl/GLContextProviderEAGL.mm b/gfx/gl/GLContextProviderEAGL.mm index 648d6642d42e..e92ad275d662 100644 --- a/gfx/gl/GLContextProviderEAGL.mm +++ b/gfx/gl/GLContextProviderEAGL.mm @@ -142,7 +142,7 @@ already_AddRefed GLContextProviderEAGL::CreateHeadless( return CreateEAGLContext(desc, GetGlobalContextEAGL()).forget(); } -static RefPtr gGlobalContext; +MOZ_RUNINIT static RefPtr gGlobalContext; GLContext* GLContextProviderEAGL::GetGlobalContext() { static bool triedToCreateContext = false; diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 577679789afd..02211238af87 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -106,7 +106,7 @@ class WaylandOffscreenGLSurface { struct wl_egl_window* mEGLWindow = nullptr; }; -static nsTHashMap, WaylandOffscreenGLSurface*> +MOZ_RUNINIT static nsTHashMap, WaylandOffscreenGLSurface*> sWaylandOffscreenGLSurfaces; void DeleteWaylandOffscreenGLSurface(EGLSurface surface) { diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 07b7a8e91508..ab1e59f44449 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -51,7 +51,7 @@ namespace mozilla::gl { using namespace mozilla::gfx; using namespace mozilla::widget; -GLXLibrary sGLXLibrary; +MOZ_RUNINIT GLXLibrary sGLXLibrary; static inline bool HasExtension(const char* aExtensions, const char* aRequiredExtension) { diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index c57add8d99e6..b274ec30f73d 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -30,7 +30,7 @@ namespace gl { using namespace mozilla::gfx; using namespace mozilla::widget; -WGLLibrary sWGLLib; +MOZ_RUNINIT WGLLibrary sWGLLib; /* ScopedWindow::~ScopedWindow() diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 0caaa8647648..c724f96ba5be 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -389,7 +389,7 @@ class AngleErrorReporting { nsACString* mFailureId; }; -AngleErrorReporting gAngleErrorReporter; +MOZ_RUNINIT AngleErrorReporting gAngleErrorReporter; static std::shared_ptr GetAndInitDisplayForAccelANGLE( GLLibraryEGL& egl, nsACString* const out_failureId, diff --git a/gfx/ipc/CanvasManagerParent.cpp b/gfx/ipc/CanvasManagerParent.cpp index f8edd515a581..61f0b03d18d2 100644 --- a/gfx/ipc/CanvasManagerParent.cpp +++ b/gfx/ipc/CanvasManagerParent.cpp @@ -23,7 +23,7 @@ namespace mozilla::gfx { -CanvasManagerParent::ManagerSet CanvasManagerParent::sManagers; +MOZ_RUNINIT CanvasManagerParent::ManagerSet CanvasManagerParent::sManagers; /* static */ void CanvasManagerParent::Init( Endpoint&& aEndpoint, diff --git a/gfx/ipc/CanvasShutdownManager.cpp b/gfx/ipc/CanvasShutdownManager.cpp index 512f6bf5e435..2c3167cd4c4e 100644 --- a/gfx/ipc/CanvasShutdownManager.cpp +++ b/gfx/ipc/CanvasShutdownManager.cpp @@ -18,7 +18,7 @@ using namespace mozilla::dom; namespace mozilla::gfx { StaticMutex CanvasShutdownManager::sManagersMutex; -std::set CanvasShutdownManager::sManagers; +MOZ_RUNINIT std::set CanvasShutdownManager::sManagers; // The owning thread will tell us to close when it is shutdown, either via // CanvasShutdownManager::Shutdown for the main thread, or via a shutdown diff --git a/gfx/layers/GLImages.cpp b/gfx/layers/GLImages.cpp index 90c817f6a62c..c1bb10405259 100644 --- a/gfx/layers/GLImages.cpp +++ b/gfx/layers/GLImages.cpp @@ -20,7 +20,7 @@ using namespace mozilla::gl; namespace mozilla::layers { -static RefPtr sSnapshotContext; +MOZ_RUNINIT static RefPtr sSnapshotContext; nsresult GLImage::ReadIntoBuffer(uint8_t* aData, int32_t aStride, const gfx::IntSize& aSize, diff --git a/gfx/layers/apz/src/AndroidVelocityTracker.cpp b/gfx/layers/apz/src/AndroidVelocityTracker.cpp index a355811a0002..9c042689870b 100644 --- a/gfx/layers/apz/src/AndroidVelocityTracker.cpp +++ b/gfx/layers/apz/src/AndroidVelocityTracker.cpp @@ -19,7 +19,7 @@ namespace layers { // stopped moving. Some input devices do not send move events in the // case where a pointer has stopped. We need to detect this case so that we can // accurately predict the velocity after the pointer starts moving again. -static const TimeDuration kAssumePointerMoveStoppedTime = +MOZ_RUNINIT static const TimeDuration kAssumePointerMoveStoppedTime = TimeDuration::FromMilliseconds(40); // The degree of the approximation. diff --git a/gfx/layers/apz/src/SimpleVelocityTracker.cpp b/gfx/layers/apz/src/SimpleVelocityTracker.cpp index 87cae10d51f9..bb73ed1ac104 100644 --- a/gfx/layers/apz/src/SimpleVelocityTracker.cpp +++ b/gfx/layers/apz/src/SimpleVelocityTracker.cpp @@ -21,7 +21,8 @@ namespace layers { // delta can be really small, which can make the velocity computation very // volatile. To avoid this we impose a minimum time delta below which we do // not recompute the velocity. -const TimeDuration MIN_VELOCITY_SAMPLE_TIME = TimeDuration::FromMilliseconds(5); +MOZ_RUNINIT const TimeDuration MIN_VELOCITY_SAMPLE_TIME = + TimeDuration::FromMilliseconds(5); extern StaticAutoPtr gVelocityCurveFunction; diff --git a/gfx/layers/apz/util/InputAPZContext.cpp b/gfx/layers/apz/util/InputAPZContext.cpp index b1af5c31183c..2cb5b16357a3 100644 --- a/gfx/layers/apz/util/InputAPZContext.cpp +++ b/gfx/layers/apz/util/InputAPZContext.cpp @@ -9,7 +9,7 @@ namespace mozilla { namespace layers { -ScrollableLayerGuid InputAPZContext::sGuid; +MOZ_RUNINIT ScrollableLayerGuid InputAPZContext::sGuid; uint64_t InputAPZContext::sBlockId = 0; nsEventStatus InputAPZContext::sApzResponse = nsEventStatus_eSentinel; bool InputAPZContext::sPendingLayerization = false; diff --git a/gfx/layers/d3d11/FenceD3D11.cpp b/gfx/layers/d3d11/FenceD3D11.cpp index d300eab96512..cb97c8318ce6 100644 --- a/gfx/layers/d3d11/FenceD3D11.cpp +++ b/gfx/layers/d3d11/FenceD3D11.cpp @@ -15,7 +15,7 @@ namespace mozilla { namespace layers { -RefPtr mDevice; +MOZ_RUNINIT RefPtr mDevice; /* static */ RefPtr FenceD3D11::Create(ID3D11Device* aDevice) { diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 9e7c01b11aa2..cb6652976123 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -108,8 +108,9 @@ using mozilla::Telemetry::LABELS_CONTENT_FRAME_TIME_REASON; StaticMonitor CompositorBridgeParent::sIndirectLayerTreesLock; /* static */ -CompositorBridgeParent::LayerTreeMap CompositorBridgeParent::sIndirectLayerTrees - MOZ_GUARDED_BY(CompositorBridgeParent::sIndirectLayerTreesLock); +MOZ_RUNINIT CompositorBridgeParent::LayerTreeMap + CompositorBridgeParent::sIndirectLayerTrees MOZ_GUARDED_BY( + CompositorBridgeParent::sIndirectLayerTreesLock); CompositorBridgeParentBase::CompositorBridgeParentBase( CompositorManagerParent* aManager) diff --git a/gfx/layers/ipc/CompositorManagerParent.cpp b/gfx/layers/ipc/CompositorManagerParent.cpp index 35784541e24e..719c4ba998b7 100644 --- a/gfx/layers/ipc/CompositorManagerParent.cpp +++ b/gfx/layers/ipc/CompositorManagerParent.cpp @@ -24,7 +24,8 @@ namespace layers { StaticMonitor CompositorManagerParent::sMonitor; StaticRefPtr CompositorManagerParent::sInstance; -CompositorManagerParent::ManagerMap CompositorManagerParent::sManagers; +MOZ_RUNINIT CompositorManagerParent::ManagerMap + CompositorManagerParent::sManagers; /* static */ already_AddRefed diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 5942e7782fb3..851449161307 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -47,7 +47,7 @@ using namespace mozilla::ipc; using namespace mozilla::gfx; using namespace mozilla::media; -ImageBridgeParent::ImageBridgeMap ImageBridgeParent::sImageBridges; +MOZ_RUNINIT ImageBridgeParent::ImageBridgeMap ImageBridgeParent::sImageBridges; StaticAutoPtr sImageBridgesLock; diff --git a/gfx/layers/ipc/VideoBridgeParent.cpp b/gfx/layers/ipc/VideoBridgeParent.cpp index eb54982a5650..ff35f66aeaf3 100644 --- a/gfx/layers/ipc/VideoBridgeParent.cpp +++ b/gfx/layers/ipc/VideoBridgeParent.cpp @@ -24,7 +24,7 @@ using VideoBridgeTable = EnumeratedArray sVideoBridgeFromProcess( +MOZ_RUNINIT static StaticDataMutex sVideoBridgeFromProcess( "VideoBridges"); static Atomic sVideoBridgeParentShutDown(false); diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index 211c28ee0a70..8620d4160dd3 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -86,7 +86,7 @@ void gfxAndroidPlatform::FontAPIInitializeCallback(void* aUnused) { } PRThread* gfxAndroidPlatform::sFontAPIInitializeThread = nullptr; -nsCString gfxAndroidPlatform::sManufacturer; +MOZ_RUNINIT nsCString gfxAndroidPlatform::sManufacturer; // static bool gfxAndroidPlatform::IsFontAPIDisabled(bool aDontCheckPref) { diff --git a/gfx/thebes/gfxDWriteCommon.cpp b/gfx/thebes/gfxDWriteCommon.cpp index ee81f15680ef..cd5cd699a20f 100644 --- a/gfx/thebes/gfxDWriteCommon.cpp +++ b/gfx/thebes/gfxDWriteCommon.cpp @@ -15,7 +15,8 @@ class gfxDWriteFontFileStream; static mozilla::StaticMutex sFontFileStreamsMutex MOZ_UNANNOTATED; static uint64_t sNextFontFileKey = 0; -static std::unordered_map sFontFileStreams; +MOZ_RUNINIT static std::unordered_map + sFontFileStreams; IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = nullptr; diff --git a/gfx/thebes/gfxFontMissingGlyphs.cpp b/gfx/thebes/gfxFontMissingGlyphs.cpp index 949a71228c0b..a268b7700e78 100644 --- a/gfx/thebes/gfxFontMissingGlyphs.cpp +++ b/gfx/thebes/gfxFontMissingGlyphs.cpp @@ -196,8 +196,8 @@ static void DestroyImageKey(void* aClosure) { delete key; } -static RefPtr gWRGlyphAtlas[8]; -static LinkedList gWRUsers; +MOZ_RUNINIT static RefPtr gWRGlyphAtlas[8]; +MOZ_RUNINIT static LinkedList gWRUsers; UserDataKey WRUserData::sWRUserDataKey; /** diff --git a/gfx/thebes/gfxFontUtils.cpp b/gfx/thebes/gfxFontUtils.cpp index a1146e8e3df0..0ca17989200e 100644 --- a/gfx/thebes/gfxFontUtils.cpp +++ b/gfx/thebes/gfxFontUtils.cpp @@ -1294,7 +1294,7 @@ nsresult gfxFontUtils::ReadCanonicalName(const char* aNameData, // on the first search. const uint16_t ANY = 0xffff; -const gfxFontUtils::MacFontNameCharsetMapping +MOZ_RUNINIT const gfxFontUtils::MacFontNameCharsetMapping gfxFontUtils::gMacFontNameCharsets[] = { {ENCODING_ID_MAC_ROMAN, LANG_ID_MAC_ENGLISH, MACINTOSH_ENCODING}, {ENCODING_ID_MAC_ROMAN, LANG_ID_MAC_ICELANDIC, X_USER_DEFINED_ENCODING}, @@ -1325,14 +1325,14 @@ const gfxFontUtils::MacFontNameCharsetMapping GB18030_ENCODING}, {ENCODING_ID_MAC_SIMP_CHINESE, ANY, GB18030_ENCODING}}; -const Encoding* gfxFontUtils::gISOFontNameCharsets[] = { +MOZ_RUNINIT const Encoding* gfxFontUtils::gISOFontNameCharsets[] = { /* 0 */ WINDOWS_1252_ENCODING, /* US-ASCII */ /* 1 */ nullptr, /* spec says "ISO 10646" but does not specify encoding form! */ /* 2 */ WINDOWS_1252_ENCODING /* ISO-8859-1 */ }; -const Encoding* gfxFontUtils::gMSFontNameCharsets[] = { +MOZ_RUNINIT const Encoding* gfxFontUtils::gMSFontNameCharsets[] = { /* [0] ENCODING_ID_MICROSOFT_SYMBOL */ UTF_16BE_ENCODING, /* [1] ENCODING_ID_MICROSOFT_UNICODEBMP */ UTF_16BE_ENCODING, /* [2] ENCODING_ID_MICROSOFT_SHIFTJIS */ SHIFT_JIS_ENCODING, diff --git a/gfx/thebes/gfxGradientCache.cpp b/gfx/thebes/gfxGradientCache.cpp index c2a1682a7d9e..98c6349566d2 100644 --- a/gfx/thebes/gfxGradientCache.cpp +++ b/gfx/thebes/gfxGradientCache.cpp @@ -255,7 +255,7 @@ class GradientCache final nsTArray> mRemovedGradientData; }; -GradientCacheMutex GradientCache::sInstanceMutex("GradientCache"); +MOZ_RUNINIT GradientCacheMutex GradientCache::sInstanceMutex("GradientCache"); void gfxGradientCache::Init() { MOZ_RELEASE_ASSERT(GradientCache::EnsureInstance(), diff --git a/gfx/thebes/gfxHarfBuzzShaper.cpp b/gfx/thebes/gfxHarfBuzzShaper.cpp index bc94f3df69c5..4a42b3407c86 100644 --- a/gfx/thebes/gfxHarfBuzzShaper.cpp +++ b/gfx/thebes/gfxHarfBuzzShaper.cpp @@ -1200,7 +1200,7 @@ static void AddOpenTypeFeature(uint32_t aTag, uint32_t aValue, void* aUserArg) { static hb_font_funcs_t* sHBFontFuncs = nullptr; static hb_font_funcs_t* sNominalGlyphFunc = nullptr; static hb_unicode_funcs_t* sHBUnicodeFuncs = nullptr; -static const hb_script_t sMathScript = +MOZ_RUNINIT static const hb_script_t sMathScript = hb_ot_tag_to_script(HB_TAG('m', 'a', 't', 'h')); bool gfxHarfBuzzShaper::Initialize() { diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index d74eab89c867..2117f043357a 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -1772,7 +1772,7 @@ bool gfxUtils::DumpDisplayList() { XRE_IsContentProcess()); } -FILE* gfxUtils::sDumpPaintFile = stderr; +MOZ_GLOBINIT FILE* gfxUtils::sDumpPaintFile = stderr; namespace mozilla { namespace gfx { diff --git a/gfx/webrender_bindings/Moz2DImageRenderer.cpp b/gfx/webrender_bindings/Moz2DImageRenderer.cpp index 66f61d719e78..adb3c66d631b 100644 --- a/gfx/webrender_bindings/Moz2DImageRenderer.cpp +++ b/gfx/webrender_bindings/Moz2DImageRenderer.cpp @@ -78,8 +78,9 @@ struct FontInstanceData { }; StaticMutex sFontDataTableLock; -std::unordered_map sFontDataTable; -std::unordered_map sBlobFontTable; +MOZ_RUNINIT std::unordered_map sFontDataTable; +MOZ_RUNINIT std::unordered_map + sBlobFontTable; // Fixed-size ring buffer logging font deletion events to aid debugging. static struct FontDeleteLog { diff --git a/hal/windows/WindowsSensor.cpp b/hal/windows/WindowsSensor.cpp index 73bd8bc57cc3..71c6236b5d25 100644 --- a/hal/windows/WindowsSensor.cpp +++ b/hal/windows/WindowsSensor.cpp @@ -16,7 +16,7 @@ using namespace mozilla::hal; namespace mozilla { namespace hal_impl { -static RefPtr sAccelerometer; +MOZ_RUNINIT static RefPtr sAccelerometer; class SensorEvent final : public ISensorEvents { public: diff --git a/ipc/chromium/src/base/process_util_linux.cc b/ipc/chromium/src/base/process_util_linux.cc index 25939622fa11..6db47612c4de 100644 --- a/ipc/chromium/src/base/process_util_linux.cc +++ b/ipc/chromium/src/base/process_util_linux.cc @@ -39,7 +39,7 @@ namespace { -static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); +MOZ_RUNINIT static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); } // namespace diff --git a/ipc/chromium/src/base/process_util_mac.mm b/ipc/chromium/src/base/process_util_mac.mm index d3c91ee362d1..ad7eede7f298 100644 --- a/ipc/chromium/src/base/process_util_mac.mm +++ b/ipc/chromium/src/base/process_util_mac.mm @@ -34,7 +34,7 @@ int responsibility_spawnattrs_setdisclaim(posix_spawnattr_t attrs, int disclaim) namespace { -static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); +MOZ_RUNINIT static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); } // namespace diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index 7e136ce320b6..91c762737417 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -746,7 +746,8 @@ bool ParentImpl::sShutdownHasStarted = false; // ChildImpl Static Members // ----------------------------------------------------------------------------- -ChildImpl::ThreadInfoWrapper ChildImpl::sParentAndContentProcessThreadInfo; +MOZ_RUNINIT ChildImpl::ThreadInfoWrapper + ChildImpl::sParentAndContentProcessThreadInfo; bool ChildImpl::sShutdownHasStarted = false; diff --git a/ipc/glue/ForkServiceChild.cpp b/ipc/glue/ForkServiceChild.cpp index c4dc1e7cab60..8e46bce304ee 100644 --- a/ipc/glue/ForkServiceChild.cpp +++ b/ipc/glue/ForkServiceChild.cpp @@ -24,7 +24,8 @@ namespace ipc { extern LazyLogModule gForkServiceLog; -mozilla::UniquePtr ForkServiceChild::sForkServiceChild; +MOZ_RUNINIT mozilla::UniquePtr + ForkServiceChild::sForkServiceChild; Atomic ForkServiceChild::sForkServiceUsed; #ifndef SOCK_CLOEXEC diff --git a/ipc/glue/IdleSchedulerParent.cpp b/ipc/glue/IdleSchedulerParent.cpp index 27a3116f3854..6ac7a36502c1 100644 --- a/ipc/glue/IdleSchedulerParent.cpp +++ b/ipc/glue/IdleSchedulerParent.cpp @@ -17,10 +17,12 @@ namespace mozilla::ipc { -RefPtr IdleSchedulerParent::sActiveChildCounter = nullptr; +MOZ_RUNINIT RefPtr IdleSchedulerParent::sActiveChildCounter = + nullptr; std::bitset IdleSchedulerParent::sInUseChildCounters; -LinkedList IdleSchedulerParent::sIdleAndGCRequests; +MOZ_RUNINIT LinkedList + IdleSchedulerParent::sIdleAndGCRequests; int32_t IdleSchedulerParent::sMaxConcurrentIdleTasksInChildProcesses = 1; uint32_t IdleSchedulerParent::sMaxConcurrentGCs = 1; uint32_t IdleSchedulerParent::sActiveGCs = 0; diff --git a/ipc/glue/ProcessChild.cpp b/ipc/glue/ProcessChild.cpp index d8159e2deaf8..0765155a92d1 100644 --- a/ipc/glue/ProcessChild.cpp +++ b/ipc/glue/ProcessChild.cpp @@ -29,7 +29,7 @@ namespace ipc { ProcessChild* ProcessChild::gProcessChild; StaticMutex ProcessChild::gIPCShutdownStateLock; -nsCString ProcessChild::gIPCShutdownStateAnnotation; +MOZ_RUNINIT nsCString ProcessChild::gIPCShutdownStateAnnotation; static Atomic sExpectingShutdown(false); diff --git a/ipc/ipdl/test/gtest/IPDLUnitTest.cpp b/ipc/ipdl/test/gtest/IPDLUnitTest.cpp index 3a5f28920fe2..a04cf710f31c 100644 --- a/ipc/ipdl/test/gtest/IPDLUnitTest.cpp +++ b/ipc/ipdl/test/gtest/IPDLUnitTest.cpp @@ -25,7 +25,8 @@ namespace mozilla::_ipdltest { -static std::unordered_map +MOZ_RUNINIT static std::unordered_map sAllocChildActorRegistry; const char* RegisterAllocChildActor(const char* aName, @@ -298,7 +299,7 @@ extern UniquePtr (*gMakeIPDLUnitTestProcessChild)( IPC::Channel::ChannelHandle, base::ProcessId, const nsID&); // Initialize gMakeIPDLUnitTestProcessChild in a static constructor. -int _childProcessEntryPointStaticConstructor = ([] { +MOZ_RUNINIT int _childProcessEntryPointStaticConstructor = ([] { gMakeIPDLUnitTestProcessChild = [](IPC::Channel::ChannelHandle aClientChannel, base::ProcessId aParentPid, const nsID& aMessageChannelId) -> UniquePtr { diff --git a/js/src/debugger/ExecutionTracer.cpp b/js/src/debugger/ExecutionTracer.cpp index 904909212926..06fc0a0395f4 100644 --- a/js/src/debugger/ExecutionTracer.cpp +++ b/js/src/debugger/ExecutionTracer.cpp @@ -28,8 +28,9 @@ enum class InlineEntryType : uint8_t { Error, }; -mozilla::Vector ExecutionTracer::globalInstances; -Mutex ExecutionTracer::globalInstanceLock(mutexid::ExecutionTracerGlobalLock); +MOZ_RUNINIT mozilla::Vector ExecutionTracer::globalInstances; +MOZ_RUNINIT Mutex + ExecutionTracer::globalInstanceLock(mutexid::ExecutionTracerGlobalLock); static JS::ExecutionTrace::ImplementationType GetImplementation( AbstractFramePtr frame) { diff --git a/js/src/frontend/ParserAtom.cpp b/js/src/frontend/ParserAtom.cpp index 129052850125..482b3e92c63a 100644 --- a/js/src/frontend/ParserAtom.cpp +++ b/js/src/frontend/ParserAtom.cpp @@ -1214,7 +1214,7 @@ bool InstantiateMarkedAtomsAsPermanent(JSContext* cx, FrontendContext* fc, } /* static */ -WellKnownParserAtoms WellKnownParserAtoms::singleton_; +MOZ_RUNINIT WellKnownParserAtoms WellKnownParserAtoms::singleton_; template TaggedParserAtomIndex WellKnownParserAtoms::lookupChar16Seq( diff --git a/js/src/fuzz-tests/tests.cpp b/js/src/fuzz-tests/tests.cpp index 4b903b6f8a92..587597bf417b 100644 --- a/js/src/fuzz-tests/tests.cpp +++ b/js/src/fuzz-tests/tests.cpp @@ -23,7 +23,7 @@ using namespace mozilla; -JS::PersistentRootedObject gGlobal; +MOZ_RUNINIT JS::PersistentRootedObject gGlobal; JSContext* gCx = nullptr; static const JSClass* getGlobalClass() { diff --git a/js/src/gdb/gdb-tests.h b/js/src/gdb/gdb-tests.h index ecaa3d796958..aeef4a718f2d 100644 --- a/js/src/gdb/gdb-tests.h +++ b/js/src/gdb/gdb-tests.h @@ -77,7 +77,7 @@ struct GDBFragment { static FRAGMENT_CLASS_NAME(category, subname) singleton; \ }; \ FRAGMENT_CLASS_NAME(category, subname) \ - FRAGMENT_CLASS_NAME(category, subname)::singleton; \ + MOZ_RUNINIT FRAGMENT_CLASS_NAME(category, subname)::singleton; \ void FRAGMENT_CLASS_NAME(category, subname)::run(JSContext* cx, \ const char**& argv) diff --git a/js/src/jit/CacheIRSpewer.cpp b/js/src/jit/CacheIRSpewer.cpp index fbc8a50b044a..e86c74049d22 100644 --- a/js/src/jit/CacheIRSpewer.cpp +++ b/js/src/jit/CacheIRSpewer.cpp @@ -297,7 +297,7 @@ class MOZ_RAII CacheIROpsJSONSpewer { } }; -CacheIRSpewer CacheIRSpewer::cacheIRspewer; +MOZ_RUNINIT CacheIRSpewer CacheIRSpewer::cacheIRspewer; CacheIRSpewer::CacheIRSpewer() : outputLock_(mutexid::CacheIRSpewer), guardCount_(0) { diff --git a/js/src/jit/JitOptions.cpp b/js/src/jit/JitOptions.cpp index 81defb1ce20d..f0d2db08d43e 100644 --- a/js/src/jit/JitOptions.cpp +++ b/js/src/jit/JitOptions.cpp @@ -19,7 +19,7 @@ using mozilla::Maybe; namespace js { namespace jit { -DefaultJitOptions JitOptions; +MOZ_RUNINIT DefaultJitOptions JitOptions; static void Warn(const char* env, const char* value) { fprintf(stderr, "Warning: I didn't understand %s=\"%s\"\n", env, value); diff --git a/js/src/jit/JitSpewer.cpp b/js/src/jit/JitSpewer.cpp index 694844ce49ea..d92e6bf29e6a 100644 --- a/js/src/jit/JitSpewer.cpp +++ b/js/src/jit/JitSpewer.cpp @@ -63,7 +63,7 @@ class IonSpewer { }; // IonSpewer singleton. -static IonSpewer ionspewer; +MOZ_RUNINIT static IonSpewer ionspewer; bool jitspew::detail::LoggingChecked = false; static_assert(JitSpew_Terminator <= 64, diff --git a/js/src/jit/PerfSpewer.cpp b/js/src/jit/PerfSpewer.cpp index 8f20d995dca7..9da743291403 100644 --- a/js/src/jit/PerfSpewer.cpp +++ b/js/src/jit/PerfSpewer.cpp @@ -104,11 +104,12 @@ static std::atomic PerfMode = PerfModeType::None; // Mutex to guard access to the profiler vectors and jitdump file if perf // profiling is enabled. -static js::Mutex PerfMutex(mutexid::PerfSpewer); +MOZ_RUNINIT static js::Mutex PerfMutex(mutexid::PerfSpewer); -static PersistentRooted> +MOZ_RUNINIT static PersistentRooted< + GCVector> jitCodeVector; -static ProfilerJitCodeVector profilerData; +MOZ_RUNINIT static ProfilerJitCodeVector profilerData; static bool IsGeckoProfiling() { return geckoProfiling; } #ifdef JS_ION_PERF diff --git a/js/src/jit/ProcessExecutableMemory.cpp b/js/src/jit/ProcessExecutableMemory.cpp index 0c00b17c73be..1565ba5e22af 100644 --- a/js/src/jit/ProcessExecutableMemory.cpp +++ b/js/src/jit/ProcessExecutableMemory.cpp @@ -884,7 +884,7 @@ void ProcessExecutableMemory::deallocate(void* addr, size_t bytes, } } -static ProcessExecutableMemory execMemory; +MOZ_RUNINIT static ProcessExecutableMemory execMemory; void* js::jit::AllocateExecutableMemory(size_t bytes, ProtectionSetting protection, diff --git a/js/src/jit/arm/Assembler-arm.cpp b/js/src/jit/arm/Assembler-arm.cpp index 3867ada7c338..d6a25ea35c41 100644 --- a/js/src/jit/arm/Assembler-arm.cpp +++ b/js/src/jit/arm/Assembler-arm.cpp @@ -1065,7 +1065,7 @@ O2RegRegShift jit::asr(Register r, Register amt) { static js::jit::DoubleEncoder doubleEncoder; /* static */ -const js::jit::VFPImm js::jit::VFPImm::One(0x3FF00000); +MOZ_RUNINIT const js::jit::VFPImm js::jit::VFPImm::One(0x3FF00000); js::jit::VFPImm::VFPImm(uint32_t top) { data_ = -1; diff --git a/js/src/jsapi-tests/testChromeBuffer.cpp b/js/src/jsapi-tests/testChromeBuffer.cpp index 97631b7ec236..0cfb66ca2984 100644 --- a/js/src/jsapi-tests/testChromeBuffer.cpp +++ b/js/src/jsapi-tests/testChromeBuffer.cpp @@ -16,7 +16,7 @@ #include "jsapi-tests/tests.h" #include "util/Text.h" -static TestJSPrincipals system_principals(1); +MOZ_RUNINIT static TestJSPrincipals system_principals(1); static const JSClass global_class = { "global", @@ -24,8 +24,8 @@ static const JSClass global_class = { &JS::DefaultGlobalClassOps, }; -static JS::PersistentRootedObject trusted_glob; -static JS::PersistentRootedObject trusted_fun; +MOZ_RUNINIT static JS::PersistentRootedObject trusted_glob; +MOZ_RUNINIT static JS::PersistentRootedObject trusted_fun; static bool CallTrusted(JSContext* cx, unsigned argc, JS::Value* vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); diff --git a/js/src/jsapi-tests/testErrorInterceptor.cpp b/js/src/jsapi-tests/testErrorInterceptor.cpp index b868b5dbe425..c1e2e2dd2f7b 100644 --- a/js/src/jsapi-tests/testErrorInterceptor.cpp +++ b/js/src/jsapi-tests/testErrorInterceptor.cpp @@ -7,7 +7,7 @@ // Tests for JS_GetErrorInterceptorCallback and JS_SetErrorInterceptorCallback. namespace { -static JS::PersistentRootedString gLatestMessage; +MOZ_RUNINIT static JS::PersistentRootedString gLatestMessage; // An interceptor that stores the error in `gLatestMessage`. struct SimpleInterceptor : JSErrorInterceptor { diff --git a/js/src/jsapi-tests/testExternalStrings.cpp b/js/src/jsapi-tests/testExternalStrings.cpp index 7b615f39c600..23fbc0a54356 100644 --- a/js/src/jsapi-tests/testExternalStrings.cpp +++ b/js/src/jsapi-tests/testExternalStrings.cpp @@ -49,10 +49,10 @@ struct ExternalStringCallbacks : public JSExternalStringCallbacks { } }; -static const ExternalStringCallbacks callbacks1(&finalized1, true); -static const ExternalStringCallbacks callbacks2(&finalized2, true); -static const ExternalStringCallbacks callbacks3(&finalized3, false); -static const ExternalStringCallbacks callbacks4(&finalized4, false); +MOZ_RUNINIT static const ExternalStringCallbacks callbacks1(&finalized1, true); +MOZ_RUNINIT static const ExternalStringCallbacks callbacks2(&finalized2, true); +MOZ_RUNINIT static const ExternalStringCallbacks callbacks3(&finalized3, false); +MOZ_RUNINIT static const ExternalStringCallbacks callbacks4(&finalized4, false); BEGIN_TEST(testExternalStrings) { const unsigned N = 1000; diff --git a/js/src/jsapi-tests/testFindSCCs.cpp b/js/src/jsapi-tests/testFindSCCs.cpp index 2c0db7daa1f2..fa8d6c47b16b 100644 --- a/js/src/jsapi-tests/testFindSCCs.cpp +++ b/js/src/jsapi-tests/testFindSCCs.cpp @@ -22,7 +22,7 @@ struct TestNode : public GraphNodeBase { using TestComponentFinder = ComponentFinder; -static TestNode Vertex[MaxVertices]; +MOZ_RUNINIT static TestNode Vertex[MaxVertices]; BEGIN_TEST(testFindSCCs) { // no vertices diff --git a/js/src/jsapi-tests/testGCExactRooting.cpp b/js/src/jsapi-tests/testGCExactRooting.cpp index 6b94fc7a2616..0c6c41701d6c 100644 --- a/js/src/jsapi-tests/testGCExactRooting.cpp +++ b/js/src/jsapi-tests/testGCExactRooting.cpp @@ -217,7 +217,7 @@ BEGIN_TEST(testGCRootedStaticStructInternalStackStorageAugmented) { } END_TEST(testGCRootedStaticStructInternalStackStorageAugmented) -static JS::PersistentRooted sLongLived; +MOZ_RUNINIT static JS::PersistentRooted sLongLived; BEGIN_TEST(testGCPersistentRootedOutlivesRuntime) { sLongLived.init(cx, JS_NewObject(cx, nullptr)); CHECK(sLongLived); @@ -229,7 +229,7 @@ END_TEST(testGCPersistentRootedOutlivesRuntime) // performance and simplicity reasons, PersistentRooted is not // allowed to outlive the container it belongs to. The following commented out // test can be used to verify that the relevant assertion fires as expected. -static JS::PersistentRooted sContainer; +MOZ_RUNINIT static JS::PersistentRooted sContainer; BEGIN_TEST(testGCPersistentRootedTraceableCannotOutliveRuntime) { JS::Rooted container(cx); container.obj() = JS_NewObject(cx, nullptr); diff --git a/js/src/jsapi-tests/testJitABIcalls.cpp b/js/src/jsapi-tests/testJitABIcalls.cpp index 1bd0468aa575..e2066cf7d61f 100644 --- a/js/src/jsapi-tests/testJitABIcalls.cpp +++ b/js/src/jsapi-tests/testJitABIcalls.cpp @@ -695,9 +695,10 @@ class JitABICall final : public JSAPIRuntimeTest, public DefineCheckArgs { // For each VMFunction and ABIFunction, create an instance of a JitABICall // class to register a jsapi-tests test case. -#define TEST_INSTANCE(Name, Sig) \ - static JitABICall MOZ_CONCAT(MOZ_CONCAT(cls_jitabicall, __COUNTER__), \ - _instance)("JIT ABI for " Name); +#define TEST_INSTANCE(Name, Sig) \ + MOZ_RUNINIT static JitABICall MOZ_CONCAT( \ + MOZ_CONCAT(cls_jitabicall, __COUNTER__), \ + _instance)("JIT ABI for " Name); #define TEST_INSTANCE_ABIFUN_TO_ALLFUN(...) \ APPLY(TEST_INSTANCE, ABIFUN_TO_ALLFUN(__VA_ARGS__)) #define TEST_INSTANCE_ABIFUN_AND_SIG_TO_ALLFUN(...) \ diff --git a/js/src/jsapi-tests/testPersistentRooted.cpp b/js/src/jsapi-tests/testPersistentRooted.cpp index 3a421fd3d326..f88049180767 100644 --- a/js/src/jsapi-tests/testPersistentRooted.cpp +++ b/js/src/jsapi-tests/testPersistentRooted.cpp @@ -181,7 +181,7 @@ BEGIN_TEST(test_PersistentRootedAssign) { } END_TEST(test_PersistentRootedAssign) -static PersistentRootedObject gGlobalRoot; +MOZ_RUNINIT static PersistentRootedObject gGlobalRoot; // PersistentRooted instances can initialized in a separate step to allow for // global PersistentRooteds. diff --git a/js/src/jsapi-tests/testProfileStrings.cpp b/js/src/jsapi-tests/testProfileStrings.cpp index a0453f85a989..4f0456646fd2 100644 --- a/js/src/jsapi-tests/testProfileStrings.cpp +++ b/js/src/jsapi-tests/testProfileStrings.cpp @@ -16,7 +16,7 @@ #include "jsapi-tests/tests.h" #include "vm/JSContext.h" -static ProfilingStack profilingStack; +MOZ_RUNINIT static ProfilingStack profilingStack; static uint32_t peakStackPointer = 0; static void reset(JSContext* cx) { diff --git a/js/src/jsapi-tests/testSetPropertyIgnoringNamedGetter.cpp b/js/src/jsapi-tests/testSetPropertyIgnoringNamedGetter.cpp index cc4ef9cdc842..1d9de0686406 100644 --- a/js/src/jsapi-tests/testSetPropertyIgnoringNamedGetter.cpp +++ b/js/src/jsapi-tests/testSetPropertyIgnoringNamedGetter.cpp @@ -42,7 +42,7 @@ class CustomProxyHandler : public Wrapper { } }; -const CustomProxyHandler customProxyHandler; +MOZ_RUNINIT const CustomProxyHandler customProxyHandler; BEGIN_TEST(testSetPropertyIgnoringNamedGetter_direct) { RootedValue protov(cx); diff --git a/js/src/jsapi-tests/tests.h b/js/src/jsapi-tests/tests.h index 342ec5d089fd..821e3db3f56a 100644 --- a/js/src/jsapi-tests/tests.h +++ b/js/src/jsapi-tests/tests.h @@ -447,7 +447,7 @@ class JSAPIFrontendTest : public JSAPITest { #define END_TEST(testname) \ } \ ; \ - static cls_##testname cls_##testname##_instance; + MOZ_RUNINIT static cls_##testname cls_##testname##_instance; /* * A "fixture" is a subclass of JSAPIRuntimeTest that holds common definitions @@ -466,7 +466,7 @@ class JSAPIFrontendTest : public JSAPITest { #define END_FIXTURE_TEST(fixture, testname) \ } \ ; \ - static cls_##testname cls_##testname##_instance; + MOZ_RUNINIT static cls_##testname cls_##testname##_instance; /* * A class for creating and managing one temporary file. diff --git a/js/src/proxy/Wrapper.cpp b/js/src/proxy/Wrapper.cpp index 0c31a11d3867..a9c2849801b8 100644 --- a/js/src/proxy/Wrapper.cpp +++ b/js/src/proxy/Wrapper.cpp @@ -422,7 +422,7 @@ void js::ReportAccessDenied(JSContext* cx) { const char Wrapper::family = 0; const Wrapper Wrapper::singleton((unsigned)0); const Wrapper Wrapper::singletonWithPrototype((unsigned)0, true); -JSObject* const Wrapper::defaultProto = TaggedProto::LazyProto; +MOZ_RUNINIT JSObject* const Wrapper::defaultProto = TaggedProto::LazyProto; /* Compartments. */ diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 61dfb45785f5..c6684585a007 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -464,8 +464,8 @@ static const double MAX_TIMEOUT_SECONDS = 1800.0; // Fuzzing support for JS runtime fuzzing #ifdef FUZZING_INTERFACES # include "shell/jsrtfuzzing/jsrtfuzzing.h" -static bool fuzzDoDebug = !!getenv("MOZ_FUZZ_DEBUG"); -static bool fuzzHaveModule = !!getenv("FUZZER"); +MOZ_RUNINIT static bool fuzzDoDebug = !!getenv("MOZ_FUZZ_DEBUG"); +MOZ_RUNINIT static bool fuzzHaveModule = !!getenv("FUZZER"); #endif // FUZZING_INTERFACES // Code to support GCOV code coverage measurements on standalone shell @@ -860,7 +860,7 @@ bool shell::dumpEntrainedVariables = false; bool shell::OOM_printAllocationCount = false; #endif -UniqueChars shell::processWideModuleLoadPath; +MOZ_RUNINIT UniqueChars shell::processWideModuleLoadPath; static bool SetTimeoutValue(JSContext* cx, double t); @@ -959,7 +959,7 @@ JSSecurityCallbacks ShellPrincipals::securityCallbacks = { subsumes}; // The fully-trusted principal subsumes all other principals. -ShellPrincipals ShellPrincipals::fullyTrusted(-1, 1); +MOZ_RUNINIT ShellPrincipals ShellPrincipals::fullyTrusted(-1, 1); #ifdef EDITLINE extern "C" { @@ -1581,7 +1581,8 @@ class MOZ_RAII AutoLockTelemetry : public LockGuard { using TelemetryData = uint32_t; using TelemetryVec = Vector; -static mozilla::Array telemetryResults; +MOZ_RUNINIT static mozilla::Array + telemetryResults; static void AccumulateTelemetryDataCallback(JSMetric id, uint32_t sample) { AutoLockTelemetry alt; // We ignore OOMs while writting teleemtry data. @@ -1621,7 +1622,7 @@ static void WriteTelemetryDataToDisk(const char* dir) { #undef MAP_TELEMETRY // Use Counter introspection -static Mutex useCounterLock(mutexid::ShellUseCounters); +MOZ_RUNINIT static Mutex useCounterLock(mutexid::ShellUseCounters); class MOZ_RAII AutoLockUseCounters : public LockGuard { using Base = LockGuard; @@ -4580,7 +4581,8 @@ static void WorkerMain(UniquePtr input) { // Workers can spawn other workers, so we need a lock to access workerThreads. static Mutex* workerThreadsLock = nullptr; -static Vector, 0, SystemAllocPolicy> workerThreads; +MOZ_RUNINIT static Vector, 0, SystemAllocPolicy> + workerThreads; class MOZ_RAII AutoLockWorkerThreads : public LockGuard { using Base = LockGuard; @@ -6695,7 +6697,8 @@ char** shell::sArgv; #ifndef __wasi__ static const char sWasmCompileAndSerializeFlag[] = "--wasm-compile-and-serialize"; -static Vector sCompilerProcessFlags; +MOZ_RUNINIT static Vector + sCompilerProcessFlags; static bool CompileAndSerializeInSeparateProcess(JSContext* cx, const uint8_t* bytecode, diff --git a/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp b/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp index 8691d5f93558..bcff7914159c 100644 --- a/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp +++ b/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp @@ -39,7 +39,7 @@ #include "vm/JSContext-inl.h" static JSContext* gCx = nullptr; -static std::string gFuzzModuleName; +MOZ_RUNINIT static std::string gFuzzModuleName; static void CrashOnPendingException() { if (JS_IsExceptionPending(gCx)) { diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 63c341bbcbc3..c247c3befd52 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -56,7 +56,7 @@ static void CancelOffThreadWasmPartialTier2CompileLocked( namespace js { -Mutex gHelperThreadLock(mutexid::GlobalHelperThreadState); +MOZ_RUNINIT Mutex gHelperThreadLock(mutexid::GlobalHelperThreadState); GlobalHelperThreadState* gHelperThreadState = nullptr; } // namespace js diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp index be6100264a23..43f9b07ffffb 100644 --- a/js/src/vm/NativeObject.cpp +++ b/js/src/vm/NativeObject.cpp @@ -86,7 +86,7 @@ static constexpr EmptyObjectSlots emptyObjectSlotsHeaders[17] = { static_assert(std::size(emptyObjectSlotsHeaders) == NativeObject::MAX_FIXED_SLOTS + 1); -HeapSlot* const js::emptyObjectSlotsForDictionaryObject[17] = { +MOZ_RUNINIT HeapSlot* const js::emptyObjectSlotsForDictionaryObject[17] = { emptyObjectSlotsHeaders[0].slots(), emptyObjectSlotsHeaders[1].slots(), emptyObjectSlotsHeaders[2].slots(), emptyObjectSlotsHeaders[3].slots(), emptyObjectSlotsHeaders[4].slots(), emptyObjectSlotsHeaders[5].slots(), @@ -100,7 +100,8 @@ HeapSlot* const js::emptyObjectSlotsForDictionaryObject[17] = { static_assert(std::size(emptyObjectSlotsForDictionaryObject) == NativeObject::MAX_FIXED_SLOTS + 1); -HeapSlot* const js::emptyObjectSlots = emptyObjectSlotsForDictionaryObject[0]; +MOZ_RUNINIT HeapSlot* const js::emptyObjectSlots = + emptyObjectSlotsForDictionaryObject[0]; #ifdef DEBUG diff --git a/js/src/vm/SharedScriptDataTableHolder.cpp b/js/src/vm/SharedScriptDataTableHolder.cpp index 8575b6695d12..6e64dda1611b 100644 --- a/js/src/vm/SharedScriptDataTableHolder.cpp +++ b/js/src/vm/SharedScriptDataTableHolder.cpp @@ -10,10 +10,11 @@ using namespace js; -js::Mutex AutoLockGlobalScriptData::mutex_(mutexid::SharedImmutableScriptData); +MOZ_RUNINIT js::Mutex AutoLockGlobalScriptData::mutex_( + mutexid::SharedImmutableScriptData); AutoLockGlobalScriptData::AutoLockGlobalScriptData() { mutex_.lock(); } AutoLockGlobalScriptData::~AutoLockGlobalScriptData() { mutex_.unlock(); } -SharedScriptDataTableHolder js::globalSharedScriptDataTableHolder; +MOZ_RUNINIT SharedScriptDataTableHolder js::globalSharedScriptDataTableHolder; diff --git a/js/src/vm/StencilCache.cpp b/js/src/vm/StencilCache.cpp index 1bf138c63ee6..c9252e8fea51 100644 --- a/js/src/vm/StencilCache.cpp +++ b/js/src/vm/StencilCache.cpp @@ -66,4 +66,5 @@ void js::StencilCache::clearAndDisable() { enabled = false; } -/* static */ js::DelazificationCache js::DelazificationCache::singleton; +MOZ_RUNINIT /* static */ js::DelazificationCache + js::DelazificationCache::singleton; diff --git a/js/src/wasm/WasmBuiltins.cpp b/js/src/wasm/WasmBuiltins.cpp index fd5c7f08af3f..9973b78f449c 100644 --- a/js/src/wasm/WasmBuiltins.cpp +++ b/js/src/wasm/WasmBuiltins.cpp @@ -1987,7 +1987,7 @@ struct BuiltinThunks { } }; -Mutex initBuiltinThunks(mutexid::WasmInitBuiltinThunks); +MOZ_RUNINIT Mutex initBuiltinThunks(mutexid::WasmInitBuiltinThunks); mozilla::Atomic builtinThunks; bool wasm::EnsureBuiltinThunksInitialized() { diff --git a/js/src/wasm/WasmModuleTypes.cpp b/js/src/wasm/WasmModuleTypes.cpp index 45d6b64909c2..4a59684a21c7 100644 --- a/js/src/wasm/WasmModuleTypes.cpp +++ b/js/src/wasm/WasmModuleTypes.cpp @@ -52,7 +52,7 @@ bool CacheableName::fromUTF8Chars(const char* utf8Chars, CacheableName* name) { return true; } -BranchHintVector BranchHintCollection::invalidVector_; +MOZ_RUNINIT BranchHintVector BranchHintCollection::invalidVector_; JSString* CacheableName::toJSString(JSContext* cx) const { return NewStringCopyUTF8N(cx, JS::UTF8Chars(begin(), length())); diff --git a/js/src/wasm/WasmProcess.cpp b/js/src/wasm/WasmProcess.cpp index 1d42681ae353..ee3fdf22c319 100644 --- a/js/src/wasm/WasmProcess.cpp +++ b/js/src/wasm/WasmProcess.cpp @@ -154,9 +154,9 @@ static const size_t MinVirtualMemoryLimitForHugeMemory = size_t(1) << MinAddressBitsForHugeMemory; #endif -ExclusiveData sHugeMemoryEnabled32( +MOZ_RUNINIT ExclusiveData sHugeMemoryEnabled32( mutexid::WasmHugeMemoryEnabled); -ExclusiveData sHugeMemoryEnabled64( +MOZ_RUNINIT ExclusiveData sHugeMemoryEnabled64( mutexid::WasmHugeMemoryEnabled); static MOZ_NEVER_INLINE bool IsHugeMemoryEnabledHelper32() { diff --git a/js/src/wasm/WasmSignalHandlers.cpp b/js/src/wasm/WasmSignalHandlers.cpp index 13bb9d9eac9a..d5cbd731bfb1 100644 --- a/js/src/wasm/WasmSignalHandlers.cpp +++ b/js/src/wasm/WasmSignalHandlers.cpp @@ -802,7 +802,7 @@ struct InstallState { InstallState() : tried(false), success(false) {} }; -static ExclusiveData sEagerInstallState( +MOZ_RUNINIT static ExclusiveData sEagerInstallState( mutexid::WasmSignalInstallState); #endif // !(JS_CODEGEN_NONE) @@ -884,7 +884,7 @@ void wasm::EnsureEagerProcessSignalHandlers() { } #ifndef JS_CODEGEN_NONE -static ExclusiveData sLazyInstallState( +MOZ_RUNINIT static ExclusiveData sLazyInstallState( mutexid::WasmSignalInstallState); static bool EnsureLazyProcessSignalHandlers() { diff --git a/js/src/wasm/WasmTypeDef.cpp b/js/src/wasm/WasmTypeDef.cpp index aa854706519f..04f6ebbe2126 100644 --- a/js/src/wasm/WasmTypeDef.cpp +++ b/js/src/wasm/WasmTypeDef.cpp @@ -581,7 +581,7 @@ class TypeIdSet { } }; -ExclusiveData typeIdSet(mutexid::WasmTypeIdSet); +MOZ_RUNINIT ExclusiveData typeIdSet(mutexid::WasmTypeIdSet); void wasm::PurgeCanonicalTypes() { ExclusiveData::Guard locked = typeIdSet.lock(); diff --git a/js/xpconnect/loader/ChromeScriptLoader.cpp b/js/xpconnect/loader/ChromeScriptLoader.cpp index 3564c186798e..405c5f7e3049 100644 --- a/js/xpconnect/loader/ChromeScriptLoader.cpp +++ b/js/xpconnect/loader/ChromeScriptLoader.cpp @@ -197,7 +197,7 @@ class AsyncScriptCompileTask final : public Task { }; /* static */ mozilla::StaticMutex AsyncScriptCompileTask::sOngoingTasksMutex; -/* static */ Vector +MOZ_RUNINIT /* static */ Vector AsyncScriptCompileTask::sOngoingTasks; /* static */ bool AsyncScriptCompileTask::sIsShutdownRegistered = false; diff --git a/js/xpconnect/loader/JSMEnvironmentProxy.cpp b/js/xpconnect/loader/JSMEnvironmentProxy.cpp index cb21151033fd..27fbe886437a 100644 --- a/js/xpconnect/loader/JSMEnvironmentProxy.cpp +++ b/js/xpconnect/loader/JSMEnvironmentProxy.cpp @@ -116,7 +116,8 @@ struct JSMEnvironmentProxyHandler : public js::BaseProxyHandler { static const JSMEnvironmentProxyHandler gHandler; }; -const JSMEnvironmentProxyHandler JSMEnvironmentProxyHandler::gHandler; +MOZ_RUNINIT const JSMEnvironmentProxyHandler + JSMEnvironmentProxyHandler::gHandler; const char JSMEnvironmentProxyHandler::gFamily = 0; JSObject* ResolveModuleObjectPropertyById(JSContext* aCx, diff --git a/js/xpconnect/loader/ModuleEnvironmentProxy.cpp b/js/xpconnect/loader/ModuleEnvironmentProxy.cpp index e70fcb38656c..70238ddc3f36 100644 --- a/js/xpconnect/loader/ModuleEnvironmentProxy.cpp +++ b/js/xpconnect/loader/ModuleEnvironmentProxy.cpp @@ -124,7 +124,8 @@ struct ModuleEnvironmentProxyHandler : public js::BaseProxyHandler { static const ModuleEnvironmentProxyHandler gHandler; }; -const ModuleEnvironmentProxyHandler ModuleEnvironmentProxyHandler::gHandler; +MOZ_RUNINIT const ModuleEnvironmentProxyHandler + ModuleEnvironmentProxyHandler::gHandler; const char ModuleEnvironmentProxyHandler::gFamily = 0; bool ModuleEnvironmentProxyHandler::getOwnPropertyDescriptor( diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index efdb676fe87e..2f70e2607a69 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -90,8 +90,8 @@ #ifdef FUZZING_INTERFACES # include "xpcrtfuzzing/xpcrtfuzzing.h" # include "XREShellData.h" -static bool fuzzDoDebug = !!getenv("MOZ_FUZZ_DEBUG"); -static bool fuzzHaveModule = !!getenv("FUZZER"); +MOZ_RUNINIT static bool fuzzDoDebug = !!getenv("MOZ_FUZZ_DEBUG"); +MOZ_RUNINIT static bool fuzzHaveModule = !!getenv("FUZZER"); #endif // FUZZING_INTERFACES using namespace mozilla; diff --git a/js/xpconnect/src/xpcrtfuzzing/xpcrtfuzzing.cpp b/js/xpconnect/src/xpcrtfuzzing/xpcrtfuzzing.cpp index 3d7b70cf84ad..0f56a55b7a06 100644 --- a/js/xpconnect/src/xpcrtfuzzing/xpcrtfuzzing.cpp +++ b/js/xpconnect/src/xpcrtfuzzing/xpcrtfuzzing.cpp @@ -28,7 +28,7 @@ using mozilla::dom::AutoJSAPI; static AutoJSAPI* gJsapi = nullptr; -static std::string gFuzzModuleName; +MOZ_RUNINIT static std::string gFuzzModuleName; static void CrashOnPendingException() { if (gJsapi->HasException()) { diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 62522c3e9790..8530097e6c19 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -2333,8 +2333,8 @@ bool XrayWrapper::getPropertyKeys( */ template -const xpc::XrayWrapper xpc::XrayWrapper::singleton( - 0); +MOZ_GLOBINIT const xpc::XrayWrapper + xpc::XrayWrapper::singleton(0); template class PermissiveXrayDOM; template class PermissiveXrayJS; diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index ca27327a6f56..0ffafb994174 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -228,7 +228,7 @@ using namespace mozilla::layout; using PaintFrameFlags = nsLayoutUtils::PaintFrameFlags; typedef ScrollableLayerGuid::ViewID ViewID; -PresShell::CapturingContentInfo PresShell::sCapturingContentInfo; +MOZ_RUNINIT PresShell::CapturingContentInfo PresShell::sCapturingContentInfo; // RangePaintInfo is used to paint ranges to offscreen buffers struct RangePaintInfo { diff --git a/layout/painting/DashedCornerFinder.cpp b/layout/painting/DashedCornerFinder.cpp index c892179df9cc..b91c3b2f09ed 100644 --- a/layout/painting/DashedCornerFinder.cpp +++ b/layout/painting/DashedCornerFinder.cpp @@ -29,7 +29,7 @@ struct BestDashLength { }; static const size_t DashedCornerCacheSize = 256; -nsTHashMap DashedCornerCache; +MOZ_RUNINIT nsTHashMap DashedCornerCache; DashedCornerFinder::DashedCornerFinder(const Bezier& aOuterBezier, const Bezier& aInnerBezier, diff --git a/layout/painting/DottedCornerFinder.cpp b/layout/painting/DottedCornerFinder.cpp index 2e8408d80b08..4c9411e86607 100644 --- a/layout/painting/DottedCornerFinder.cpp +++ b/layout/painting/DottedCornerFinder.cpp @@ -31,7 +31,7 @@ struct BestOverlap { }; static const size_t DottedCornerCacheSize = 256; -nsTHashMap DottedCornerCache; +MOZ_RUNINIT nsTHashMap DottedCornerCache; DottedCornerFinder::DottedCornerFinder(const Bezier& aOuterBezier, const Bezier& aInnerBezier, diff --git a/layout/style/SharedSubResourceCache.h b/layout/style/SharedSubResourceCache.h index be0710d650b9..a8a512dc84d9 100644 --- a/layout/style/SharedSubResourceCache.h +++ b/layout/style/SharedSubResourceCache.h @@ -261,7 +261,7 @@ class SharedSubResourceCache { protected: // Lazily created in the first Get() call. // The singleton should be deleted by DeleteSingleton() during shutdown. - inline static StaticRefPtr sSingleton; + inline static MOZ_GLOBINIT StaticRefPtr sSingleton; }; template diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index e82825b8f086..926495ab5d85 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -51,7 +51,8 @@ using namespace mozilla; using namespace mozilla::dom; -static const nscoord kMediumBorderWidth = nsPresContext::CSSPixelsToAppUnits(3); +MOZ_RUNINIT static const nscoord kMediumBorderWidth = + nsPresContext::CSSPixelsToAppUnits(3); // We set the size limit of style structs to 504 bytes so that when they // are allocated by Servo side with Arc, the total size doesn't exceed @@ -309,7 +310,7 @@ static StyleRect StyleRectWithAllSides(const T& aSide) { return {aSide, aSide, aSide, aSide}; } -const StyleMargin nsStyleMargin::kZeroMargin = +MOZ_RUNINIT const StyleMargin nsStyleMargin::kZeroMargin = StyleMargin::LengthPercentage(StyleLengthPercentage::Zero()); nsStyleMargin::nsStyleMargin() @@ -1357,9 +1358,10 @@ StyleJustifySelf nsStylePosition::UsedJustifySelf( return {StyleAlignFlags::NORMAL}; } -const StyleInset nsStylePosition::kAutoInset = StyleInset::Auto(); -const StyleSize nsStylePosition::kAutoSize = StyleSize::Auto(); -const StyleMaxSize nsStylePosition::kNoneMaxSize = StyleMaxSize::None(); +MOZ_RUNINIT const StyleInset nsStylePosition::kAutoInset = StyleInset::Auto(); +MOZ_RUNINIT const StyleSize nsStylePosition::kAutoSize = StyleSize::Auto(); +MOZ_RUNINIT const StyleMaxSize nsStylePosition::kNoneMaxSize = + StyleMaxSize::None(); // -------------------- // nsStyleTable diff --git a/media/webrtc/signaling/gtest/jsep_session_unittest.cpp b/media/webrtc/signaling/gtest/jsep_session_unittest.cpp index 0b7f27e01a8b..f610cfafcaad 100644 --- a/media/webrtc/signaling/gtest/jsep_session_unittest.cpp +++ b/media/webrtc/signaling/gtest/jsep_session_unittest.cpp @@ -26,7 +26,7 @@ #include "jsep/JsepSessionImpl.h" namespace mozilla { -static std::string kAEqualsCandidate("a=candidate:"); +MOZ_RUNINIT static std::string kAEqualsCandidate("a=candidate:"); const static size_t kNumCandidatesPerComponent = 3; class JsepSessionTestBase : public ::testing::Test { @@ -5533,7 +5533,7 @@ TEST_F(JsepSessionTest, CreateOfferDontReceiveVideoRemoveVideoTrack) { CreateOffer(Some(options)); } -static const std::string strSampleCandidate = +MOZ_RUNINIT static const std::string strSampleCandidate = "a=candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host\r\n"; static const unsigned short nSamplelevel = 2; diff --git a/media/webrtc/signaling/gtest/sdp_unittests.cpp b/media/webrtc/signaling/gtest/sdp_unittests.cpp index 2c6cab9c067d..3b6cd4d3b4f3 100644 --- a/media/webrtc/signaling/gtest/sdp_unittests.cpp +++ b/media/webrtc/signaling/gtest/sdp_unittests.cpp @@ -246,7 +246,7 @@ class SdpTest : public ::testing::Test { sdp_t* sdp_ptr_; }; -static const std::string kVideoSdp = +MOZ_RUNINIT static const std::string kVideoSdp = "v=0\r\n" "o=- 4294967296 2 IN IP4 127.0.0.1\r\n" "s=SIP Call\r\n" @@ -406,7 +406,7 @@ TEST_F(SdpTest, parseRtcpFbFooBarBaz) { ParseSdp(kVideoSdp + "a=rtcp-fb:120 foo bar baz\r\n"); } -static const std::string kVideoSdpWithUnknonwBrokenFtmp = +MOZ_RUNINIT static const std::string kVideoSdpWithUnknonwBrokenFtmp = "v=0\r\n" "o=- 4294967296 2 IN IP4 127.0.0.1\r\n" "s=SIP Call\r\n" @@ -1509,7 +1509,7 @@ TEST_F(SdpTest, addFmtpMaxFsFr) { std::string::npos); } -static const std::string kBrokenFmtp = +MOZ_RUNINIT static const std::string kBrokenFmtp = "v=0\r\n" "o=- 4294967296 2 IN IP4 127.0.0.1\r\n" "s=SIP Call\r\n" @@ -1730,7 +1730,7 @@ TEST_P(NewSdpTest, ParseEmpty) { ASSERT_NE(0U, ParseErrorCount()) << "Expected at least one parse error."; } -const std::string kBadSdp = "This is SDPARTA!!!!"; +MOZ_RUNINIT const std::string kBadSdp = "This is SDPARTA!!!!"; TEST_P(NewSdpTest, ParseGarbage) { ParseSdp(kBadSdp, false); @@ -1882,7 +1882,7 @@ TEST_P(NewSdpTest, CheckMediaSectionGetBandwidth) { "BiAGEAFQASAAkAZQBkAGAAFAARAAgABgADAQA=" // SDP from a basic A/V apprtc call FFX/FFX -const std::vector kBasicAudioVideoOfferLines = { +MOZ_RUNINIT const std::vector kBasicAudioVideoOfferLines = { "v=0", "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0", "s=SIP Call", @@ -2004,10 +2004,10 @@ static std::string joinSdp(const std::vector& aSdp, return result.str(); } -const std::string kBasicAudioVideoOffer = +MOZ_RUNINIT const std::string kBasicAudioVideoOffer = joinSdp(kBasicAudioVideoOfferLines, "\r\n"); -const std::string kBasicAudioVideoOfferLinefeedOnly = +MOZ_RUNINIT const std::string kBasicAudioVideoOfferLinefeedOnly = joinSdp(kBasicAudioVideoOfferLines, "\n"); TEST_P(NewSdpTest, BasicAudioVideoSdpParse) { ParseSdp(kBasicAudioVideoOffer); } @@ -2326,7 +2326,7 @@ TEST_P(NewSdpTest, CheckRtpmap) { videosec.GetFormats()[3], videoRtpmap); } -static const std::string kAudioWithTelephoneEvent = +MOZ_RUNINIT static const std::string kAudioWithTelephoneEvent = "v=0" CRLF "o=- 4294967296 2 IN IP4 127.0.0.1" CRLF "s=SIP Call" CRLF "c=IN IP4 198.51.100.7" CRLF "t=0 0" CRLF "m=audio 9 RTP/SAVPF 109 9 0 8 101" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -2542,7 +2542,7 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadRangeReversed) { CheckDtmfFmtp("0-15"); } -static const std::string kVideoWithRedAndUlpfecSdp = +MOZ_RUNINIT static const std::string kVideoWithRedAndUlpfecSdp = "v=0" CRLF "o=- 4294967296 2 IN IP4 127.0.0.1" CRLF "s=SIP Call" CRLF "c=IN IP4 198.51.100.7" CRLF "t=0 0" CRLF "m=video 9 RTP/SAVPF 97 120 121 122 123" CRLF "c=IN IP6 ::1" CRLF @@ -2656,7 +2656,7 @@ TEST_P(NewSdpTest, CheckRedFmtpWith3Codecs) { ASSERT_EQ(123U, red_parameters->encodings[2]); } -const std::string kH264AudioVideoOffer = +MOZ_RUNINIT const std::string kH264AudioVideoOffer = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=ice-ufrag:4a799b2e" CRLF @@ -3140,7 +3140,7 @@ TEST_P(NewSdpTest, CheckManyGroups) { } // SDP from a basic A/V call with data channel FFX/FFX -const std::string kBasicAudioVideoDataOffer = +MOZ_RUNINIT const std::string kBasicAudioVideoDataOffer = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 27987 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "t=0 0" CRLF "a=ice-ufrag:8a39d2ae" CRLF "a=ice-pwd:601d53aba51a318351b3ecf5ee00048f" CRLF @@ -3427,7 +3427,7 @@ TEST_P(NewSdpTest, CheckMaxPtime) { ASSERT_EQ(Sdp()->GetMediaSection(0).GetAttributeList().GetMaxptime(), 20U); } -const std::string kNewSctpportOfferDraft21 = +MOZ_RUNINIT const std::string kNewSctpportOfferDraft21 = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 27987 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "t=0 0" CRLF "a=ice-ufrag:8a39d2ae" CRLF "a=ice-pwd:601d53aba51a318351b3ecf5ee00048f" CRLF @@ -3446,7 +3446,7 @@ INSTANTIATE_TEST_SUITE_P(RoundTripSerialize, NewSdpTest, ::testing::Combine(::testing::Bool(), ::testing::Bool())); -const std::string kCandidateInSessionSDP = +MOZ_RUNINIT const std::string kCandidateInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=candidate:0 1 UDP 2130379007 10.0.0.36 62453 typ host" CRLF @@ -3465,7 +3465,7 @@ TEST_P(NewSdpTest, CheckCandidateInSessionLevel) { } } -const std::string kBundleOnlyInSessionSDP = +MOZ_RUNINIT const std::string kBundleOnlyInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=bundle-only" CRLF "m=audio 9 RTP/SAVPF 109 9 0 8 101" CRLF @@ -3483,7 +3483,7 @@ TEST_P(NewSdpTest, CheckBundleOnlyInSessionLevel) { } } -const std::string kFmtpInSessionSDP = +MOZ_RUNINIT const std::string kFmtpInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=fmtp:109 0-15" CRLF "m=audio 9 RTP/SAVPF 109 9 0 8 101" CRLF @@ -3501,7 +3501,7 @@ TEST_P(NewSdpTest, CheckFmtpInSessionLevel) { } } -const std::string kIceMismatchInSessionSDP = +MOZ_RUNINIT const std::string kIceMismatchInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=ice-mismatch" CRLF "m=audio 9 RTP/SAVPF 109 9 0 8 101" CRLF @@ -3519,7 +3519,7 @@ TEST_P(NewSdpTest, CheckIceMismatchInSessionLevel) { } } -const std::string kImageattrInSessionSDP = +MOZ_RUNINIT const std::string kImageattrInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=imageattr:120 send * recv *" CRLF "m=video 9 RTP/SAVPF 120" CRLF @@ -3537,7 +3537,7 @@ TEST_P(NewSdpTest, CheckImageattrInSessionLevel) { } } -const std::string kLabelInSessionSDP = +MOZ_RUNINIT const std::string kLabelInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=label:foobar" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3555,7 +3555,7 @@ TEST_P(NewSdpTest, CheckLabelInSessionLevel) { } } -const std::string kMaxptimeInSessionSDP = +MOZ_RUNINIT const std::string kMaxptimeInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=maxptime:100" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3573,7 +3573,7 @@ TEST_P(NewSdpTest, CheckMaxptimeInSessionLevel) { } } -const std::string kMidInSessionSDP = +MOZ_RUNINIT const std::string kMidInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=mid:foobar" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3591,7 +3591,7 @@ TEST_P(NewSdpTest, CheckMidInSessionLevel) { } } -const std::string kMsidInSessionSDP = +MOZ_RUNINIT const std::string kMsidInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=msid:foobar" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3609,7 +3609,7 @@ TEST_P(NewSdpTest, CheckMsidInSessionLevel) { } } -const std::string kPtimeInSessionSDP = +MOZ_RUNINIT const std::string kPtimeInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=ptime:50" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3627,7 +3627,7 @@ TEST_P(NewSdpTest, CheckPtimeInSessionLevel) { } } -const std::string kRemoteCandidatesInSessionSDP = +MOZ_RUNINIT const std::string kRemoteCandidatesInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=remote-candidates:0 10.0.0.1 5555" CRLF "m=video 9 RTP/SAVPF 120" CRLF @@ -3645,7 +3645,7 @@ TEST_P(NewSdpTest, CheckRemoteCandidatesInSessionLevel) { } } -const std::string kRtcpInSessionSDP = +MOZ_RUNINIT const std::string kRtcpInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=rtcp:5555" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3663,7 +3663,7 @@ TEST_P(NewSdpTest, CheckRtcpInSessionLevel) { } } -const std::string kRtcpFbInSessionSDP = +MOZ_RUNINIT const std::string kRtcpFbInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=rtcp-fb:120 nack" CRLF "m=video 9 RTP/SAVPF 120" CRLF @@ -3681,7 +3681,7 @@ TEST_P(NewSdpTest, CheckRtcpFbInSessionLevel) { } } -const std::string kRtcpMuxInSessionSDP = +MOZ_RUNINIT const std::string kRtcpMuxInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=rtcp-mux" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3699,7 +3699,7 @@ TEST_P(NewSdpTest, CheckRtcpMuxInSessionLevel) { } } -const std::string kRtcpRsizeInSessionSDP = +MOZ_RUNINIT const std::string kRtcpRsizeInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=rtcp-rsize" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3717,7 +3717,7 @@ TEST_P(NewSdpTest, CheckRtcpRsizeInSessionLevel) { } } -const std::string kRtpmapInSessionSDP = +MOZ_RUNINIT const std::string kRtpmapInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=rtpmap:120 VP8/90000" CRLF "m=video 9 RTP/SAVPF 120" CRLF @@ -3735,7 +3735,7 @@ TEST_P(NewSdpTest, CheckRtpmapInSessionLevel) { } } -const std::string kSctpmapInSessionSDP = +MOZ_RUNINIT const std::string kSctpmapInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=sctpmap:5000" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3753,7 +3753,7 @@ TEST_P(NewSdpTest, CheckSctpmapInSessionLevel) { } } -const std::string kSsrcInSessionSDP = +MOZ_RUNINIT const std::string kSsrcInSessionSDP = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "a=ssrc:5000" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3771,7 +3771,7 @@ TEST_P(NewSdpTest, CheckSsrcInSessionLevel) { } } -const std::string kMalformedImageattr = +MOZ_RUNINIT const std::string kMalformedImageattr = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3836,7 +3836,7 @@ TEST_P(NewSdpTest, ParseInvalidRidNoSuchPt) { ASSERT_NE(0U, ParseErrorCount()); } -const std::string kNoAttributes = +MOZ_RUNINIT const std::string kNoAttributes = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF @@ -3876,7 +3876,7 @@ TEST_P(NewSdpTest, CheckNoAttributes) { Sdp()->GetAttributeList().GetDirection()); } -const std::string kMediaLevelDtlsMessage = +MOZ_RUNINIT const std::string kMediaLevelDtlsMessage = "v=0" CRLF "o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF "s=SIP Call" CRLF "c=IN IP4 224.0.0.1/100/12" CRLF "t=0 0" CRLF "m=video 9 RTP/SAVPF 120" CRLF "c=IN IP4 0.0.0.0" CRLF diff --git a/memory/build/mozjemalloc.cpp b/memory/build/mozjemalloc.cpp index 0aec0870b4fe..82a8c2514f57 100644 --- a/memory/build/mozjemalloc.cpp +++ b/memory/build/mozjemalloc.cpp @@ -1431,7 +1431,7 @@ class ArenaCollection { Maybe mMainThreadId; }; -static ArenaCollection gArenas; +MOZ_RUNINIT static ArenaCollection gArenas; // ****** // Chunks. diff --git a/memory/mozalloc/msvc_raise_wrappers.cpp b/memory/mozalloc/msvc_raise_wrappers.cpp index 6eb8bdbe314c..a665917abb88 100644 --- a/memory/mozalloc/msvc_raise_wrappers.cpp +++ b/memory/mozalloc/msvc_raise_wrappers.cpp @@ -12,6 +12,6 @@ static void __cdecl RaiseHandler(const std::exception& e) { mozalloc_abort(e.what()); } -static struct StaticScopeStruct final { +MOZ_RUNINIT static struct StaticScopeStruct final { StaticScopeStruct() { std::exception::_Set_raise_handler(RaiseHandler); } } StaticScopeInvoke; diff --git a/memory/replace/dmd/test/SmokeDMD.cpp b/memory/replace/dmd/test/SmokeDMD.cpp index c72e92a543d6..9d9fdcdf423a 100644 --- a/memory/replace/dmd/test/SmokeDMD.cpp +++ b/memory/replace/dmd/test/SmokeDMD.cpp @@ -31,7 +31,7 @@ using mozilla::MakeUnique; using namespace mozilla::dmd; -DMDFuncs::Singleton DMDFuncs::sSingleton; +MOZ_RUNINIT DMDFuncs::Singleton DMDFuncs::sSingleton; class FpWriteFunc final : public mozilla::JSONWriteFunc { public: diff --git a/memory/replace/logalloc/replay/Replay.cpp b/memory/replace/logalloc/replay/Replay.cpp index 191a192bb81f..b0d846361e28 100644 --- a/memory/replace/logalloc/replay/Replay.cpp +++ b/memory/replace/logalloc/replay/Replay.cpp @@ -38,7 +38,7 @@ static void die(const char* message) { } #ifdef XP_LINUX -static size_t sPageSize = []() { return sysconf(_SC_PAGESIZE); }(); +MOZ_RUNINIT static size_t sPageSize = []() { return sysconf(_SC_PAGESIZE); }(); #endif /* We don't want to be using malloc() to allocate our internal tracking @@ -1077,7 +1077,7 @@ class Replay { #endif // XP_LINUX }; -static Replay replay; +MOZ_RUNINIT static Replay replay; int main(int argc, const char* argv[]) { size_t first_pid = 0; diff --git a/mfbt/Attributes.h b/mfbt/Attributes.h index 4aaa3fc88986..2919b93cbfcd 100644 --- a/mfbt/Attributes.h +++ b/mfbt/Attributes.h @@ -621,6 +621,11 @@ * expression. If a member of another class uses this class, or if another * class inherits from this class, then it is considered to be a non-heap * class as well, although this attribute need not be provided in such cases. + * MOZ_CONSTINIT: pre-C++20 equivalent to `constinit`. + * MOZ_RUNINIT: Applies to global variables with runtime initialization. + * MOZ_GLOBINIT: Applies to global variables with potential runtime + * initialization (e.g. inside macro or when initialisation status depends on + * template parameter). * MOZ_HEAP_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the heap, so it is a compile-time error to use it, or * an array of such objects, as the type of a variable declaration, or as a @@ -858,12 +863,17 @@ # define MOZ_MAY_CALL_AFTER_MUST_RETURN \ __attribute__((annotate("moz_may_call_after_must_return"))) # define MOZ_KNOWN_LIVE __attribute__((annotate("moz_known_live"))) -# ifndef XGILL_PLUGIN +# ifdef MOZ_CLANG_PLUGIN # define MOZ_UNANNOTATED __attribute__((annotate("moz_unannotated"))) # define MOZ_ANNOTATED __attribute__((annotate("moz_annotated"))) +# define MOZ_RUNINIT __attribute__((annotate("moz_global_var"))) +# define MOZ_GLOBINIT \ + MOZ_RUNINIT __attribute__((annotate("moz_generated"))) # else # define MOZ_UNANNOTATED /* nothing */ # define MOZ_ANNOTATED /* nothing */ +# define MOZ_RUNINIT /* nothing */ +# define MOZ_GLOBINIT /* nothing */ # endif /* @@ -885,6 +895,8 @@ # define MOZ_CAN_RUN_SCRIPT_BOUNDARY /* nothing */ # define MOZ_MUST_OVERRIDE /* nothing */ # define MOZ_STATIC_CLASS /* nothing */ +# define MOZ_RUNINIT /* nothing */ +# define MOZ_GLOBINIT /* nothing */ # define MOZ_STATIC_LOCAL_CLASS /* nothing */ # define MOZ_STACK_CLASS /* nothing */ # define MOZ_NONHEAP_CLASS /* nothing */ diff --git a/mfbt/Poison.cpp b/mfbt/Poison.cpp index d4ec08e7039e..d70774e4087b 100644 --- a/mfbt/Poison.cpp +++ b/mfbt/Poison.cpp @@ -198,8 +198,9 @@ static uintptr_t GetPoisonValue(uintptr_t aBase, uintptr_t aSize) { // specifically comes before libxul, so nearly all gecko code runs strictly // after this.) extern "C" { -uintptr_t gMozillaPoisonSize = GetDesiredRegionSize(); -uintptr_t gMozillaPoisonBase = ReservePoisonArea(gMozillaPoisonSize); -uintptr_t gMozillaPoisonValue = +MOZ_RUNINIT uintptr_t gMozillaPoisonSize = GetDesiredRegionSize(); +MOZ_RUNINIT uintptr_t gMozillaPoisonBase = + ReservePoisonArea(gMozillaPoisonSize); +MOZ_RUNINIT uintptr_t gMozillaPoisonValue = GetPoisonValue(gMozillaPoisonBase, gMozillaPoisonSize); } diff --git a/mfbt/tests/TestCompactPair.cpp b/mfbt/tests/TestCompactPair.cpp index 66300c338a19..9c07ee1fe8ec 100644 --- a/mfbt/tests/TestCompactPair.cpp +++ b/mfbt/tests/TestCompactPair.cpp @@ -16,7 +16,7 @@ using mozilla::MakeCompactPair; // verify our attempts at compactness through EBO are moderately functional, // *somewhere*. #define INSTANTIATE(T1, T2, name, size) \ - CompactPair name##_1(T1(0), T2(0)); \ + MOZ_GLOBINIT CompactPair name##_1(T1(0), T2(0)); \ static_assert(sizeof(name##_1.first()) > 0, \ "first method should work on CompactPair<" #T1 ", " #T2 ">"); \ \ @@ -26,7 +26,7 @@ using mozilla::MakeCompactPair; static_assert(sizeof(name##_1) == (size), \ "CompactPair<" #T1 ", " #T2 "> has an unexpected size"); \ \ - CompactPair name##_2(T2(0), T1(0)); \ + MOZ_GLOBINIT CompactPair name##_2(T2(0), T1(0)); \ static_assert(sizeof(name##_2.first()) > 0, \ "first method should work on CompactPair<" #T2 ", " #T1 ">"); \ \ diff --git a/mobile/android/annotations/src/main/java/org/mozilla/gecko/annotationProcessors/CodeGenerator.java b/mobile/android/annotations/src/main/java/org/mozilla/gecko/annotationProcessors/CodeGenerator.java index f47dd6b8ec0c..21f20b723cfb 100644 --- a/mobile/android/annotations/src/main/java/org/mozilla/gecko/annotationProcessors/CodeGenerator.java +++ b/mobile/android/annotations/src/main/java/org/mozilla/gecko/annotationProcessors/CodeGenerator.java @@ -826,7 +826,7 @@ public class CodeGenerator { + "};\n" + "\n" + "template\n" - + "const JNINativeMethod " + + "MOZ_GLOBINIT const JNINativeMethod " + clsName + "::Natives::methods[] = {" + nativesInits diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index cb30b8358453..04b3ad668df4 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -2045,7 +2045,7 @@ static void TestParseErrorHandlePref(const char* aPrefName, PrefType aType, PrefValueKind aKind, PrefValue aValue, bool aIsSticky, bool aIsLocked) {} -static nsCString gTestParseErrorMsgs; +MOZ_RUNINIT static nsCString gTestParseErrorMsgs; static void TestParseErrorHandleError(const char* aMsg) { gTestParseErrorMsgs.Append(aMsg); @@ -5772,7 +5772,7 @@ void MaybeInitOncePrefs() { #define ALWAYS_PREF(name, base_id, full_id, cpp_type, default_value) \ cpp_type sMirror_##full_id(default_value); #define ALWAYS_DATAMUTEX_PREF(name, base_id, full_id, cpp_type, default_value) \ - cpp_type sMirror_##full_id("DataMutexString"); + MOZ_RUNINIT cpp_type sMirror_##full_id("DataMutexString"); #define ONCE_PREF(name, base_id, full_id, cpp_type, default_value) \ cpp_type sMirror_##full_id(default_value); #include "mozilla/StaticPrefListAll.h" diff --git a/mozglue/android/APKOpen.cpp b/mozglue/android/APKOpen.cpp index a9f68c649060..08e70a090354 100644 --- a/mozglue/android/APKOpen.cpp +++ b/mozglue/android/APKOpen.cpp @@ -135,7 +135,7 @@ void abortThroughJava(const char* msg) { env->PopLocalFrame(nullptr); } -Bootstrap::UniquePtr gBootstrap; +MOZ_RUNINIT Bootstrap::UniquePtr gBootstrap; #ifndef MOZ_FOLD_LIBS static void* sqlite_handle = nullptr; static void* nspr_handle = nullptr; diff --git a/mozglue/baseprofiler/core/platform.cpp b/mozglue/baseprofiler/core/platform.cpp index 6080ba88c61f..f33cea2ba253 100644 --- a/mozglue/baseprofiler/core/platform.cpp +++ b/mozglue/baseprofiler/core/platform.cpp @@ -278,7 +278,8 @@ class MOZ_RAII PSAutoLock { detail::BaseProfilerAutoLock mLock; }; -detail::BaseProfilerMutex PSAutoLock::gPSMutex{"Base Profiler mutex"}; +MOZ_RUNINIT detail::BaseProfilerMutex PSAutoLock::gPSMutex{ + "Base Profiler mutex"}; // Only functions that take a PSLockRef arg can access CorePS's and ActivePS's // fields. diff --git a/mozglue/baseprofiler/core/shared-libraries-macos.cc b/mozglue/baseprofiler/core/shared-libraries-macos.cc index f9955810011b..c2611cd6b03b 100644 --- a/mozglue/baseprofiler/core/shared-libraries-macos.cc +++ b/mozglue/baseprofiler/core/shared-libraries-macos.cc @@ -58,7 +58,7 @@ class MOZ_RAII SharedLibrariesLock { static mozilla::baseprofiler::detail::BaseProfilerMutex sSharedLibrariesMutex; }; -mozilla::baseprofiler::detail::BaseProfilerMutex +MOZ_RUNINIT mozilla::baseprofiler::detail::BaseProfilerMutex SharedLibrariesLock::sSharedLibrariesMutex; static void SharedLibraryAddImage(const struct mach_header* mh, diff --git a/mozglue/baseprofiler/lul/LulCommonExt.h b/mozglue/baseprofiler/lul/LulCommonExt.h index b20a7321ff2a..8ecc1ee8ff7f 100644 --- a/mozglue/baseprofiler/lul/LulCommonExt.h +++ b/mozglue/baseprofiler/lul/LulCommonExt.h @@ -374,7 +374,7 @@ class scoped_ptr_malloc { }; template -FP const scoped_ptr_malloc::free_ = FP(); +MOZ_RUNINIT FP const scoped_ptr_malloc::free_ = FP(); template inline void swap(scoped_ptr_malloc& a, scoped_ptr_malloc& b) { diff --git a/mozglue/build/arm.cpp b/mozglue/build/arm.cpp index 20eb9b5821a2..7980a7c51e90 100644 --- a/mozglue/build/arm.cpp +++ b/mozglue/build/arm.cpp @@ -5,6 +5,7 @@ /* compile-time and runtime tests for whether to use various ARM extensions */ #include "arm.h" +#include "mozilla/Attributes.h" #if defined(MOZILLA_ARM_HAVE_CPUID_DETECTION) @@ -88,7 +89,7 @@ static unsigned get_arm_cpu_flags(void) { } // Cache a local copy so we only have to read /proc/cpuinfo once. -static unsigned arm_cpu_flags = get_arm_cpu_flags(); +MOZ_RUNINIT static unsigned arm_cpu_flags = get_arm_cpu_flags(); # if !defined(MOZILLA_PRESUME_EDSP) static bool check_edsp(void) { @@ -125,19 +126,19 @@ static bool check_aes(void) { namespace mozilla { namespace arm_private { # if !defined(MOZILLA_PRESUME_EDSP) -bool edsp_enabled = check_edsp(); +MOZ_RUNINIT bool edsp_enabled = check_edsp(); # endif # if !defined(MOZILLA_PRESUME_ARMV6) -bool armv6_enabled = check_armv6(); +MOZ_RUNINIT bool armv6_enabled = check_armv6(); # endif # if !defined(MOZILLA_PRESUME_ARMV7) -bool armv7_enabled = check_armv7(); +MOZ_RUNINIT bool armv7_enabled = check_armv7(); # endif # if !defined(MOZILLA_PRESUME_NEON) -bool neon_enabled = check_neon(); +MOZ_RUNINIT bool neon_enabled = check_neon(); # endif # if !defined(MOZILLA_PRESUME_ARM_AES) -bool aes_enabled = check_aes(); +MOZ_RUNINIT bool aes_enabled = check_aes(); # endif } // namespace arm_private } // namespace mozilla diff --git a/mozglue/linker/ElfLoader.cpp b/mozglue/linker/ElfLoader.cpp index 88efbf58b8bb..3e31449eaf96 100644 --- a/mozglue/linker/ElfLoader.cpp +++ b/mozglue/linker/ElfLoader.cpp @@ -367,7 +367,7 @@ const void* SystemElf::FindExidx(int* pcount) const { */ /* Unique ElfLoader instance */ -ElfLoader ElfLoader::Singleton; +MOZ_RUNINIT ElfLoader ElfLoader::Singleton; already_AddRefed ElfLoader::Load(const char* path, int flags, LibHandle* parent) { diff --git a/mozglue/misc/AutoProfilerLabel.cpp b/mozglue/misc/AutoProfilerLabel.cpp index 5fd820cc5ba2..c6d01c2700e2 100644 --- a/mozglue/misc/AutoProfilerLabel.cpp +++ b/mozglue/misc/AutoProfilerLabel.cpp @@ -53,7 +53,8 @@ class MOZ_RAII AutoProfilerLabelData { static uint32_t sGeneration; }; -/* static */ AutoProfilerLabelData::Mutex AutoProfilerLabelData::sAPLMutex; +MOZ_RUNINIT /* static */ AutoProfilerLabelData::Mutex + AutoProfilerLabelData::sAPLMutex; /* static */ ProfilerLabelEnter AutoProfilerLabelData::sEnter = nullptr; /* static */ ProfilerLabelExit AutoProfilerLabelData::sExit = nullptr; /* static */ uint32_t AutoProfilerLabelData::sGeneration = 0; diff --git a/mozglue/misc/SSE.cpp b/mozglue/misc/SSE.cpp index 74f3917788d0..61060e46e600 100644 --- a/mozglue/misc/SSE.cpp +++ b/mozglue/misc/SSE.cpp @@ -7,6 +7,8 @@ #include "SSE.h" +#include "mozilla/Attributes.h" + #ifdef HAVE_CPUID_H // cpuid.h is available on gcc 4.3 and higher on i386 and x86_64 # include @@ -169,39 +171,39 @@ namespace sse_private { #if defined(MOZILLA_SSE_HAVE_CPUID_DETECTION) # if !defined(MOZILLA_PRESUME_MMX) -bool mmx_enabled = has_cpuid_bits(1u, edx, (1u << 23)); +MOZ_RUNINIT bool mmx_enabled = has_cpuid_bits(1u, edx, (1u << 23)); # endif # if !defined(MOZILLA_PRESUME_SSE) -bool sse_enabled = has_cpuid_bits(1u, edx, (1u << 25)); +MOZ_RUNINIT bool sse_enabled = has_cpuid_bits(1u, edx, (1u << 25)); # endif # if !defined(MOZILLA_PRESUME_SSE2) -bool sse2_enabled = has_cpuid_bits(1u, edx, (1u << 26)); +MOZ_RUNINIT bool sse2_enabled = has_cpuid_bits(1u, edx, (1u << 26)); # endif # if !defined(MOZILLA_PRESUME_SSE3) -bool sse3_enabled = has_cpuid_bits(1u, ecx, (1u << 0)); +MOZ_RUNINIT bool sse3_enabled = has_cpuid_bits(1u, ecx, (1u << 0)); # endif # if !defined(MOZILLA_PRESUME_SSSE3) -bool ssse3_enabled = has_cpuid_bits(1u, ecx, (1u << 9)); +MOZ_RUNINIT bool ssse3_enabled = has_cpuid_bits(1u, ecx, (1u << 9)); # endif # if !defined(MOZILLA_PRESUME_SSE4A) -bool sse4a_enabled = has_cpuid_bits(0x80000001u, ecx, (1u << 6)); +MOZ_RUNINIT bool sse4a_enabled = has_cpuid_bits(0x80000001u, ecx, (1u << 6)); # endif # if !defined(MOZILLA_PRESUME_SSE4_1) -bool sse4_1_enabled = has_cpuid_bits(1u, ecx, (1u << 19)); +MOZ_RUNINIT bool sse4_1_enabled = has_cpuid_bits(1u, ecx, (1u << 19)); # endif # if !defined(MOZILLA_PRESUME_SSE4_2) -bool sse4_2_enabled = has_cpuid_bits(1u, ecx, (1u << 20)); +MOZ_RUNINIT bool sse4_2_enabled = has_cpuid_bits(1u, ecx, (1u << 20)); # endif # if !defined(MOZILLA_PRESUME_FMA3) -bool fma3_enabled = has_cpuid_bits(1u, ecx, (1u << 12)); +MOZ_RUNINIT bool fma3_enabled = has_cpuid_bits(1u, ecx, (1u << 12)); # endif # if !defined(MOZILLA_PRESUME_AVX) || !defined(MOZILLA_PRESUME_AVX2) @@ -225,22 +227,22 @@ static bool has_avx() { # endif // !MOZILLA_PRESUME_AVX || !MOZILLA_PRESUME_AVX2 # if !defined(MOZILLA_PRESUME_AVX) -bool avx_enabled = has_avx(); +MOZ_RUNINIT bool avx_enabled = has_avx(); # endif # if !defined(MOZILLA_PRESUME_AVX2) -bool avx2_enabled = has_avx() && has_cpuid_bits(7u, ebx, (1u << 5)); +MOZ_RUNINIT bool avx2_enabled = has_avx() && has_cpuid_bits(7u, ebx, (1u << 5)); # endif # if !defined(MOZILLA_PRESUME_AVXVNNI) -bool avxvnni_enabled = has_cpuid_bits_ex(7u, eax, (1u << 4)); +MOZ_RUNINIT bool avxvnni_enabled = has_cpuid_bits_ex(7u, eax, (1u << 4)); # endif # if !defined(MOZILLA_PRESUME_AES) -bool aes_enabled = has_cpuid_bits(1u, ecx, (1u << 25)); +MOZ_RUNINIT bool aes_enabled = has_cpuid_bits(1u, ecx, (1u << 25)); # endif -bool has_constant_tsc = has_cpuid_bits(0x80000007u, edx, (1u << 8)); +MOZ_RUNINIT bool has_constant_tsc = has_cpuid_bits(0x80000007u, edx, (1u << 8)); #endif diff --git a/mozglue/misc/TimeStamp.cpp b/mozglue/misc/TimeStamp.cpp index f77cf631323b..3f2da17c80e9 100644 --- a/mozglue/misc/TimeStamp.cpp +++ b/mozglue/misc/TimeStamp.cpp @@ -43,7 +43,7 @@ struct TimeStampInitialization { ~TimeStampInitialization() { TimeStamp::Shutdown(); } }; -static TimeStampInitialization sInitOnce; +MOZ_RUNINIT static TimeStampInitialization sInitOnce; MFBT_API TimeStamp TimeStamp::ProcessCreation() { if (sInitOnce.mProcessCreation.IsNull()) { diff --git a/mozglue/misc/WindowsDiagnostics.cpp b/mozglue/misc/WindowsDiagnostics.cpp index 7d038c02b861..6aac49201759 100644 --- a/mozglue/misc/WindowsDiagnostics.cpp +++ b/mozglue/misc/WindowsDiagnostics.cpp @@ -17,7 +17,7 @@ namespace mozilla { -static OnSingleStepCallback sOnSingleStepCallback{}; +MOZ_RUNINIT static OnSingleStepCallback sOnSingleStepCallback{}; static void* sOnSingleStepCallbackState = nullptr; static bool sIsSingleStepping = false; diff --git a/netwerk/base/FuzzyLayer.cpp b/netwerk/base/FuzzyLayer.cpp index 83c2f40c5ebe..1b8c56c98358 100644 --- a/netwerk/base/FuzzyLayer.cpp +++ b/netwerk/base/FuzzyLayer.cpp @@ -40,11 +40,11 @@ typedef struct { } NetworkFuzzingBuffer; // This holds all connections we have currently open. -static nsTHashMap, NetworkFuzzingBuffer*> +MOZ_RUNINIT static nsTHashMap, NetworkFuzzingBuffer*> gConnectedNetworkFuzzingBuffers; // This holds all buffers for connections we can still open. -static nsDeque gNetworkFuzzingBuffers; +MOZ_RUNINIT static nsDeque gNetworkFuzzingBuffers; // This is `true` once all connections are closed and either there are // no buffers left to be used or all remaining buffers are marked optional. diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index dd4520018fcb..746fd73a0a78 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -201,7 +201,7 @@ const nsACString& nsStandardURL::nsSegmentEncoder::EncodeSegment( #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN static StaticMutex gAllURLsMutex MOZ_UNANNOTATED; -static LinkedList gAllURLs; +MOZ_RUNINIT static LinkedList gAllURLs; #endif nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL) diff --git a/netwerk/cache2/CacheFileUtils.cpp b/netwerk/cache2/CacheFileUtils.cpp index fd1a8665e481..cdf2f0ae2cdf 100644 --- a/netwerk/cache2/CacheFileUtils.cpp +++ b/netwerk/cache2/CacheFileUtils.cpp @@ -354,7 +354,7 @@ ValidityPair& ValidityMap::operator[](uint32_t aIdx) { StaticMutex DetailedCacheHitTelemetry::sLock; uint32_t DetailedCacheHitTelemetry::sRecordCnt = 0; -DetailedCacheHitTelemetry::HitRate +MOZ_RUNINIT DetailedCacheHitTelemetry::HitRate DetailedCacheHitTelemetry::sHRStats[kNumOfRanges]; DetailedCacheHitTelemetry::HitRate::HitRate() { Reset(); } @@ -452,7 +452,8 @@ void DetailedCacheHitTelemetry::AddRecord(ERecType aType, } StaticMutex CachePerfStats::sLock; -CachePerfStats::PerfData CachePerfStats::sData[CachePerfStats::LAST]; +MOZ_RUNINIT CachePerfStats::PerfData + CachePerfStats::sData[CachePerfStats::LAST]; uint32_t CachePerfStats::sCacheSlowCnt = 0; uint32_t CachePerfStats::sCacheNotSlowCnt = 0; diff --git a/netwerk/protocol/http/HttpConnectionMgrParent.cpp b/netwerk/protocol/http/HttpConnectionMgrParent.cpp index 594fea20ece9..83d44d28b4e9 100644 --- a/netwerk/protocol/http/HttpConnectionMgrParent.cpp +++ b/netwerk/protocol/http/HttpConnectionMgrParent.cpp @@ -21,7 +21,7 @@ namespace mozilla::net { -nsTHashMap> +MOZ_RUNINIT nsTHashMap> HttpConnectionMgrParent::sHttpUpgradeListenerMap; uint32_t HttpConnectionMgrParent::sListenerId = 0; StaticMutex HttpConnectionMgrParent::sLock; diff --git a/netwerk/protocol/http/nsHttp.cpp b/netwerk/protocol/http/nsHttp.cpp index 74c9aaaed631..5bf38dbf9fb3 100644 --- a/netwerk/protocol/http/nsHttp.cpp +++ b/netwerk/protocol/http/nsHttp.cpp @@ -49,7 +49,8 @@ enum { }; #undef HTTP_ATOM -static StaticDataMutex> +MOZ_RUNINIT static StaticDataMutex< + nsTHashtable> sAtomTable("nsHttp::sAtomTable"); // This is set to true in DestroyAtomTable so we don't try to repopulate the diff --git a/netwerk/test/fuzz/TestHttpFuzzing.cpp b/netwerk/test/fuzz/TestHttpFuzzing.cpp index 5724035cdd74..b2f9267ef6b6 100644 --- a/netwerk/test/fuzz/TestHttpFuzzing.cpp +++ b/netwerk/test/fuzz/TestHttpFuzzing.cpp @@ -30,8 +30,8 @@ namespace net { // Target spec and optional proxy type to use, set by the respective // initialization function so we can cover all combinations. -static nsAutoCString httpSpec; -static nsAutoCString proxyType; +MOZ_RUNINIT static nsAutoCString httpSpec; +MOZ_RUNINIT static nsAutoCString proxyType; static size_t minSize; static int FuzzingInitNetworkHttp(int* argc, char*** argv) { diff --git a/netwerk/test/gtest/TestLinkHeader.cpp b/netwerk/test/gtest/TestLinkHeader.cpp index 4da7002f8730..7d80e3e289b2 100644 --- a/netwerk/test/gtest/TestLinkHeader.cpp +++ b/netwerk/test/gtest/TestLinkHeader.cpp @@ -141,7 +141,7 @@ TEST_P(SimpleParseTest, Simple) { // Some test data copied and adapted from // https://source.chromium.org/chromium/chromium/src/+/main:components/link_header_util/link_header_util_unittest.cc // the different behavior of the parser is commented above each test case. -const SimpleParseTestData simple_parse_tests[] = { +MOZ_RUNINIT const SimpleParseTestData simple_parse_tests[] = { {u"; rel=stylesheet; fetchpriority=\"auto\""_ns, true, u"s.css"_ns, u"stylesheet"_ns, u""_ns, u"auto"_ns}, {u"; rel=stylesheet; fetchpriority=\"low\""_ns, true, u"s.css"_ns, @@ -306,7 +306,7 @@ struct AnchorTestData { class AnchorTest : public ::testing::TestWithParam {}; -const AnchorTestData anchor_tests[] = { +MOZ_RUNINIT const AnchorTestData anchor_tests[] = { {u"http://example.com/path/to/index.html"_ns, u""_ns, u"page.html"_ns, "http://example.com/path/to/page.html"}, {u"http://example.com/path/to/index.html"_ns, diff --git a/netwerk/test/gtest/TestPACMan.cpp b/netwerk/test/gtest/TestPACMan.cpp index daa58d517b9f..a6cee08c6b90 100644 --- a/netwerk/test/gtest/TestPACMan.cpp +++ b/netwerk/test/gtest/TestPACMan.cpp @@ -20,7 +20,7 @@ #define GETTING_NETWORK_PROXY_TYPE_FAILED (-1) static mozilla::StaticMutex sMutex; -nsCString WPADOptionResult MOZ_GUARDED_BY(sMutex); +MOZ_RUNINIT nsCString WPADOptionResult MOZ_GUARDED_BY(sMutex); namespace mozilla { namespace net { diff --git a/netwerk/url-classifier/UrlClassifierFeaturePhishingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeaturePhishingProtection.cpp index d03f9c790bc6..d347624fca52 100644 --- a/netwerk/url-classifier/UrlClassifierFeaturePhishingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeaturePhishingProtection.cpp @@ -21,8 +21,8 @@ struct UrlClassifierFeaturePhishingProtection::PhishingProtectionFeature { namespace { -struct UrlClassifierFeaturePhishingProtection::PhishingProtectionFeature - sPhishingProtectionFeaturesMap[] = { +MOZ_RUNINIT struct UrlClassifierFeaturePhishingProtection:: + PhishingProtectionFeature sPhishingProtectionFeaturesMap[] = { {"malware", "urlclassifier.malwareTable", StaticPrefs::browser_safebrowsing_malware_enabled}, {"phishing", "urlclassifier.phishTable", diff --git a/security/ct/CTPolicyEnforcer.cpp b/security/ct/CTPolicyEnforcer.cpp index 4e932e5884ca..440d3e7aaa1c 100644 --- a/security/ct/CTPolicyEnforcer.cpp +++ b/security/ct/CTPolicyEnforcer.cpp @@ -19,7 +19,7 @@ using namespace mozilla::pkix; // Returns the number of embedded SCTs required to be present in a certificate. // For certificates with a lifetime of less than or equal to 180 days, only 2 // embedded SCTs are required. Otherwise 3 are required. -const Duration ONE_HUNDRED_AND_EIGHTY_DAYS = +MOZ_RUNINIT const Duration ONE_HUNDRED_AND_EIGHTY_DAYS = Duration(180 * Time::ONE_DAY_IN_SECONDS); size_t GetRequiredEmbeddedSctsCount(Duration certLifetime) { // pkix::Duration doesn't define operator<=, hence phrasing this comparison diff --git a/security/ct/tests/gtest/BTSignedTreeHeadTest.cpp b/security/ct/tests/gtest/BTSignedTreeHeadTest.cpp index 580d6a84f386..addd6698090e 100644 --- a/security/ct/tests/gtest/BTSignedTreeHeadTest.cpp +++ b/security/ct/tests/gtest/BTSignedTreeHeadTest.cpp @@ -104,76 +104,77 @@ static const char* kValidRootHashSHA512Hex = "374d794a95cdcfd8b35993185fef9ba368f160d8daf432d08ba9f1ed1e5abe6c" "c69291e0fa2fe0006a52570ef18c19def4e617c33ce52ef0a6e5fbe318cb0387"; -static const BTSignedTreeHeadTestParams BT_SIGNED_TREE_HEAD_TEST_PARAMS[] = { - {ValidSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, ValidSTH::kSTHHex, Success, - 1541189938000, 7, kValidRootHashHex}, - {ValidSTH::kSPKIHex, pkix::DigestAlgorithm::sha512, - pkix::der::PublicKeyAlgorithm::ECDSA, ValidSTH::kSTHHex, - Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, - {ValidSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::RSA_PKCS1, ValidSTH::kSTHHex, - Result::FATAL_ERROR_INVALID_ARGS, 0, 0, nullptr}, - {ValidWithExtensionSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, ValidWithExtensionSTH::kSTHHex, - Success, 1541189938000, 7, kValidRootHashHex}, - {ValidSecp521r1SHA512STH::kSPKIHex, pkix::DigestAlgorithm::sha512, - pkix::der::PublicKeyAlgorithm::ECDSA, ValidSecp521r1SHA512STH::kSTHHex, - Success, 1542136309473, 731393445, kValidRootHashSHA512Hex}, - {ValidSecp521r1SHA512STH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, ValidSecp521r1SHA512STH::kSTHHex, - Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, - {ValidSTH::kSPKIHex, pkix::DigestAlgorithm::sha512, - pkix::der::PublicKeyAlgorithm::ECDSA, ValidSecp521r1SHA512STH::kSTHHex, - Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, - {SignatureCoversLogIDSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, SignatureCoversLogIDSTH::kSTHHex, - Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, - {WrongSPKISTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, WrongSPKISTH::kSTHHex, - Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, - {WrongSigningKeySTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, WrongSigningKeySTH::kSTHHex, - Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, - {MissingLogIDSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, MissingLogIDSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {MissingTimestampSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, MissingTimestampSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {MissingTreeSizeSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, MissingTreeSizeSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {MissingRootHashSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, MissingRootHashSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {MissingExtensionsSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, MissingExtensionsSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {TruncatedLogIDSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedLogIDSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {TruncatedTimestampSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedTimestampSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {TruncatedTreeSizeSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedTreeSizeSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {TruncatedRootHashSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedRootHashSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {TruncatedExtensionSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedExtensionSTH::kSTHHex, - Result::ERROR_BAD_DER, 0, 0, nullptr}, - {RSASignerRSASPKISTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, RSASignerRSASPKISTH::kSTHHex, - Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, - {RSASignerECSPKISTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, RSASignerECSPKISTH::kSTHHex, - Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, - {ECSignerRSASPKISTH::kSPKIHex, pkix::DigestAlgorithm::sha256, - pkix::der::PublicKeyAlgorithm::ECDSA, ECSignerRSASPKISTH::kSTHHex, - Result::ERROR_INVALID_KEY, 0, 0, nullptr}, +MOZ_RUNINIT static const BTSignedTreeHeadTestParams + BT_SIGNED_TREE_HEAD_TEST_PARAMS[] = { + {ValidSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, ValidSTH::kSTHHex, Success, + 1541189938000, 7, kValidRootHashHex}, + {ValidSTH::kSPKIHex, pkix::DigestAlgorithm::sha512, + pkix::der::PublicKeyAlgorithm::ECDSA, ValidSTH::kSTHHex, + Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, + {ValidSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::RSA_PKCS1, ValidSTH::kSTHHex, + Result::FATAL_ERROR_INVALID_ARGS, 0, 0, nullptr}, + {ValidWithExtensionSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, ValidWithExtensionSTH::kSTHHex, + Success, 1541189938000, 7, kValidRootHashHex}, + {ValidSecp521r1SHA512STH::kSPKIHex, pkix::DigestAlgorithm::sha512, + pkix::der::PublicKeyAlgorithm::ECDSA, ValidSecp521r1SHA512STH::kSTHHex, + Success, 1542136309473, 731393445, kValidRootHashSHA512Hex}, + {ValidSecp521r1SHA512STH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, ValidSecp521r1SHA512STH::kSTHHex, + Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, + {ValidSTH::kSPKIHex, pkix::DigestAlgorithm::sha512, + pkix::der::PublicKeyAlgorithm::ECDSA, ValidSecp521r1SHA512STH::kSTHHex, + Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, + {SignatureCoversLogIDSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, SignatureCoversLogIDSTH::kSTHHex, + Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, + {WrongSPKISTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, WrongSPKISTH::kSTHHex, + Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, + {WrongSigningKeySTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, WrongSigningKeySTH::kSTHHex, + Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, + {MissingLogIDSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, MissingLogIDSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {MissingTimestampSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, MissingTimestampSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {MissingTreeSizeSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, MissingTreeSizeSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {MissingRootHashSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, MissingRootHashSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {MissingExtensionsSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, MissingExtensionsSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {TruncatedLogIDSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedLogIDSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {TruncatedTimestampSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedTimestampSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {TruncatedTreeSizeSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedTreeSizeSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {TruncatedRootHashSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedRootHashSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {TruncatedExtensionSTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, TruncatedExtensionSTH::kSTHHex, + Result::ERROR_BAD_DER, 0, 0, nullptr}, + {RSASignerRSASPKISTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, RSASignerRSASPKISTH::kSTHHex, + Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, + {RSASignerECSPKISTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, RSASignerECSPKISTH::kSTHHex, + Result::ERROR_BAD_SIGNATURE, 0, 0, nullptr}, + {ECSignerRSASPKISTH::kSPKIHex, pkix::DigestAlgorithm::sha256, + pkix::der::PublicKeyAlgorithm::ECDSA, ECSignerRSASPKISTH::kSTHHex, + Result::ERROR_INVALID_KEY, 0, 0, nullptr}, }; TEST_P(BTSignedTreeHeadTest, BTSignedTreeHeadSimpleTest) { diff --git a/security/ct/tests/gtest/BTVerificationTest.cpp b/security/ct/tests/gtest/BTVerificationTest.cpp index 41d8a11d2c27..38b4a9241527 100644 --- a/security/ct/tests/gtest/BTVerificationTest.cpp +++ b/security/ct/tests/gtest/BTVerificationTest.cpp @@ -208,29 +208,31 @@ static const char* kInputSHA512Hex = "3865396533623666306432333839666234623763396563356638643833373534" "6239313635313165333661373238653863303236376564653761666561316638"; -static const BTVerificationTestParams BT_VERIFICATION_TEST_PARAMS[] = { - {kValidInclusionProofHex, kExpectedRootHashHex, kInputHex, - pkix::DigestAlgorithm::sha256, Success}, - {kValidInclusionProofHex, kExpectedRootHashHex, kAlteredInputHex, - pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, - {kShortInclusionProofHex, kExpectedRootHashHex, kInputHex, - pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, - {kLongInclusionProofHex, kExpectedRootHashHex, kInputHex, - pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, - {kValidInclusionProofHex, kIncorrectRootHashHex, kInputHex, - pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, - {kWrongTreeSizeInclusionProofHex, kExpectedRootHashHex, kInputHex, - pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, - {kWrongLeafIndexInclusionProofHex, kExpectedRootHashHex, kInputHex, - pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, - {kValidInclusionProofHex, kExpectedRootHashHex, kInputHex, - pkix::DigestAlgorithm::sha512, pkix::Result::ERROR_BAD_SIGNATURE}, - {kValidInclusionProof2Hex, kExpectedRootHash2Hex, kInput2Hex, - pkix::DigestAlgorithm::sha256, Success}, - {kValidInclusionProofSHA512Hex, kExpectedRootHashSHA512Hex, kInputSHA512Hex, - pkix::DigestAlgorithm::sha512, Success}, - {kValidInclusionProofSHA512Hex, kExpectedRootHashSHA512Hex, kInputSHA512Hex, - pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, +MOZ_RUNINIT static const BTVerificationTestParams + BT_VERIFICATION_TEST_PARAMS[] = { + {kValidInclusionProofHex, kExpectedRootHashHex, kInputHex, + pkix::DigestAlgorithm::sha256, Success}, + {kValidInclusionProofHex, kExpectedRootHashHex, kAlteredInputHex, + pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, + {kShortInclusionProofHex, kExpectedRootHashHex, kInputHex, + pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, + {kLongInclusionProofHex, kExpectedRootHashHex, kInputHex, + pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, + {kValidInclusionProofHex, kIncorrectRootHashHex, kInputHex, + pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, + {kWrongTreeSizeInclusionProofHex, kExpectedRootHashHex, kInputHex, + pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, + {kWrongLeafIndexInclusionProofHex, kExpectedRootHashHex, kInputHex, + pkix::DigestAlgorithm::sha256, pkix::Result::ERROR_BAD_SIGNATURE}, + {kValidInclusionProofHex, kExpectedRootHashHex, kInputHex, + pkix::DigestAlgorithm::sha512, pkix::Result::ERROR_BAD_SIGNATURE}, + {kValidInclusionProof2Hex, kExpectedRootHash2Hex, kInput2Hex, + pkix::DigestAlgorithm::sha256, Success}, + {kValidInclusionProofSHA512Hex, kExpectedRootHashSHA512Hex, + kInputSHA512Hex, pkix::DigestAlgorithm::sha512, Success}, + {kValidInclusionProofSHA512Hex, kExpectedRootHashSHA512Hex, + kInputSHA512Hex, pkix::DigestAlgorithm::sha256, + pkix::Result::ERROR_BAD_SIGNATURE}, }; TEST_P(BTVerificationTest, BTVerificationSimpleTest) { diff --git a/security/manager/ssl/EnterpriseRoots.cpp b/security/manager/ssl/EnterpriseRoots.cpp index f172157de2bf..5ba0313c99eb 100644 --- a/security/manager/ssl/EnterpriseRoots.cpp +++ b/security/manager/ssl/EnterpriseRoots.cpp @@ -75,7 +75,7 @@ struct CertStoreLocation { // The documentation doesn't make this clear, but the certificate location // identified by "ROOT" contains trusted root certificates. The certificate // location identified by "CA" contains intermediate certificates. -const CertStoreLocation kCertStoreLocations[] = { +MOZ_RUNINIT const CertStoreLocation kCertStoreLocations[] = { CertStoreLocation(L"ROOT", true), CertStoreLocation(L"CA", false)}; // Because HCERTSTORE is just a typedef void*, we can't use any of the nice diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp index 4fdc893d2c37..9d3edf7adebd 100644 --- a/security/manager/ssl/nsNSSComponent.cpp +++ b/security/manager/ssl/nsNSSComponent.cpp @@ -645,7 +645,7 @@ nsresult nsNSSComponent::BlockUntilLoadableCertsLoaded() { #ifndef MOZ_NO_SMART_CARDS static StaticMutex sCheckForSmartCardChangesMutex MOZ_UNANNOTATED; -static TimeStamp sLastCheckedForSmartCardChanges = TimeStamp::Now(); +MOZ_RUNINIT static TimeStamp sLastCheckedForSmartCardChanges = TimeStamp::Now(); #endif nsresult nsNSSComponent::CheckForSmartCardChanges() { diff --git a/security/manager/ssl/tests/gtest/HMACTest.cpp b/security/manager/ssl/tests/gtest/HMACTest.cpp index 434a52d3f071..efa264b6943d 100644 --- a/security/manager/ssl/tests/gtest/HMACTest.cpp +++ b/security/manager/ssl/tests/gtest/HMACTest.cpp @@ -18,7 +18,7 @@ struct HMACTestCase { #define EXPECTED_RESULT(val) std::string(val, sizeof(val) - 1) -static const HMACTestCase HMACTestCases[] = { +MOZ_RUNINIT static const HMACTestCase HMACTestCases[] = { { SEC_OID_MD5, EXPECTED_RESULT( diff --git a/security/manager/ssl/tests/gtest/OCSPCacheTest.cpp b/security/manager/ssl/tests/gtest/OCSPCacheTest.cpp index 23d0cefc2b52..e08f4fbdd18c 100644 --- a/security/manager/ssl/tests/gtest/OCSPCacheTest.cpp +++ b/security/manager/ssl/tests/gtest/OCSPCacheTest.cpp @@ -60,10 +60,10 @@ static void PutAndGet( ASSERT_EQ(time, timeOut); } -Input fakeIssuer1(LiteralInput("CN=issuer1")); -Input fakeKey000(LiteralInput("key000")); -Input fakeKey001(LiteralInput("key001")); -Input fakeSerial0000(LiteralInput("0000")); +MOZ_RUNINIT Input fakeIssuer1(LiteralInput("CN=issuer1")); +MOZ_RUNINIT Input fakeKey000(LiteralInput("key000")); +MOZ_RUNINIT Input fakeKey001(LiteralInput("key001")); +MOZ_RUNINIT Input fakeSerial0000(LiteralInput("0000")); TEST_F(psm_OCSPCacheTest, TestPutAndGet) { Input fakeSerial000(LiteralInput("000")); diff --git a/security/manager/ssl/tests/unit/tlsserver/cmd/EncryptedClientHelloServer.cpp b/security/manager/ssl/tests/unit/tlsserver/cmd/EncryptedClientHelloServer.cpp index fd284874b3ad..2101b09c1b47 100644 --- a/security/manager/ssl/tests/unit/tlsserver/cmd/EncryptedClientHelloServer.cpp +++ b/security/manager/ssl/tests/unit/tlsserver/cmd/EncryptedClientHelloServer.cpp @@ -23,7 +23,7 @@ struct EchHost { const char* mCertName; }; -const std::vector kSuiteChaCha = { +MOZ_RUNINIT const std::vector kSuiteChaCha = { (static_cast(HpkeKdfHkdfSha256) << 16) | HpkeAeadChaCha20Poly1305}; diff --git a/security/manager/ssl/tests/unit/tlsserver/cmd/FaultyServer.cpp b/security/manager/ssl/tests/unit/tlsserver/cmd/FaultyServer.cpp index f2c8d8fc1cbb..3c597c6a90be 100644 --- a/security/manager/ssl/tests/unit/tlsserver/cmd/FaultyServer.cpp +++ b/security/manager/ssl/tests/unit/tlsserver/cmd/FaultyServer.cpp @@ -49,7 +49,7 @@ const char* kCertWildcard = "default-ee"; * the "default-ee" cert has a SAN for *.example.com * the "no-san-ee" cert is signed by the test-ca, but it doesn't have any SANs. */ -const FaultyServerHost sFaultyServerHosts[]{ +MOZ_RUNINIT const FaultyServerHost sFaultyServerHosts[]{ {kHostOk, kCertWildcard, None}, {kHostUnknown, kCertWildcard, UnknownSNI}, {kHostZeroRttAlertBadMac, kCertWildcard, ZeroRtt}, diff --git a/security/manager/ssl/tests/unit/tlsserver/cmd/OCSPStaplingServer.cpp b/security/manager/ssl/tests/unit/tlsserver/cmd/OCSPStaplingServer.cpp index b7dbabe0c262..1defc524374b 100644 --- a/security/manager/ssl/tests/unit/tlsserver/cmd/OCSPStaplingServer.cpp +++ b/security/manager/ssl/tests/unit/tlsserver/cmd/OCSPStaplingServer.cpp @@ -112,7 +112,7 @@ struct CTHost { SCTsVia mSCTsVia; }; -const CTHost sCTHosts[] = { +MOZ_RUNINIT const CTHost sCTHosts[] = { {"ct-via-ocsp.example.com", {"test_ct/ct-via-ocsp-1.sct", "test_ct/ct-via-ocsp-2.sct"}, SCTsVia::OCSP}, diff --git a/security/sandbox/linux/SandboxInfo.cpp b/security/sandbox/linux/SandboxInfo.cpp index b3bc13848396..9272b7ed5460 100644 --- a/security/sandbox/linux/SandboxInfo.cpp +++ b/security/sandbox/linux/SandboxInfo.cpp @@ -175,7 +175,7 @@ static bool CanCreateUserNamespace() { } /* static */ -const SandboxInfo SandboxInfo::sSingleton = SandboxInfo(); +MOZ_RUNINIT const SandboxInfo SandboxInfo::sSingleton = SandboxInfo(); SandboxInfo::SandboxInfo() { int flags = 0; diff --git a/security/sandbox/win/SandboxInitialization.cpp b/security/sandbox/win/SandboxInitialization.cpp index 8ba8b4e69a82..7171bbbf54c6 100644 --- a/security/sandbox/win/SandboxInitialization.cpp +++ b/security/sandbox/win/SandboxInitialization.cpp @@ -68,8 +68,8 @@ static BOOL WINAPI patched_ApiSetQueryApiSetPresence( return stub_ApiSetQueryApiSetPresence(aNamespace, aPresent); } -static WindowsDllInterceptor Kernel32Intercept; -static WindowsDllInterceptor gApiQueryIntercept; +MOZ_RUNINIT static WindowsDllInterceptor Kernel32Intercept; +MOZ_RUNINIT static WindowsDllInterceptor gApiQueryIntercept; static bool EnableHandleCloseMonitoring() { Kernel32Intercept.Init("kernel32.dll"); diff --git a/testing/gtest/mozilla/GTestRunner.cpp b/testing/gtest/mozilla/GTestRunner.cpp index bebf0a88efde..28b227c980ae 100644 --- a/testing/gtest/mozilla/GTestRunner.cpp +++ b/testing/gtest/mozilla/GTestRunner.cpp @@ -176,7 +176,7 @@ int RunGTestFunc(int* argc, char** argv) { // RunGTest is initialized to nullptr but if GTest (this file) // is linked in then RunGTest will be set here indicating // GTest is supported. -class _InitRunGTest { +MOZ_RUNINIT class _InitRunGTest { public: _InitRunGTest() { RunGTest = RunGTestFunc; } } InitRunGTest; diff --git a/testing/mochitest/ssltunnel/ssltunnel.cpp b/testing/mochitest/ssltunnel/ssltunnel.cpp index 53b9822bf71a..78832694e665 100644 --- a/testing/mochitest/ssltunnel/ssltunnel.cpp +++ b/testing/mochitest/ssltunnel/ssltunnel.cpp @@ -204,8 +204,8 @@ const uint32_t MAX_THREADS = 100; const uint32_t DEFAULT_STACKSIZE = (512 * 1024); // global data -string nssconfigdir; -vector servers; +MOZ_RUNINIT string nssconfigdir; +MOZ_RUNINIT vector servers; PRNetAddr remote_addr; PRNetAddr websocket_server; PRThreadPool* threads = nullptr; diff --git a/third_party/rlbox/include/rlbox_sandbox.hpp b/third_party/rlbox/include/rlbox_sandbox.hpp index 63995c89adf2..5d193ce565c7 100644 --- a/third_party/rlbox/include/rlbox_sandbox.hpp +++ b/third_party/rlbox/include/rlbox_sandbox.hpp @@ -104,7 +104,7 @@ private: // The actual type of the vector is std::vector*> // However clang 5, 6 have bugs where compilation seg-faults on this type // So we just use this std::vector - static inline std::vector sandbox_list; + static inline MOZ_RUNINIT std::vector sandbox_list; RLBOX_SHARED_LOCK(func_ptr_cache_lock); std::map func_ptr_map; diff --git a/toolkit/components/aboutthirdparty/AboutThirdParty.cpp b/toolkit/components/aboutthirdparty/AboutThirdParty.cpp index 73cef0d531df..3b7d3bc08b5f 100644 --- a/toolkit/components/aboutthirdparty/AboutThirdParty.cpp +++ b/toolkit/components/aboutthirdparty/AboutThirdParty.cpp @@ -620,7 +620,7 @@ class KnownModule final { KnownModule& operator=(const KnownModule&) = delete; }; -KnownModule KnownModule::sKnownExtensions[] = { +MOZ_RUNINIT KnownModule KnownModule::sKnownExtensions[] = { {HandlerType::Multi, u"TIP"_ns}, {HandlerType::Multi, u"ShellIconOverlayIdentifiers"_ns}, {HandlerType::Multi, u"ContextMenuHandlers"_ns}, diff --git a/toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp b/toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp index dc0588483f3f..66a913b5c476 100644 --- a/toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp +++ b/toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp @@ -17,7 +17,7 @@ GUID CLSID_TestShellEx = { 0x10a9521e, 0x205, 0x4cc7, {0x93, 0xa1, 0x62, 0xf3, 0xa, 0x9a, 0x54, 0xb3}}; wchar_t kFriendlyName[] = L"Minimum Shell Extension for Firefox testing"; -std::wstring gDllPath; +MOZ_RUNINIT std::wstring gDllPath; BOOL APIENTRY DllMain(HMODULE aModule, DWORD aReason, LPVOID) { wchar_t buf[MAX_PATH]; diff --git a/toolkit/components/antitracking/SettingsChangeObserver.cpp b/toolkit/components/antitracking/SettingsChangeObserver.cpp index eb2ba5bbd334..138016c6abe8 100644 --- a/toolkit/components/antitracking/SettingsChangeObserver.cpp +++ b/toolkit/components/antitracking/SettingsChangeObserver.cpp @@ -17,7 +17,8 @@ using namespace mozilla; namespace { -UniquePtr> +MOZ_RUNINIT UniquePtr< + nsTArray> gSettingsChangedCallbacks; } diff --git a/toolkit/components/contentanalysis/tests/gtest/TestContentAnalysis.cpp b/toolkit/components/contentanalysis/tests/gtest/TestContentAnalysis.cpp index 25f2fdb87892..984918a7651c 100644 --- a/toolkit/components/contentanalysis/tests/gtest/TestContentAnalysis.cpp +++ b/toolkit/components/contentanalysis/tests/gtest/TestContentAnalysis.cpp @@ -111,8 +111,8 @@ class ContentAnalysisTest : public testing::Test { return mContentAnalysis->FilterByUrlLists(aReq); } }; -nsString ContentAnalysisTest::mPipeName; -MozAgentInfo ContentAnalysisTest::mAgentInfo; +MOZ_RUNINIT nsString ContentAnalysisTest::mPipeName; +MOZ_RUNINIT MozAgentInfo ContentAnalysisTest::mAgentInfo; TEST_F(ContentAnalysisTest, AllowUrlList) { MOZ_ALWAYS_SUCCEEDS( diff --git a/toolkit/components/mediasniffer/nsMediaSniffer.cpp b/toolkit/components/mediasniffer/nsMediaSniffer.cpp index e1851d3276d1..f97332ccd8f6 100644 --- a/toolkit/components/mediasniffer/nsMediaSniffer.cpp +++ b/toolkit/components/mediasniffer/nsMediaSniffer.cpp @@ -75,7 +75,7 @@ struct nsMediaSnifferFtypEntry : nsMediaSnifferEntry { }; // For a complete list of file types, see http://www.ftyps.com/index.html -nsMediaSnifferFtypEntry sFtypEntries[] = { +MOZ_RUNINIT nsMediaSnifferFtypEntry sFtypEntries[] = { {PATTERN_ENTRY("\xFF\xFF\xFF", "mp4", VIDEO_MP4), PatternLabel::ftyp_mp4}, // Could be mp41 or mp42. {PATTERN_ENTRY("\xFF\xFF\xFF", "avc", VIDEO_MP4), diff --git a/toolkit/components/nimbus/lib/NimbusFeatures.cpp b/toolkit/components/nimbus/lib/NimbusFeatures.cpp index 0f3a1b78358c..ce19f85d23ef 100644 --- a/toolkit/components/nimbus/lib/NimbusFeatures.cpp +++ b/toolkit/components/nimbus/lib/NimbusFeatures.cpp @@ -15,7 +15,7 @@ namespace mozilla { -static nsTHashSet sExposureFeatureSet; +MOZ_RUNINIT static nsTHashSet sExposureFeatureSet; void NimbusFeatures::GetPrefName(const nsACString& branchPrefix, const nsACString& aFeatureId, diff --git a/toolkit/components/places/tests/gtest/test_IHistory.cpp b/toolkit/components/places/tests/gtest/test_IHistory.cpp index a047ca0e63d1..75a72569283d 100644 --- a/toolkit/components/places/tests/gtest/test_IHistory.cpp +++ b/toolkit/components/places/tests/gtest/test_IHistory.cpp @@ -120,8 +120,8 @@ void test_wait_checkpoint() { // These variables are shared between part 1 and part 2 of the test. Part 2 // sets the nsCOMPtr's to nullptr, freeing the reference. namespace test_unvisited_does_not_notify { -nsCOMPtr testURI; -RefPtr testLink; +MOZ_RUNINIT nsCOMPtr testURI; +MOZ_RUNINIT RefPtr testLink; } // namespace test_unvisited_does_not_notify void test_unvisited_does_not_notify_part1() { using namespace test_unvisited_does_not_notify; diff --git a/toolkit/components/telemetry/build_scripts/gen_scalar_data.py b/toolkit/components/telemetry/build_scripts/gen_scalar_data.py index 6ef1f457b54b..25af9be14d18 100644 --- a/toolkit/components/telemetry/build_scripts/gen_scalar_data.py +++ b/toolkit/components/telemetry/build_scripts/gen_scalar_data.py @@ -91,7 +91,7 @@ def write_scalar_tables(scalars, output): keys_table = [] total_key_count = 0 - print("const ScalarInfo gScalars[] = {", file=output) + print("MOZ_RUNINIT const ScalarInfo gScalars[] = {", file=output) for s in scalars: # We add both the scalar label and the expiration string to the strings # table. diff --git a/toolkit/components/telemetry/core/Telemetry.cpp b/toolkit/components/telemetry/core/Telemetry.cpp index 67ffe08f3a58..1babaf51d462 100644 --- a/toolkit/components/telemetry/core/Telemetry.cpp +++ b/toolkit/components/telemetry/core/Telemetry.cpp @@ -185,7 +185,8 @@ class TelemetryImpl final : public nsITelemetry, public nsIMemoryReporter { friend class nsFetchTelemetryData; }; -StaticDataMutex TelemetryImpl::sTelemetry(nullptr, nullptr); +MOZ_RUNINIT StaticDataMutex TelemetryImpl::sTelemetry(nullptr, + nullptr); MOZ_DEFINE_MALLOC_SIZE_OF(TelemetryMallocSizeOf) diff --git a/toolkit/components/telemetry/core/TelemetryEvent.cpp b/toolkit/components/telemetry/core/TelemetryEvent.cpp index afa897133a25..785b054fc206 100644 --- a/toolkit/components/telemetry/core/TelemetryEvent.cpp +++ b/toolkit/components/telemetry/core/TelemetryEvent.cpp @@ -327,10 +327,10 @@ bool gCanRecordBase; bool gCanRecordExtended; // The EventName -> EventKey cache map. -nsTHashMap gEventNameIDMap(kEventCount); +MOZ_RUNINIT nsTHashMap gEventNameIDMap(kEventCount); // The CategoryName set. -nsTHashSet gCategoryNames; +MOZ_RUNINIT nsTHashSet gCategoryNames; // The main event storage. Events are inserted here, keyed by process id and // in recording order. @@ -339,7 +339,7 @@ typedef nsTArray EventRecordArray; typedef nsClassHashtable EventRecordsMapType; -EventRecordsMapType gEventRecords; +MOZ_RUNINIT EventRecordsMapType gEventRecords; // The details on dynamic events that are recorded from addons are registered // here. diff --git a/toolkit/components/telemetry/core/TelemetryScalar.cpp b/toolkit/components/telemetry/core/TelemetryScalar.cpp index e69ad5456b4d..57ff5a284050 100644 --- a/toolkit/components/telemetry/core/TelemetryScalar.cpp +++ b/toolkit/components/telemetry/core/TelemetryScalar.cpp @@ -1173,18 +1173,18 @@ bool gCanRecordBase; bool gCanRecordExtended; // The Name -> ID cache map. -ScalarMapType gScalarNameIDMap(kScalarCount); +MOZ_RUNINIT ScalarMapType gScalarNameIDMap(kScalarCount); // The (Process Id -> (Scalar ID -> Scalar Object)) map. This is a // nsClassHashtable, it owns the scalar instances and takes care of deallocating // them when they are removed from the map. -ProcessesScalarsMapType gScalarStorageMap; +MOZ_RUNINIT ProcessesScalarsMapType gScalarStorageMap; // As above, for the keyed scalars. -ProcessesKeyedScalarsMapType gKeyedScalarStorageMap; +MOZ_RUNINIT ProcessesKeyedScalarsMapType gKeyedScalarStorageMap; // Provide separate storage for "dynamic builtin" plain and keyed scalars, // needed to support "build faster" in local developer builds. -ProcessesScalarsMapType gDynamicBuiltinScalarStorageMap; -ProcessesKeyedScalarsMapType gDynamicBuiltinKeyedScalarStorageMap; +MOZ_RUNINIT ProcessesScalarsMapType gDynamicBuiltinScalarStorageMap; +MOZ_RUNINIT ProcessesKeyedScalarsMapType gDynamicBuiltinKeyedScalarStorageMap; } // namespace //////////////////////////////////////////////////////////////////////// diff --git a/toolkit/components/telemetry/other/TelemetryIOInterposeObserver.cpp b/toolkit/components/telemetry/other/TelemetryIOInterposeObserver.cpp index c0792bb48c2d..c201d90fe714 100644 --- a/toolkit/components/telemetry/other/TelemetryIOInterposeObserver.cpp +++ b/toolkit/components/telemetry/other/TelemetryIOInterposeObserver.cpp @@ -29,7 +29,7 @@ void TelemetryIOInterposeObserver::AddPath(const nsAString& aPath, } // Threshold for reporting slow main-thread I/O (50 milliseconds). -const TimeDuration kTelemetryReportThreshold = +MOZ_RUNINIT const TimeDuration kTelemetryReportThreshold = TimeDuration::FromMilliseconds(50); void TelemetryIOInterposeObserver::Observe(Observation& aOb) { diff --git a/toolkit/components/url-classifier/tests/gtest/TestFindFullHash.cpp b/toolkit/components/url-classifier/tests/gtest/TestFindFullHash.cpp index 4c17e74011c9..85c2577dfe52 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestFindFullHash.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestFindFullHash.cpp @@ -104,7 +104,7 @@ void PopulateDuration(Duration& aDest, const MyDuration& aSrc) { // The expected match data. static MyDuration EXPECTED_MIN_WAIT_DURATION = {12, 10}; static MyDuration EXPECTED_NEG_CACHE_DURATION = {120, 9}; -static const struct ExpectedMatch { +MOZ_RUNINIT static const struct ExpectedMatch { nsCString mCompleteHash; ThreatType mThreatType; MyDuration mPerHashCacheDuration; diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 3e1b4707e76a..992233ce70ab 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -138,7 +138,7 @@ using namespace mozilla; namespace mozilla::phc { // Global instance that is retrieved by the process generating the crash report -mozilla::phc::AddrInfo gAddrInfo; +MOZ_GLOBINIT mozilla::phc::AddrInfo gAddrInfo; } // namespace mozilla::phc @@ -201,20 +201,20 @@ static const XP_CHAR dumpFileExtension[] = XP_TEXT(".dmp"); static const XP_CHAR extraFileExtension[] = XP_TEXT(".extra"); static const XP_CHAR memoryReportExtension[] = XP_TEXT(".memory.json.gz"); -static std::optional defaultMemoryReportPath = {}; +MOZ_RUNINIT static std::optional defaultMemoryReportPath = {}; static const char kCrashMainID[] = "crash.main.3\n"; static google_breakpad::ExceptionHandler* gExceptionHandler = nullptr; static mozilla::Atomic gEncounteredChildException(false); -static nsCString gServerURL; +MOZ_RUNINIT static nsCString gServerURL; -static xpstring pendingDirectory; -static xpstring crashReporterPath; -static xpstring memoryReportPath; +MOZ_RUNINIT static xpstring pendingDirectory; +MOZ_RUNINIT static xpstring crashReporterPath; +MOZ_RUNINIT static xpstring memoryReportPath; // Where crash events should go. -static xpstring eventsDirectory; +MOZ_RUNINIT static xpstring eventsDirectory; // If this is false, we don't launch the crash reporter static bool doReport = true; @@ -324,7 +324,7 @@ typedef LPTOP_LEVEL_EXCEPTION_FILTER(WINAPI* SetUnhandledExceptionFilter_func)( static WindowsDllInterceptor::FuncHookType stub_SetUnhandledExceptionFilter; static LPTOP_LEVEL_EXCEPTION_FILTER previousUnhandledExceptionFilter = nullptr; -static WindowsDllInterceptor gKernel32Intercept; +MOZ_RUNINIT static WindowsDllInterceptor gKernel32Intercept; static bool gBlockUnhandledExceptionFilter = true; static LPTOP_LEVEL_EXCEPTION_FILTER GetUnhandledExceptionFilter() { @@ -369,7 +369,7 @@ static void SetJitExceptionHandler() { # endif #endif // defined(XP_WIN) -static struct ReservedResources { +MOZ_RUNINIT static struct ReservedResources { #if defined(XP_WIN) && !defined(HAVE_64BIT_BUILD) // This should be bigger than xul.dll plus a bit of extra space for // MinidumpWriteDump allocations. diff --git a/toolkit/mozapps/notificationserver/NotificationComServer.cpp b/toolkit/mozapps/notificationserver/NotificationComServer.cpp index 184b55be44cc..ee44525c6f51 100644 --- a/toolkit/mozapps/notificationserver/NotificationComServer.cpp +++ b/toolkit/mozapps/notificationserver/NotificationComServer.cpp @@ -13,7 +13,7 @@ using namespace std::filesystem; -static path processDllPath = {}; +MOZ_RUNINIT static path processDllPath = {}; // Populate the path to this DLL. bool PopulateDllPath(HINSTANCE dllInstance) { diff --git a/toolkit/mozapps/update/common/updateutils_win.cpp b/toolkit/mozapps/update/common/updateutils_win.cpp index fc2554e56992..eb6696b5ffa0 100644 --- a/toolkit/mozapps/update/common/updateutils_win.cpp +++ b/toolkit/mozapps/update/common/updateutils_win.cpp @@ -9,6 +9,12 @@ #include #include +#ifdef MOZ_CLANG_PLUGIN +# define MOZ_RUNINIT __attribute__((annotate("moz_global_var"))) +#else +# define MOZ_RUNINIT +#endif + /** * Note: The reason that these functions are separated from those in * updatehelper.h/updatehelper.cpp is that those functions are strictly @@ -19,7 +25,7 @@ // This section implements the minimum set of dirent APIs used by updater.cpp on // Windows. If updater.cpp is modified to use more of this API, we need to // implement those parts here too. -static dirent gDirEnt; +MOZ_RUNINIT static dirent gDirEnt; DIR::DIR(const WCHAR* path) : findHandle(INVALID_HANDLE_VALUE) { memset(name, 0, sizeof(name)); diff --git a/toolkit/mozapps/update/updater/loaddlls.cpp b/toolkit/mozapps/update/updater/loaddlls.cpp index 462bd0bc1880..bfa4156238da 100644 --- a/toolkit/mozapps/update/updater/loaddlls.cpp +++ b/toolkit/mozapps/update/updater/loaddlls.cpp @@ -5,10 +5,16 @@ #include +#ifdef MOZ_CLANG_PLUGIN +# define MOZ_RUNINIT __attribute__((annotate("moz_global_var"))) +#else +# define MOZ_RUNINIT +#endif + // Delayed load libraries are loaded when the first symbol is used. // The following ensures that we load the delayed loaded libraries from the // system directory. -struct AutoLoadSystemDependencies { +MOZ_RUNINIT struct AutoLoadSystemDependencies { AutoLoadSystemDependencies() { // Remove the current directory from the search path for dynamically loaded // DLLs as a precaution. This call has no effect for delay load DLLs. diff --git a/toolkit/mozapps/update/updater/progressui_gtk.cpp b/toolkit/mozapps/update/updater/progressui_gtk.cpp index cfdcd5587c63..78c0c17dd3b9 100644 --- a/toolkit/mozapps/update/updater/progressui_gtk.cpp +++ b/toolkit/mozapps/update/updater/progressui_gtk.cpp @@ -24,7 +24,7 @@ static GtkWidget* sLabel; static GtkWidget* sProgressBar; static GdkPixbuf* sPixbuf; -StringTable sStrings; +MOZ_RUNINIT StringTable sStrings; static gboolean UpdateDialog(gpointer data) { if (sQuit) { diff --git a/toolkit/mozapps/update/updater/progressui_osx.mm b/toolkit/mozapps/update/updater/progressui_osx.mm index 4a9f8ef3b1b3..7fe11d170bdc 100644 --- a/toolkit/mozapps/update/updater/progressui_osx.mm +++ b/toolkit/mozapps/update/updater/progressui_osx.mm @@ -17,7 +17,7 @@ static float sProgressVal; // between 0 and 100 static BOOL sQuit = NO; static BOOL sIndeterminate = NO; -static StringTable sLabels; +MOZ_RUNINIT static StringTable sLabels; static const char* sUpdatePath; @interface UpdaterUI : NSObject { diff --git a/toolkit/mozapps/update/updater/progressui_win.cpp b/toolkit/mozapps/update/updater/progressui_win.cpp index 51bd2d8cce5d..741e730c0f72 100644 --- a/toolkit/mozapps/update/updater/progressui_win.cpp +++ b/toolkit/mozapps/update/updater/progressui_win.cpp @@ -42,7 +42,7 @@ static float sProgress; // between 0 and 100 static BOOL sQuit = FALSE; static BOOL sIndeterminate = FALSE; -static StringTable sUIStrings; +MOZ_RUNINIT static StringTable sUIStrings; static BOOL GetStringsFile(WCHAR filename[MAX_PATH]) { if (!GetModuleFileNameW(nullptr, filename, MAX_PATH)) { diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp index 89fa83871765..4383d9cffbe8 100644 --- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -277,7 +277,7 @@ class Thread { static NS_tchar gPatchDirPath[MAXPATHLEN]; static NS_tchar gInstallDirPath[MAXPATHLEN]; static NS_tchar gWorkingDirPath[MAXPATHLEN]; -static ArchiveReader gArchiveReader; +MOZ_RUNINIT static ArchiveReader gArchiveReader; static bool gSucceeded = false; static bool sStagedUpdate = false; static bool sReplaceRequest = false; @@ -289,7 +289,7 @@ static bool gIsElevated = false; // This string contains the MAR channel IDs that are later extracted by one of // the `ReadMARChannelIDsFrom` variants. -static MARChannelStringTable gMARStrings; +MOZ_RUNINIT static MARChannelStringTable gMARStrings; // Normally, we run updates as a result of user action (the user started Firefox // or clicked a "Restart to Update" button). But there are some cases when diff --git a/toolkit/system/osxproxy/nsOSXSystemProxySettings.mm b/toolkit/system/osxproxy/nsOSXSystemProxySettings.mm index 27c7b4714816..f02deb7bd712 100644 --- a/toolkit/system/osxproxy/nsOSXSystemProxySettings.mm +++ b/toolkit/system/osxproxy/nsOSXSystemProxySettings.mm @@ -75,7 +75,7 @@ nsOSXSystemProxySettings::GetSystemWPADSetting(bool* aSystemWPADSetting) { } // Mapping of URI schemes to SystemConfiguration keys -const nsOSXSystemProxySettings::SchemeMapping +MOZ_RUNINIT const nsOSXSystemProxySettings::SchemeMapping nsOSXSystemProxySettings::gSchemeMappingList[] = { {"http", kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPPort, false}, diff --git a/toolkit/xre/dllservices/DynamicBlocklistWriter.cpp b/toolkit/xre/dllservices/DynamicBlocklistWriter.cpp index faa2c7ada02d..92a6b161d11d 100644 --- a/toolkit/xre/dllservices/DynamicBlocklistWriter.cpp +++ b/toolkit/xre/dllservices/DynamicBlocklistWriter.cpp @@ -12,9 +12,9 @@ namespace mozilla { #if ENABLE_TESTS -nsDependentString testEntryString(DynamicBlockList::kTestDll, - DynamicBlockList::kTestDllBytes / - sizeof(DynamicBlockList::kTestDll[0])); +MOZ_RUNINIT nsDependentString testEntryString( + DynamicBlockList::kTestDll, + DynamicBlockList::kTestDllBytes / sizeof(DynamicBlockList::kTestDll[0])); #endif bool ShouldWriteEntry(const nsAString& name) { diff --git a/toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp b/toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp index 4f97ccc39f66..40f35dd2171e 100644 --- a/toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp +++ b/toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp @@ -56,7 +56,7 @@ static uint32_t sInitFlags; static bool sBlocklistInitAttempted; static bool sBlocklistInitFailed; static bool sUser32BeforeBlocklist; -static WritableBuffer sBlocklistWriter; +MOZ_RUNINIT static WritableBuffer sBlocklistWriter; typedef MOZ_NORETURN_PTR void(__fastcall* BaseThreadInitThunk_func)( BOOL aIsInitialThread, void* aStartAddress, void* aThreadParam); @@ -562,13 +562,13 @@ static MOZ_NORETURN void __fastcall patched_BaseThreadInitThunk( stub_BaseThreadInitThunk(aIsInitialThread, aStartAddress, aThreadParam); } -static WindowsDllInterceptor NtDllIntercept; -static WindowsDllInterceptor Kernel32Intercept; +MOZ_RUNINIT static WindowsDllInterceptor NtDllIntercept; +MOZ_RUNINIT static WindowsDllInterceptor Kernel32Intercept; static void GetNativeNtBlockSetWriter(); static glue::LoaderObserver gMozglueLoaderObserver; -static nt::WinLauncherServices gWinLauncher; +MOZ_RUNINIT static nt::WinLauncherServices gWinLauncher; MFBT_API void DllBlocklist_Initialize(uint32_t aInitFlags) { if (sBlocklistInitAttempted) { diff --git a/toolkit/xre/dllservices/mozglue/WindowsMsctfInitialization.cpp b/toolkit/xre/dllservices/mozglue/WindowsMsctfInitialization.cpp index 03a6a30deb80..e971dcc40901 100644 --- a/toolkit/xre/dllservices/mozglue/WindowsMsctfInitialization.cpp +++ b/toolkit/xre/dllservices/mozglue/WindowsMsctfInitialization.cpp @@ -29,7 +29,7 @@ struct LPARAM20000 { uintptr_t Reserved2; // Used as a boolean (though never saw it set to true) }; -static WindowsDllInterceptor MsctfIntercept; +MOZ_RUNINIT static WindowsDllInterceptor MsctfIntercept; typedef uintptr_t(WINAPI* TF_Notify_func)(UINT uMsg, WPARAM wParam, LPARAM lParam); diff --git a/toolkit/xre/dllservices/mozglue/WindowsOleAut32Initialization.cpp b/toolkit/xre/dllservices/mozglue/WindowsOleAut32Initialization.cpp index 718caa3f50c0..7a7014c89776 100644 --- a/toolkit/xre/dllservices/mozglue/WindowsOleAut32Initialization.cpp +++ b/toolkit/xre/dllservices/mozglue/WindowsOleAut32Initialization.cpp @@ -12,7 +12,7 @@ namespace mozilla { -static WindowsDllInterceptor sOleAut32Intercept; +MOZ_RUNINIT static WindowsDllInterceptor sOleAut32Intercept; static WindowsDllInterceptor::FuncHookType stub_VariantClear; diff --git a/toolkit/xre/dllservices/mozglue/WindowsStackWalkInitialization.cpp b/toolkit/xre/dllservices/mozglue/WindowsStackWalkInitialization.cpp index 19da9b307b9b..ee934f39a003 100644 --- a/toolkit/xre/dllservices/mozglue/WindowsStackWalkInitialization.cpp +++ b/toolkit/xre/dllservices/mozglue/WindowsStackWalkInitialization.cpp @@ -14,7 +14,7 @@ namespace mozilla { #if defined(_M_AMD64) || defined(_M_ARM64) -static WindowsDllInterceptor NtDllIntercept; +MOZ_RUNINIT static WindowsDllInterceptor NtDllIntercept; typedef NTSTATUS(NTAPI* LdrUnloadDll_func)(HMODULE module); static WindowsDllInterceptor::FuncHookType stub_LdrUnloadDll; diff --git a/toolkit/xre/dllservices/tests/TestDllBlocklistAssumptions.cpp b/toolkit/xre/dllservices/tests/TestDllBlocklistAssumptions.cpp index 17c68f26dc9e..39ff3ba53317 100644 --- a/toolkit/xre/dllservices/tests/TestDllBlocklistAssumptions.cpp +++ b/toolkit/xre/dllservices/tests/TestDllBlocklistAssumptions.cpp @@ -23,7 +23,7 @@ NTSTATUS NTAPI NtMapViewOfSection( using namespace mozilla; -static WindowsDllInterceptor NtdllIntercept; +MOZ_RUNINIT static WindowsDllInterceptor NtdllIntercept; static WindowsDllInterceptor::FuncHookType stub_NtMapViewOfSection; @@ -80,7 +80,7 @@ class MappedViewsInfoCollector { }; static bool sIsTestRunning = false; -static MappedViewsInfoCollector sMappedViewsInfoCollector; +MOZ_RUNINIT static MappedViewsInfoCollector sMappedViewsInfoCollector; NTSTATUS NTAPI patched_NtMapViewOfSection( HANDLE aSection, HANDLE aProcess, PVOID* aBaseAddress, ULONG_PTR aZeroBits, diff --git a/toolkit/xre/dllservices/tests/TestDllInterceptor.cpp b/toolkit/xre/dllservices/tests/TestDllInterceptor.cpp index 5482e9723aa5..e9ffd019acda 100644 --- a/toolkit/xre/dllservices/tests/TestDllInterceptor.cpp +++ b/toolkit/xre/dllservices/tests/TestDllInterceptor.cpp @@ -806,7 +806,7 @@ bool TestShortDetour() { constexpr uintptr_t NoStubAddressCheck = 0; constexpr uintptr_t ExpectedFail = 1; -struct TestCase { +MOZ_GLOBINIT struct TestCase { const char* mFunctionName; uintptr_t mExpectedStub; bool mPatchedOnce; @@ -964,7 +964,7 @@ struct DetouredCallChunk { // a module doesn't seem to work. Presumably it conflicts with the static // function tables. So we recreate gDetouredCall as dynamic code to be able to // associate it with unwind information. -decltype(&DetouredCallCode) gDetouredCall = +MOZ_RUNINIT decltype(&DetouredCallCode) gDetouredCall = []() -> decltype(&DetouredCallCode) { // We first adjust the detoured call jumper from: // ff 25 00 00 00 00 jmp qword ptr [rip + 0] diff --git a/toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp b/toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp index a5afed61a512..21718d8b5808 100644 --- a/toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp +++ b/toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp @@ -247,14 +247,15 @@ class UntrustedModulesFixture : public TelemetryTestFixture { } }; -const nsString UntrustedModulesFixture::kTestModules[] = { +MOZ_RUNINIT const nsString UntrustedModulesFixture::kTestModules[] = { // Sorted for binary-search u"TestUntrustedModules_Dll1.dll"_ns, u"TestUntrustedModules_Dll2.dll"_ns, }; INIT_ONCE UntrustedModulesFixture::sInitLoadOnce = INIT_ONCE_STATIC_INIT; -UntrustedModulesCollector UntrustedModulesFixture::sInitLoadDataCollector; +MOZ_RUNINIT UntrustedModulesCollector + UntrustedModulesFixture::sInitLoadDataCollector; void UntrustedModulesFixture::ValidateUntrustedModules( const UntrustedModulesData& aData, bool aIsTruncatedData) { diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 58df3006066b..3b62a8d42057 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -311,8 +311,8 @@ extern const char gToolkitBuildID[]; static nsIProfileLock* gProfileLock; #if defined(MOZ_HAS_REMOTE) -static RefPtr gRemoteService; -static RefPtr gStartupLock; +MOZ_RUNINIT static RefPtr gRemoteService; +MOZ_RUNINIT static RefPtr gStartupLock; #endif int gRestartArgc; @@ -328,10 +328,10 @@ int gKioskMonitor = -1; bool gAllowContentAnalysisArgPresent = false; -nsString gAbsoluteArgv0Path; +MOZ_RUNINIT nsString gAbsoluteArgv0Path; #if defined(XP_WIN) -nsString gProcessStartupShortcut; +MOZ_RUNINIT nsString gProcessStartupShortcut; #endif #if defined(MOZ_WIDGET_GTK) @@ -349,7 +349,7 @@ nsString gProcessStartupShortcut; #endif #if defined(MOZ_WAYLAND) -std::unique_ptr gWaylandProxy; +MOZ_RUNINIT std::unique_ptr gWaylandProxy; #endif #include "BinaryPath.h" @@ -1287,8 +1287,8 @@ nsXULAppInfo::GetRemoteType(nsACString& aRemoteType) { return NS_OK; } -static nsCString gLastAppVersion; -static nsCString gLastAppBuildID; +MOZ_RUNINIT static nsCString gLastAppVersion; +MOZ_RUNINIT static nsCString gLastAppBuildID; NS_IMETHODIMP nsXULAppInfo::GetLastAppVersion(nsACString& aResult) { @@ -2906,7 +2906,7 @@ static ReturnAbortOnError ShowProfileSelector( static bool gDoMigration = false; static bool gDoProfileReset = false; -static nsCOMPtr gResetOldProfile; +MOZ_RUNINIT static nsCOMPtr gResetOldProfile; static nsresult LockProfile(nsINativeAppSupport* aNative, nsIFile* aRootDir, nsIFile* aLocalDir, nsIToolkitProfile* aProfile, @@ -6321,7 +6321,7 @@ struct InstallRustHooks { InstallRustHooks() { install_rust_hooks(); } }; -InstallRustHooks sInstallRustHooks; +MOZ_RUNINIT InstallRustHooks sInstallRustHooks; #ifdef MOZ_ASAN_REPORTER void setASanReporterPath(nsIFile* aDir) { diff --git a/toolkit/xre/nsX11ErrorHandler.cpp b/toolkit/xre/nsX11ErrorHandler.cpp index 77f71db8f9d8..ab5a18852515 100644 --- a/toolkit/xre/nsX11ErrorHandler.cpp +++ b/toolkit/xre/nsX11ErrorHandler.cpp @@ -24,7 +24,7 @@ struct XExtension { XExtension(const char* aName, int aCode) : name(aName), major_opcode(aCode) {} }; -static nsTArray sXExtensions; +MOZ_RUNINIT static nsTArray sXExtensions; // man XSetErrorHandler says "the error handler should not call any // functions (directly or indirectly) on the display that will generate diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index e3be04e70c6d..de0512d4c97a 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -93,8 +93,8 @@ nsXREDirProvider* gDirServiceProvider = nullptr; nsIFile* gDataDirHomeLocal = nullptr; nsIFile* gDataDirHome = nullptr; -nsCOMPtr gDataDirProfileLocal = nullptr; -nsCOMPtr gDataDirProfile = nullptr; +MOZ_RUNINIT nsCOMPtr gDataDirProfileLocal = nullptr; +MOZ_RUNINIT nsCOMPtr gDataDirProfile = nullptr; // These are required to allow nsXREDirProvider to be usable in xpcshell tests. // where gAppData is null. diff --git a/toolkit/xre/test/gtest/TestCmdLineAndEnvUtils.cpp b/toolkit/xre/test/gtest/TestCmdLineAndEnvUtils.cpp index 759bdbb6fd0a..9da29a257b71 100644 --- a/toolkit/xre/test/gtest/TestCmdLineAndEnvUtils.cpp +++ b/toolkit/xre/test/gtest/TestCmdLineAndEnvUtils.cpp @@ -182,7 +182,8 @@ std::pair kStrMatches16[] = { constexpr const char* kRequiredArgs[] = {"aleph", "beth"}; -std::pair> const kCommandLines[] = { +MOZ_RUNINIT std::pair> const kCommandLines[] = { // the basic admissible forms {PASS, {"-osint", "-aleph", "http://www.example.com/"}}, {PASS, {"-osint", "-beth", "http://www.example.com/"}}, @@ -254,29 +255,35 @@ constexpr static char const* const kOptionalArgs[] = {"mozilla", "allizom"}; // Test cases marked PASS should pass iff the above optional parameters are // permitted. (Test cases marked FAIL should fail regardless, and are only // grouped here for convenience and semantic coherence.) -std::pair> kCommandLinesOpt[] = { - // one permitted optional argument - {PASS, {"-osint", "-mozilla", "-aleph", "http://www.example.com/"}}, - {PASS, {"-osint", "-allizom", "-aleph", "http://www.example.com/"}}, +MOZ_RUNINIT std::pair> + kCommandLinesOpt[] = { + // one permitted optional argument + {PASS, {"-osint", "-mozilla", "-aleph", "http://www.example.com/"}}, + {PASS, {"-osint", "-allizom", "-aleph", "http://www.example.com/"}}, - // multiple permitted optional arguments - {PASS, - {"-osint", "-mozilla", "-allizom", "-aleph", "http://www.example.com/"}}, - {PASS, - {"-osint", "-allizom", "-mozilla", "-aleph", "http://www.example.com/"}}, + // multiple permitted optional arguments + {PASS, + {"-osint", "-mozilla", "-allizom", "-aleph", + "http://www.example.com/"}}, + {PASS, + {"-osint", "-allizom", "-mozilla", "-aleph", + "http://www.example.com/"}}, - // optional arguments in the wrong place - {FAIL, {"-mozilla", "-osint", "-aleph", "http://www.example.com/"}}, - {FAIL, {"-osint", "-aleph", "-mozilla", "http://www.example.com/"}}, - {FAIL, {"-osint", "-aleph", "http://www.example.com/", "-mozilla"}}, + // optional arguments in the wrong place + {FAIL, {"-mozilla", "-osint", "-aleph", "http://www.example.com/"}}, + {FAIL, {"-osint", "-aleph", "-mozilla", "http://www.example.com/"}}, + {FAIL, {"-osint", "-aleph", "http://www.example.com/", "-mozilla"}}, - // optional arguments in both right and wrong places - {FAIL, - {"-mozilla", "-osint", "-allizom", "-aleph", "http://www.example.com/"}}, - {FAIL, - {"-osint", "-allizom", "-aleph", "-mozilla", "http://www.example.com/"}}, - {FAIL, - {"-osint", "-allizom", "-aleph", "http://www.example.com/", "-mozilla"}}, + // optional arguments in both right and wrong places + {FAIL, + {"-mozilla", "-osint", "-allizom", "-aleph", + "http://www.example.com/"}}, + {FAIL, + {"-osint", "-allizom", "-aleph", "-mozilla", + "http://www.example.com/"}}, + {FAIL, + {"-osint", "-allizom", "-aleph", "http://www.example.com/", + "-mozilla"}}, }; enum WithOptionalState : bool { diff --git a/toolkit/xre/test/win/TestLauncherRegistryInfo.cpp b/toolkit/xre/test/win/TestLauncherRegistryInfo.cpp index ab5edcf1ca23..66d347d4d630 100644 --- a/toolkit/xre/test/win/TestLauncherRegistryInfo.cpp +++ b/toolkit/xre/test/win/TestLauncherRegistryInfo.cpp @@ -25,10 +25,10 @@ static const wchar_t kLauncherSuffix[] = L"|Launcher"; static const wchar_t kImageSuffix[] = L"|Image"; static const wchar_t kTelemetrySuffix[] = L"|Telemetry"; -static std::wstring gBrowserValue; -static std::wstring gLauncherValue; -static std::wstring gImageValue; -static std::wstring gTelemetryValue; +MOZ_RUNINIT static std::wstring gBrowserValue; +MOZ_RUNINIT static std::wstring gLauncherValue; +MOZ_RUNINIT static std::wstring gImageValue; +MOZ_RUNINIT static std::wstring gTelemetryValue; static DWORD gMyImageTimestamp; diff --git a/tools/fuzzing/interface/FuzzingInterface.cpp b/tools/fuzzing/interface/FuzzingInterface.cpp index 6466f95dcfd1..3dc8ceb16ea8 100644 --- a/tools/fuzzing/interface/FuzzingInterface.cpp +++ b/tools/fuzzing/interface/FuzzingInterface.cpp @@ -14,7 +14,7 @@ namespace mozilla { #ifdef JS_STANDALONE -static bool fuzzing_verbose = !!getenv("MOZ_FUZZ_LOG"); +MOZ_RUNINIT static bool fuzzing_verbose = !!getenv("MOZ_FUZZ_LOG"); void fuzzing_log(const char* aFmt, ...) { if (fuzzing_verbose) { va_list ap; diff --git a/tools/fuzzing/interface/harness/FuzzerRunner.cpp b/tools/fuzzing/interface/harness/FuzzerRunner.cpp index 4e6e07401d2b..0d7836c4ad50 100644 --- a/tools/fuzzing/interface/harness/FuzzerRunner.cpp +++ b/tools/fuzzing/interface/harness/FuzzerRunner.cpp @@ -17,7 +17,7 @@ namespace mozilla { // fuzzerRunner is initialized to nullptr but if this file is linked in, // then fuzzerRunner will be set here indicating that // we want to call into either LibFuzzer's main or the AFL entrypoint. -class _InitFuzzer { +MOZ_RUNINIT class _InitFuzzer { public: _InitFuzzer() { fuzzerRunner = new FuzzerRunner(); } void InitXPCOM() { mScopedXPCOM = new ScopedXPCOM("Fuzzer"); } diff --git a/tools/power/rapl.cpp b/tools/power/rapl.cpp index 1aa5fcf6eedd..060176b07099 100644 --- a/tools/power/rapl.cpp +++ b/tools/power/rapl.cpp @@ -48,6 +48,12 @@ #include #include +#ifdef MOZ_CLANG_PLUGIN +# define MOZ_RUNINIT __attribute__((annotate("moz_global_var"))) +#else +# define MOZ_RUNINIT +#endif + //--------------------------------------------------------------------------- // Utilities //--------------------------------------------------------------------------- @@ -604,7 +610,7 @@ static double gSampleInterval_sec; static RAPL* gRapl; // All the sampled "total" values, in Watts. -static std::vector gTotals_W; +MOZ_RUNINIT static std::vector gTotals_W; // Power = Energy / Time, where power is measured in Watts, Energy is measured // in Joules, and Time is measured in seconds. diff --git a/tools/profiler/core/ProfilerThreadRegistry.cpp b/tools/profiler/core/ProfilerThreadRegistry.cpp index cb456471d975..a7eb700ef3ea 100644 --- a/tools/profiler/core/ProfilerThreadRegistry.cpp +++ b/tools/profiler/core/ProfilerThreadRegistry.cpp @@ -9,10 +9,11 @@ namespace mozilla::profiler { /* static */ -ThreadRegistry::RegistryContainer ThreadRegistry::sRegistryContainer; +MOZ_RUNINIT ThreadRegistry::RegistryContainer + ThreadRegistry::sRegistryContainer; /* static */ -ThreadRegistry::RegistryMutex ThreadRegistry::sRegistryMutex; +MOZ_RUNINIT ThreadRegistry::RegistryMutex ThreadRegistry::sRegistryMutex; #if !defined(MOZ_GECKO_PROFILER) // When MOZ_GECKO_PROFILER is not defined, the function definitions in diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index d5ffc4c70c5d..ee88a0fe9aee 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -462,9 +462,9 @@ Json::String ToCompactString(const Json::Value& aJsonValue) { return Json::writeString(builder, aJsonValue); } -/* static */ mozilla::baseprofiler::detail::BaseProfilerMutex +MOZ_RUNINIT /* static */ mozilla::baseprofiler::detail::BaseProfilerMutex ProfilingLog::gMutex; -/* static */ mozilla::UniquePtr ProfilingLog::gLog; +MOZ_RUNINIT /* static */ mozilla::UniquePtr ProfilingLog::gLog; /* static */ void ProfilingLog::Init() { mozilla::baseprofiler::detail::BaseProfilerAutoLock lock{gMutex}; @@ -516,7 +516,7 @@ class MOZ_RAII PSAutoLock { mozilla::baseprofiler::detail::BaseProfilerAutoLock mLock; }; -/* static */ mozilla::baseprofiler::detail::BaseProfilerMutex +MOZ_RUNINIT /* static */ mozilla::baseprofiler::detail::BaseProfilerMutex PSAutoLock::gPSMutex{"Gecko Profiler mutex"}; // Only functions that take a PSLockRef arg can access CorePS's and ActivePS's @@ -1887,7 +1887,7 @@ using ProfilerStateChangeMutex = mozilla::baseprofiler::detail::BaseProfilerMutex; using ProfilerStateChangeLock = mozilla::baseprofiler::detail::BaseProfilerAutoLock; -static ProfilerStateChangeMutex gProfilerStateChangeMutex; +MOZ_RUNINIT static ProfilerStateChangeMutex gProfilerStateChangeMutex; struct IdentifiedProfilingStateChangeCallback { ProfilingStateSet mProfilingStateSet; @@ -1905,7 +1905,7 @@ struct IdentifiedProfilingStateChangeCallback { using IdentifiedProfilingStateChangeCallbackUPtr = UniquePtr; -static Vector +MOZ_RUNINIT static Vector mIdentifiedProfilingStateChangeCallbacks; void profiler_add_state_change_callback( diff --git a/tools/profiler/gecko/ProfilerChild.cpp b/tools/profiler/gecko/ProfilerChild.cpp index db7ef9942381..b5deda29b9cc 100644 --- a/tools/profiler/gecko/ProfilerChild.cpp +++ b/tools/profiler/gecko/ProfilerChild.cpp @@ -20,8 +20,8 @@ namespace mozilla { -/* static */ DataMutexBase +MOZ_RUNINIT /* static */ DataMutexBase ProfilerChild::sPendingChunkManagerUpdate{ "ProfilerChild::sPendingChunkManagerUpdate"}; diff --git a/tools/profiler/gecko/ProfilerParent.cpp b/tools/profiler/gecko/ProfilerParent.cpp index 122017392d9d..eff0898e3829 100644 --- a/tools/profiler/gecko/ProfilerParent.cpp +++ b/tools/profiler/gecko/ProfilerParent.cpp @@ -154,8 +154,9 @@ class ProfileBufferGlobalController final { }; /* static */ -DataMutexBase +MOZ_RUNINIT DataMutexBase< + ProfileBufferGlobalController::ParentChunkManagerAndPendingUpdate, + baseprofiler::detail::BaseProfilerMutex> ProfileBufferGlobalController::sParentChunkManagerAndPendingUpdate{ "ProfileBufferGlobalController::sParentChunkManagerAndPendingUpdate"}; diff --git a/tools/profiler/lul/LulCommonExt.h b/tools/profiler/lul/LulCommonExt.h index b20a7321ff2a..8ecc1ee8ff7f 100644 --- a/tools/profiler/lul/LulCommonExt.h +++ b/tools/profiler/lul/LulCommonExt.h @@ -374,7 +374,7 @@ class scoped_ptr_malloc { }; template -FP const scoped_ptr_malloc::free_ = FP(); +MOZ_RUNINIT FP const scoped_ptr_malloc::free_ = FP(); template inline void swap(scoped_ptr_malloc& a, scoped_ptr_malloc& b) { diff --git a/tools/rewriting/ThirdPartyPaths.txt b/tools/rewriting/ThirdPartyPaths.txt index 52daa289c681..6965076610e9 100644 --- a/tools/rewriting/ThirdPartyPaths.txt +++ b/tools/rewriting/ThirdPartyPaths.txt @@ -204,3 +204,4 @@ tools/profiler/core/vtune/ xpcom/build/mach_override.c xpcom/build/mach_override.h xpcom/io/crc32c.c +rlbox/rlbox_sandbox.hpp diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index 811de7efad6b..498e9d861061 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -1208,7 +1208,7 @@ nsresult GfxInfoBase::GetInfo(JSContext* aCx, return NS_OK; } -nsAutoCString gBaseAppVersion; +MOZ_RUNINIT nsAutoCString gBaseAppVersion; const nsCString& GfxInfoBase::GetApplicationVersion() { static bool versionInitialized = false; diff --git a/widget/android/AndroidAlerts.cpp b/widget/android/AndroidAlerts.cpp index 456dc08290be..6a8c34410692 100644 --- a/widget/android/AndroidAlerts.cpp +++ b/widget/android/AndroidAlerts.cpp @@ -15,7 +15,7 @@ namespace widget { NS_IMPL_ISUPPORTS(AndroidAlerts, nsIAlertsService) StaticAutoPtr AndroidAlerts::sListenerMap; -nsTHashMap +MOZ_RUNINIT nsTHashMap AndroidAlerts::mNotificationsMap; NS_IMETHODIMP diff --git a/widget/android/AndroidVsync.cpp b/widget/android/AndroidVsync.cpp index 6aed5f1e539c..8c792a4becfe 100644 --- a/widget/android/AndroidVsync.cpp +++ b/widget/android/AndroidVsync.cpp @@ -16,8 +16,8 @@ namespace mozilla { namespace widget { -StaticDataMutex> AndroidVsync::sInstance( - "AndroidVsync::sInstance"); +MOZ_RUNINIT StaticDataMutex> + AndroidVsync::sInstance("AndroidVsync::sInstance"); /* static */ RefPtr AndroidVsync::GetInstance() { auto weakInstance = sInstance.Lock(); diff --git a/widget/android/ImageDecoderSupport.cpp b/widget/android/ImageDecoderSupport.cpp index 4418b79746f0..a642dd0a4db8 100644 --- a/widget/android/ImageDecoderSupport.cpp +++ b/widget/android/ImageDecoderSupport.cpp @@ -24,8 +24,9 @@ namespace { class ImageCallbackHelper; -HashSet, PointerHasher> - gDecodeRequests; +MOZ_RUNINIT + HashSet, PointerHasher> + gDecodeRequests; class ImageCallbackHelper : public imgIContainerCallback, public imgINotificationObserver { diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index a8b8bf08e8d2..d8166e789b91 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -111,7 +111,7 @@ class WakeLockListener final : public nsIDOMMozWakeLockListener { }; NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener) -nsCOMPtr sPowerManagerService = nullptr; +MOZ_RUNINIT nsCOMPtr sPowerManagerService = nullptr; StaticRefPtr sWakeLockListener; class GeckoThreadSupport final diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 504429de2653..66f03e1bf337 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -129,7 +129,7 @@ static mozilla::LazyLogModule sGVSupportLog("GeckoViewSupport"); // All the toplevel windows that have been created; these are in // stacking order, so the window at gTopLevelWindows[0] is the topmost // one. -static nsTArray gTopLevelWindows; +MOZ_RUNINIT static nsTArray gTopLevelWindows; static bool sFailedToCreateGLContext = false; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index c327b256c2c2..7b867088786a 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -152,7 +152,8 @@ extern nsIArray* gDraggedTransferables; ChildView* ChildViewMouseTracker::sLastMouseEventView = nil; NSEvent* ChildViewMouseTracker::sLastMouseMoveEvent = nil; NSWindow* ChildViewMouseTracker::sWindowUnderMouse = nil; -NSPoint ChildViewMouseTracker::sLastScrollEventScreenLocation = NSZeroPoint; +MOZ_RUNINIT NSPoint ChildViewMouseTracker::sLastScrollEventScreenLocation = + NSZeroPoint; #ifdef INVALIDATE_DEBUGGING static void blinkRect(Rect* r); @@ -4850,7 +4851,7 @@ nsresult nsChildView::RestoreHiDPIMode() { + (NSMutableDictionary*)sNativeKeyEventsMap { // This dictionary is "leaked". - static NSMutableDictionary* sNativeKeyEventsMap = + MOZ_RUNINIT static NSMutableDictionary* sNativeKeyEventsMap = [[NSMutableDictionary alloc] init]; return sNativeKeyEventsMap; } diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index 39e16050a72f..0b84bf06f7b2 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -3093,9 +3093,9 @@ static NSMutableSet* gSwizzledFrameViewClasses = nil; } } - static IMP our_closeButtonOrigin = class_getMethodImplementation( + MOZ_RUNINIT static IMP our_closeButtonOrigin = class_getMethodImplementation( [NSView class], @selector(FrameView__closeButtonOrigin)); - static IMP our_titlebarHeight = class_getMethodImplementation( + MOZ_RUNINIT static IMP our_titlebarHeight = class_getMethodImplementation( [NSView class], @selector(FrameView__titlebarHeight)); if (![gSwizzledFrameViewClasses containsObject:frameViewClass]) { diff --git a/widget/cocoa/nsCursorManager.mm b/widget/cocoa/nsCursorManager.mm index 5e4315e3c254..135b7216f276 100644 --- a/widget/cocoa/nsCursorManager.mm +++ b/widget/cocoa/nsCursorManager.mm @@ -10,7 +10,7 @@ static nsCursorManager* gInstance; static CGFloat sCurrentCursorScaleFactor = 0.0f; -static nsIWidget::Cursor sCurrentCursor; +MOZ_RUNINIT static nsIWidget::Cursor sCurrentCursor; static constexpr nsCursor kCustomCursor = eCursorCount; /*! @category nsCursorManager(PrivateMethods) diff --git a/widget/cocoa/nsMacDockSupport.mm b/widget/cocoa/nsMacDockSupport.mm index 33b79275c8aa..685b330407c3 100644 --- a/widget/cocoa/nsMacDockSupport.mm +++ b/widget/cocoa/nsMacDockSupport.mm @@ -293,7 +293,7 @@ CFURLRef _CFURLCreateFromPropertyListRepresentation( namespace { -const NSArray* const browserAppNames = [NSArray +MOZ_RUNINIT const NSArray* const browserAppNames = [NSArray arrayWithObjects:@"Firefox.app", @"Firefox Beta.app", @"Firefox Nightly.app", @"Safari.app", @"WebKit.app", @"Google Chrome.app", @"Google Chrome Canary.app", diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index a97a7813fd34..674a84dd2e23 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -897,7 +897,7 @@ static void ApplyControlParamsToNSCell( // These are the sizes that Gecko needs to request to draw if it wants // to get a standard-sized Aqua radio button drawn. Note that the rects // that draw these are actually a little bigger. -static const CellRenderSettings radioSettings = { +MOZ_RUNINIT static const CellRenderSettings radioSettings = { { NSMakeSize(11, 11), // mini NSMakeSize(13, 13), // small @@ -917,7 +917,7 @@ static const CellRenderSettings radioSettings = { {0, 0, 0, 0} // regular }}}; -static const CellRenderSettings checkboxSettings = { +MOZ_RUNINIT static const CellRenderSettings checkboxSettings = { { NSMakeSize(11, 11), // mini NSMakeSize(13, 13), // small @@ -980,7 +980,7 @@ void nsNativeThemeCocoa::DrawCheckboxOrRadio( NS_OBJC_END_TRY_IGNORE_BLOCK; } -static const CellRenderSettings searchFieldSettings = { +MOZ_RUNINIT static const CellRenderSettings searchFieldSettings = { { NSMakeSize(0, 16), // mini NSMakeSize(0, 19), // small @@ -1115,10 +1115,10 @@ nsNativeThemeCocoa::ControlParams nsNativeThemeCocoa::ComputeControlParams( return params; } -static const NSSize kHelpButtonSize = NSMakeSize(20, 20); -static const NSSize kDisclosureButtonSize = NSMakeSize(21, 21); +MOZ_RUNINIT static const NSSize kHelpButtonSize = NSMakeSize(20, 20); +MOZ_RUNINIT static const NSSize kDisclosureButtonSize = NSMakeSize(21, 21); -static const CellRenderSettings pushButtonSettings = { +MOZ_RUNINIT static const CellRenderSettings pushButtonSettings = { { NSMakeSize(0, 16), // mini NSMakeSize(0, 19), // small @@ -1373,7 +1373,7 @@ void nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, } } -static const CellRenderSettings dropdownSettings = { +MOZ_RUNINIT static const CellRenderSettings dropdownSettings = { { NSMakeSize(0, 16), // mini NSMakeSize(0, 19), // small @@ -1397,7 +1397,7 @@ static const CellRenderSettings dropdownSettings = { {3, 0, 3, 0} // regular }}}; -static const CellRenderSettings editableMenulistSettings = { +MOZ_RUNINIT static const CellRenderSettings editableMenulistSettings = { { NSMakeSize(0, 15), // mini NSMakeSize(0, 18), // small @@ -1451,7 +1451,7 @@ void nsNativeThemeCocoa::DrawDropdown(CGContextRef cgContext, NS_OBJC_END_TRY_IGNORE_BLOCK; } -static const CellRenderSettings spinnerSettings = { +MOZ_RUNINIT static const CellRenderSettings spinnerSettings = { { NSMakeSize(11, 16), // mini (width trimmed by 2px to reduce blank border) @@ -1544,7 +1544,7 @@ void nsNativeThemeCocoa::DrawSpinButton(CGContextRef cgContext, NS_OBJC_END_TRY_IGNORE_BLOCK; } -static const CellRenderSettings progressSettings[2][2] = { +MOZ_RUNINIT static const CellRenderSettings progressSettings[2][2] = { // Vertical progress bar. {// Determined settings. {{ @@ -1657,7 +1657,7 @@ void nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext, NS_OBJC_END_TRY_IGNORE_BLOCK; } -static const CellRenderSettings meterSetting = { +MOZ_RUNINIT static const CellRenderSettings meterSetting = { { NSMakeSize(0, 16), // mini NSMakeSize(0, 16), // small @@ -2562,10 +2562,14 @@ LayoutDeviceIntMargin nsNativeThemeCocoa::DirectionAwareMargin( return LayoutDeviceIntMargin(m.top, m.right, m.bottom, m.left); } -static const LayoutDeviceIntMargin kAquaDropdownBorder(1, 22, 2, 5); -static const LayoutDeviceIntMargin kAquaComboboxBorder(3, 20, 3, 4); -static const LayoutDeviceIntMargin kAquaSearchfieldBorder(3, 5, 2, 19); -static const LayoutDeviceIntMargin kAquaSearchfieldBorderBigSur(5, 5, 4, 26); +MOZ_RUNINIT static const LayoutDeviceIntMargin kAquaDropdownBorder(1, 22, 2, 5); +MOZ_RUNINIT static const LayoutDeviceIntMargin kAquaComboboxBorder(3, 20, 3, 4); +MOZ_RUNINIT static const LayoutDeviceIntMargin kAquaSearchfieldBorder(3, 5, 2, + 19); +MOZ_RUNINIT static const LayoutDeviceIntMargin kAquaSearchfieldBorderBigSur(5, + 5, + 4, + 26); LayoutDeviceIntMargin nsNativeThemeCocoa::GetWidgetBorder( nsDeviceContext* aContext, nsIFrame* aFrame, StyleAppearance aAppearance) { diff --git a/widget/gtk/DMABufSurface.cpp b/widget/gtk/DMABufSurface.cpp index a2337bb16891..ddffdb21616b 100644 --- a/widget/gtk/DMABufSurface.cpp +++ b/widget/gtk/DMABufSurface.cpp @@ -79,7 +79,7 @@ static LazyLogModule gDmabufRefLog("DmabufRef"); #define BUFFER_FLAGS 0 -static RefPtr sSnapshotContext; +MOZ_RUNINIT static RefPtr sSnapshotContext; static StaticMutex sSnapshotContextMutex MOZ_UNANNOTATED; static Atomic gNewSurfaceUID(1); diff --git a/widget/gtk/MPRISServiceHandler.cpp b/widget/gtk/MPRISServiceHandler.cpp index 063adbaab0fc..2ac8c8364a3e 100644 --- a/widget/gtk/MPRISServiceHandler.cpp +++ b/widget/gtk/MPRISServiceHandler.cpp @@ -874,7 +874,8 @@ struct InterfaceProperty { const char* interface; const char* property; }; -static const std::unordered_map +MOZ_RUNINIT static const std::unordered_map gKeyProperty = { {dom::MediaControlKey::Focus, {DBUS_MPRIS_INTERFACE, "CanRaise"}}, {dom::MediaControlKey::Nexttrack, diff --git a/widget/gtk/WaylandBuffer.cpp b/widget/gtk/WaylandBuffer.cpp index f9e9f7c39a24..400937ec3e53 100644 --- a/widget/gtk/WaylandBuffer.cpp +++ b/widget/gtk/WaylandBuffer.cpp @@ -37,9 +37,10 @@ namespace mozilla::widget { gfx::SurfaceFormat WaylandBuffer::mFormat = gfx::SurfaceFormat::B8G8R8A8; #ifdef MOZ_LOGGING -int WaylandBufferSHM::mDumpSerial = +MOZ_RUNINIT int WaylandBufferSHM::mDumpSerial = PR_GetEnv("MOZ_WAYLAND_DUMP_WL_BUFFERS") ? 1 : 0; -char* WaylandBufferSHM::mDumpDir = PR_GetEnv("MOZ_WAYLAND_DUMP_DIR"); +MOZ_RUNINIT char* WaylandBufferSHM::mDumpDir = + PR_GetEnv("MOZ_WAYLAND_DUMP_DIR"); #endif /* static */ diff --git a/widget/gtk/WaylandVsyncSource.cpp b/widget/gtk/WaylandVsyncSource.cpp index 5512987e3b09..685a39491b43 100644 --- a/widget/gtk/WaylandVsyncSource.cpp +++ b/widget/gtk/WaylandVsyncSource.cpp @@ -55,7 +55,7 @@ static float GetFPS(TimeDuration aVsyncRate) { return 1000.0f / float(aVsyncRate.ToMilliseconds()); } -static nsTArray gWaylandVsyncSources; +MOZ_RUNINIT static nsTArray gWaylandVsyncSources; Maybe WaylandVsyncSource::GetFastestVsyncRate() { Maybe retVal; diff --git a/widget/gtk/nsClipboard.cpp b/widget/gtk/nsClipboard.cpp index 288f0a95f3b0..ed3a70d494e8 100644 --- a/widget/gtk/nsClipboard.cpp +++ b/widget/gtk/nsClipboard.cpp @@ -66,8 +66,8 @@ static const char kHTMLMarkupPrefix[] = static const char kURIListMime[] = "text/uri-list"; -ClipboardTargets nsRetrievalContext::sClipboardTargets; -ClipboardTargets nsRetrievalContext::sPrimaryTargets; +MOZ_CONSTINIT ClipboardTargets nsRetrievalContext::sClipboardTargets; +MOZ_CONSTINIT ClipboardTargets nsRetrievalContext::sPrimaryTargets; // Callback when someone asks us for the data static void clipboard_get_cb(GtkClipboard* aGtkClipboard, diff --git a/widget/gtk/nsWaylandDisplay.cpp b/widget/gtk/nsWaylandDisplay.cpp index ca0f12262618..13fd572214d6 100644 --- a/widget/gtk/nsWaylandDisplay.cpp +++ b/widget/gtk/nsWaylandDisplay.cpp @@ -135,7 +135,7 @@ class WaylandPointerEvent { float mDeltaY = 0; }; -static WaylandPointerEvent sHoldGesture; +MOZ_RUNINIT static WaylandPointerEvent sHoldGesture; static void gesture_hold_begin(void* data, struct zwp_pointer_gesture_hold_v1* hold, @@ -164,7 +164,7 @@ static void gesture_hold_end(void* data, static const struct zwp_pointer_gesture_hold_v1_listener gesture_hold_listener = {gesture_hold_begin, gesture_hold_end}; -static WaylandPointerEvent sScrollEvent; +MOZ_RUNINIT static WaylandPointerEvent sScrollEvent; static void pointer_handle_enter(void* data, struct wl_pointer* pointer, uint32_t serial, struct wl_surface* surface, diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 41214954621b..9eed31e7633d 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -348,7 +348,7 @@ static uint32_t gLastTouchID = 0; // event is a correct one when we get it. // Store it and issue it later from enter notify event if it's correct, // throw it away otherwise. -static GUniquePtr sStoredLeaveNotifyEvent; +MOZ_RUNINIT static GUniquePtr sStoredLeaveNotifyEvent; #define NS_WINDOW_TITLE_MAX_LENGTH 4095 diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 6428bb56cfa5..e21349311c49 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -116,7 +116,7 @@ int32_t nsIWidget::sPointerIdCounter = 0; // Some statics from nsIWidget.h /*static*/ uint64_t AutoObserverNotifier::sObserverId = 0; -/*static*/ nsTHashMap> +MOZ_RUNINIT /*static*/ nsTHashMap> AutoObserverNotifier::sSavedObservers; // The maximum amount of time to let the EnableDragDrop runnable wait in the diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index f4cd71008278..843bbc589a38 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -115,7 +115,8 @@ static ColorCaches sColorCaches; static EnumeratedCache, FloatID::End> sFloatCache; static EnumeratedCache, IntID::End> sIntCache; -static EnumeratedCache sFontCache; +MOZ_RUNINIT static EnumeratedCache + sFontCache; // To make one of these prefs toggleable from a reftest add a user // pref in testing/profiles/reftest/user.js. For example, to make diff --git a/widget/uikit/nsAppShell.mm b/widget/uikit/nsAppShell.mm index 6324a04b4d0c..e3db5ee5a00e 100644 --- a/widget/uikit/nsAppShell.mm +++ b/widget/uikit/nsAppShell.mm @@ -20,7 +20,8 @@ nsAppShell* nsAppShell::gAppShell = NULL; UIWindow* nsAppShell::gWindow = nil; -NSMutableArray* nsAppShell::gTopLevelViews = [[NSMutableArray alloc] init]; +MOZ_RUNINIT NSMutableArray* nsAppShell::gTopLevelViews = + [[NSMutableArray alloc] init]; #define ALOG(args...) \ fprintf(stderr, args); \ diff --git a/widget/windows/IMMHandler.cpp b/widget/windows/IMMHandler.cpp index 2f64f9392253..cdc00ed841c1 100644 --- a/widget/windows/IMMHandler.cpp +++ b/widget/windows/IMMHandler.cpp @@ -180,8 +180,8 @@ void IMEContext::Clear() { static UINT sWM_MSIME_MOUSE = 0; // mouse message for MSIME 98/2000 -WritingMode IMMHandler::sWritingModeOfCompositionFont; -nsString IMMHandler::sIMEName; +MOZ_RUNINIT WritingMode IMMHandler::sWritingModeOfCompositionFont; +MOZ_RUNINIT nsString IMMHandler::sIMEName; UINT IMMHandler::sCodePage = 0; DWORD IMMHandler::sIMEProperty = 0; DWORD IMMHandler::sIMEUIProperty = 0; diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 256f030536c5..3f94e338011a 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -525,7 +525,7 @@ HWND WinUtils::GetTopLevelHWND(HWND aWnd, bool aStopIfNotChild, // Map from native window handles to nsWindow structures. Does not AddRef. // Inherently unsafe to access outside the main thread. -static nsTHashMap sExtantNSWindows; +MOZ_RUNINIT static nsTHashMap sExtantNSWindows; /* static */ void WinUtils::SetNSWindowPtr(HWND aWnd, nsWindow* aWindow) { diff --git a/widget/windows/nsFilePicker.cpp b/widget/windows/nsFilePicker.cpp index 4d77e84d62ca..031b2dda7065 100644 --- a/widget/windows/nsFilePicker.cpp +++ b/widget/windows/nsFilePicker.cpp @@ -56,7 +56,7 @@ using namespace mozilla::widget; template using FDPromise = filedialog::Promise; -UniquePtr +MOZ_RUNINIT UniquePtr nsFilePicker::sLastUsedUnicodeDirectory; #define MAX_EXTENSION_LENGTH 10 diff --git a/widget/windows/nsUXThemeData.cpp b/widget/windows/nsUXThemeData.cpp index 88546b01c6f0..fb0a1c89ab45 100644 --- a/widget/windows/nsUXThemeData.cpp +++ b/widget/windows/nsUXThemeData.cpp @@ -17,7 +17,7 @@ using namespace mozilla; using namespace mozilla::widget; -nsUXThemeData::ThemeHandle nsUXThemeData::sThemes[eUXNumClasses]; +MOZ_RUNINIT nsUXThemeData::ThemeHandle nsUXThemeData::sThemes[eUXNumClasses]; nsUXThemeData::ThemeHandle::~ThemeHandle() { Close(); } diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 49482298d60f..b7efb0f1a826 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -255,7 +255,7 @@ static const wchar_t kUser32LibName[] = L"user32.dll"; uint32_t nsWindow::sInstanceCount = 0; bool nsWindow::sIsOleInitialized = false; -nsIWidget::Cursor nsWindow::sCurrentCursor = {}; +MOZ_RUNINIT nsIWidget::Cursor nsWindow::sCurrentCursor = {}; nsWindow* nsWindow::sCurrentWindow = nullptr; bool nsWindow::sJustGotDeactivate = false; bool nsWindow::sJustGotActivate = false; @@ -418,7 +418,7 @@ extern mozilla::LazyLogModule gWindowsLog; static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); // General purpose user32.dll hook object -static WindowsDllInterceptor sUser32Intercept; +MOZ_RUNINIT static WindowsDllInterceptor sUser32Intercept; // When the client area is extended out into the default window frame area, // this is the minimum amount of space along the edge of resizable windows diff --git a/widget/windows/nsWindowDbg.cpp b/widget/windows/nsWindowDbg.cpp index dabbe64cf902..427fbb7e5c7f 100644 --- a/widget/windows/nsWindowDbg.cpp +++ b/widget/windows/nsWindowDbg.cpp @@ -147,7 +147,7 @@ AutoProfilerMessageMarker::~AutoProfilerMessageMarker() { // Using an unordered_set so we can initialize this with nice syntax instead of // having to add them one at a time to a mozilla::HashSet. -std::unordered_set gEventsToLogOriginalParams = { +MOZ_RUNINIT std::unordered_set gEventsToLogOriginalParams = { WM_WINDOWPOSCHANGING, // (dummy comments for clang-format) WM_SIZING, // WM_STYLECHANGING, @@ -160,7 +160,7 @@ std::unordered_set gEventsToLogOriginalParams = { // If you add an event here, you must add cases for these to // MakeMessageSpecificData() and AppendFriendlyMessageSpecificData() // in nsWindowLoggedMessages.cpp. -std::unordered_set gEventsToRecordInAboutPage = { +MOZ_RUNINIT std::unordered_set gEventsToRecordInAboutPage = { WM_WINDOWPOSCHANGING, // (dummy comments for clang-format) WM_WINDOWPOSCHANGED, // WM_SIZING, @@ -1000,7 +1000,7 @@ nsAutoCString WmSizeParamInfo(uint64_t wParam, uint64_t lParam, return result; } -const nsTArray windowPositionFlags = { +MOZ_RUNINIT const nsTArray windowPositionFlags = { VALANDNAME_ENTRY(SWP_DRAWFRAME), VALANDNAME_ENTRY(SWP_HIDEWINDOW), VALANDNAME_ENTRY(SWP_NOACTIVATE), VALANDNAME_ENTRY(SWP_NOCOPYBITS), VALANDNAME_ENTRY(SWP_NOMOVE), VALANDNAME_ENTRY(SWP_NOOWNERZORDER), @@ -1188,7 +1188,7 @@ void ResolutionParamInfo(nsCString& result, uint64_t value, const char* name, #_msg, _msg, nullptr, wParamInfoFn, wParamName, lParamInfoFn, lParamName \ } \ } -std::unordered_map gAllEvents = { +MOZ_RUNINIT std::unordered_map gAllEvents = { ENTRY_WITH_NO_PARAM_INFO(WM_NULL), ENTRY_WITH_SPLIT_PARAM_INFOS(WM_CREATE, nullptr, nullptr, CreateStructParamInfo, "createStruct"), diff --git a/widget/windows/nsWindowTaskbarConcealer.cpp b/widget/windows/nsWindowTaskbarConcealer.cpp index b2b6b13a1dba..288f2845db00 100644 --- a/widget/windows/nsWindowTaskbarConcealer.cpp +++ b/widget/windows/nsWindowTaskbarConcealer.cpp @@ -82,7 +82,8 @@ static mozilla::LazyLogModule sTaskbarConcealerLog("TaskbarConcealer"); // Map of all relevant Gecko windows, along with the monitor on which each // window was last known to be located. /* static */ -nsTHashMap nsWindow::TaskbarConcealer::sKnownWindows; +MOZ_RUNINIT nsTHashMap + nsWindow::TaskbarConcealer::sKnownWindows; // Returns Nothing if the window in question is irrelevant (for any reason), // or Some(the window's current state) otherwise. diff --git a/xpcom/base/nsIClassInfoImpl.h b/xpcom/base/nsIClassInfoImpl.h index 045e75e5aff9..951f256d7ded 100644 --- a/xpcom/base/nsIClassInfoImpl.h +++ b/xpcom/base/nsIClassInfoImpl.h @@ -118,11 +118,12 @@ class GenericClassInfo : public nsIClassInfo { #define NS_IMPL_CLASSINFO(_class, _getscriptablehelper, _flags, _cid) \ NS_DECL_CI_INTERFACE_GETTER(_class) \ - static const GenericClassInfo::ClassInfoData k##_class##ClassInfoData = { \ - NS_CI_INTERFACE_GETTER_NAME(_class), \ - _getscriptablehelper, \ - _flags | nsIClassInfo::SINGLETON_CLASSINFO, \ - _cid, \ + MOZ_GLOBINIT static const GenericClassInfo::ClassInfoData \ + k##_class##ClassInfoData = { \ + NS_CI_INTERFACE_GETTER_NAME(_class), \ + _getscriptablehelper, \ + _flags | nsIClassInfo::SINGLETON_CLASSINFO, \ + _cid, \ }; \ mozilla::AlignedStorage2 k##_class##ClassInfoDataPlace; \ nsIClassInfo* NS_CLASSINFO_NAME(_class) = nullptr; diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp index 43ad94ab096d..b4f46fa9b64e 100644 --- a/xpcom/base/nsMemoryInfoDumper.cpp +++ b/xpcom/base/nsMemoryInfoDumper.cpp @@ -690,7 +690,7 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier, } #ifdef MOZ_DMD -dmd::DMDFuncs::Singleton dmd::DMDFuncs::sSingleton; +MOZ_RUNINIT dmd::DMDFuncs::Singleton dmd::DMDFuncs::sSingleton; nsresult nsMemoryInfoDumper::OpenDMDFile(const nsAString& aIdentifier, int aPid, FILE** aOutFile) { diff --git a/xpcom/base/nsTraceRefcnt.cpp b/xpcom/base/nsTraceRefcnt.cpp index 36fede4b5a0a..d359c9e98295 100644 --- a/xpcom/base/nsTraceRefcnt.cpp +++ b/xpcom/base/nsTraceRefcnt.cpp @@ -81,7 +81,7 @@ class MOZ_CAPABILITY("mutex") TraceLogMutex } }; -static TraceLogMutex gTraceLog; +MOZ_RUNINIT static TraceLogMutex gTraceLog; class MOZ_RAII AutoTraceLogLock { public: diff --git a/xpcom/build/PoisonIOInterposerWin.cpp b/xpcom/build/PoisonIOInterposerWin.cpp index 7c37a8cfe1d7..dc2f942b30c4 100644 --- a/xpcom/build/PoisonIOInterposerWin.cpp +++ b/xpcom/build/PoisonIOInterposerWin.cpp @@ -116,7 +116,8 @@ typedef NTSTATUS(NTAPI* NtQueryFullAttributesFileFn)( // resolved with the first entry (best case), and 32 entries cover >95% of // cases, reducing the average `Filename()` cost by 5-10x. using HandleToFilenameCache = mozilla::SmallArrayLRUCache; -static mozilla::UniquePtr sHandleToFilenameCache; +MOZ_RUNINIT static mozilla::UniquePtr + sHandleToFilenameCache; /** * RAII class for timing the duration of an I/O call and reporting the result @@ -427,7 +428,7 @@ static NTSTATUS NTAPI InterposedNtQueryFullAttributesFile( /******************************** IO Poisoning ********************************/ // Windows DLL interceptor -static mozilla::WindowsDllInterceptor sNtDllInterceptor; +MOZ_RUNINIT static mozilla::WindowsDllInterceptor sNtDllInterceptor; namespace mozilla { diff --git a/xpcom/tests/gtest/TestAutoRefCnt.cpp b/xpcom/tests/gtest/TestAutoRefCnt.cpp index 92cc0d253803..e9467f8c330f 100644 --- a/xpcom/tests/gtest/TestAutoRefCnt.cpp +++ b/xpcom/tests/gtest/TestAutoRefCnt.cpp @@ -39,7 +39,7 @@ class nsThreadSafeAutoRefCntRunner final : public Runnable { ~nsThreadSafeAutoRefCntRunner() = default; }; -ThreadSafeAutoRefCnt nsThreadSafeAutoRefCntRunner::sRefCnt; +MOZ_RUNINIT ThreadSafeAutoRefCnt nsThreadSafeAutoRefCntRunner::sRefCnt; Atomic nsThreadSafeAutoRefCntRunner::sIncToOne(0); Atomic nsThreadSafeAutoRefCntRunner::sDecToZero(0); diff --git a/xpcom/tests/gtest/TestBase64.cpp b/xpcom/tests/gtest/TestBase64.cpp index 55fbcefe38c2..570fe6849828 100644 --- a/xpcom/tests/gtest/TestBase64.cpp +++ b/xpcom/tests/gtest/TestBase64.cpp @@ -27,39 +27,41 @@ struct Test { const char* mResult; }; -static Chunk kTest1Chunks[] = {Chunk(9, "Hello sir"), Chunk(0, nullptr)}; +MOZ_RUNINIT static Chunk kTest1Chunks[] = {Chunk(9, "Hello sir"), + Chunk(0, nullptr)}; -static Chunk kTest2Chunks[] = {Chunk(3, "Hel"), Chunk(3, "lo "), - Chunk(3, "sir"), Chunk(0, nullptr)}; +MOZ_RUNINIT static Chunk kTest2Chunks[] = {Chunk(3, "Hel"), Chunk(3, "lo "), + Chunk(3, "sir"), Chunk(0, nullptr)}; -static Chunk kTest3Chunks[] = {Chunk(1, "I"), Chunk(0, nullptr)}; +MOZ_RUNINIT static Chunk kTest3Chunks[] = {Chunk(1, "I"), Chunk(0, nullptr)}; -static Chunk kTest4Chunks[] = {Chunk(2, "Hi"), Chunk(0, nullptr)}; +MOZ_RUNINIT static Chunk kTest4Chunks[] = {Chunk(2, "Hi"), Chunk(0, nullptr)}; -static Chunk kTest5Chunks[] = {Chunk(1, "B"), Chunk(2, "ob"), - Chunk(0, nullptr)}; +MOZ_RUNINIT static Chunk kTest5Chunks[] = {Chunk(1, "B"), Chunk(2, "ob"), + Chunk(0, nullptr)}; -static Chunk kTest6Chunks[] = {Chunk(2, "Bo"), Chunk(1, "b"), - Chunk(0, nullptr)}; +MOZ_RUNINIT static Chunk kTest6Chunks[] = {Chunk(2, "Bo"), Chunk(1, "b"), + Chunk(0, nullptr)}; -static Chunk kTest7Chunks[] = {Chunk(1, "F"), // Carry over 1 - Chunk(4, "iref"), // Carry over 2 - Chunk(2, "ox"), // 1 - Chunk(4, " is "), // 2 - Chunk(2, "aw"), // 1 - Chunk(4, "esom"), // 2 - Chunk(2, "e!"), Chunk(0, nullptr)}; +MOZ_RUNINIT static Chunk kTest7Chunks[] = {Chunk(1, "F"), // Carry over 1 + Chunk(4, "iref"), // Carry over 2 + Chunk(2, "ox"), // 1 + Chunk(4, " is "), // 2 + Chunk(2, "aw"), // 1 + Chunk(4, "esom"), // 2 + Chunk(2, "e!"), Chunk(0, nullptr)}; -static Chunk kTest8Chunks[] = {Chunk(5, "ALL T"), - Chunk(1, "H"), - Chunk(4, "ESE "), - Chunk(2, "WO"), - Chunk(21, "RLDS ARE YOURS EXCEPT"), - Chunk(9, " EUROPA. "), - Chunk(25, "ATTEMPT NO LANDING THERE."), - Chunk(0, nullptr)}; +MOZ_RUNINIT static Chunk kTest8Chunks[] = { + Chunk(5, "ALL T"), + Chunk(1, "H"), + Chunk(4, "ESE "), + Chunk(2, "WO"), + Chunk(21, "RLDS ARE YOURS EXCEPT"), + Chunk(9, " EUROPA. "), + Chunk(25, "ATTEMPT NO LANDING THERE."), + Chunk(0, nullptr)}; -static Test kTests[] = { +MOZ_RUNINIT static Test kTests[] = { // Test 1, test a simple round string in one chunk Test(kTest1Chunks, "SGVsbG8gc2ly"), // Test 2, test a simple round string split into round chunks diff --git a/xpcom/tests/gtest/TestHandleWatcher.cpp b/xpcom/tests/gtest/TestHandleWatcher.cpp index b3997140d1c9..71af45bbd6e6 100644 --- a/xpcom/tests/gtest/TestHandleWatcher.cpp +++ b/xpcom/tests/gtest/TestHandleWatcher.cpp @@ -112,7 +112,8 @@ class TestHandleWatcher : public testing::Test { /* static */ bool TestHandleWatcher::sIsLive = false; /* static */ -RefPtr TestHandleWatcher::sPool = nullptr; +MOZ_RUNINIT RefPtr TestHandleWatcher::sPool = + nullptr; /////////////////////////////////////////////////////////////////////// // WindowsEventObject diff --git a/xpcom/tests/gtest/TestSubstringTuple.cpp b/xpcom/tests/gtest/TestSubstringTuple.cpp index 6dfd6bc1549a..453f68c82dd5 100644 --- a/xpcom/tests/gtest/TestSubstringTuple.cpp +++ b/xpcom/tests/gtest/TestSubstringTuple.cpp @@ -12,9 +12,9 @@ namespace TestSubstringTuple { static const auto kFooLiteral = u"foo"_ns; -static const auto kFoo = nsCString("foo"); -static const auto kBar = nsCString("bar"); -static const auto kBaz = nsCString("baz"); +MOZ_RUNINIT static const auto kFoo = nsCString("foo"); +MOZ_RUNINIT static const auto kBar = nsCString("bar"); +MOZ_RUNINIT static const auto kBaz = nsCString("baz"); // The test must be done in a macro to ensure that tuple is always a temporary. #define DO_SUBSTRING_TUPLE_TEST(tuple, dependentString, expectedLength, \ diff --git a/xpfe/appshell/AppWindow.cpp b/xpfe/appshell/AppWindow.cpp index fcab89e4c870..9e24bd019963 100644 --- a/xpfe/appshell/AppWindow.cpp +++ b/xpfe/appshell/AppWindow.cpp @@ -2870,7 +2870,7 @@ static bool sWaitingForHiddenWindowToLoadNativeMenus = # endif ; -static nsTArray sLoadNativeMenusListeners; +MOZ_RUNINIT static nsTArray sLoadNativeMenusListeners; static void BeginLoadNativeMenus(Document* aDoc, nsIWidget* aParentWindow);