mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 928476 - Add telemetry to measure cross-global adopts. r=mrbkap,nfroyd
This commit is contained in:
parent
7f3555c1cf
commit
d23fe1a7b3
@ -1659,14 +1659,19 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg)
|
||||
|
||||
JSAutoCompartment oldAc(aCx, oldParent);
|
||||
|
||||
if (js::GetObjectCompartment(oldParent) ==
|
||||
js::GetObjectCompartment(newParent)) {
|
||||
JSCompartment* oldCompartment = js::GetObjectCompartment(oldParent);
|
||||
JSCompartment* newCompartment = js::GetObjectCompartment(newParent);
|
||||
if (oldCompartment == newCompartment) {
|
||||
if (!JS_SetParent(aCx, aObj, newParent)) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Telemetry.
|
||||
xpc::RecordDonatedNode(oldCompartment);
|
||||
xpc::RecordAdoptedNode(newCompartment);
|
||||
|
||||
nsISupports* native = UnwrapDOMObjectToISupports(aObj);
|
||||
if (!native) {
|
||||
return NS_OK;
|
||||
|
@ -261,9 +261,32 @@ public:
|
||||
|
||||
namespace xpc {
|
||||
|
||||
static uint32_t kLivingAdopters = 0;
|
||||
|
||||
void
|
||||
RecordAdoptedNode(JSCompartment *c)
|
||||
{
|
||||
CompartmentPrivate *priv = EnsureCompartmentPrivate(c);
|
||||
if (!priv->adoptedNode) {
|
||||
priv->adoptedNode = true;
|
||||
++kLivingAdopters;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RecordDonatedNode(JSCompartment *c)
|
||||
{
|
||||
EnsureCompartmentPrivate(c)->donatedNode = true;
|
||||
}
|
||||
|
||||
CompartmentPrivate::~CompartmentPrivate()
|
||||
{
|
||||
MOZ_COUNT_DTOR(xpc::CompartmentPrivate);
|
||||
|
||||
Telemetry::Accumulate(Telemetry::COMPARTMENT_ADOPTED_NODE, adoptedNode);
|
||||
Telemetry::Accumulate(Telemetry::COMPARTMENT_DONATED_NODE, donatedNode);
|
||||
if (adoptedNode)
|
||||
--kLivingAdopters;
|
||||
}
|
||||
|
||||
bool CompartmentPrivate::TryParseLocationURI()
|
||||
@ -653,6 +676,13 @@ XPCJSRuntime::GCSliceCallback(JSRuntime *rt,
|
||||
void
|
||||
XPCJSRuntime::CustomGCCallback(JSGCStatus status)
|
||||
{
|
||||
// Record kLivingAdopters once per GC to approximate time sampling during
|
||||
// periods of activity.
|
||||
if (status == JSGC_BEGIN) {
|
||||
Telemetry::Accumulate(Telemetry::COMPARTMENT_LIVING_ADOPTERS,
|
||||
kLivingAdopters);
|
||||
}
|
||||
|
||||
nsTArray<xpcGCCallback> callbacks(extraGCCallbacks);
|
||||
for (uint32_t i = 0; i < callbacks.Length(); ++i)
|
||||
callbacks[i](status);
|
||||
|
@ -3744,6 +3744,8 @@ public:
|
||||
CompartmentPrivate()
|
||||
: wantXrays(false)
|
||||
, universalXPConnectEnabled(false)
|
||||
, adoptedNode(false)
|
||||
, donatedNode(false)
|
||||
, scope(nullptr)
|
||||
, locationWasParsed(false)
|
||||
{
|
||||
@ -3760,6 +3762,10 @@ public:
|
||||
// the old scoping rules of enablePrivilege). Using it is inherently unsafe.
|
||||
bool universalXPConnectEnabled;
|
||||
|
||||
// for telemetry. See bug 928476.
|
||||
bool adoptedNode;
|
||||
bool donatedNode;
|
||||
|
||||
// Our XPCWrappedNativeScope. This is non-null if and only if this is an
|
||||
// XPConnect compartment.
|
||||
XPCWrappedNativeScope *scope;
|
||||
|
@ -359,6 +359,12 @@ SystemErrorReporterExternal(JSContext *cx, const char *message,
|
||||
NS_EXPORT_(void)
|
||||
SimulateActivityCallback(bool aActive);
|
||||
|
||||
void
|
||||
RecordAdoptedNode(JSCompartment *c);
|
||||
|
||||
void
|
||||
RecordDonatedNode(JSCompartment *c);
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -28,6 +28,19 @@
|
||||
"n_values": 21,
|
||||
"description": "Maximum number of concurrent threads reached during a given download session"
|
||||
},
|
||||
"COMPARTMENT_DONATED_NODE": {
|
||||
"kind": "boolean",
|
||||
"description": "When a compartment is destroyed, we record whether one of its nodes was ever adopted into another compartment"
|
||||
},
|
||||
"COMPARTMENT_ADOPTED_NODE": {
|
||||
"kind": "boolean",
|
||||
"description": "When a compartment is destroyed, we record whether it had ever adopted a node from another compartment"
|
||||
},
|
||||
"COMPARTMENT_LIVING_ADOPTERS": {
|
||||
"kind": "enumerated",
|
||||
"n_values": 10,
|
||||
"description": "The number of living compartments for which COMPARTMENT_ADOPTED_NODE is true"
|
||||
},
|
||||
"CYCLE_COLLECTOR": {
|
||||
"kind": "exponential",
|
||||
"high": "10000",
|
||||
|
Loading…
Reference in New Issue
Block a user