From 8d8fb4a2b51e64586376814c262d47b71b519f20 Mon Sep 17 00:00:00 2001 From: Iulian Moraru Date: Thu, 30 Nov 2023 07:19:04 +0200 Subject: [PATCH] Backed out 2 changesets (bug 1864828) for causing build bustages on TestJemalloc.cpp. CLOSED TREE Backed out changeset c1b4a8307702 (bug 1864828) Backed out changeset ba88f119b1fc (bug 1864828) --- memory/build/Utils.h | 21 ++++++++++ memory/build/mozjemalloc.cpp | 1 - mfbt/Literals.h | 37 ------------------ mfbt/moz.build | 1 - modules/libpref/init/StaticPrefList.yaml | 5 --- .../components/nimbus/FeatureManifest.yaml | 4 -- xpcom/base/PHCManager.cpp | 39 ++++++++----------- 7 files changed, 37 insertions(+), 71 deletions(-) delete mode 100644 mfbt/Literals.h diff --git a/memory/build/Utils.h b/memory/build/Utils.h index b1a05e7ae3b0..6032bf23d0c6 100644 --- a/memory/build/Utils.h +++ b/memory/build/Utils.h @@ -47,6 +47,27 @@ Order CompareAddr(T* aAddr1, T* aAddr2) { return CompareInt(uintptr_t(aAddr1), uintptr_t(aAddr2)); } +// User-defined literals to make constants more legible +constexpr size_t operator"" _KiB(unsigned long long int aNum) { + return size_t(aNum) * 1024; +} + +constexpr size_t operator"" _KiB(long double aNum) { + return size_t(aNum * 1024); +} + +constexpr size_t operator"" _MiB(unsigned long long int aNum) { + return size_t(aNum) * 1024_KiB; +} + +constexpr size_t operator"" _MiB(long double aNum) { + return size_t(aNum * 1024_KiB); +} + +constexpr double operator""_percent(long double aPercent) { + return double(aPercent) / 100; +} + // Helper for (fast) comparison of fractions without involving divisions or // floats. class Fraction { diff --git a/memory/build/mozjemalloc.cpp b/memory/build/mozjemalloc.cpp index 66c096fd8ae9..0e2acb9a42c1 100644 --- a/memory/build/mozjemalloc.cpp +++ b/memory/build/mozjemalloc.cpp @@ -150,7 +150,6 @@ #include "mozilla/DoublyLinkedList.h" #include "mozilla/HelperMacros.h" #include "mozilla/Likely.h" -#include "mozilla/Literals.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/RandomNum.h" // Note: MozTaggedAnonymousMmap() could call an LD_PRELOADed mmap diff --git a/mfbt/Literals.h b/mfbt/Literals.h deleted file mode 100644 index 0f5faf782b64..000000000000 --- a/mfbt/Literals.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Helpers for units on integer literals. */ - -#ifndef mozilla_Literals_h -#define mozilla_Literals_h - -// User-defined literals to make constants more legible. Use them by -// appending them to literals such as: -// -// size_t page_size = 4_KiB; -// -constexpr size_t operator"" _KiB(unsigned long long int aNum) { - return size_t(aNum) * 1024; -} - -constexpr size_t operator"" _KiB(long double aNum) { - return size_t(aNum * 1024); -} - -constexpr size_t operator"" _MiB(unsigned long long int aNum) { - return size_t(aNum) * 1024_KiB; -} - -constexpr size_t operator"" _MiB(long double aNum) { - return size_t(aNum * 1024_KiB); -} - -constexpr double operator""_percent(long double aPercent) { - return double(aPercent) / 100; -} - -#endif /* ! mozilla_Literals_h */ diff --git a/mfbt/moz.build b/mfbt/moz.build index 1571473bfd12..52e99e77dacd 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -63,7 +63,6 @@ EXPORTS.mozilla = [ "Latin1.h", "Likely.h", "LinkedList.h", - "Literals.h", "MacroArgs.h", "MacroForEach.h", "MathAlgorithms.h", diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index b39ac443cb7c..602b48e1292d 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -11054,11 +11054,6 @@ value: @IS_EARLY_BETA_OR_EARLIER@ mirror: always -- name: memory.phc.min_ram_mb - type: uint32_t - value: 8000 - mirror: always - #--------------------------------------------------------------------------- # Prefs starting with "midi." #--------------------------------------------------------------------------- diff --git a/toolkit/components/nimbus/FeatureManifest.yaml b/toolkit/components/nimbus/FeatureManifest.yaml index b5a15559d6c2..e1b9f20366b1 100644 --- a/toolkit/components/nimbus/FeatureManifest.yaml +++ b/toolkit/components/nimbus/FeatureManifest.yaml @@ -2011,10 +2011,6 @@ phc: description: Whether to enable PHC type: boolean setPref: memory.phc.enabled - phcMinRamMB: - description: The minimum amount of RAM required to enable PHC - type: int - setPref: memory.phc.min_ram_mb mailto: description: Prefs to control aspects of the mailto handler diff --git a/xpcom/base/PHCManager.cpp b/xpcom/base/PHCManager.cpp index d2cc2a861c97..73ba656d7df1 100644 --- a/xpcom/base/PHCManager.cpp +++ b/xpcom/base/PHCManager.cpp @@ -7,7 +7,6 @@ #include "PHCManager.h" #include "PHC.h" -#include "mozilla/Literals.h" #include "mozilla/Preferences.h" #include "mozilla/StaticPrefs_memory.h" #include "mozilla/Telemetry.h" @@ -17,37 +16,31 @@ namespace mozilla { using namespace phc; -static const char kPHCEnabledPref[] = "memory.phc.enabled"; -static const char kPHCMinRamMBPref[] = "memory.phc.min_ram_mb"; +static const char kPHCPref[] = "memory.phc.enabled"; -static void UpdatePHCState() { - size_t mem_size = PR_GetPhysicalMemorySize() / (1_MiB); - size_t min_mem_size = StaticPrefs::memory_phc_min_ram_mb(); +static PHCState GetPHCStateFromPref() { + return StaticPrefs::memory_phc_enabled() ? Enabled : OnlyFree; +} +static void PrefChangeCallback(const char* aPrefName, void* aNull) { + MOZ_ASSERT(0 == strcmp(aPrefName, kPHCPref)); + + SetPHCState(GetPHCStateFromPref()); +} + +void InitPHCState() { + size_t memSize = PR_GetPhysicalMemorySize(); // Only enable PHC if there are at least 8GB of ram. Note that we use // 1000 bytes per kilobyte rather than 1024. Some 8GB machines will have // slightly lower actual RAM available after some hardware devices // reserve some. - if (StaticPrefs::memory_phc_enabled() && mem_size >= min_mem_size) { - SetPHCState(Enabled); - } else { - SetPHCState(OnlyFree); + if (memSize >= size_t(8'000'000'000llu)) { + SetPHCState(GetPHCStateFromPref()); + + Preferences::RegisterCallback(PrefChangeCallback, kPHCPref); } } -static void PrefChangeCallback(const char* aPrefName, void* aNull) { - MOZ_ASSERT((0 == strcmp(aPrefName, kPHCEnabledPref)) || - (0 == strcmp(aPrefName, kPHCMinRamMBPref))); - - UpdatePHCState(); -} - -void InitPHCState() { - Preferences::RegisterCallback(PrefChangeCallback, kPHCEnabledPref); - Preferences::RegisterCallback(PrefChangeCallback, kPHCMinRamMBPref); - UpdatePHCState(); -} - void ReportPHCTelemetry() { MemoryUsage usage; PHCMemoryUsage(usage);