Bug 1163006, part 4 - De-COM the nsICycleCollectorListener methods we only call from C++. r=smaug

This commit is contained in:
Andrew McCreight 2015-06-04 14:41:31 -07:00
parent 36211f1f19
commit 7d7ee5c55a
2 changed files with 45 additions and 106 deletions

View File

@ -1771,7 +1771,7 @@ public:
return NS_OK;
}
NS_IMETHOD Begin() override
nsresult Begin()
{
nsresult rv;
@ -1795,8 +1795,8 @@ public:
fprintf(mCCLog, "# WantAllTraces=%s\n", mWantAllTraces ? "true" : "false");
return NS_OK;
}
NS_IMETHOD NoteRefCountedObject(uint64_t aAddress, uint32_t aRefCount,
const char* aObjectDescription) override
void NoteRefCountedObject(uint64_t aAddress, uint32_t aRefCount,
const char* aObjectDescription)
{
if (!mDisableLog) {
fprintf(mCCLog, "%p [rc=%u] %s\n", (void*)aAddress, aRefCount,
@ -1812,11 +1812,10 @@ public:
d->mCnt = aRefCount;
d->mName.Append(aObjectDescription);
}
return NS_OK;
}
NS_IMETHOD NoteGCedObject(uint64_t aAddress, bool aMarked,
const char* aObjectDescription,
uint64_t aCompartmentAddress) override
void NoteGCedObject(uint64_t aAddress, bool aMarked,
const char* aObjectDescription,
uint64_t aCompartmentAddress)
{
if (!mDisableLog) {
fprintf(mCCLog, "%p [gc%s] %s\n", (void*)aAddress,
@ -1838,9 +1837,8 @@ public:
d->mCompartmentOrToAddress.SetIsVoid(true);
}
}
return NS_OK;
}
NS_IMETHOD NoteEdge(uint64_t aToAddress, const char* aEdgeName) override
void NoteEdge(uint64_t aToAddress, const char* aEdgeName)
{
if (!mDisableLog) {
fprintf(mCCLog, "> %p %s\n", (void*)aToAddress, aEdgeName);
@ -1854,34 +1852,30 @@ public:
d->mCompartmentOrToAddress.AppendInt(aToAddress, 16);
d->mName.Append(aEdgeName);
}
return NS_OK;
}
NS_IMETHOD NoteWeakMapEntry(uint64_t aMap, uint64_t aKey,
uint64_t aKeyDelegate, uint64_t aValue) override
void NoteWeakMapEntry(uint64_t aMap, uint64_t aKey,
uint64_t aKeyDelegate, uint64_t aValue)
{
if (!mDisableLog) {
fprintf(mCCLog, "WeakMapEntry map=%p key=%p keyDelegate=%p value=%p\n",
(void*)aMap, (void*)aKey, (void*)aKeyDelegate, (void*)aValue);
}
// We don't support after-processing for weak map entries.
return NS_OK;
}
NS_IMETHOD NoteIncrementalRoot(uint64_t aAddress) override
void NoteIncrementalRoot(uint64_t aAddress)
{
if (!mDisableLog) {
fprintf(mCCLog, "IncrementalRoot %p\n", (void*)aAddress);
}
// We don't support after-processing for incremental roots.
return NS_OK;
}
NS_IMETHOD BeginResults() override
void BeginResults()
{
if (!mDisableLog) {
fputs("==========\n", mCCLog);
}
return NS_OK;
}
NS_IMETHOD DescribeRoot(uint64_t aAddress, uint32_t aKnownEdges) override
void DescribeRoot(uint64_t aAddress, uint32_t aKnownEdges)
{
if (!mDisableLog) {
fprintf(mCCLog, "%p [known=%u]\n", (void*)aAddress, aKnownEdges);
@ -1893,9 +1887,8 @@ public:
d->mAddress.AppendInt(aAddress, 16);
d->mCnt = aKnownEdges;
}
return NS_OK;
}
NS_IMETHOD DescribeGarbage(uint64_t aAddress) override
void DescribeGarbage(uint64_t aAddress)
{
if (!mDisableLog) {
fprintf(mCCLog, "%p [garbage]\n", (void*)aAddress);
@ -1906,16 +1899,13 @@ public:
d->mType = CCGraphDescriber::eGarbage;
d->mAddress.AppendInt(aAddress, 16);
}
return NS_OK;
}
NS_IMETHOD End() override
void End()
{
if (!mDisableLog) {
mCCLog = nullptr;
nsresult rv = mLogSink->CloseCCLog();
NS_ENSURE_SUCCESS(rv, rv);
NS_WARN_IF(NS_FAILED(mLogSink->CloseCCLog()));
}
return NS_OK;
}
NS_IMETHOD ProcessNext(nsICycleCollectorHandler* aHandler,
bool* aCanContinue) override

View File

@ -15,31 +15,35 @@ class nsCycleCollectorLogger;
interface nsIFile;
/**
* Interfaces for observing the cycle collector's work, both from C++ and
* from JavaScript.
*
* If given an object implementing nsICycleCollectorListener, the cycle
* collector calls that object's methods as it works, describing the
* objects it visits, the edges it finds, and the conclusions it reaches
* about which objects are live.
*
* Analyzing cycle collection from JS is harder: an nsICycleCollectorListener
* mustn't mess with the object graph while the cycle collector is trying to
* figure it out, which means it can't be implemented by JS code: JS can't do
* much of anything useful within those constraints. Instead, JS code can
* instantiate @mozilla.org/cycle-collector-logger;1, a C++ class implementing
* nsICycleCollectorListener that logs the cycle collector's mumblings and then
* replays them later to an nsICycleCollectorHandler --- which *can* be
* implemented in JS.
* A set of interfaces for recording the cycle collector's work. An instance
* of @mozilla.org/cycle-collector-logger;1 can be configured to enable various
* options, then passed to the cycle collector when it runs.
* Note that additional logging options are available by setting environment
* variables, as described at the top of nsCycleCollector.cpp.
*/
/**
* The interface JS code should implement to receive annotations logged by an
* @mozilla.org/cycle-collector-logger;1 instance. Pass an instance of this to
* the logger's 'processNext' method.
* nsICycleCollectorHandler is the interface JS code should implement to
* receive the results logged by a @mozilla.org/cycle-collector-logger;1
* instance. Pass an instance of this to the logger's 'processNext' method
* after the collection has run. This will describe the objects the cycle
* collector visited, the edges it found, and the conclusions it reached
* about the liveness of objects.
*
* The methods are a subset of those in nsICycleCollectorListener; see the
* descriptions there.
* In more detail:
* - For each node in the graph:
* - a call is made to either |noteRefCountedObject| or |noteGCedObject|, to
* describe the node itself; and
* - for each edge starting at that node, a call is made to |noteEdge|.
*
* - Then, a series of calls are made to:
* - |describeRoot|, for reference-counted nodes that the CC has identified as
* being alive because there are unknown references to those nodes.
* - |describeGarbage|, for nodes the cycle collector has identified as garbage.
*
* Any node not mentioned in a call to |describeRoot| or |describeGarbage| is
* neither a root nor garbage. The cycle collector was able to find all of the
* edges implied by the node's reference count.
*/
[scriptable, uuid(7f093367-1492-4b89-87af-c01dbc831246)]
interface nsICycleCollectorHandler : nsISupports
@ -88,44 +92,11 @@ interface nsICycleCollectorLogSink : nsISupports
/**
* Given an instance of this interface, the cycle collector calls the instance's
* methods to report the objects it visits, the edges between them, and its
* conclusions about which objects are roots and which are garbage.
* This interface is used to configure some reporting options for the cycle
* collector. This interface cannot be implemented by JavaScript code, as it
* is called while the cycle collector is running.
*
* For a single cycle collection pass, the cycle collector calls this
* interface's methods in the following order:
*
* - First, |begin|. If |begin| returns an error, none of the listener's other
* methods will be called.
*
* - Then, for each node in the graph:
* - a call to either |noteRefCountedObject| or |noteGCedObject|, to describe
* the node itself; and
* - for each edge starting at that node, a call to |noteEdge|.
*
* - Then, zero or more calls to |noteIncrementalRoot|; an "incremental
* root" is an object that may have had a new reference to it created
* during an incremental collection, and must therefore be treated as
* live for safety.
*
* - After all the nodes have been described, a call to |beginResults|.
*
* - A series of calls to:
* - |describeRoot|, for reference-counted nodes that the CC has identified as
* roots of collection. (The cycle collector didn't find enough incoming
* edges to account for these nodes' reference counts, so there must be code
* holding on to them that the cycle collector doesn't know about.)
* - |describeGarbage|, for nodes the cycle collector has identified as garbage.
*
* Any node not mentioned in a call to |describeRoot| or |describeGarbage| is
* neither a root nor garbage. (The cycle collector was able to find all the
* edges implied by the node's reference count.)
*
* - Finally, a call to |end|.
*
*
* This interface cannot be implemented by JavaScript code, as it is called
* while the cycle collector is running. To analyze cycle collection data in JS:
* To analyze cycle collection data in JS:
*
* - Create an instance of @mozilla.org/cycle-collector-logger;1, which
* implements this interface.
@ -147,7 +118,7 @@ interface nsICycleCollectorLogSink : nsISupports
* on objects however it pleases: the cycle collector has finished its
* work, and the JS code is simply consuming recorded data.
*/
[scriptable, builtinclass, uuid(d88a2896-7357-4462-ad5f-939d264ff64c)]
[scriptable, builtinclass, uuid(703b53b6-24f6-40c6-9ea9-aeb2dc53d170)]
interface nsICycleCollectorListener : nsISupports
{
// Return a listener that directs the cycle collector to traverse
@ -179,28 +150,6 @@ interface nsICycleCollectorListener : nsISupports
// using |processNext|. Initially false.
attribute boolean wantAfterProcessing;
void begin();
void noteRefCountedObject (in unsigned long long aAddress,
in unsigned long aRefCount,
in string aObjectDescription);
void noteGCedObject (in unsigned long long aAddress,
in boolean aMarked,
in string aObjectDescription,
in unsigned long long aCompartmentAddress);
void noteEdge(in unsigned long long aToAddress,
in string aEdgeName);
void noteWeakMapEntry(in unsigned long long aMap,
in unsigned long long aKey,
in unsigned long long aKeyDelegate,
in unsigned long long aValue);
void noteIncrementalRoot(in unsigned long long aAddress);
void beginResults();
void describeRoot(in unsigned long long aAddress,
in unsigned long aKnownEdges);
void describeGarbage(in unsigned long long aAddress);
void end();
// Report the next recorded event to |aHandler|, and remove it from the
// record. Return false if there isn't anything more to process.
//