summaryrefslogtreecommitdiffstats
path: root/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-07 13:12:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 10:02:59 +0000
commit33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (patch)
treef6af110909c79b2759136554f1143d8b0572af0a /chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h
parent7d2c5d177e9813077a621df8d18c0deda73099b3 (diff)
BASELINE: Update Chromium to 104.0.5112.120
Change-Id: I5d2726c2ab018d75d055739b6ba64317904f05bb Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438935 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h')
-rw-r--r--chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h b/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h
index 7cc6d9bc83d..8d14691b9d4 100644
--- a/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h
+++ b/chromium/base/sampling_heap_profiler/poisson_allocation_sampler.h
@@ -69,6 +69,21 @@ class BASE_EXPORT PoissonAllocationSampler {
static bool IsMuted();
};
+ // An instance of this class makes the sampler behave deterministically to
+ // ensure test results are repeatable. Does not support nesting.
+ class BASE_EXPORT ScopedSuppressRandomnessForTesting {
+ public:
+ ScopedSuppressRandomnessForTesting();
+ ~ScopedSuppressRandomnessForTesting();
+
+ ScopedSuppressRandomnessForTesting(
+ const ScopedSuppressRandomnessForTesting&) = delete;
+ ScopedSuppressRandomnessForTesting& operator=(
+ const ScopedSuppressRandomnessForTesting&) = delete;
+
+ static bool IsSuppressed();
+ };
+
// Must be called early during the process initialization. It creates and
// reserves a TLS slot.
static void Init();
@@ -100,8 +115,6 @@ class BASE_EXPORT PoissonAllocationSampler {
// Returns the current mean sampling interval, in bytes.
size_t SamplingInterval() const;
- void SuppressRandomnessForTest(bool suppress);
-
static void RecordAlloc(void* address,
size_t,
AllocatorType,
@@ -148,8 +161,15 @@ class BASE_EXPORT PoissonAllocationSampler {
PoissonAllocationSampler();
~PoissonAllocationSampler() = delete;
- static void InstallAllocatorHooksOnce();
+ // Installs allocator hooks if they weren't already installed. This is not
+ // static to ensure that allocator hooks can't be installed unless the
+ // PoissonAllocationSampler singleton exists.
+ void InstallAllocatorHooksOnce();
+
static size_t GetNextSampleInterval(size_t base_interval);
+
+ // Return the set of sampled addresses. This is only valid to call after
+ // Init().
static LockFreeAddressHashSet& sampled_addresses_set();
void DoRecordAlloc(intptr_t accumulated_bytes,
@@ -174,6 +194,7 @@ class BASE_EXPORT PoissonAllocationSampler {
friend class heap_profiling::HeapProfilerControllerTest;
friend class NoDestructor<PoissonAllocationSampler>;
friend class SamplingHeapProfilerTest;
+ FRIEND_TEST_ALL_PREFIXES(PoissonAllocationSamplerTest, MuteHooksWithoutInit);
FRIEND_TEST_ALL_PREFIXES(SamplingHeapProfilerTest, HookedAllocatorMuted);
};