From f47569e9d9c79767a911bc43140eafa72f71c9ed Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Thu, 23 Jul 2020 02:31:57 +0000 Subject: [PATCH] Bug 1654523 - Insist that iteration callbacks don't GC r=sfink,mccr8 Differential Revision: https://phabricator.services.mozilla.com/D84500 --- caps/ContentPrincipal.cpp | 3 +- dom/workers/WorkerPrivate.cpp | 9 ++--- js/public/MemoryMetrics.h | 8 +++-- js/public/Realm.h | 8 +++-- js/src/gc/GC.h | 12 ++++--- js/src/gc/PublicIterators.cpp | 39 +++++++++++++--------- js/src/jsapi.h | 4 +-- js/src/jsfriendapi.cpp | 22 +++++++----- js/src/jsfriendapi.h | 13 ++++---- js/src/vm/CodeCoverage.cpp | 3 +- js/src/vm/MemoryMetrics.cpp | 28 +++++++++------- js/src/vm/Realm.cpp | 2 +- js/xpconnect/src/XPCJSRuntime.cpp | 16 +++++---- js/xpconnect/src/XPCWrappedNativeScope.cpp | 3 +- xpcom/base/CycleCollectedJSRuntime.cpp | 7 ++-- xpcom/base/CycleCollectedJSRuntime.h | 3 +- 16 files changed, 105 insertions(+), 75 deletions(-) diff --git a/caps/ContentPrincipal.cpp b/caps/ContentPrincipal.cpp index bb7d9ce73a8d..6152a0e0f7e8 100644 --- a/caps/ContentPrincipal.cpp +++ b/caps/ContentPrincipal.cpp @@ -357,7 +357,8 @@ ContentPrincipal::SetDomain(nsIURI* aDomain) { // Set the changed-document-domain flag on compartments containing realms // using this principal. - auto cb = [](JSContext*, void*, JS::Handle aRealm) { + auto cb = [](JSContext*, void*, JS::Realm* aRealm, + const JS::AutoRequireNoGC& nogc) { JS::Compartment* comp = JS::GetCompartmentForRealm(aRealm); xpc::SetCompartmentChangedDocumentDomain(comp); }; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 4bc8f9051da5..ad6998081fae 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -997,8 +997,8 @@ class WorkerJSContextStats final : public JS::RuntimeStats { const nsCString& Path() const { return mRtPath; } - virtual void initExtraZoneStats(JS::Zone* aZone, - JS::ZoneStats* aZoneStats) override { + virtual void initExtraZoneStats(JS::Zone* aZone, JS::ZoneStats* aZoneStats, + const JS::AutoRequireNoGC& nogc) override { MOZ_ASSERT(!aZoneStats->extra); // ReportJSRuntimeExplicitTreeStats expects that @@ -1012,8 +1012,9 @@ class WorkerJSContextStats final : public JS::RuntimeStats { aZoneStats->extra = extras; } - virtual void initExtraRealmStats(JS::Handle aRealm, - JS::RealmStats* aRealmStats) override { + virtual void initExtraRealmStats(JS::Realm* aRealm, + JS::RealmStats* aRealmStats, + const JS::AutoRequireNoGC& nogc) override { MOZ_ASSERT(!aRealmStats->extra); // ReportJSRuntimeExplicitTreeStats expects that diff --git a/js/public/MemoryMetrics.h b/js/public/MemoryMetrics.h index 39c42d2d2653..ad699c147b4f 100644 --- a/js/public/MemoryMetrics.h +++ b/js/public/MemoryMetrics.h @@ -19,6 +19,7 @@ #include "jspubtd.h" #include "js/AllocPolicy.h" +#include "js/GCAPI.h" #include "js/HashTable.h" #include "js/TracingAPI.h" #include "js/Utility.h" @@ -846,9 +847,10 @@ struct RuntimeStats { mozilla::MallocSizeOf mallocSizeOf_; - virtual void initExtraRealmStats(JS::Handle realm, - RealmStats* rstats) = 0; - virtual void initExtraZoneStats(JS::Zone* zone, ZoneStats* zstats) = 0; + virtual void initExtraRealmStats(JS::Realm* realm, RealmStats* rstats, + const JS::AutoRequireNoGC& nogc) = 0; + virtual void initExtraZoneStats(JS::Zone* zone, ZoneStats* zstats, + const JS::AutoRequireNoGC& nogc) = 0; #undef FOR_EACH_SIZE }; diff --git a/js/public/Realm.h b/js/public/Realm.h index 50e6a371eba3..882f8906ca39 100644 --- a/js/public/Realm.h +++ b/js/public/Realm.h @@ -8,6 +8,7 @@ #define js_Realm_h #include "jspubtd.h" +#include "js/GCAPI.h" #include "js/GCPolicyAPI.h" #include "js/TypeDecls.h" // forward-declaration of JS::Realm @@ -84,8 +85,9 @@ typedef void (*DestroyRealmCallback)(JSFreeOp* fop, Realm* realm); extern JS_PUBLIC_API void SetDestroyRealmCallback( JSContext* cx, DestroyRealmCallback callback); -typedef void (*RealmNameCallback)(JSContext* cx, Handle realm, - char* buf, size_t bufsize); +using RealmNameCallback = void (*)(JSContext* cx, Realm* realm, char* buf, + size_t bufsize, + const JS::AutoRequireNoGC& nogc); // Set the callback SpiderMonkey calls to get the name of a realm, for // diagnostic output. @@ -94,7 +96,7 @@ extern JS_PUBLIC_API void SetRealmNameCallback(JSContext* cx, // Get the global object for the given realm. This only returns nullptr during // GC, between collecting the global object and destroying the Realm. -extern JS_PUBLIC_API JSObject* GetRealmGlobalOrNull(Handle realm); +extern JS_PUBLIC_API JSObject* GetRealmGlobalOrNull(Realm* realm); // Initialize standard JS class constructors, prototypes, and any top-level // functions and constants associated with the standard classes (e.g. isNaN diff --git a/js/src/gc/GC.h b/js/src/gc/GC.h index e3d7a325c53d..0cc620e75aa6 100644 --- a/js/src/gc/GC.h +++ b/js/src/gc/GC.h @@ -71,11 +71,15 @@ extern unsigned NotifyGCPreSwap(JSObject* a, JSObject* b); extern void NotifyGCPostSwap(JSObject* a, JSObject* b, unsigned preResult); -using IterateChunkCallback = void (*)(JSRuntime*, void*, gc::Chunk*); -using IterateZoneCallback = void (*)(JSRuntime*, void*, JS::Zone*); +using IterateChunkCallback = void (*)(JSRuntime*, void*, gc::Chunk*, + const JS::AutoRequireNoGC&); +using IterateZoneCallback = void (*)(JSRuntime*, void*, JS::Zone*, + const JS::AutoRequireNoGC&); using IterateArenaCallback = void (*)(JSRuntime*, void*, gc::Arena*, - JS::TraceKind, size_t); -using IterateCellCallback = void (*)(JSRuntime*, void*, JS::GCCellPtr, size_t); + JS::TraceKind, size_t, + const JS::AutoRequireNoGC&); +using IterateCellCallback = void (*)(JSRuntime*, void*, JS::GCCellPtr, size_t, + const JS::AutoRequireNoGC&); /* * This function calls |zoneCallback| on every zone, |realmCallback| on diff --git a/js/src/gc/PublicIterators.cpp b/js/src/gc/PublicIterators.cpp index a2355ecd3c4d..942c67e67ea4 100644 --- a/js/src/gc/PublicIterators.cpp +++ b/js/src/gc/PublicIterators.cpp @@ -21,12 +21,12 @@ using namespace js::gc; static void IterateRealmsArenasCellsUnbarriered( JSContext* cx, Zone* zone, void* data, JS::IterateRealmCallback realmCallback, IterateArenaCallback arenaCallback, - IterateCellCallback cellCallback) { + IterateCellCallback cellCallback, const JS::AutoRequireNoGC& nogc) { { Rooted realm(cx); for (RealmsInZoneIter r(zone); !r.done(); r.next()) { realm = r; - (*realmCallback)(cx, data, realm); + (*realmCallback)(cx, data, realm, nogc); } } @@ -36,10 +36,10 @@ static void IterateRealmsArenasCellsUnbarriered( for (ArenaIter aiter(zone, thingKind); !aiter.done(); aiter.next()) { Arena* arena = aiter.get(); - (*arenaCallback)(cx->runtime(), data, arena, traceKind, thingSize); + (*arenaCallback)(cx->runtime(), data, arena, traceKind, thingSize, nogc); for (ArenaCellIter cell(arena); !cell.done(); cell.next()) { (*cellCallback)(cx->runtime(), data, JS::GCCellPtr(cell, traceKind), - thingSize); + thingSize, nogc); } } } @@ -51,11 +51,12 @@ void js::IterateHeapUnbarriered(JSContext* cx, void* data, IterateArenaCallback arenaCallback, IterateCellCallback cellCallback) { AutoPrepareForTracing prep(cx); + JS::AutoSuppressGCAnalysis nogc(cx); for (ZonesIter zone(cx->runtime(), WithAtoms); !zone.done(); zone.next()) { - (*zoneCallback)(cx->runtime(), data, zone); + (*zoneCallback)(cx->runtime(), data, zone, nogc); IterateRealmsArenasCellsUnbarriered(cx, zone, data, realmCallback, - arenaCallback, cellCallback); + arenaCallback, cellCallback, nogc); } } @@ -65,20 +66,22 @@ void js::IterateHeapUnbarrieredForZone(JSContext* cx, Zone* zone, void* data, IterateArenaCallback arenaCallback, IterateCellCallback cellCallback) { AutoPrepareForTracing prep(cx); + JS::AutoSuppressGCAnalysis nogc(cx); - (*zoneCallback)(cx->runtime(), data, zone); + (*zoneCallback)(cx->runtime(), data, zone, nogc); IterateRealmsArenasCellsUnbarriered(cx, zone, data, realmCallback, - arenaCallback, cellCallback); + arenaCallback, cellCallback, nogc); } void js::IterateChunks(JSContext* cx, void* data, IterateChunkCallback chunkCallback) { AutoPrepareForTracing prep(cx); AutoLockGC lock(cx->runtime()); + JS::AutoSuppressGCAnalysis nogc(cx); for (auto chunk = cx->runtime()->gc.allNonEmptyChunks(lock); !chunk.done(); chunk.next()) { - chunkCallback(cx->runtime(), data, chunk); + chunkCallback(cx->runtime(), data, chunk, nogc); } } @@ -176,15 +179,18 @@ void js::IterateLazyScripts(JSContext* cx, Realm* realm, void* data, IterateScriptsImpl(cx, realm, data, scriptCallback); } -void js::IterateGrayObjects(Zone* zone, GCThingCallback cellCallback, +void js::IterateGrayObjects(Zone* zone, IterateGCThingCallback cellCallback, void* data) { MOZ_ASSERT(!JS::RuntimeHeapIsBusy()); - AutoPrepareForTracing prep(TlsContext.get()); + JSContext* cx = TlsContext.get(); + AutoPrepareForTracing prep(cx); + JS::AutoSuppressGCAnalysis nogc(cx); + for (auto kind : ObjectAllocKinds()) { for (GrayObjectIter obj(zone, kind); !obj.done(); obj.next()) { if (obj->asTenured().isMarkedGray()) { - cellCallback(data, JS::GCCellPtr(obj.get())); + cellCallback(data, JS::GCCellPtr(obj.get()), nogc); } } } @@ -219,11 +225,12 @@ JS_PUBLIC_API void JS_IterateCompartmentsInZone( JS_PUBLIC_API void JS::IterateRealms(JSContext* cx, void* data, JS::IterateRealmCallback realmCallback) { AutoTraceSession session(cx->runtime()); + JS::AutoSuppressGCAnalysis nogc(cx); Rooted realm(cx); for (RealmsIter r(cx->runtime()); !r.done(); r.next()) { realm = r; - (*realmCallback)(cx, data, realm); + (*realmCallback)(cx, data, realm, nogc); } } @@ -233,6 +240,7 @@ JS_PUBLIC_API void JS::IterateRealmsWithPrincipals( MOZ_ASSERT(principals); AutoTraceSession session(cx->runtime()); + JS::AutoSuppressGCAnalysis nogc(cx); Rooted realm(cx); for (RealmsIter r(cx->runtime()); !r.done(); r.next()) { @@ -240,7 +248,7 @@ JS_PUBLIC_API void JS::IterateRealmsWithPrincipals( continue; } realm = r; - (*realmCallback)(cx, data, realm); + (*realmCallback)(cx, data, realm, nogc); } } @@ -248,10 +256,11 @@ JS_PUBLIC_API void JS::IterateRealmsInCompartment( JSContext* cx, JS::Compartment* compartment, void* data, JS::IterateRealmCallback realmCallback) { AutoTraceSession session(cx->runtime()); + JS::AutoSuppressGCAnalysis nogc(cx); Rooted realm(cx); for (RealmsInCompartmentIter r(compartment); !r.done(); r.next()) { realm = r; - (*realmCallback)(cx, data, realm); + (*realmCallback)(cx, data, realm, nogc); } } diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 4fd820ad25a7..8f42a797bcba 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -452,8 +452,8 @@ extern JS_PUBLIC_API JS::Realm* EnterRealm(JSContext* cx, JSObject* target); extern JS_PUBLIC_API void LeaveRealm(JSContext* cx, JS::Realm* oldRealm); -using IterateRealmCallback = void (*)(JSContext* cx, void* data, - Handle realm); +using IterateRealmCallback = void (*)(JSContext* cx, void* data, Realm* realm, + const AutoRequireNoGC& nogc); /** * This function calls |realmCallback| on every realm. Beware that there is no diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 8b9885a0bbd2..48d524731c90 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -548,14 +548,15 @@ JS_FRIEND_API bool js::IsCompartmentZoneSweepingOrCompacting( } JS_FRIEND_API void js::VisitGrayWrapperTargets(Zone* zone, - GCThingCallback callback, + IterateGCThingCallback callback, void* closure) { + JS::AutoSuppressGCAnalysis nogc; + for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) { for (Compartment::ObjectWrapperEnum e(comp); !e.empty(); e.popFront()) { JSObject* target = e.front().key(); if (target->isMarkedGray()) { - JS::AutoSuppressGCAnalysis nogc; - callback(closure, JS::GCCellPtr(target)); + callback(closure, JS::GCCellPtr(target), nogc); } } } @@ -1156,16 +1157,17 @@ static char MarkDescriptor(gc::Cell* thing) { return 'W'; } -static void DumpHeapVisitZone(JSRuntime* rt, void* data, Zone* zone) { +static void DumpHeapVisitZone(JSRuntime* rt, void* data, Zone* zone, + const JS::AutoRequireNoGC& nogc) { DumpHeapTracer* dtrc = static_cast(data); fprintf(dtrc->output, "# zone %p\n", (void*)zone); } -static void DumpHeapVisitRealm(JSContext* cx, void* data, - Handle realm) { +static void DumpHeapVisitRealm(JSContext* cx, void* data, Realm* realm, + const JS::AutoRequireNoGC& nogc) { char name[1024]; if (auto nameCallback = cx->runtime()->realmNameCallback) { - nameCallback(cx, realm, name, sizeof(name)); + nameCallback(cx, realm, name, sizeof(name), nogc); } else { strcpy(name, ""); } @@ -1176,14 +1178,16 @@ static void DumpHeapVisitRealm(JSContext* cx, void* data, } static void DumpHeapVisitArena(JSRuntime* rt, void* data, gc::Arena* arena, - JS::TraceKind traceKind, size_t thingSize) { + JS::TraceKind traceKind, size_t thingSize, + const JS::AutoRequireNoGC& nogc) { DumpHeapTracer* dtrc = static_cast(data); fprintf(dtrc->output, "# arena allockind=%u size=%u\n", unsigned(arena->getAllocKind()), unsigned(thingSize)); } static void DumpHeapVisitCell(JSRuntime* rt, void* data, JS::GCCellPtr cellptr, - size_t thingSize) { + size_t thingSize, + const JS::AutoRequireNoGC& nogc) { DumpHeapTracer* dtrc = static_cast(data); char cellDesc[1024 * 32]; JS_GetTraceThingInfo(cellDesc, sizeof(cellDesc), dtrc, cellptr.asCell(), diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 582afba530b4..4d1947ecef96 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -473,18 +473,17 @@ extern JS_FRIEND_API bool ZoneGlobalsAreAllGray(JS::Zone* zone); extern JS_FRIEND_API bool IsCompartmentZoneSweepingOrCompacting( JS::Compartment* comp); -using GCThingCallback = void (*)(void*, JS::GCCellPtr); +using IterateGCThingCallback = void (*)(void*, JS::GCCellPtr, + const JS::AutoRequireNoGC&); -extern JS_FRIEND_API void VisitGrayWrapperTargets(JS::Zone* zone, - GCThingCallback callback, - void* closure); +extern JS_FRIEND_API void VisitGrayWrapperTargets( + JS::Zone* zone, IterateGCThingCallback callback, void* closure); /** * Invoke cellCallback on every gray JSObject in the given zone. */ -extern JS_FRIEND_API void IterateGrayObjects(JS::Zone* zone, - GCThingCallback cellCallback, - void* data); +extern JS_FRIEND_API void IterateGrayObjects( + JS::Zone* zone, IterateGCThingCallback cellCallback, void* data); #if defined(JS_GC_ZEAL) || defined(DEBUG) // Trace the heap and check there are no black to gray edges. These are diff --git a/js/src/vm/CodeCoverage.cpp b/js/src/vm/CodeCoverage.cpp index c597e03e4ece..62ddf170d673 100644 --- a/js/src/vm/CodeCoverage.cpp +++ b/js/src/vm/CodeCoverage.cpp @@ -469,8 +469,7 @@ void LCovRealm::writeRealmName(JS::Realm* realm) { { // Hazard analysis cannot tell that the callback does not GC. JS::AutoSuppressGCAnalysis nogc; - Rooted rootedRealm(cx, realm); - (*cx->runtime()->realmNameCallback)(cx, rootedRealm, name, sizeof(name)); + (*cx->runtime()->realmNameCallback)(cx, realm, name, sizeof(name), nogc); } for (char* s = name; s < name + sizeof(name) && *s; s++) { if (('a' <= *s && *s <= 'z') || ('A' <= *s && *s <= 'Z') || diff --git a/js/src/vm/MemoryMetrics.cpp b/js/src/vm/MemoryMetrics.cpp index dedb60fcffed..5a9a4e319598 100644 --- a/js/src/vm/MemoryMetrics.cpp +++ b/js/src/vm/MemoryMetrics.cpp @@ -184,7 +184,8 @@ struct StatsClosure { }; static void DecommittedArenasChunkCallback(JSRuntime* rt, void* data, - gc::Chunk* chunk) { + gc::Chunk* chunk, + const JS::AutoRequireNoGC& nogc) { // This case is common and fast to check. Do it first. if (chunk->decommittedArenas.isAllClear()) { return; @@ -200,7 +201,8 @@ static void DecommittedArenasChunkCallback(JSRuntime* rt, void* data, *static_cast(data) += n; } -static void StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone) { +static void StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone, + const JS::AutoRequireNoGC& nogc) { // Append a new RealmStats to the vector. RuntimeStats* rtStats = static_cast(data)->rtStats; @@ -208,7 +210,7 @@ static void StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone) { MOZ_ALWAYS_TRUE(rtStats->zoneStatsVector.growBy(1)); ZoneStats& zStats = rtStats->zoneStatsVector.back(); zStats.initStrings(); - rtStats->initExtraZoneStats(zone, &zStats); + rtStats->initExtraZoneStats(zone, &zStats, nogc); rtStats->currZoneStats = &zStats; zone->addSizeOfIncludingThis( @@ -220,8 +222,8 @@ static void StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone) { &zStats.scriptCountsMap); } -static void StatsRealmCallback(JSContext* cx, void* data, - Handle realm) { +static void StatsRealmCallback(JSContext* cx, void* data, Realm* realm, + const JS::AutoRequireNoGC& nogc) { // Append a new RealmStats to the vector. RuntimeStats* rtStats = static_cast(data)->rtStats; @@ -229,7 +231,7 @@ static void StatsRealmCallback(JSContext* cx, void* data, MOZ_ALWAYS_TRUE(rtStats->realmStatsVector.growBy(1)); RealmStats& realmStats = rtStats->realmStatsVector.back(); realmStats.initClasses(); - rtStats->initExtraRealmStats(realm, &realmStats); + rtStats->initExtraRealmStats(realm, &realmStats, nogc); realm->setRealmStats(&realmStats); @@ -245,7 +247,8 @@ static void StatsRealmCallback(JSContext* cx, void* data, } static void StatsArenaCallback(JSRuntime* rt, void* data, gc::Arena* arena, - JS::TraceKind traceKind, size_t thingSize) { + JS::TraceKind traceKind, size_t thingSize, + const JS::AutoRequireNoGC& nogc) { RuntimeStats* rtStats = static_cast(data)->rtStats; // The admin space includes (a) the header fields and (b) the padding @@ -325,7 +328,8 @@ static void CollectScriptSourceStats(StatsClosure* closure, ScriptSource* ss) { // profile speed for complex pages such as gmail.com. template static void StatsCellCallback(JSRuntime* rt, void* data, JS::GCCellPtr cellptr, - size_t thingSize) { + size_t thingSize, + const JS::AutoRequireNoGC& nogc) { StatsClosure* closure = static_cast(data); RuntimeStats* rtStats = closure->rtStats; ZoneStats* zStats = rtStats->currZoneStats; @@ -794,11 +798,11 @@ class SimpleJSRuntimeStats : public JS::RuntimeStats { explicit SimpleJSRuntimeStats(MallocSizeOf mallocSizeOf) : JS::RuntimeStats(mallocSizeOf) {} - virtual void initExtraZoneStats(JS::Zone* zone, - JS::ZoneStats* zStats) override {} + virtual void initExtraZoneStats(JS::Zone* zone, JS::ZoneStats* zStats, + const JS::AutoRequireNoGC& nogc) override {} - virtual void initExtraRealmStats(Handle realm, - JS::RealmStats* realmStats) override {} + virtual void initExtraRealmStats(Realm* realm, JS::RealmStats* realmStats, + const JS::AutoRequireNoGC& nogc) override {} }; JS_PUBLIC_API bool AddSizeOfTab(JSContext* cx, HandleObject obj, diff --git a/js/src/vm/Realm.cpp b/js/src/vm/Realm.cpp index 29a9f14d8db8..cf4f7cc9fa2c 100644 --- a/js/src/vm/Realm.cpp +++ b/js/src/vm/Realm.cpp @@ -872,7 +872,7 @@ JS_PUBLIC_API void JS::SetRealmNameCallback(JSContext* cx, cx->runtime()->realmNameCallback = callback; } -JS_PUBLIC_API JSObject* JS::GetRealmGlobalOrNull(Handle realm) { +JS_PUBLIC_API JSObject* JS::GetRealmGlobalOrNull(JS::Realm* realm) { return realm->maybeGlobal(); } diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 22aced81a531..ec5e0eae3f90 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -2044,7 +2044,8 @@ class JSMainRuntimeRealmsReporter final : public nsIMemoryReporter { js::Vector paths; }; - static void RealmCallback(JSContext* cx, void* vdata, Handle realm) { + static void RealmCallback(JSContext* cx, void* vdata, Realm* realm, + const JS::AutoRequireNoGC& nogc) { // silently ignore OOM errors Data* data = static_cast(vdata); nsCString path; @@ -2147,8 +2148,8 @@ class XPCJSRuntimeStats : public JS::RuntimeStats { } } - virtual void initExtraZoneStats(JS::Zone* zone, - JS::ZoneStats* zStats) override { + virtual void initExtraZoneStats(JS::Zone* zone, JS::ZoneStats* zStats, + const JS::AutoRequireNoGC& nogc) override { xpc::ZoneStatsExtras* extras = new xpc::ZoneStatsExtras; extras->pathPrefix.AssignLiteral("explicit/js-non-window/zones/"); @@ -2174,8 +2175,8 @@ class XPCJSRuntimeStats : public JS::RuntimeStats { zStats->extra = extras; } - virtual void initExtraRealmStats(Handle realm, - JS::RealmStats* realmStats) override { + virtual void initExtraRealmStats(Realm* realm, JS::RealmStats* realmStats, + const JS::AutoRequireNoGC& nogc) override { xpc::RealmStatsExtras* extras = new xpc::RealmStatsExtras; nsCString rName; GetRealmName(realm, rName, &mAnonymizeID, /* replaceSlashes = */ true); @@ -2661,8 +2662,9 @@ static void SetUseCounterCallback(JSObject* obj, JSUseCounter counter) { } } -static void GetRealmNameCallback(JSContext* cx, Handle realm, char* buf, - size_t bufsize) { +static void GetRealmNameCallback(JSContext* cx, Realm* realm, char* buf, + size_t bufsize, + const JS::AutoRequireNoGC& nogc) { nsCString name; // This is called via the JSAPI and isn't involved in memory reporting, so // we don't need to anonymize realm names. diff --git a/js/xpconnect/src/XPCWrappedNativeScope.cpp b/js/xpconnect/src/XPCWrappedNativeScope.cpp index 775a0189e20b..923d78a70fa8 100644 --- a/js/xpconnect/src/XPCWrappedNativeScope.cpp +++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp @@ -478,7 +478,8 @@ void XPCWrappedNativeScope::AddSizeOfIncludingThis( scopeSizeInfo->mScopeAndMapSize += mWrappedNativeProtoMap->SizeOfIncludingThis(scopeSizeInfo->mMallocSizeOf); - auto realmCb = [](JSContext*, void* aData, JS::Handle aRealm) { + auto realmCb = [](JSContext*, void* aData, JS::Realm* aRealm, + const JS::AutoRequireNoGC& nogc) { auto* scopeSizeInfo = static_cast(aData); JSObject* global = GetRealmGlobalOrNull(aRealm); if (global && dom::HasProtoAndIfaceCache(global)) { diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index 07fd3ec467c7..4fa03c3063f9 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -436,7 +436,8 @@ bool TraversalTracer::onChild(const JS::GCCellPtr& aThing) { return true; } -static void NoteJSChildGrayWrapperShim(void* aData, JS::GCCellPtr aThing) { +static void NoteJSChildGrayWrapperShim(void* aData, JS::GCCellPtr aThing, + const JS::AutoRequireNoGC& nogc) { TraversalTracer* trc = static_cast(aData); trc->onChild(aThing); } @@ -926,8 +927,8 @@ void CycleCollectedJSRuntime::TraverseZone( } /* static */ -void CycleCollectedJSRuntime::TraverseObjectShim(void* aData, - JS::GCCellPtr aThing) { +void CycleCollectedJSRuntime::TraverseObjectShim( + void* aData, JS::GCCellPtr aThing, const JS::AutoRequireNoGC& nogc) { TraverseObjectShimClosure* closure = static_cast(aData); diff --git a/xpcom/base/CycleCollectedJSRuntime.h b/xpcom/base/CycleCollectedJSRuntime.h index 64226a4e09c2..72db47428d0a 100644 --- a/xpcom/base/CycleCollectedJSRuntime.h +++ b/xpcom/base/CycleCollectedJSRuntime.h @@ -198,7 +198,8 @@ class CycleCollectedJSRuntime { void TraverseZone(JS::Zone* aZone, nsCycleCollectionTraversalCallback& aCb); - static void TraverseObjectShim(void* aData, JS::GCCellPtr aThing); + static void TraverseObjectShim(void* aData, JS::GCCellPtr aThing, + const JS::AutoRequireNoGC& nogc); void TraverseNativeRoots(nsCycleCollectionNoteRootCallback& aCb);