Backed out 2 changesets (bug 1814798) for multiple phc related failures.

Backed out changeset 50b72ab948b2 (bug 1814798)
Backed out changeset bf7d386ad43a (bug 1814798)
This commit is contained in:
Stanca Serban 2023-09-12 07:54:18 +03:00
Родитель 33923f23c1
Коммит 6d490604c6
9 изменённых файлов: 2 добавлений и 148 удалений

Просмотреть файл

@ -116,19 +116,6 @@ struct DMDFuncs;
} // namespace dmd
namespace phc {
// PHC has three different states:
// * Not compiled in
// * OnlyFree - The memory allocator is hooked but new allocations
// requests will be forwarded to mozjemalloc, free() will
// correctly free any PHC allocations and realloc() will
// "move" PHC allocations to mozjemalloc allocations.
// * Enabled - Full use.
enum PHCState {
OnlyFree,
Enabled,
};
class AddrInfo;
struct MemoryUsage {
@ -152,7 +139,7 @@ struct DebugFdRegistry {
} // namespace mozilla
struct ReplaceMallocBridge {
ReplaceMallocBridge() : mVersion(6) {}
ReplaceMallocBridge() : mVersion(5) {}
// This method was added in version 1 of the bridge.
virtual mozilla::dmd::DMDFuncs* GetDMDFuncs() { return nullptr; }
@ -208,11 +195,6 @@ struct ReplaceMallocBridge {
// This method was added in version 5 of the bridge.
virtual void PHCMemoryUsage(mozilla::phc::MemoryUsage& aMemoryUsage) {}
// Set PHC's state. See the comments above on `PHCState` for the meaning of
// each state.
// This method was added in version 6 of the bridge.
virtual void SetPHCState(mozilla::phc::PHCState aState) {}
# ifndef REPLACE_MALLOC_IMPL
// Returns the replace-malloc bridge if its version is at least the
// requested one.
@ -287,13 +269,6 @@ struct ReplaceMalloc {
singleton->PHCMemoryUsage(aMemoryUsage);
}
}
static void SetPHCState(mozilla::phc::PHCState aPHCState) {
auto singleton = ReplaceMallocBridge::Get(/* minimumVersion */ 6);
if (singleton) {
singleton->SetPHCState(aPHCState);
}
}
};
# endif

Просмотреть файл

@ -323,9 +323,6 @@ static const size_t kAllPagesSize = kNumAllPages * kPageSize;
// AllocAllPages() for more information.
static const size_t kAllPagesJemallocSize = kAllPagesSize - kPageSize;
// The default state for PHC. Either Enabled or OnlyFree.
#define DEFAULT_STATE mozilla::phc::OnlyFree
// The junk value used to fill new allocation in debug builds. It's same value
// as the one used by mozjemalloc. PHC applies it unconditionally in debug
// builds. Unlike mozjemalloc, PHC doesn't consult the MALLOC_OPTIONS
@ -877,14 +874,6 @@ class GMut {
}
#endif
// Should we make new PHC allocations?
bool ShouldMakeNewAllocations() const {
return mPhcState == mozilla::phc::Enabled;
}
using PHCState = mozilla::phc::PHCState;
void SetState(PHCState aState) { mPhcState = aState; }
private:
template <int N>
uint64_t RandomSeed() {
@ -944,11 +933,6 @@ class GMut {
size_t mPageAllocHits = 0;
size_t mPageAllocMisses = 0;
#endif
// This will only ever be updated from one thread. The other threads should
// eventually get the update.
Atomic<PHCState, Relaxed> mPhcState =
Atomic<PHCState, Relaxed>(DEFAULT_STATE);
};
Mutex GMut::sMutex;
@ -1090,11 +1074,6 @@ static void* MaybePageAlloc(const Maybe<arena_id_t>& aArenaId, size_t aReqSize,
return nullptr;
}
MOZ_ASSERT(gMut);
if (!gMut->ShouldMakeNewAllocations()) {
return nullptr;
}
GAtomic::IncrementNow();
// Decrement the delay. If it's zero, we do a page allocation and reset the
@ -1365,7 +1344,7 @@ MOZ_ALWAYS_INLINE static void* PageRealloc(const Maybe<arena_id_t>& aArenaId,
// Check for realloc() of a freed block.
gMut->EnsureValidAndInUse(lock, aOldPtr, index);
if (aNewSize <= kPageSize && gMut->ShouldMakeNewAllocations()) {
if (aNewSize <= kPageSize) {
// A page-to-page transition. Just keep using the page allocation. We do
// this even if the thread is disabled, because it doesn't create a new
// page allocation. Note that ResizePageInUse() checks aArenaId.
@ -1708,12 +1687,6 @@ class PHCBridge : public ReplaceMallocBridge {
aMemoryUsage.mFragmentationBytes = 0;
}
}
// Enable or Disable PHC at runtime. If PHC is disabled it will still trap
// bad uses of previous allocations, but won't track any new allocations.
virtual void SetPHCState(mozilla::phc::PHCState aState) override {
gMut->SetState(aState);
}
};
// WARNING: this function runs *very* early -- before all static initializers

Просмотреть файл

@ -11010,19 +11010,6 @@
mirror: always
#endif
#---------------------------------------------------------------------------
# Prefs starting with "memory."
#---------------------------------------------------------------------------
- name: memory.phc.enabled
type: bool
#if defined(MOZ_PHC)
value: true
#else
value: false
#endif
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "midi."
#---------------------------------------------------------------------------

Просмотреть файл

@ -62,7 +62,6 @@ pref_groups = [
"layout",
"mathml",
"media",
"memory",
"midi",
"mousewheel",
"mozilla",
@ -173,6 +172,3 @@ else:
FINAL_TARGET_PP_FILES += [
"greprefs.js",
]
if CONFIG["MOZ_PHC"]:
DEFINES["MOZ_PHC"] = True

Просмотреть файл

@ -1,35 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "PHCManager.h"
#include "replace_malloc_bridge.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_memory.h"
namespace mozilla {
using namespace phc;
static const char kPHCPref[] = "memory.phc.enabled";
static PHCState GetPHCStateFromPref() {
return StaticPrefs::memory_phc_enabled() ? Enabled : OnlyFree;
}
static void PrefChangeCallback(const char* aPrefName, void* aNull) {
MOZ_ASSERT(0 == strcmp(aPrefName, kPHCPref));
ReplaceMalloc::SetPHCState(GetPHCStateFromPref());
}
void InitPHCState() {
ReplaceMalloc::SetPHCState(GetPHCStateFromPref());
Preferences::RegisterCallback(PrefChangeCallback, kPHCPref);
}
}; // namespace mozilla

Просмотреть файл

@ -1,18 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#ifndef mozilla_PHCManager_h
#define mozilla_PHCManager_h
namespace mozilla {
// Read the PHC pref and potentially initialise PHC. Also register a
// callback for the pref to update PHC as the pref changes.
void InitPHCState();
}; // namespace mozilla
#endif // mozilla_PHCManager_h

Просмотреть файл

@ -257,15 +257,3 @@ LOCAL_INCLUDES += [
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"]
if CONFIG["MOZ_PHC"]:
EXPORTS.mozilla += [
"PHCManager.h",
]
DEFINES["MOZ_PHC"] = 1
UNIFIED_SOURCES += ["PHCManager.cpp"]
with Files("PHCManager.*"):
BUG_COMPONENT = ("Core", "Memory Allocator")

Просмотреть файл

@ -89,9 +89,6 @@
#include "mozilla/AvailableMemoryTracker.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/CountingAllocatorBase.h"
#ifdef MOZ_PHC
# include "mozilla/PHCManager.h"
#endif
#include "mozilla/UniquePtr.h"
#include "mozilla/ServoStyleConsts.h"
@ -451,12 +448,6 @@ NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory,
NS_ADDREF(*aResult = nsComponentManagerImpl::gComponentManager);
}
#ifdef MOZ_PHC
// This is the earliest possible moment we can start PHC while still being
// able to read prefs.
mozilla::InitPHCState();
#endif
// After autoreg, but before we actually instantiate any components,
// add any services listed in the "xpcom-directory-providers" category
// to the directory service.

Просмотреть файл

@ -103,6 +103,3 @@ if CONFIG["MOZ_VPX"]:
LOCAL_INCLUDES += [
"/media/libvpx",
]
if CONFIG["MOZ_PHC"]:
DEFINES["MOZ_PHC"] = 1