mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 936789 - Faster CC logger, r=mccr8
This commit is contained in:
parent
d4145ed754
commit
bf53185fb9
@ -101,6 +101,7 @@
|
||||
/* This must occur *after* base/process_util.h to avoid typedefs conflicts. */
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@ -1111,7 +1112,7 @@ GraphWalker<Visitor>::DoWalk(nsDeque &aQueue)
|
||||
}
|
||||
}
|
||||
|
||||
struct CCGraphDescriber
|
||||
struct CCGraphDescriber : public LinkedListElement<CCGraphDescriber>
|
||||
{
|
||||
CCGraphDescriber()
|
||||
: mAddress("0x"), mToAddress("0x"), mCnt(0), mType(eUnknown) {}
|
||||
@ -1139,12 +1140,12 @@ class nsCycleCollectorLogger MOZ_FINAL : public nsICycleCollectorListener
|
||||
public:
|
||||
nsCycleCollectorLogger() :
|
||||
mStream(nullptr), mWantAllTraces(false),
|
||||
mDisableLog(false), mWantAfterProcessing(false),
|
||||
mNextIndex(0)
|
||||
mDisableLog(false), mWantAfterProcessing(false)
|
||||
{
|
||||
}
|
||||
~nsCycleCollectorLogger()
|
||||
{
|
||||
ClearDescribers();
|
||||
if (mStream) {
|
||||
MozillaUnRegisterDebugFILE(mStream);
|
||||
fclose(mStream);
|
||||
@ -1209,8 +1210,7 @@ public:
|
||||
NS_IMETHOD Begin()
|
||||
{
|
||||
mCurrentAddress.AssignLiteral("0x");
|
||||
mDescribers.Clear();
|
||||
mNextIndex = 0;
|
||||
ClearDescribers();
|
||||
if (mDisableLog) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1278,7 +1278,8 @@ public:
|
||||
aObjectDescription);
|
||||
}
|
||||
if (mWantAfterProcessing) {
|
||||
CCGraphDescriber* d = mDescribers.AppendElement();
|
||||
CCGraphDescriber* d = new CCGraphDescriber();
|
||||
mDescribers.insertBack(d);
|
||||
mCurrentAddress.AssignLiteral("0x");
|
||||
mCurrentAddress.AppendInt(aAddress, 16);
|
||||
d->mType = CCGraphDescriber::eRefCountedObject;
|
||||
@ -1296,7 +1297,8 @@ public:
|
||||
aMarked ? ".marked" : "", aObjectDescription);
|
||||
}
|
||||
if (mWantAfterProcessing) {
|
||||
CCGraphDescriber* d = mDescribers.AppendElement();
|
||||
CCGraphDescriber* d = new CCGraphDescriber();
|
||||
mDescribers.insertBack(d);
|
||||
mCurrentAddress.AssignLiteral("0x");
|
||||
mCurrentAddress.AppendInt(aAddress, 16);
|
||||
d->mType = aMarked ? CCGraphDescriber::eGCMarkedObject :
|
||||
@ -1312,7 +1314,8 @@ public:
|
||||
fprintf(mStream, "> %p %s\n", (void*)aToAddress, aEdgeName);
|
||||
}
|
||||
if (mWantAfterProcessing) {
|
||||
CCGraphDescriber* d = mDescribers.AppendElement();
|
||||
CCGraphDescriber* d = new CCGraphDescriber();
|
||||
mDescribers.insertBack(d);
|
||||
d->mType = CCGraphDescriber::eEdge;
|
||||
d->mAddress = mCurrentAddress;
|
||||
d->mToAddress.AppendInt(aToAddress, 16);
|
||||
@ -1343,7 +1346,8 @@ public:
|
||||
fprintf(mStream, "%p [known=%u]\n", (void*)aAddress, aKnownEdges);
|
||||
}
|
||||
if (mWantAfterProcessing) {
|
||||
CCGraphDescriber* d = mDescribers.AppendElement();
|
||||
CCGraphDescriber* d = new CCGraphDescriber();
|
||||
mDescribers.insertBack(d);
|
||||
d->mType = CCGraphDescriber::eRoot;
|
||||
d->mAddress.AppendInt(aAddress, 16);
|
||||
d->mCnt = aKnownEdges;
|
||||
@ -1356,7 +1360,8 @@ public:
|
||||
fprintf(mStream, "%p [garbage]\n", (void*)aAddress);
|
||||
}
|
||||
if (mWantAfterProcessing) {
|
||||
CCGraphDescriber* d = mDescribers.AppendElement();
|
||||
CCGraphDescriber* d = new CCGraphDescriber();
|
||||
mDescribers.insertBack(d);
|
||||
d->mType = CCGraphDescriber::eGarbage;
|
||||
d->mAddress.AppendInt(aAddress, 16);
|
||||
}
|
||||
@ -1403,42 +1408,41 @@ public:
|
||||
bool* aCanContinue)
|
||||
{
|
||||
NS_ENSURE_STATE(aHandler && mWantAfterProcessing);
|
||||
if (mNextIndex < mDescribers.Length()) {
|
||||
CCGraphDescriber& d = mDescribers[mNextIndex++];
|
||||
switch (d.mType) {
|
||||
CCGraphDescriber* d = mDescribers.popFirst();
|
||||
if (d) {
|
||||
switch (d->mType) {
|
||||
case CCGraphDescriber::eRefCountedObject:
|
||||
aHandler->NoteRefCountedObject(d.mAddress,
|
||||
d.mCnt,
|
||||
d.mName);
|
||||
aHandler->NoteRefCountedObject(d->mAddress,
|
||||
d->mCnt,
|
||||
d->mName);
|
||||
break;
|
||||
case CCGraphDescriber::eGCedObject:
|
||||
case CCGraphDescriber::eGCMarkedObject:
|
||||
aHandler->NoteGCedObject(d.mAddress,
|
||||
d.mType ==
|
||||
aHandler->NoteGCedObject(d->mAddress,
|
||||
d->mType ==
|
||||
CCGraphDescriber::eGCMarkedObject,
|
||||
d.mName);
|
||||
d->mName);
|
||||
break;
|
||||
case CCGraphDescriber::eEdge:
|
||||
aHandler->NoteEdge(d.mAddress,
|
||||
d.mToAddress,
|
||||
d.mName);
|
||||
aHandler->NoteEdge(d->mAddress,
|
||||
d->mToAddress,
|
||||
d->mName);
|
||||
break;
|
||||
case CCGraphDescriber::eRoot:
|
||||
aHandler->DescribeRoot(d.mAddress,
|
||||
d.mCnt);
|
||||
aHandler->DescribeRoot(d->mAddress,
|
||||
d->mCnt);
|
||||
break;
|
||||
case CCGraphDescriber::eGarbage:
|
||||
aHandler->DescribeGarbage(d.mAddress);
|
||||
aHandler->DescribeGarbage(d->mAddress);
|
||||
break;
|
||||
case CCGraphDescriber::eUnknown:
|
||||
NS_NOTREACHED("CCGraphDescriber::eUnknown");
|
||||
break;
|
||||
}
|
||||
delete d;
|
||||
}
|
||||
if (!(*aCanContinue = mNextIndex < mDescribers.Length())) {
|
||||
if (!(*aCanContinue = !mDescribers.isEmpty())) {
|
||||
mCurrentAddress.AssignLiteral("0x");
|
||||
mDescribers.Clear();
|
||||
mNextIndex = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1477,6 +1481,14 @@ private:
|
||||
return dont_AddRef(logFile);
|
||||
}
|
||||
|
||||
void ClearDescribers()
|
||||
{
|
||||
CCGraphDescriber* d;
|
||||
while((d = mDescribers.popFirst())) {
|
||||
delete d;
|
||||
}
|
||||
}
|
||||
|
||||
FILE *mStream;
|
||||
nsCOMPtr<nsIFile> mOutFile;
|
||||
bool mWantAllTraces;
|
||||
@ -1484,8 +1496,7 @@ private:
|
||||
bool mWantAfterProcessing;
|
||||
nsString mFilenameIdentifier;
|
||||
nsCString mCurrentAddress;
|
||||
nsTArray<CCGraphDescriber> mDescribers;
|
||||
uint32_t mNextIndex;
|
||||
mozilla::LinkedList<CCGraphDescriber> mDescribers;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCycleCollectorLogger, nsICycleCollectorListener)
|
||||
|
Loading…
Reference in New Issue
Block a user