Backed out 2 changesets (bug 1668825) for build bustages on TracingAPI.h. CLOSED TREE

Backed out changeset 5bc8cb307c61 (bug 1668825)
Backed out changeset 0e6a88c27779 (bug 1668825)
This commit is contained in:
Razvan Maries 2020-10-07 14:34:10 +03:00
parent 0d11db55c4
commit 7ed0fd1168
6 changed files with 77 additions and 68 deletions

View File

@ -86,32 +86,6 @@ enum class WeakMapTraceAction {
TraceKeysAndValues TraceKeysAndValues
}; };
// Whether a tracer should trace weak edges. GCMarker sets this to Skip.
enum class WeakEdgeTraceAction { Skip, Trace };
// Whether a tracer can skip tracing JS::Ids. This is needed by the cycle
// collector to skip some Ids for performance reasons. Not all Ids are skipped.
enum class IdTraceAction { CanSkip, Trace };
struct TraceOptions {
JS::WeakMapTraceAction weakMapAction = WeakMapTraceAction::TraceValues;
JS::WeakEdgeTraceAction weakEdgeAction = WeakEdgeTraceAction::Trace;
JS::IdTraceAction idAction = IdTraceAction::Trace;
TraceOptions() = default;
TraceOptions(JS::WeakMapTraceAction weakMapAction,
JS::WeakEdgeTraceAction weakEdgeAction,
JS::IdTraceAction idAction = IdTraceAction::Trace)
: weakMapAction(weakMapAction),
weakEdgeAction(weakEdgeAction),
idAction(idAction) {}
MOZ_IMPLICIT TraceOptions(JS::WeakMapTraceAction weakMapAction)
: weakMapAction(weakMapAction) {}
MOZ_IMPLICIT TraceOptions(JS::WeakEdgeTraceAction weakEdgeAction)
: weakEdgeAction(weakEdgeAction) {}
MOZ_IMPLICIT TraceOptions(JS::IdTraceAction idAction) : idAction(idAction) {}
};
class AutoTracingName; class AutoTracingName;
class AutoTracingIndex; class AutoTracingIndex;
class AutoTracingCallback; class AutoTracingCallback;
@ -196,18 +170,17 @@ class JS_PUBLIC_API JSTracer {
bool isGenericTracer() const { return kind_ >= JS::TracerKind::Generic; } bool isGenericTracer() const { return kind_ >= JS::TracerKind::Generic; }
bool isCallbackTracer() const { return kind_ >= JS::TracerKind::Callback; } bool isCallbackTracer() const { return kind_ >= JS::TracerKind::Callback; }
// Return the weak map tracing behavior currently set on this tracer.
JS::WeakMapTraceAction weakMapAction() const { return weakMapAction_; }
inline js::GenericTracer* asGenericTracer(); inline js::GenericTracer* asGenericTracer();
inline JS::CallbackTracer* asCallbackTracer(); inline JS::CallbackTracer* asCallbackTracer();
JS::WeakMapTraceAction weakMapAction() const { bool traceWeakEdges() const { return traceWeakEdges_; }
return options_.weakMapAction; bool canSkipJsids() const { return canSkipJsids_; }
} #ifdef DEBUG
bool traceWeakEdges() const { bool checkEdges() { return checkEdges_; }
return options_.weakEdgeAction == JS::WeakEdgeTraceAction::Trace; #endif
}
bool canSkipJsids() const {
return options_.idAction == JS::IdTraceAction::CanSkip;
}
// Get the current GC number. Only call this method if |isMarkingTracer()| // Get the current GC number. Only call this method if |isMarkingTracer()|
// is true. // is true.
@ -215,16 +188,37 @@ class JS_PUBLIC_API JSTracer {
protected: protected:
JSTracer(JSRuntime* rt, JS::TracerKind kind, JSTracer(JSRuntime* rt, JS::TracerKind kind,
JS::TraceOptions options = JS::TraceOptions()) JS::WeakMapTraceAction weakMapAction =
: runtime_(rt), kind_(kind), options_(options) {} JS::WeakMapTraceAction::TraceValues)
: runtime_(rt), kind_(kind), weakMapAction_(weakMapAction) {}
void setContext(JS::TracingContext* tcx) { maybeContext_ = tcx; } void setContext(JS::TracingContext* tcx) { maybeContext_ = tcx; }
void setTraceWeakEdges(bool value) { 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; }
#ifdef DEBUG
// Set whether to check edges are valid in debug builds.
void setCheckEdges(bool check) { checkEdges_ = check; }
#endif
private: private:
JSRuntime* const runtime_; JSRuntime* const runtime_;
JS::TracingContext* maybeContext_ = nullptr; JS::TracingContext* maybeContext_ = nullptr;
const JS::TracerKind kind_; const JS::TracerKind kind_;
const JS::TraceOptions options_; const JS::WeakMapTraceAction weakMapAction_;
// Whether the tracer should trace weak edges. GCMarker sets this to false.
bool traceWeakEdges_ = true;
bool canSkipJsids_ = false;
#ifdef DEBUG
bool checkEdges_ = true;
#endif
}; };
namespace js { namespace js {
@ -232,8 +226,9 @@ namespace js {
class GenericTracer : public JSTracer { class GenericTracer : public JSTracer {
public: public:
GenericTracer(JSRuntime* rt, JS::TracerKind kind = JS::TracerKind::Generic, GenericTracer(JSRuntime* rt, JS::TracerKind kind = JS::TracerKind::Generic,
JS::TraceOptions options = JS::TraceOptions()) JS::WeakMapTraceAction weakMapAction =
: JSTracer(rt, kind, options) { JS::WeakMapTraceAction::TraceValues)
: JSTracer(rt, kind, weakMapAction) {
MOZ_ASSERT(isGenericTracer()); MOZ_ASSERT(isGenericTracer());
} }
@ -285,14 +280,16 @@ namespace JS {
class JS_PUBLIC_API CallbackTracer : public js::GenericTracer { class JS_PUBLIC_API CallbackTracer : public js::GenericTracer {
public: public:
CallbackTracer(JSRuntime* rt, JS::TracerKind kind = JS::TracerKind::Callback, CallbackTracer(
JS::TraceOptions options = JS::TraceOptions()) JSRuntime* rt, JS::TracerKind kind = JS::TracerKind::Callback,
: GenericTracer(rt, kind, options) { WeakMapTraceAction weakMapAction = WeakMapTraceAction::TraceValues)
: GenericTracer(rt, kind, weakMapAction) {
MOZ_ASSERT(isCallbackTracer()); MOZ_ASSERT(isCallbackTracer());
setContext(&context_); setContext(&context_);
} }
CallbackTracer(JSContext* cx, JS::TracerKind kind = JS::TracerKind::Callback, CallbackTracer(
JS::TraceOptions options = JS::TraceOptions()); JSContext* cx, JS::TracerKind kind = JS::TracerKind::Callback,
WeakMapTraceAction weakMapAction = WeakMapTraceAction::TraceValues);
TracingContext& context() { return context_; } TracingContext& context() { return context_; }

View File

@ -3852,11 +3852,12 @@ class CompartmentCheckTracer final : public JS::CallbackTracer {
public: public:
explicit CompartmentCheckTracer(JSRuntime* rt) explicit CompartmentCheckTracer(JSRuntime* rt)
: JS::CallbackTracer(rt, JS::TracerKind::Callback, : JS::CallbackTracer(rt),
JS::WeakEdgeTraceAction::Skip),
src(nullptr), src(nullptr),
zone(nullptr), zone(nullptr),
compartment(nullptr) {} compartment(nullptr) {
setTraceWeakEdges(false);
}
Cell* src; Cell* src;
JS::TraceKind srcKind; JS::TraceKind srcKind;

View File

@ -179,6 +179,10 @@ void js::CheckTracedThing(JSTracer* trc, T* thing) {
MOZ_ASSERT(trc); MOZ_ASSERT(trc);
MOZ_ASSERT(thing); MOZ_ASSERT(thing);
if (!trc->checkEdges()) {
return;
}
if (IsForwarded(thing)) { if (IsForwarded(thing)) {
MOZ_ASSERT(IsTracerKind(trc, JS::TracerKind::Moving) || MOZ_ASSERT(IsTracerKind(trc, JS::TracerKind::Moving) ||
trc->isTenuringTracer()); trc->isTenuringTracer());
@ -2451,9 +2455,7 @@ inline void MarkStackIter::nextArray() {
* potential key. * potential key.
*/ */
GCMarker::GCMarker(JSRuntime* rt) GCMarker::GCMarker(JSRuntime* rt)
: JSTracer(rt, JS::TracerKind::Marking, : JSTracer(rt, JS::TracerKind::Marking, JS::WeakMapTraceAction::Expand),
JS::TraceOptions(JS::WeakMapTraceAction::Expand,
JS::WeakEdgeTraceAction::Skip)),
stack(), stack(),
auxStack(), auxStack(),
mainStackColor(MarkColor::Black), mainStackColor(MarkColor::Black),
@ -2471,6 +2473,7 @@ GCMarker::GCMarker(JSRuntime* rt)
#endif #endif
{ {
setMarkColorUnchecked(MarkColor::Black); setMarkColorUnchecked(MarkColor::Black);
setTraceWeakEdges(false);
} }
bool GCMarker::init(JSGCMode gcMode) { bool GCMarker::init(JSGCMode gcMode) {

View File

@ -359,8 +359,10 @@ void js::gc::GetTraceThingInfo(char* buf, size_t bufsize, void* thing,
} }
JS::CallbackTracer::CallbackTracer(JSContext* cx, JS::TracerKind kind, JS::CallbackTracer::CallbackTracer(JSContext* cx, JS::TracerKind kind,
JS::TraceOptions options) WeakMapTraceAction weakMapAction)
: CallbackTracer(cx->runtime(), kind, options) {} : CallbackTracer(cx->runtime(), kind, weakMapAction) {
MOZ_ASSERT(isCallbackTracer());
}
uint32_t JSTracer::gcNumberForMarking() const { uint32_t JSTracer::gcNumberForMarking() const {
MOZ_ASSERT(isMarkingTracer()); MOZ_ASSERT(isMarkingTracer());

View File

@ -106,8 +106,7 @@ class js::VerifyPreTracer final : public JS::CallbackTracer {
NodeMap nodemap; NodeMap nodemap;
explicit VerifyPreTracer(JSRuntime* rt) explicit VerifyPreTracer(JSRuntime* rt)
: JS::CallbackTracer(rt, JS::TracerKind::Callback, : JS::CallbackTracer(rt),
JS::WeakEdgeTraceAction::Skip),
noggc(rt->mainContextFromOwnThread()), noggc(rt->mainContextFromOwnThread()),
number(rt->gc.gcNumber()), number(rt->gc.gcNumber()),
count(0), count(0),
@ -117,6 +116,7 @@ class js::VerifyPreTracer final : public JS::CallbackTracer {
term(nullptr) { term(nullptr) {
// We don't care about weak edges here. Since they are not marked they // We don't care about weak edges here. Since they are not marked they
// cannot cause the problem that the pre-write barrier protects against. // cannot cause the problem that the pre-write barrier protects against.
setTraceWeakEdges(false);
} }
~VerifyPreTracer() { js_free(root); } ~VerifyPreTracer() { js_free(root); }
@ -758,7 +758,8 @@ void GCRuntime::finishMarkingValidation() {
class HeapCheckTracerBase : public JS::CallbackTracer { class HeapCheckTracerBase : public JS::CallbackTracer {
public: public:
explicit HeapCheckTracerBase(JSRuntime* rt, JS::TraceOptions options); explicit HeapCheckTracerBase(JSRuntime* rt,
JS::WeakMapTraceAction weakMapAction);
bool traceHeap(AutoTraceSession& session); bool traceHeap(AutoTraceSession& session);
virtual void checkCell(Cell* cell) = 0; virtual void checkCell(Cell* cell) = 0;
@ -796,12 +797,16 @@ class HeapCheckTracerBase : public JS::CallbackTracer {
}; };
HeapCheckTracerBase::HeapCheckTracerBase(JSRuntime* rt, HeapCheckTracerBase::HeapCheckTracerBase(JSRuntime* rt,
JS::TraceOptions options) JS::WeakMapTraceAction weakMapAction)
: CallbackTracer(rt, JS::TracerKind::Callback, options), : CallbackTracer(rt, JS::TracerKind::Callback, weakMapAction),
failures(0), failures(0),
rt(rt), rt(rt),
oom(false), oom(false),
parentIndex(-1) {} parentIndex(-1) {
# ifdef DEBUG
setCheckEdges(false);
# endif
}
void HeapCheckTracerBase::onChild(const JS::GCCellPtr& thing) { void HeapCheckTracerBase::onChild(const JS::GCCellPtr& thing) {
Cell* cell = thing.asCell(); Cell* cell = thing.asCell();
@ -948,9 +953,9 @@ class CheckGrayMarkingTracer final : public HeapCheckTracerBase {
}; };
CheckGrayMarkingTracer::CheckGrayMarkingTracer(JSRuntime* rt) CheckGrayMarkingTracer::CheckGrayMarkingTracer(JSRuntime* rt)
: HeapCheckTracerBase(rt, JS::TraceOptions(JS::WeakMapTraceAction::Skip, : HeapCheckTracerBase(rt, JS::WeakMapTraceAction::Skip) {
JS::WeakEdgeTraceAction::Skip)) {
// Weak gray->black edges are allowed. // Weak gray->black edges are allowed.
setTraceWeakEdges(false);
} }
void CheckGrayMarkingTracer::checkCell(Cell* cell) { void CheckGrayMarkingTracer::checkCell(Cell* cell) {

View File

@ -148,13 +148,14 @@ class IncrementalFinalizeRunnable : public CancelableRunnable {
struct NoteWeakMapChildrenTracer : public JS::CallbackTracer { struct NoteWeakMapChildrenTracer : public JS::CallbackTracer {
NoteWeakMapChildrenTracer(JSRuntime* aRt, NoteWeakMapChildrenTracer(JSRuntime* aRt,
nsCycleCollectionNoteRootCallback& aCb) nsCycleCollectionNoteRootCallback& aCb)
: JS::CallbackTracer(aRt, JS::TracerKind::Callback, : JS::CallbackTracer(aRt),
JS::IdTraceAction::CanSkip),
mCb(aCb), mCb(aCb),
mTracedAny(false), mTracedAny(false),
mMap(nullptr), mMap(nullptr),
mKey(nullptr), mKey(nullptr),
mKeyDelegate(nullptr) {} mKeyDelegate(nullptr) {
setCanSkipJsids(true);
}
void onChild(const JS::GCCellPtr& aThing) override; void onChild(const JS::GCCellPtr& aThing) override;
nsCycleCollectionNoteRootCallback& mCb; nsCycleCollectionNoteRootCallback& mCb;
bool mTracedAny; bool mTracedAny;
@ -389,10 +390,10 @@ JSZoneParticipant::TraverseNative(void* aPtr,
struct TraversalTracer : public JS::CallbackTracer { struct TraversalTracer : public JS::CallbackTracer {
TraversalTracer(JSRuntime* aRt, nsCycleCollectionTraversalCallback& aCb) TraversalTracer(JSRuntime* aRt, nsCycleCollectionTraversalCallback& aCb)
: JS::CallbackTracer(aRt, JS::TracerKind::Callback, : JS::CallbackTracer(aRt, JS::TracerKind::Callback,
JS::TraceOptions(JS::WeakMapTraceAction::Skip, JS::WeakMapTraceAction::Skip),
JS::WeakEdgeTraceAction::Trace, mCb(aCb) {
JS::IdTraceAction::CanSkip)), setCanSkipJsids(true);
mCb(aCb) {} }
void onChild(const JS::GCCellPtr& aThing) override; void onChild(const JS::GCCellPtr& aThing) override;
nsCycleCollectionTraversalCallback& mCb; nsCycleCollectionTraversalCallback& mCb;
}; };