mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1460636 - Don't trace jsids on ObjectGroup in the cycle collector. r=jonco,sfink
For some reason, the CC spends a lot of time tracing jsids on ObjectGroups when an addon is installed. This patch avoids that by adding a canSkipJsids flag to JSTracer, and using it in ObjectGroup::traceChildren. If this is true, then the tracer is free to not report every jsid. This flag is set to true for the two CC tracers. MozReview-Commit-ID: CWFqQEr0SxV --HG-- extra : rebase_source : cc31c22717f8990166454db191e0d40c145e09f0
This commit is contained in:
parent
f78be9e725
commit
6c4a1d23f2
@ -86,6 +86,7 @@ class JS_PUBLIC_API(JSTracer)
|
||||
bool isCallbackTracer() const { return tag_ == TracerKindTag::Callback; }
|
||||
inline JS::CallbackTracer* asCallbackTracer();
|
||||
bool traceWeakEdges() const { return traceWeakEdges_; }
|
||||
bool canSkipJsids() const { return canSkipJsids_; }
|
||||
#ifdef DEBUG
|
||||
bool checkEdges() { return checkEdges_; }
|
||||
#endif
|
||||
@ -104,6 +105,7 @@ class JS_PUBLIC_API(JSTracer)
|
||||
#endif
|
||||
, tag_(tag)
|
||||
, traceWeakEdges_(true)
|
||||
, canSkipJsids_(false)
|
||||
{}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -123,6 +125,7 @@ class JS_PUBLIC_API(JSTracer)
|
||||
protected:
|
||||
TracerKindTag tag_;
|
||||
bool traceWeakEdges_;
|
||||
bool canSkipJsids_;
|
||||
};
|
||||
|
||||
namespace JS {
|
||||
@ -254,6 +257,12 @@ class JS_PUBLIC_API(CallbackTracer) : public JSTracer
|
||||
traceWeakEdges_ = value;
|
||||
}
|
||||
|
||||
// If this is set to false, then the tracer will skip some jsids
|
||||
// to improve performance. This is needed for the cycle collector.
|
||||
void setCanSkipJsids(bool value) {
|
||||
canSkipJsids_ = value;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class AutoTracingName;
|
||||
const char* contextName_;
|
||||
|
@ -1470,10 +1470,13 @@ void
|
||||
js::ObjectGroup::traceChildren(JSTracer* trc)
|
||||
{
|
||||
AutoSweepObjectGroup sweep(this);
|
||||
unsigned count = getPropertyCount(sweep);
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
if (ObjectGroup::Property* prop = getProperty(sweep, i))
|
||||
TraceEdge(trc, &prop->id, "group_property");
|
||||
|
||||
if (!trc->canSkipJsids()) {
|
||||
unsigned count = getPropertyCount(sweep);
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
if (ObjectGroup::Property* prop = getProperty(sweep, i))
|
||||
TraceEdge(trc, &prop->id, "group_property");
|
||||
}
|
||||
}
|
||||
|
||||
if (proto().isObject())
|
||||
|
@ -143,6 +143,7 @@ struct NoteWeakMapChildrenTracer : public JS::CallbackTracer
|
||||
: JS::CallbackTracer(aRt), mCb(aCb), mTracedAny(false), mMap(nullptr),
|
||||
mKey(nullptr), mKeyDelegate(nullptr)
|
||||
{
|
||||
setCanSkipJsids(true);
|
||||
}
|
||||
void onChild(const JS::GCCellPtr& aThing) override;
|
||||
nsCycleCollectionNoteRootCallback& mCb;
|
||||
@ -399,6 +400,7 @@ struct TraversalTracer : public JS::CallbackTracer
|
||||
TraversalTracer(JSRuntime* aRt, nsCycleCollectionTraversalCallback& aCb)
|
||||
: JS::CallbackTracer(aRt, DoNotTraceWeakMaps), mCb(aCb)
|
||||
{
|
||||
setCanSkipJsids(true);
|
||||
}
|
||||
void onChild(const JS::GCCellPtr& aThing) override;
|
||||
nsCycleCollectionTraversalCallback& mCb;
|
||||
|
Loading…
x
Reference in New Issue
Block a user