Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1615082 - Fix IsMarked assertions to allow use by off-thread mark…
Browse files Browse the repository at this point in the history
…ing during sweeping and make wasm::Instance use IsMarked rather than IsAboutToBeFinalized r=sfink

I unintentionally changed the assertions in CheckIsMarkedThing to ignore marking (but left the comment intact!).

Also, IsAboutToBeFinalized always returns true during marking so this assertion will always pass. Fixed this by changing to IsMarked, but I had to add back a previouly removed version of IsMarked.

Differential Revision: https://phabricator.services.mozilla.com/D62938
  • Loading branch information
jonco3 committed Feb 17, 2020
1 parent 38ac6bb commit bf6d20a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion js/src/gc/Marking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3544,7 +3544,8 @@ static inline void CheckIsMarkedThing(T* thingp) {
// try to check the zone. Some threads have access to all zones when sweeping.
JSContext* cx = TlsContext.get();
MOZ_ASSERT(cx->gcUse != JSContext::GCUse::Finalizing);
if (cx->gcUse == JSContext::GCUse::Sweeping) {
if (cx->gcUse == JSContext::GCUse::Sweeping ||
cx->gcUse == JSContext::GCUse::Marking) {
Zone* zone = thing->zoneFromAnyThread();
MOZ_ASSERT_IF(cx->gcSweepZone,
cx->gcSweepZone == zone || zone->isAtomsZone());
Expand Down
9 changes: 9 additions & 0 deletions js/src/gc/Marking.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ inline bool IsMarkedUnbarriered(JSRuntime* rt, T* thingp) {
return IsMarkedInternal(rt, ConvertToBase(thingp));
}

// Report whether a GC thing has been marked with any color. Things which are in
// zones that are not currently being collected or are owned by another runtime
// are always reported as being marked.
template <typename T>
inline bool IsMarked(JSRuntime* rt, BarrieredBase<T>* thingp) {
return IsMarkedInternal(rt,
ConvertToBase(thingp->unsafeUnbarrieredForTracing()));
}

template <typename T>
inline bool IsAboutToBeFinalizedUnbarriered(T* thingp) {
return IsAboutToBeFinalizedInternal(ConvertToBase(thingp));
Expand Down
2 changes: 1 addition & 1 deletion js/src/wasm/WasmInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ void Instance::tracePrivate(JSTracer* trc) {
// This method is only called from WasmInstanceObject so the only reason why
// TraceEdge is called is so that the pointer can be updated during a moving
// GC.
MOZ_ASSERT(!gc::IsAboutToBeFinalized(&object_));
MOZ_ASSERT_IF(trc->isMarkingTracer(), gc::IsMarked(trc->runtime(), &object_));
TraceEdge(trc, &object_, "wasm instance object");

// OK to just do one tier here; though the tiers have different funcImports
Expand Down

0 comments on commit bf6d20a

Please sign in to comment.