mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 826526 - Modify the orphan node reporter so it handles WebIDL objects. r=bz.
This commit is contained in:
parent
81a169a667
commit
4a7bdc918c
@ -19,6 +19,8 @@
|
||||
#include "js/Utility.h"
|
||||
#include "js/Vector.h"
|
||||
|
||||
class nsISupports; // This is needed for ObjectPrivateVisitor.
|
||||
|
||||
namespace js {
|
||||
|
||||
// In memory reporting, we have concept of "sundries", line items which are too
|
||||
@ -391,8 +393,17 @@ class ObjectPrivateVisitor
|
||||
{
|
||||
public:
|
||||
// Within CollectRuntimeStats, this method is called for each JS object
|
||||
// that has a private slot containing an nsISupports pointer.
|
||||
virtual size_t sizeOfIncludingThis(void *aSupports) = 0;
|
||||
// that has an nsISupports pointer.
|
||||
virtual size_t sizeOfIncludingThis(nsISupports *aSupports) = 0;
|
||||
|
||||
// A callback that gets a JSObject's nsISupports pointer, if it has one.
|
||||
// Note: this function does *not* addref |iface|.
|
||||
typedef JSBool(*GetISupportsFun)(JSObject *obj, nsISupports **iface);
|
||||
GetISupportsFun getISupports;
|
||||
|
||||
ObjectPrivateVisitor(GetISupportsFun getISupports)
|
||||
: getISupports(getISupports)
|
||||
{}
|
||||
};
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
|
@ -159,11 +159,9 @@ StatsCellCallback(JSRuntime *rt, void *data, void *thing, JSGCTraceKind traceKin
|
||||
// JSObject::sizeOfExcludingThis() doesn't measure objectsExtraPrivate,
|
||||
// so we do it here.
|
||||
if (ObjectPrivateVisitor *opv = closure->opv) {
|
||||
js::Class *clazz = js::GetObjectClass(obj);
|
||||
if (clazz->flags & JSCLASS_HAS_PRIVATE &&
|
||||
clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)
|
||||
{
|
||||
cStats->objectsExtra.private_ += opv->sizeOfIncludingThis(GetObjectPrivate(obj));
|
||||
nsISupports *iface;
|
||||
if (opv->getISupports(obj, &iface) && iface) {
|
||||
cStats->objectsExtra.private_ += opv->sizeOfIncludingThis(iface);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1995,15 +1995,16 @@ SizeOfTreeIncludingThis(nsINode *tree)
|
||||
class OrphanReporter : public JS::ObjectPrivateVisitor
|
||||
{
|
||||
public:
|
||||
OrphanReporter()
|
||||
OrphanReporter(GetISupportsFun aGetISupports)
|
||||
: JS::ObjectPrivateVisitor(aGetISupports)
|
||||
{
|
||||
mAlreadyMeasuredOrphanTrees.Init();
|
||||
}
|
||||
|
||||
virtual size_t sizeOfIncludingThis(void *aSupports)
|
||||
virtual size_t sizeOfIncludingThis(nsISupports *aSupports)
|
||||
{
|
||||
size_t n = 0;
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(static_cast<nsISupports*>(aSupports));
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aSupports);
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=773533#c11 explains
|
||||
// that we have to skip XBL elements because they violate certain
|
||||
// assumptions. Yuk.
|
||||
@ -2065,15 +2066,15 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
|
||||
cJSPathPrefix.AppendLiteral("/js/");
|
||||
} else {
|
||||
cJSPathPrefix.AssignLiteral("explicit/js-non-window/compartments/unknown-window-global/");
|
||||
cDOMPathPrefix.AssignLiteral("explicit/dom/?!/");
|
||||
cDOMPathPrefix.AssignLiteral("explicit/dom/unknown-window-global?!/");
|
||||
}
|
||||
} else {
|
||||
cJSPathPrefix.AssignLiteral("explicit/js-non-window/compartments/non-window-global/");
|
||||
cDOMPathPrefix.AssignLiteral("explicit/dom/?!/");
|
||||
cDOMPathPrefix.AssignLiteral("explicit/dom/non-window-global?!/");
|
||||
}
|
||||
} else {
|
||||
cJSPathPrefix.AssignLiteral("explicit/js-non-window/compartments/no-global/");
|
||||
cDOMPathPrefix.AssignLiteral("explicit/dom/?!/");
|
||||
cDOMPathPrefix.AssignLiteral("explicit/dom/no-global?!/");
|
||||
}
|
||||
|
||||
cJSPathPrefix += NS_LITERAL_CSTRING("compartment(") + cName + NS_LITERAL_CSTRING(")/");
|
||||
@ -2108,7 +2109,7 @@ JSMemoryMultiReporter::CollectReports(WindowPaths *windowPaths,
|
||||
// stats seems like a bad idea.
|
||||
|
||||
XPCJSRuntimeStats rtStats(windowPaths);
|
||||
OrphanReporter orphanReporter;
|
||||
OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);
|
||||
if (!JS::CollectRuntimeStats(xpcrt->GetJSRuntime(), &rtStats, &orphanReporter))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user