mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
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:
parent
0d11db55c4
commit
7ed0fd1168
@ -86,32 +86,6 @@ enum class WeakMapTraceAction {
|
||||
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 AutoTracingIndex;
|
||||
class AutoTracingCallback;
|
||||
@ -196,18 +170,17 @@ class JS_PUBLIC_API JSTracer {
|
||||
bool isGenericTracer() const { return kind_ >= JS::TracerKind::Generic; }
|
||||
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::CallbackTracer* asCallbackTracer();
|
||||
|
||||
JS::WeakMapTraceAction weakMapAction() const {
|
||||
return options_.weakMapAction;
|
||||
}
|
||||
bool traceWeakEdges() const {
|
||||
return options_.weakEdgeAction == JS::WeakEdgeTraceAction::Trace;
|
||||
}
|
||||
bool canSkipJsids() const {
|
||||
return options_.idAction == JS::IdTraceAction::CanSkip;
|
||||
}
|
||||
bool traceWeakEdges() const { return traceWeakEdges_; }
|
||||
bool canSkipJsids() const { return canSkipJsids_; }
|
||||
#ifdef DEBUG
|
||||
bool checkEdges() { return checkEdges_; }
|
||||
#endif
|
||||
|
||||
// Get the current GC number. Only call this method if |isMarkingTracer()|
|
||||
// is true.
|
||||
@ -215,16 +188,37 @@ class JS_PUBLIC_API JSTracer {
|
||||
|
||||
protected:
|
||||
JSTracer(JSRuntime* rt, JS::TracerKind kind,
|
||||
JS::TraceOptions options = JS::TraceOptions())
|
||||
: runtime_(rt), kind_(kind), options_(options) {}
|
||||
JS::WeakMapTraceAction weakMapAction =
|
||||
JS::WeakMapTraceAction::TraceValues)
|
||||
: runtime_(rt), kind_(kind), weakMapAction_(weakMapAction) {}
|
||||
|
||||
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:
|
||||
JSRuntime* const runtime_;
|
||||
JS::TracingContext* maybeContext_ = nullptr;
|
||||
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 {
|
||||
@ -232,8 +226,9 @@ namespace js {
|
||||
class GenericTracer : public JSTracer {
|
||||
public:
|
||||
GenericTracer(JSRuntime* rt, JS::TracerKind kind = JS::TracerKind::Generic,
|
||||
JS::TraceOptions options = JS::TraceOptions())
|
||||
: JSTracer(rt, kind, options) {
|
||||
JS::WeakMapTraceAction weakMapAction =
|
||||
JS::WeakMapTraceAction::TraceValues)
|
||||
: JSTracer(rt, kind, weakMapAction) {
|
||||
MOZ_ASSERT(isGenericTracer());
|
||||
}
|
||||
|
||||
@ -285,14 +280,16 @@ namespace JS {
|
||||
|
||||
class JS_PUBLIC_API CallbackTracer : public js::GenericTracer {
|
||||
public:
|
||||
CallbackTracer(JSRuntime* rt, JS::TracerKind kind = JS::TracerKind::Callback,
|
||||
JS::TraceOptions options = JS::TraceOptions())
|
||||
: GenericTracer(rt, kind, options) {
|
||||
CallbackTracer(
|
||||
JSRuntime* rt, JS::TracerKind kind = JS::TracerKind::Callback,
|
||||
WeakMapTraceAction weakMapAction = WeakMapTraceAction::TraceValues)
|
||||
: GenericTracer(rt, kind, weakMapAction) {
|
||||
MOZ_ASSERT(isCallbackTracer());
|
||||
setContext(&context_);
|
||||
}
|
||||
CallbackTracer(JSContext* cx, JS::TracerKind kind = JS::TracerKind::Callback,
|
||||
JS::TraceOptions options = JS::TraceOptions());
|
||||
CallbackTracer(
|
||||
JSContext* cx, JS::TracerKind kind = JS::TracerKind::Callback,
|
||||
WeakMapTraceAction weakMapAction = WeakMapTraceAction::TraceValues);
|
||||
|
||||
TracingContext& context() { return context_; }
|
||||
|
||||
|
@ -3852,11 +3852,12 @@ class CompartmentCheckTracer final : public JS::CallbackTracer {
|
||||
|
||||
public:
|
||||
explicit CompartmentCheckTracer(JSRuntime* rt)
|
||||
: JS::CallbackTracer(rt, JS::TracerKind::Callback,
|
||||
JS::WeakEdgeTraceAction::Skip),
|
||||
: JS::CallbackTracer(rt),
|
||||
src(nullptr),
|
||||
zone(nullptr),
|
||||
compartment(nullptr) {}
|
||||
compartment(nullptr) {
|
||||
setTraceWeakEdges(false);
|
||||
}
|
||||
|
||||
Cell* src;
|
||||
JS::TraceKind srcKind;
|
||||
|
@ -179,6 +179,10 @@ void js::CheckTracedThing(JSTracer* trc, T* thing) {
|
||||
MOZ_ASSERT(trc);
|
||||
MOZ_ASSERT(thing);
|
||||
|
||||
if (!trc->checkEdges()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsForwarded(thing)) {
|
||||
MOZ_ASSERT(IsTracerKind(trc, JS::TracerKind::Moving) ||
|
||||
trc->isTenuringTracer());
|
||||
@ -2451,9 +2455,7 @@ inline void MarkStackIter::nextArray() {
|
||||
* potential key.
|
||||
*/
|
||||
GCMarker::GCMarker(JSRuntime* rt)
|
||||
: JSTracer(rt, JS::TracerKind::Marking,
|
||||
JS::TraceOptions(JS::WeakMapTraceAction::Expand,
|
||||
JS::WeakEdgeTraceAction::Skip)),
|
||||
: JSTracer(rt, JS::TracerKind::Marking, JS::WeakMapTraceAction::Expand),
|
||||
stack(),
|
||||
auxStack(),
|
||||
mainStackColor(MarkColor::Black),
|
||||
@ -2471,6 +2473,7 @@ GCMarker::GCMarker(JSRuntime* rt)
|
||||
#endif
|
||||
{
|
||||
setMarkColorUnchecked(MarkColor::Black);
|
||||
setTraceWeakEdges(false);
|
||||
}
|
||||
|
||||
bool GCMarker::init(JSGCMode gcMode) {
|
||||
|
@ -359,8 +359,10 @@ void js::gc::GetTraceThingInfo(char* buf, size_t bufsize, void* thing,
|
||||
}
|
||||
|
||||
JS::CallbackTracer::CallbackTracer(JSContext* cx, JS::TracerKind kind,
|
||||
JS::TraceOptions options)
|
||||
: CallbackTracer(cx->runtime(), kind, options) {}
|
||||
WeakMapTraceAction weakMapAction)
|
||||
: CallbackTracer(cx->runtime(), kind, weakMapAction) {
|
||||
MOZ_ASSERT(isCallbackTracer());
|
||||
}
|
||||
|
||||
uint32_t JSTracer::gcNumberForMarking() const {
|
||||
MOZ_ASSERT(isMarkingTracer());
|
||||
|
@ -106,8 +106,7 @@ class js::VerifyPreTracer final : public JS::CallbackTracer {
|
||||
NodeMap nodemap;
|
||||
|
||||
explicit VerifyPreTracer(JSRuntime* rt)
|
||||
: JS::CallbackTracer(rt, JS::TracerKind::Callback,
|
||||
JS::WeakEdgeTraceAction::Skip),
|
||||
: JS::CallbackTracer(rt),
|
||||
noggc(rt->mainContextFromOwnThread()),
|
||||
number(rt->gc.gcNumber()),
|
||||
count(0),
|
||||
@ -117,6 +116,7 @@ class js::VerifyPreTracer final : public JS::CallbackTracer {
|
||||
term(nullptr) {
|
||||
// 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.
|
||||
setTraceWeakEdges(false);
|
||||
}
|
||||
|
||||
~VerifyPreTracer() { js_free(root); }
|
||||
@ -758,7 +758,8 @@ void GCRuntime::finishMarkingValidation() {
|
||||
|
||||
class HeapCheckTracerBase : public JS::CallbackTracer {
|
||||
public:
|
||||
explicit HeapCheckTracerBase(JSRuntime* rt, JS::TraceOptions options);
|
||||
explicit HeapCheckTracerBase(JSRuntime* rt,
|
||||
JS::WeakMapTraceAction weakMapAction);
|
||||
bool traceHeap(AutoTraceSession& session);
|
||||
virtual void checkCell(Cell* cell) = 0;
|
||||
|
||||
@ -796,12 +797,16 @@ class HeapCheckTracerBase : public JS::CallbackTracer {
|
||||
};
|
||||
|
||||
HeapCheckTracerBase::HeapCheckTracerBase(JSRuntime* rt,
|
||||
JS::TraceOptions options)
|
||||
: CallbackTracer(rt, JS::TracerKind::Callback, options),
|
||||
JS::WeakMapTraceAction weakMapAction)
|
||||
: CallbackTracer(rt, JS::TracerKind::Callback, weakMapAction),
|
||||
failures(0),
|
||||
rt(rt),
|
||||
oom(false),
|
||||
parentIndex(-1) {}
|
||||
parentIndex(-1) {
|
||||
# ifdef DEBUG
|
||||
setCheckEdges(false);
|
||||
# endif
|
||||
}
|
||||
|
||||
void HeapCheckTracerBase::onChild(const JS::GCCellPtr& thing) {
|
||||
Cell* cell = thing.asCell();
|
||||
@ -948,9 +953,9 @@ class CheckGrayMarkingTracer final : public HeapCheckTracerBase {
|
||||
};
|
||||
|
||||
CheckGrayMarkingTracer::CheckGrayMarkingTracer(JSRuntime* rt)
|
||||
: HeapCheckTracerBase(rt, JS::TraceOptions(JS::WeakMapTraceAction::Skip,
|
||||
JS::WeakEdgeTraceAction::Skip)) {
|
||||
: HeapCheckTracerBase(rt, JS::WeakMapTraceAction::Skip) {
|
||||
// Weak gray->black edges are allowed.
|
||||
setTraceWeakEdges(false);
|
||||
}
|
||||
|
||||
void CheckGrayMarkingTracer::checkCell(Cell* cell) {
|
||||
|
@ -148,13 +148,14 @@ class IncrementalFinalizeRunnable : public CancelableRunnable {
|
||||
struct NoteWeakMapChildrenTracer : public JS::CallbackTracer {
|
||||
NoteWeakMapChildrenTracer(JSRuntime* aRt,
|
||||
nsCycleCollectionNoteRootCallback& aCb)
|
||||
: JS::CallbackTracer(aRt, JS::TracerKind::Callback,
|
||||
JS::IdTraceAction::CanSkip),
|
||||
: JS::CallbackTracer(aRt),
|
||||
mCb(aCb),
|
||||
mTracedAny(false),
|
||||
mMap(nullptr),
|
||||
mKey(nullptr),
|
||||
mKeyDelegate(nullptr) {}
|
||||
mKeyDelegate(nullptr) {
|
||||
setCanSkipJsids(true);
|
||||
}
|
||||
void onChild(const JS::GCCellPtr& aThing) override;
|
||||
nsCycleCollectionNoteRootCallback& mCb;
|
||||
bool mTracedAny;
|
||||
@ -389,10 +390,10 @@ JSZoneParticipant::TraverseNative(void* aPtr,
|
||||
struct TraversalTracer : public JS::CallbackTracer {
|
||||
TraversalTracer(JSRuntime* aRt, nsCycleCollectionTraversalCallback& aCb)
|
||||
: JS::CallbackTracer(aRt, JS::TracerKind::Callback,
|
||||
JS::TraceOptions(JS::WeakMapTraceAction::Skip,
|
||||
JS::WeakEdgeTraceAction::Trace,
|
||||
JS::IdTraceAction::CanSkip)),
|
||||
mCb(aCb) {}
|
||||
JS::WeakMapTraceAction::Skip),
|
||||
mCb(aCb) {
|
||||
setCanSkipJsids(true);
|
||||
}
|
||||
void onChild(const JS::GCCellPtr& aThing) override;
|
||||
nsCycleCollectionTraversalCallback& mCb;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user