mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:37:11 +00:00
14412dba88
- Bug 1200795, part 1 - Eliminate excessive detail from cycle collector graph memory reporting. r=njn (8775704ad4)
- Bug 1200795, part 2 - Add memory reporting for CCGraph::mPtrToNodeMap. r=njn (154912392e)
- Bug 1202670 - Move most of nsCycleCollector::RemoveObjectFromGraph into CCGraph. r=smaug (78b449602d)
- Bug 1163006, part 1 - Make the cycle collector use the concrete logger class. r=smaug (a23f4adfd3)
- Bug 1163657 - Clean up setting of mFlags in CCGraphBuilder's ctor. r=smaug (c49fa66d20)
- Bug 1163006, part 2 - Rename various cycle collector listener variables to logger. r=smaug (c655503d1b)
- Bug 1163006, part 3 - Clean up some cycle collector logger set up code. r=smaug (9825ec8e80)
- Bug 1163006, part 4 - De-COM the nsICycleCollectorListener methods we only call from C++. r=smaug (39e579782f)
- Bug 1163006, part 5 - Add a less COM-y getter for mWantAllTraces. r=smaug (70c424197e)
- Bug 1152505 - CCGraphBuilder::NoteChild should pass aEdgeName by reference. r=smaug (25ffabb54c)
- Bug 1189122 - Assert when we Suspect() when a CC scan is in progress. r=smaug (ae997c0fec)
- Bug 1189829 - fix quadratic behavior in nsConsoleService; r=erahm (2b37337085)
- Bug 1189231 - Impl operator->* to nsAutoPtr. r=nfroyd (a491e0e775)
- Bug 1196050 - Replace NSCAP_Zero usage with decltype(nullptr). r=froydnj (4b4d411103)
- Bug 1196925 - Remove the non-existing relocatable store buffer counts from about:memory; r=njn (d030d12a81)
- Bug 1123237 - Part 2. MemoryProfiler hooks in js engine. r=terrence (e3495c3520)
- Bug 1196847 - Part 1: Allow storage of a unique id for a cell independent of address; r=jonco (53b94846f1)
- Bug 1207730 - Update comments in Barrier.h and sort classes in same order; r=sfink (ba3abf54cb)
- Bug 1196847 - Part 2: Implement a cell hasher that uses unique id based hashes; r=jonco (3811c58b7a)
- Bug 1196848 - Add Zone::uniqueIds to about:memory reports; r=njn (bff35eb98c)
- Bug 1123237 - Part 3. Monitoring allocation and gc events in nursery and tenured heaps. r=terrence (47cc20bb98)
- Bug 1123237 - Part 4. Monitoring allocations and frees for ArrayBuffer. r=terrence,sfink (3495e46571)
- Bug 1123237 - Part 5. Don't emit inline allocation when memory profiler enabled. r=terrence (b4b44652d0)
- Bug 1123237 - Part 6. A new API to get backtrace without allocating memory in profiler. r=mstange (eff2d42cbd)
- Bug 1123237 - Part 7. XPCOM interface for memory profiler. r=smaug (f3a85f8181)
- Bug 1123237 - Part 8. Tracking the memory events. r=BenWa,terrence (8694fa4ad4)
- Bug 1123237 - Part 9. Interface to memory-profiler add-ons. r=jimb (1f8ed472ad)
- Bug 1123237 - Part 10. Expose SwapElements from nsBaseHashtable. r=nfroyd (a2e06425ad)
- Bug 1123237 - Part 11. Don't use STL in memory-profiler. r=BenWa,cervantes (c13096634c)
- Bug 1123237 - Part 12. Fix GC hazards. r=terrence (64776fc60e)
- Bug 1194424 - Part 0: Extend the core dump protobuf message format to accomodate allocation stacks; r=sfink (d25ca13aec)
- Bug 1167292 - Part 1: Add a telemetry probe to time how long it takes to save a heap snapshot; r=ejpbruel (25a9047d18)
- Bug 1167292 - Part 2: Add a telemetry probe to time how long it takes to read a heap snapshot; r=ejpbruel (71e3bb5fe3)
- Bug 1167292 - Part 3: Add telemetry probes for node and edge counts when saving heap snapshots; r=ejpbruel (7985b9edf6)
- Bug 1187062 - Part 0: Make js::Debugger::getObjectAllocationSite return a SavedFrame* rather than a JSObject*; r=sfink (0ec4175b9c)
- Bug 1204613 - Add a static_assert that ProfileEntry::{Flags,Category} do not overlap; r=djvj (a2d3672676)
- Bug 1204168 - Add the js::ProfileEntry::setCategory method; r=djvj (dce07b7eb4)
161 lines
3.9 KiB
C++
161 lines
3.9 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=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/. */
|
|
|
|
#ifndef tools_profiler_MemoryProfiler_h
|
|
#define tools_profiler_MemoryProfiler_h
|
|
|
|
#include "nsIMemoryProfiler.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "CompactTraceTable.h"
|
|
#include "nsTArray.h"
|
|
#include "prlock.h"
|
|
|
|
#define MEMORY_PROFILER_CID \
|
|
{ 0xf976eaa2, 0xcc1f, 0x47ee, \
|
|
{ 0x81, 0x29, 0xb8, 0x26, 0x2a, 0x3d, 0xb6, 0xb2 } }
|
|
|
|
#define MEMORY_PROFILER_CONTRACT_ID "@mozilla.org/tools/memory-profiler;1"
|
|
|
|
struct JSRuntime;
|
|
struct PRLock;
|
|
|
|
namespace mozilla {
|
|
|
|
class NativeProfilerImpl;
|
|
class GCHeapProfilerImpl;
|
|
|
|
struct ProfilerForJSRuntime
|
|
{
|
|
ProfilerForJSRuntime()
|
|
: mProfiler(nullptr)
|
|
, mEnabled(false)
|
|
{}
|
|
GCHeapProfilerImpl* mProfiler;
|
|
bool mEnabled;
|
|
};
|
|
using JSRuntimeProfilerMap =
|
|
nsDataHashtable<nsClearingPtrHashKey<JSRuntime>, ProfilerForJSRuntime>;
|
|
|
|
class MemoryProfiler final : public nsIMemoryProfiler
|
|
{
|
|
public:
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIMEMORYPROFILER
|
|
|
|
private:
|
|
static void InitOnce();
|
|
~MemoryProfiler() {}
|
|
|
|
// The accesses to other static member are guarded by sLock and
|
|
// sProfileRuntimeCount.
|
|
static PRLock* sLock;
|
|
static uint32_t sProfileRuntimeCount;
|
|
|
|
static StaticAutoPtr<NativeProfilerImpl> sNativeProfiler;
|
|
static StaticAutoPtr<JSRuntimeProfilerMap> sJSRuntimeProfilerMap;
|
|
static TimeStamp sStartTime;
|
|
};
|
|
|
|
// Allocation events to be reported.
|
|
struct AllocEvent {
|
|
TimeStamp mTimestamp;
|
|
// index to a stacktrace singleton.
|
|
uint32_t mTraceIdx;
|
|
// Allocation size
|
|
int32_t mSize;
|
|
|
|
AllocEvent(uint32_t aTraceIdx, int32_t aSize, TimeStamp aTimestamp)
|
|
: mTimestamp(aTimestamp)
|
|
, mTraceIdx(aTraceIdx)
|
|
, mSize(aSize)
|
|
{}
|
|
};
|
|
|
|
// Index to allocation events but also a mark bit to be GC-able.
|
|
struct AllocEntry {
|
|
uint32_t mEventIdx : 31;
|
|
bool mMarked : 1;
|
|
|
|
// Default constructor for uninitialized stack value required by
|
|
// getter methods.
|
|
AllocEntry()
|
|
: mEventIdx(0)
|
|
, mMarked(false)
|
|
{}
|
|
explicit AllocEntry(int aEventIdx)
|
|
: mEventIdx(aEventIdx)
|
|
, mMarked(false)
|
|
{}
|
|
};
|
|
|
|
using AllocMap = nsDataHashtable<nsClearingVoidPtrHashKey, AllocEntry>;
|
|
|
|
class ProfilerImpl
|
|
{
|
|
public:
|
|
static nsTArray<nsCString> GetStacktrace();
|
|
static double DRandom();
|
|
|
|
ProfilerImpl();
|
|
virtual nsTArray<nsCString> GetNames() const = 0;
|
|
virtual nsTArray<TrieNode> GetTraces() const = 0;
|
|
virtual const nsTArray<AllocEvent>& GetEvents() const = 0;
|
|
|
|
protected:
|
|
/**
|
|
* The sampler generates a random variable which conforms to a geometric
|
|
* distribution of probability p = 1 / mSampleSize to calculate the
|
|
* next-to-be-sampled byte directly; It avoids rolling a dice on each byte.
|
|
*
|
|
* Let Bn denote a Bernoulli process with first success on n-th trial, the
|
|
* cumulative distribution function of Bn is Cn = 1 - (1 - p) ^ n.
|
|
* Let U denote a uniformly distributed random variable in [0, 1).
|
|
* A geometric random variable can be generated by Cn's reverse function:
|
|
* G = floor(log(1 - U) / log(1 - p)).
|
|
*
|
|
* @param aSize the number of bytes seen
|
|
* @return the number of events sampled
|
|
*/
|
|
size_t AddBytesSampled(uint32_t aBytes);
|
|
|
|
uint32_t mSampleSize;
|
|
|
|
private:
|
|
uint32_t mRemainingBytes;
|
|
double mLog1minusP;
|
|
};
|
|
|
|
/*
|
|
* This class is used to make sure the profile data is only accessed
|
|
* on one thread at a time. Don't use mozilla::Mutex because we don't
|
|
* want to allocate memory.
|
|
*/
|
|
class AutoMPLock
|
|
{
|
|
public:
|
|
explicit AutoMPLock(PRLock* aLock)
|
|
{
|
|
MOZ_ASSERT(aLock);
|
|
mLock = aLock;
|
|
PR_Lock(mLock);
|
|
}
|
|
|
|
~AutoMPLock()
|
|
{
|
|
PR_Unlock(mLock);
|
|
}
|
|
|
|
private:
|
|
PRLock* mLock;
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif
|