Bug 1757956 - Part 3: Rename JSFreeOp to JS::GCContext in the JS engine r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D140525
This commit is contained in:
Jon Coppeard 2022-03-10 08:40:03 +00:00
parent 5c41d580bc
commit d40ccf2be0
148 changed files with 726 additions and 707 deletions

View File

@ -488,7 +488,7 @@ class nsOuterWindowProxy : public MaybeCrossOriginObject<js::Wrapper> {
const char* className(JSContext* cx,
JS::Handle<JSObject*> wrapper) const override;
void finalize(JSFreeOp* fop, JSObject* proxy) const override;
void finalize(JS::GCContext* gcx, JSObject* proxy) const override;
size_t objectMoved(JSObject* proxy, JSObject* old) const override;
bool isCallable(JSObject* obj) const override { return false; }
@ -556,7 +556,7 @@ const char* nsOuterWindowProxy::className(JSContext* cx,
return "Window";
}
void nsOuterWindowProxy::finalize(JSFreeOp* fop, JSObject* proxy) const {
void nsOuterWindowProxy::finalize(JS::GCContext* gcx, JSObject* proxy) const {
nsGlobalWindowOuter* outerWindow = GetOuterWindow(proxy);
if (outerWindow) {
outerWindow->ClearWrapper(proxy);

View File

@ -2792,7 +2792,7 @@ bool ConvertJSValueToByteString(BindingCallContext& cx, JS::Handle<JS::Value> v,
return true;
}
void FinalizeGlobal(JSFreeOp* aFreeOp, JSObject* aObj) {
void FinalizeGlobal(JS::GCContext* aGcx, JSObject* aObj) {
MOZ_ASSERT(JS::GetClass(aObj)->flags & JSCLASS_DOM_GLOBAL);
mozilla::dom::DestroyProtoAndIfaceCache(aObj);
}

View File

@ -2815,7 +2815,7 @@ class GetCCParticipant<T, true> {
static constexpr nsCycleCollectionParticipant* Get() { return nullptr; }
};
void FinalizeGlobal(JSFreeOp* aFop, JSObject* aObj);
void FinalizeGlobal(JS::GCContext* aGcx, JSObject* aObj);
bool ResolveGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj,
JS::Handle<jsid> aId, bool* aResolvedp);

View File

@ -2120,7 +2120,7 @@ class CGGetWrapperCacheHook(CGAbstractClassHook):
)
def finalizeHook(descriptor, hookName, freeOp, obj):
def finalizeHook(descriptor, hookName, gcx, obj):
finalize = "JS::SetReservedSlot(%s, DOM_OBJECT_SLOT, JS::UndefinedValue());\n" % obj
if descriptor.interface.getExtendedAttribute("LegacyOverrideBuiltIns"):
finalize += fill(
@ -2148,7 +2148,7 @@ def finalizeHook(descriptor, hookName, freeOp, obj):
if descriptor.wrapperCache:
finalize += "ClearWrapper(self, self, %s);\n" % obj
if descriptor.isGlobal():
finalize += "mozilla::dom::FinalizeGlobal(%s, %s);\n" % (freeOp, obj)
finalize += "mozilla::dom::FinalizeGlobal(%s, %s);\n" % (gcx, obj)
finalize += fill(
"""
if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) {
@ -2168,7 +2168,7 @@ class CGClassFinalizeHook(CGAbstractClassHook):
"""
def __init__(self, descriptor):
args = [Argument("JSFreeOp*", "fop"), Argument("JSObject*", "obj")]
args = [Argument("JS::GCContext*", "gcx"), Argument("JSObject*", "obj")]
CGAbstractClassHook.__init__(self, descriptor, FINALIZE_HOOK_NAME, "void", args)
def generate_code(self):
@ -15637,7 +15637,7 @@ class CGDOMJSProxyHandler_finalizeInBackground(ClassMethod):
class CGDOMJSProxyHandler_finalize(ClassMethod):
def __init__(self, descriptor):
args = [Argument("JSFreeOp*", "fop"), Argument("JSObject*", "proxy")]
args = [Argument("JS::GCContext*", "gcx"), Argument("JSObject*", "proxy")]
ClassMethod.__init__(
self, "finalize", "void", args, virtual=True, override=True, const=True
)

View File

@ -138,7 +138,7 @@ class RemoteObjectProxyBase : public js::BaseProxyHandler,
template <class Native, const CrossOriginProperties& P>
class RemoteObjectProxy : public RemoteObjectProxyBase {
public:
void finalize(JSFreeOp* aFop, JSObject* aProxy) const final {
void finalize(JS::GCContext* aGcx, JSObject* aProxy) const final {
auto native = static_cast<Native*>(GetNative(aProxy));
RefPtr<Native> self(dont_AddRef(native));
}

View File

@ -43,7 +43,7 @@ NS_INTERFACE_MAP_END
static SimpleGlobalObject* GetSimpleGlobal(JSObject* global);
static void SimpleGlobal_finalize(JSFreeOp* fop, JSObject* obj) {
static void SimpleGlobal_finalize(JS::GCContext* gcx, JSObject* obj) {
SimpleGlobalObject* globalObject = GetSimpleGlobal(obj);
if (globalObject) {
globalObject->ClearWrapper(obj);

View File

@ -291,7 +291,7 @@ typedef bool (*JSMayResolveOp)(const JSAtomState& names, jsid id,
* from other live objects or from GC roots. Obviously, finalizers must never
* store a reference to obj.
*/
typedef void (*JSFinalizeOp)(JSFreeOp* fop, JSObject* obj);
typedef void (*JSFinalizeOp)(JS::GCContext* gcx, JSObject* obj);
/**
* Check whether v is an instance of obj. Return false on error or exception,
@ -652,9 +652,9 @@ struct alignas(js::gc::JSClassAlignBytes) JSClass {
// The special treatment of |finalize| and |trace| is necessary because if we
// assign either of those hooks to a local variable and then call it -- as is
// done with the other hooks -- the GC hazard analysis gets confused.
void doFinalize(JSFreeOp* fop, JSObject* obj) const {
void doFinalize(JS::GCContext* gcx, JSObject* obj) const {
MOZ_ASSERT(cOps && cOps->finalize);
cOps->finalize(fop, obj);
cOps->finalize(gcx, obj);
}
void doTrace(JSTracer* trc, JSObject* obj) const {
MOZ_ASSERT(cOps && cOps->trace);

View File

@ -492,7 +492,7 @@ typedef enum JSFinalizeStatus {
JSFINALIZE_COLLECTION_END
} JSFinalizeStatus;
typedef void (*JSFinalizeCallback)(JSFreeOp* fop, JSFinalizeStatus status,
typedef void (*JSFinalizeCallback)(JS::GCContext* gcx, JSFinalizeStatus status,
void* data);
typedef void (*JSWeakPointerZonesCallback)(JSTracer* trc, void* data);

View File

@ -356,7 +356,7 @@ class JS_PUBLIC_API BaseProxyHandler {
virtual bool boxedValue_unbox(JSContext* cx, JS::HandleObject proxy,
JS::MutableHandleValue vp) const;
virtual void trace(JSTracer* trc, JSObject* proxy) const;
virtual void finalize(JSFreeOp* fop, JSObject* proxy) const;
virtual void finalize(JS::GCContext* gcx, JSObject* proxy) const;
virtual size_t objectMoved(JSObject* proxy, JSObject* old) const;
// Allow proxies, wrappers in particular, to specify callability at runtime.

View File

@ -61,7 +61,7 @@ extern JS_PUBLIC_API void* GetRealmPrivate(Realm* realm);
// Set the "private data" internal field of the given Realm.
extern JS_PUBLIC_API void SetRealmPrivate(Realm* realm, void* data);
typedef void (*DestroyRealmCallback)(JSFreeOp* fop, Realm* realm);
typedef void (*DestroyRealmCallback)(JS::GCContext* gcx, Realm* realm);
// Set the callback SpiderMonkey calls just before garbage-collecting a realm.
// Embeddings can use this callback to free private data associated with the

View File

@ -28,7 +28,6 @@ class JS_PUBLIC_API JSAtom;
struct JS_PUBLIC_API JSContext;
struct JSClass;
class JS_PUBLIC_API JSFunction;
class JS_PUBLIC_API JSFreeOp;
class JS_PUBLIC_API JSObject;
struct JS_PUBLIC_API JSRuntime;
class JS_PUBLIC_API JSScript;
@ -42,6 +41,7 @@ class JS_PUBLIC_API TempAllocPolicy;
namespace JS {
class JS_PUBLIC_API GCContext;
class JS_PUBLIC_API PropertyKey;
typedef unsigned char Latin1Char;

View File

@ -462,9 +462,9 @@ static inline void js_free(void* p) {
* - Ordinarily, use js_free/js_delete.
*
* - For deallocations during GC finalization, use one of the following
* operations on the JSFreeOp provided to the finalizer:
* operations on the JS::GCContext provided to the finalizer:
*
* JSFreeOp::{free_,delete_}
* JS::GCContext::{free_,delete_}
*/
/*

View File

@ -34,9 +34,9 @@
// can operate on one or more zones at a time. The browser uses roughly one zone
// per tab.
using JSDestroyZoneCallback = void (*)(JSFreeOp*, JS::Zone*);
using JSDestroyZoneCallback = void (*)(JS::GCContext*, JS::Zone*);
using JSDestroyCompartmentCallback = void (*)(JSFreeOp*, JS::Compartment*);
using JSDestroyCompartmentCallback = void (*)(JS::GCContext*, JS::Compartment*);
using JSSizeOfIncludingThisCompartmentCallback =
size_t (*)(mozilla::MallocSizeOf, JS::Compartment*);

View File

@ -137,9 +137,10 @@ void FinalizationRegistrationsObject::trace(JSTracer* trc, JSObject* obj) {
}
/* static */
void FinalizationRegistrationsObject::finalize(JSFreeOp* fop, JSObject* obj) {
void FinalizationRegistrationsObject::finalize(JS::GCContext* gcx,
JSObject* obj) {
auto* self = &obj->as<FinalizationRegistrationsObject>();
fop->delete_(obj, self->records(), MemoryUse::FinalizationRecordVector);
gcx->delete_(obj, self->records(), MemoryUse::FinalizationRecordVector);
}
inline WeakFinalizationRecordVector*
@ -313,14 +314,14 @@ void FinalizationRegistryObject::traceWeak(JSTracer* trc) {
}
/* static */
void FinalizationRegistryObject::finalize(JSFreeOp* fop, JSObject* obj) {
void FinalizationRegistryObject::finalize(JS::GCContext* gcx, JSObject* obj) {
auto registry = &obj->as<FinalizationRegistryObject>();
// The queue's flag should have been updated by
// GCRuntime::sweepFinalizationRegistries.
MOZ_ASSERT_IF(registry->queue(), !registry->queue()->hasRegistry());
fop->delete_(obj, registry->registrations(),
gcx->delete_(obj, registry->registrations(),
MemoryUse::FinalizationRegistryRegistrations);
}
@ -715,10 +716,10 @@ void FinalizationQueueObject::trace(JSTracer* trc, JSObject* obj) {
}
/* static */
void FinalizationQueueObject::finalize(JSFreeOp* fop, JSObject* obj) {
void FinalizationQueueObject::finalize(JS::GCContext* gcx, JSObject* obj) {
auto queue = &obj->as<FinalizationQueueObject>();
fop->delete_(obj, queue->recordsToBeCleanedUp(),
gcx->delete_(obj, queue->recordsToBeCleanedUp(),
MemoryUse::FinalizationRegistryRecordVector);
}

View File

@ -171,7 +171,7 @@ class FinalizationRegistrationsObject : public NativeObject {
void* privatePtr() const;
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
using FinalizationRecordVector =
@ -218,7 +218,7 @@ class FinalizationRegistryObject : public NativeObject {
static bool preserveDOMWrapper(JSContext* cx, HandleObject obj);
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
// Contains information about the cleanup callback and the records queued to
@ -266,7 +266,7 @@ class FinalizationQueueObject : public NativeObject {
static bool doCleanup(JSContext* cx, unsigned argc, Value* vp);
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
} // namespace js

View File

@ -313,16 +313,16 @@ MapIteratorObject* MapIteratorObject::create(JSContext* cx, HandleObject obj,
return iterobj;
}
void MapIteratorObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void MapIteratorObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
MOZ_ASSERT(!IsInsideNursery(obj));
auto range = MapIteratorObjectRange(&obj->as<NativeObject>());
MOZ_ASSERT(!fop->runtime()->gc.nursery().isInside(range));
MOZ_ASSERT(!gcx->runtime()->gc.nursery().isInside(range));
// Bug 1560019: Malloc memory associated with MapIteratorObjects is not
// currently tracked.
fop->deleteUntracked(range);
gcx->deleteUntracked(range);
}
size_t MapIteratorObject::objectMoved(JSObject* obj, JSObject* old) {
@ -712,18 +712,18 @@ size_t MapObject::sizeOfData(mozilla::MallocSizeOf mallocSizeOf) {
return size;
}
void MapObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void MapObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
if (ValueMap* map = obj->as<MapObject>().getData()) {
fop->delete_(obj, map, MemoryUse::MapObjectTable);
gcx->delete_(obj, map, MemoryUse::MapObjectTable);
}
}
/* static */
void MapObject::sweepAfterMinorGC(JSFreeOp* fop, MapObject* mapobj) {
void MapObject::sweepAfterMinorGC(JS::GCContext* gcx, MapObject* mapobj) {
bool wasInsideNursery = IsInsideNursery(mapobj);
if (wasInsideNursery && !IsForwarded(mapobj)) {
finalize(fop, mapobj);
finalize(gcx, mapobj);
return;
}
@ -1118,16 +1118,16 @@ SetIteratorObject* SetIteratorObject::create(JSContext* cx, HandleObject obj,
return iterobj;
}
void SetIteratorObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void SetIteratorObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
MOZ_ASSERT(!IsInsideNursery(obj));
auto range = SetIteratorObjectRange(&obj->as<NativeObject>());
MOZ_ASSERT(!fop->runtime()->gc.nursery().isInside(range));
MOZ_ASSERT(!gcx->runtime()->gc.nursery().isInside(range));
// Bug 1560019: Malloc memory associated with SetIteratorObjects is not
// currently tracked.
fop->deleteUntracked(range);
gcx->deleteUntracked(range);
}
size_t SetIteratorObject::objectMoved(JSObject* obj, JSObject* old) {
@ -1385,19 +1385,19 @@ size_t SetObject::sizeOfData(mozilla::MallocSizeOf mallocSizeOf) {
return size;
}
void SetObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void SetObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
SetObject* setobj = static_cast<SetObject*>(obj);
if (ValueSet* set = setobj->getData()) {
fop->delete_(obj, set, MemoryUse::MapObjectTable);
gcx->delete_(obj, set, MemoryUse::MapObjectTable);
}
}
/* static */
void SetObject::sweepAfterMinorGC(JSFreeOp* fop, SetObject* setobj) {
void SetObject::sweepAfterMinorGC(JS::GCContext* gcx, SetObject* setobj) {
bool wasInsideNursery = IsInsideNursery(setobj);
if (wasInsideNursery && !IsForwarded(setobj)) {
finalize(fop, setobj);
finalize(gcx, setobj);
return;
}

View File

@ -143,7 +143,7 @@ class MapObject : public NativeObject {
OrderedHashMap<Value, Value, UnbarrieredHashPolicy, ZoneAllocPolicy>;
friend class OrderedHashTableRef<MapObject>;
static void sweepAfterMinorGC(JSFreeOp* fop, MapObject* mapobj);
static void sweepAfterMinorGC(JS::GCContext* gcx, MapObject* mapobj);
size_t sizeOfData(mozilla::MallocSizeOf mallocSizeOf);
@ -169,7 +169,7 @@ class MapObject : public NativeObject {
static ValueMap& extract(HandleObject o);
static ValueMap& extract(const CallArgs& args);
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
[[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
static bool is(HandleValue v);
@ -214,7 +214,7 @@ class MapIteratorObject : public NativeObject {
static MapIteratorObject* create(JSContext* cx, HandleObject mapobj,
ValueMap* data,
MapObject::IteratorKind kind);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
static size_t objectMoved(JSObject* obj, JSObject* old);
void init(MapObject* mapObj, MapObject::IteratorKind kind) {
@ -276,7 +276,7 @@ class SetObject : public NativeObject {
OrderedHashSet<Value, UnbarrieredHashPolicy, ZoneAllocPolicy>;
friend class OrderedHashTableRef<SetObject>;
static void sweepAfterMinorGC(JSFreeOp* fop, SetObject* setobj);
static void sweepAfterMinorGC(JS::GCContext* gcx, SetObject* setobj);
size_t sizeOfData(mozilla::MallocSizeOf mallocSizeOf);
@ -299,7 +299,7 @@ class SetObject : public NativeObject {
static ValueSet& extract(HandleObject o);
static ValueSet& extract(const CallArgs& args);
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
static bool construct(JSContext* cx, unsigned argc, Value* vp);
static bool is(HandleValue v);
@ -342,7 +342,7 @@ class SetIteratorObject : public NativeObject {
static SetIteratorObject* create(JSContext* cx, HandleObject setobj,
ValueSet* data,
SetObject::IteratorKind kind);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
static size_t objectMoved(JSObject* obj, JSObject* old);
void init(SetObject* setObj, SetObject::IteratorKind kind) {

View File

@ -754,12 +754,12 @@ void ModuleNamespaceObject::ProxyHandler::trace(JSTracer* trc,
}
}
void ModuleNamespaceObject::ProxyHandler::finalize(JSFreeOp* fop,
void ModuleNamespaceObject::ProxyHandler::finalize(JS::GCContext* gcx,
JSObject* proxy) const {
auto& self = proxy->as<ModuleNamespaceObject>();
if (self.hasBindings()) {
fop->delete_(proxy, &self.bindings(), MemoryUse::ModuleBindingMap);
gcx->delete_(proxy, &self.bindings(), MemoryUse::ModuleBindingMap);
}
}
@ -854,15 +854,15 @@ ModuleObject* ModuleObject::create(JSContext* cx) {
}
/* static */
void ModuleObject::finalize(JSFreeOp* fop, JSObject* obj) {
void ModuleObject::finalize(JS::GCContext* gcx, JSObject* obj) {
ModuleObject* self = &obj->as<ModuleObject>();
if (self->hasImportBindings()) {
fop->delete_(obj, &self->importBindings(), MemoryUse::ModuleBindingMap);
gcx->delete_(obj, &self->importBindings(), MemoryUse::ModuleBindingMap);
}
if (frontend::FunctionDeclarationVector* funDecls =
GetFunctionDeclarations(self)) {
// Not tracked as these may move between zones on merge.
fop->deleteUntracked(funDecls);
gcx->deleteUntracked(funDecls);
}
}

View File

@ -34,7 +34,6 @@
#include "vm/PromiseObject.h" // js::PromiseObject
#include "vm/ProxyObject.h" // ProxyObject
class JSFreeOp;
class JSScript;
class JSTracer;
@ -243,7 +242,7 @@ class ModuleNamespaceObject : public ProxyObject {
HandleValue receiver, ObjectOpResult& result) const override;
void trace(JSTracer* trc, JSObject* proxy) const override;
void finalize(JSFreeOp* fop, JSObject* proxy) const override;
void finalize(JS::GCContext* gcx, JSObject* proxy) const override;
static const char family;
};
@ -416,7 +415,7 @@ class ModuleObject : public NativeObject {
static const JSClassOps classOps_;
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
bool hasImportBindings() const;
};

View File

@ -352,7 +352,8 @@ static const JSPropertySpec ReadableByteStreamController_properties[] = {
static const JSFunctionSpec ReadableByteStreamController_methods[] = {
JS_FS_END};
static void ReadableByteStreamControllerFinalize(JSFreeOp* fop, JSObject* obj) {
static void ReadableByteStreamControllerFinalize(JS::GCContext* gcx,
JSObject* obj) {
ReadableByteStreamController& controller =
obj->as<ReadableByteStreamController>();

View File

@ -3894,7 +3894,7 @@ static bool StreamsAreEnabled(JSContext* cx, unsigned argc, Value* vp) {
static unsigned finalizeCount = 0;
static void finalize_counter_finalize(JSFreeOp* fop, JSObject* obj) {
static void finalize_counter_finalize(JS::GCContext* gcx, JSObject* obj) {
++finalizeCount;
}
@ -4663,7 +4663,7 @@ class CloneBufferObject : public NativeObject {
return CallNonGenericMethod<is, getCloneBufferAsArrayBuffer_impl>(cx, args);
}
static void Finalize(JSFreeOp* fop, JSObject* obj) {
static void Finalize(JS::GCContext* gcx, JSObject* obj) {
obj->as<CloneBufferObject>().discard();
}
};
@ -5026,7 +5026,7 @@ class ShapeSnapshotObject : public NativeObject {
static ShapeSnapshotObject* create(JSContext* cx, HandleObject obj);
static void finalize(JSFreeOp* fop, JSObject* obj) {
static void finalize(JS::GCContext* gcx, JSObject* obj) {
if (obj->as<ShapeSnapshotObject>().hasSnapshot()) {
js_delete(&obj->as<ShapeSnapshotObject>().snapshot());
}

View File

@ -189,9 +189,9 @@ static void WeakCollection_trace(JSTracer* trc, JSObject* obj) {
}
}
static void WeakCollection_finalize(JSFreeOp* fop, JSObject* obj) {
static void WeakCollection_finalize(JS::GCContext* gcx, JSObject* obj) {
if (ObjectValueWeakMap* map = obj->as<WeakCollectionObject>().getMap()) {
fop->delete_(obj, map, MemoryUse::WeakMapObject);
gcx->delete_(obj, map, MemoryUse::WeakMapObject);
}
}

View File

@ -123,7 +123,7 @@ void WeakRefObject::trace(JSTracer* trc, JSObject* obj) {
}
/* static */
void WeakRefObject::finalize(JSFreeOp* fop, JSObject* obj) {
void WeakRefObject::finalize(JS::GCContext* gcx, JSObject* obj) {
// The target is cleared when the target's zone is swept and that always
// happens before this object is finalized because of the CCW from the target
// zone to this object. If the CCW is nuked, the target is cleared in

View File

@ -31,7 +31,7 @@ class WeakRefObject : public NativeObject {
[[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* op, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
static bool preserveDOMWrapper(JSContext* cx, HandleObject obj);

View File

@ -140,11 +140,11 @@ bool js::intl_Collator(JSContext* cx, unsigned argc, Value* vp) {
return Collator(cx, args);
}
void js::CollatorObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void js::CollatorObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
if (mozilla::intl::Collator* coll = obj->as<CollatorObject>().getCollator()) {
intl::RemoveICUCellMemory(fop, obj, CollatorObject::EstimatedMemoryUse);
intl::RemoveICUCellMemory(gcx, obj, CollatorObject::EstimatedMemoryUse);
delete coll;
}
}

View File

@ -53,7 +53,7 @@ class CollatorObject : public NativeObject {
static const JSClassOps classOps_;
static const ClassSpec classSpec_;
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
/**

View File

@ -143,7 +143,7 @@ void js::intl::AddICUCellMemory(JSObject* obj, size_t nbytes) {
AddCellMemory(obj, nbytes, MemoryUse::ICUObject);
}
void js::intl::RemoveICUCellMemory(JSFreeOp* fop, JSObject* obj,
void js::intl::RemoveICUCellMemory(JS::GCContext* gcx, JSObject* obj,
size_t nbytes) {
fop->removeCellMemory(obj, nbytes, MemoryUse::ICUObject);
gcx->removeCellMemory(obj, nbytes, MemoryUse::ICUObject);
}

View File

@ -102,7 +102,7 @@ constexpr size_t INITIAL_CHAR_BUFFER_SIZE = 32;
void AddICUCellMemory(JSObject* obj, size_t nbytes);
void RemoveICUCellMemory(JSFreeOp* fop, JSObject* obj, size_t nbytes);
void RemoveICUCellMemory(JS::GCContext* gcx, JSObject* obj, size_t nbytes);
} // namespace intl
} // namespace js

View File

@ -183,8 +183,8 @@ bool js::intl_DateTimeFormat(JSContext* cx, unsigned argc, Value* vp) {
return DateTimeFormat(cx, args, true, DateTimeFormatOptions::Standard);
}
void js::DateTimeFormatObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void js::DateTimeFormatObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
auto* dateTimeFormat = &obj->as<DateTimeFormatObject>();
mozilla::intl::DateTimeFormat* df = dateTimeFormat->getDateFormat();
@ -193,14 +193,14 @@ void js::DateTimeFormatObject::finalize(JSFreeOp* fop, JSObject* obj) {
if (df) {
intl::RemoveICUCellMemory(
fop, obj, DateTimeFormatObject::UDateFormatEstimatedMemoryUse);
gcx, obj, DateTimeFormatObject::UDateFormatEstimatedMemoryUse);
delete df;
}
if (dif) {
intl::RemoveICUCellMemory(
fop, obj, DateTimeFormatObject::UDateIntervalFormatEstimatedMemoryUse);
gcx, obj, DateTimeFormatObject::UDateIntervalFormatEstimatedMemoryUse);
delete dif;
}

View File

@ -69,7 +69,7 @@ class DateTimeFormatObject : public NativeObject {
static const JSClassOps classOps_;
static const ClassSpec classSpec_;
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
/**

View File

@ -198,12 +198,12 @@ static bool MozDisplayNames(JSContext* cx, unsigned argc, Value* vp) {
return DisplayNames(cx, args, DisplayNamesOptions::EnableMozExtensions);
}
void js::DisplayNamesObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void js::DisplayNamesObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
if (mozilla::intl::DisplayNames* displayNames =
obj->as<DisplayNamesObject>().getDisplayNames()) {
intl::RemoveICUCellMemory(fop, obj, DisplayNamesObject::EstimatedMemoryUse);
intl::RemoveICUCellMemory(gcx, obj, DisplayNamesObject::EstimatedMemoryUse);
delete displayNames;
}
}

View File

@ -15,13 +15,13 @@
#include "builtin/SelfHostingDefines.h"
#include "js/Class.h" // JSClass, JSClassOps, js::ClassSpec
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "vm/JSObject.h"
#include "vm/List.h"
#include "vm/NativeObject.h"
struct JS_PUBLIC_API JSContext;
class JS_PUBLIC_API JSFreeOp;
namespace mozilla::intl {
class DisplayNames;
@ -62,7 +62,7 @@ class DisplayNamesObject : public NativeObject {
static const JSClassOps classOps_;
static const ClassSpec classSpec_;
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
/**

View File

@ -125,13 +125,13 @@ static bool ListFormat(JSContext* cx, unsigned argc, Value* vp) {
return true;
}
void js::ListFormatObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void js::ListFormatObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
mozilla::intl::ListFormat* lf =
obj->as<ListFormatObject>().getListFormatSlot();
if (lf) {
intl::RemoveICUCellMemory(fop, obj, ListFormatObject::EstimatedMemoryUse);
intl::RemoveICUCellMemory(gcx, obj, ListFormatObject::EstimatedMemoryUse);
delete lf;
}
}

View File

@ -12,10 +12,9 @@
#include "builtin/SelfHostingDefines.h"
#include "js/Class.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "vm/NativeObject.h"
class JSFreeOp;
namespace mozilla::intl {
class ListFormat;
} // namespace mozilla::intl
@ -54,7 +53,7 @@ class ListFormatObject : public NativeObject {
static const JSClassOps classOps_;
static const ClassSpec classSpec_;
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
/**

View File

@ -176,8 +176,8 @@ bool js::intl_NumberFormat(JSContext* cx, unsigned argc, Value* vp) {
return NumberFormat(cx, args, true);
}
void js::NumberFormatObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void js::NumberFormatObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
auto* numberFormat = &obj->as<NumberFormatObject>();
mozilla::intl::NumberFormat* nf = numberFormat->getNumberFormatter();
@ -185,14 +185,14 @@ void js::NumberFormatObject::finalize(JSFreeOp* fop, JSObject* obj) {
numberFormat->getNumberRangeFormatter();
if (nf) {
intl::RemoveICUCellMemory(fop, obj, NumberFormatObject::EstimatedMemoryUse);
intl::RemoveICUCellMemory(gcx, obj, NumberFormatObject::EstimatedMemoryUse);
// This was allocated using `new` in mozilla::intl::NumberFormat, so we
// delete here.
delete nf;
}
if (nrf) {
intl::RemoveICUCellMemory(fop, obj, EstimatedRangeFormatterMemoryUse);
intl::RemoveICUCellMemory(gcx, obj, EstimatedRangeFormatterMemoryUse);
// This was allocated using `new` in mozilla::intl::NumberRangeFormat, so we
// delete here.
delete nrf;

View File

@ -72,7 +72,7 @@ class NumberFormatObject : public NativeObject {
static const JSClassOps classOps_;
static const ClassSpec classSpec_;
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
/**

View File

@ -129,13 +129,13 @@ static bool PluralRules(JSContext* cx, unsigned argc, Value* vp) {
return true;
}
void js::PluralRulesObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void js::PluralRulesObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
auto* pluralRules = &obj->as<PluralRulesObject>();
if (mozilla::intl::PluralRules* pr = pluralRules->getPluralRules()) {
intl::RemoveICUCellMemory(
fop, obj, PluralRulesObject::UPluralRulesEstimatedMemoryUse);
gcx, obj, PluralRulesObject::UPluralRulesEstimatedMemoryUse);
delete pr;
}
}

View File

@ -53,7 +53,7 @@ class PluralRulesObject : public NativeObject {
static const JSClassOps classOps_;
static const ClassSpec classSpec_;
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
/**

View File

@ -132,12 +132,12 @@ static bool RelativeTimeFormat(JSContext* cx, unsigned argc, Value* vp) {
return true;
}
void js::RelativeTimeFormatObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void js::RelativeTimeFormatObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
if (mozilla::intl::RelativeTimeFormat* rtf =
obj->as<RelativeTimeFormatObject>().getRelativeTimeFormatter()) {
intl::RemoveICUCellMemory(fop, obj,
intl::RemoveICUCellMemory(gcx, obj,
RelativeTimeFormatObject::EstimatedMemoryUse);
// This was allocated using `new` in mozilla::intl::RelativeTimeFormat,

View File

@ -55,7 +55,7 @@ class RelativeTimeFormatObject : public NativeObject {
static const JSClassOps classOps_;
static const ClassSpec classSpec_;
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
/**

View File

@ -142,7 +142,7 @@ static bool ConstructBasic(JSContext* cx, HandleObject obj,
const CallArgs& args);
static void Trace(JSTracer* trc, JSObject* obj);
static void Finalize(JSFreeOp* fop, JSObject* obj);
static void Finalize(JS::GCContext* gcx, JSObject* obj);
bool IsCType(HandleValue v);
bool IsCTypeOrProto(HandleValue v);
@ -248,7 +248,7 @@ bool IsVariadicGetter(JSContext* cx, const JS::CallArgs& args);
namespace CClosure {
static void Trace(JSTracer* trc, JSObject* obj);
static void Finalize(JSFreeOp* fop, JSObject* obj);
static void Finalize(JS::GCContext* gcx, JSObject* obj);
// libffi callback
static void ClosureStub(ffi_cif* cif, void* result, void** args,
@ -269,7 +269,7 @@ struct ArgClosure : public ScriptEnvironmentPreparer::Closure {
} // namespace CClosure
namespace CData {
static void Finalize(JSFreeOp* fop, JSObject* obj);
static void Finalize(JS::GCContext* gcx, JSObject* obj);
bool ValueGetter(JSContext* cx, const JS::CallArgs& args);
bool ValueSetter(JSContext* cx, const JS::CallArgs& args);
@ -391,7 +391,7 @@ static JSObject* GetCType(JSContext* cx, JSObject* obj);
/*
* Perform finalization of a |CDataFinalizer|
*/
static void Finalize(JSFreeOp* fop, JSObject* obj);
static void Finalize(JS::GCContext* gcx, JSObject* obj);
/*
* Return the Value contained by this finalizer.
@ -415,7 +415,7 @@ bool ToString(JSContext* cx, JSObject* obj, const CallArgs& args,
bool ToSource(JSContext* cx, JSObject* obj, const CallArgs& args,
bool isUnsigned);
static void Finalize(JSFreeOp* fop, JSObject* obj);
static void Finalize(JS::GCContext* gcx, JSObject* obj);
} // namespace Int64Base
namespace Int64 {
@ -4452,15 +4452,15 @@ JSObject* CType::DefineBuiltin(JSContext* cx, HandleObject ctypesObj,
return typeObj;
}
static void FinalizeFFIType(JSFreeOp* fop, JSObject* obj, const Value& slot,
size_t elementCount) {
static void FinalizeFFIType(JS::GCContext* gcx, JSObject* obj,
const Value& slot, size_t elementCount) {
ffi_type* ffiType = static_cast<ffi_type*>(slot.toPrivate());
size_t size = elementCount * sizeof(ffi_type*);
fop->free_(obj, ffiType->elements, size, MemoryUse::CTypeFFITypeElements);
fop->delete_(obj, ffiType, MemoryUse::CTypeFFIType);
gcx->free_(obj, ffiType->elements, size, MemoryUse::CTypeFFITypeElements);
gcx->delete_(obj, ffiType, MemoryUse::CTypeFFIType);
}
void CType::Finalize(JSFreeOp* fop, JSObject* obj) {
void CType::Finalize(JS::GCContext* gcx, JSObject* obj) {
// Make sure our TypeCode slot is legit. If it's not, bail.
Value slot = JS::GetReservedSlot(obj, SLOT_TYPECODE);
if (slot.isUndefined()) {
@ -4474,7 +4474,7 @@ void CType::Finalize(JSFreeOp* fop, JSObject* obj) {
slot = JS::GetReservedSlot(obj, SLOT_FNINFO);
if (!slot.isUndefined()) {
auto fninfo = static_cast<FunctionInfo*>(slot.toPrivate());
fop->delete_(obj, fninfo, MemoryUse::CTypeFunctionInfo);
gcx->delete_(obj, fninfo, MemoryUse::CTypeFunctionInfo);
}
break;
}
@ -4487,14 +4487,14 @@ void CType::Finalize(JSFreeOp* fop, JSObject* obj) {
if (!slot.isUndefined()) {
auto info = static_cast<FieldInfoHash*>(slot.toPrivate());
fieldCount = info->count();
fop->delete_(obj, info, MemoryUse::CTypeFieldInfo);
gcx->delete_(obj, info, MemoryUse::CTypeFieldInfo);
}
// Free the ffi_type info.
Value slot = JS::GetReservedSlot(obj, SLOT_FFITYPE);
if (!slot.isUndefined()) {
size_t elementCount = fieldCount != 0 ? fieldCount + 1 : 2;
FinalizeFFIType(fop, obj, slot, elementCount);
FinalizeFFIType(gcx, obj, slot, elementCount);
}
// Free the ffi_type info.
@ -4506,7 +4506,7 @@ void CType::Finalize(JSFreeOp* fop, JSObject* obj) {
Value slot = JS::GetReservedSlot(obj, SLOT_FFITYPE);
if (!slot.isUndefined()) {
size_t elementCount = ArrayType::GetLength(obj);
FinalizeFFIType(fop, obj, slot, elementCount);
FinalizeFFIType(gcx, obj, slot, elementCount);
}
break;
}
@ -7358,7 +7358,7 @@ void CClosure::Trace(JSTracer* trc, JSObject* obj) {
TraceNullableEdge(trc, &cinfo->thisObj, "thisObj");
}
void CClosure::Finalize(JSFreeOp* fop, JSObject* obj) {
void CClosure::Finalize(JS::GCContext* gcx, JSObject* obj) {
// Make sure our ClosureInfo slot is legit. If it's not, bail.
Value slot = JS::GetReservedSlot(obj, SLOT_CLOSUREINFO);
if (slot.isUndefined()) {
@ -7366,7 +7366,7 @@ void CClosure::Finalize(JSFreeOp* fop, JSObject* obj) {
}
ClosureInfo* cinfo = static_cast<ClosureInfo*>(slot.toPrivate());
fop->delete_(obj, cinfo, MemoryUse::CClosureInfo);
gcx->delete_(obj, cinfo, MemoryUse::CClosureInfo);
}
void CClosure::ClosureStub(ffi_cif* cif, void* result, void** args,
@ -7612,7 +7612,7 @@ JSObject* CData::Create(JSContext* cx, HandleObject typeObj,
options);
}
void CData::Finalize(JSFreeOp* fop, JSObject* obj) {
void CData::Finalize(JS::GCContext* gcx, JSObject* obj) {
// Delete our buffer, and the data it contains if we own it.
Value slot = JS::GetReservedSlot(obj, SLOT_OWNS);
if (slot.isUndefined()) {
@ -7630,9 +7630,9 @@ void CData::Finalize(JSFreeOp* fop, JSObject* obj) {
if (owns) {
JSObject* typeObj = &JS::GetReservedSlot(obj, SLOT_CTYPE).toObject();
size_t size = CType::GetSize(typeObj);
fop->free_(obj, *buffer, size, MemoryUse::CDataBuffer);
gcx->free_(obj, *buffer, size, MemoryUse::CDataBuffer);
}
fop->delete_(obj, buffer, MemoryUse::CDataBufferPtr);
gcx->delete_(obj, buffer, MemoryUse::CDataBufferPtr);
}
JSObject* CData::GetCType(JSObject* dataObj) {
@ -8638,7 +8638,7 @@ bool CDataFinalizer::Methods::Dispose(JSContext* cx, unsigned argc, Value* vp) {
* finalizer, cleans up the Private memory and releases all
* strong references.
*/
void CDataFinalizer::Finalize(JSFreeOp* fop, JSObject* obj) {
void CDataFinalizer::Finalize(JS::GCContext* gcx, JSObject* obj) {
CDataFinalizer::Private* p = GetFinalizerPrivate(obj);
if (!p) {
@ -8709,14 +8709,14 @@ JSObject* Int64Base::Construct(JSContext* cx, HandleObject proto, uint64_t data,
return result;
}
void Int64Base::Finalize(JSFreeOp* fop, JSObject* obj) {
void Int64Base::Finalize(JS::GCContext* gcx, JSObject* obj) {
Value slot = JS::GetReservedSlot(obj, SLOT_INT64);
if (slot.isUndefined()) {
return;
}
uint64_t* buffer = static_cast<uint64_t*>(slot.toPrivate());
fop->delete_(obj, buffer, MemoryUse::CTypesInt64);
gcx->delete_(obj, buffer, MemoryUse::CTypesInt64);
}
uint64_t Int64Base::GetInt(JSObject* obj) {

View File

@ -31,7 +31,7 @@ namespace js::ctypes {
*******************************************************************************/
namespace Library {
static void Finalize(JSFreeOp* fop, JSObject* obj);
static void Finalize(JS::GCContext* gcx, JSObject* obj);
static bool Close(JSContext* cx, unsigned argc, Value* vp);
static bool Declare(JSContext* cx, unsigned argc, Value* vp);
@ -222,7 +222,9 @@ static void UnloadLibrary(JSObject* obj) {
}
}
void Library::Finalize(JSFreeOp* fop, JSObject* obj) { UnloadLibrary(obj); }
void Library::Finalize(JS::GCContext* gcx, JSObject* obj) {
UnloadLibrary(obj);
}
bool Library::Open(JSContext* cx, unsigned argc, Value* vp) {
CallArgs args = CallArgsFromVp(argc, vp);

View File

@ -112,13 +112,13 @@ class DebugAPI {
// debuggee edges at a point where the parties concerned are all still
// initialized. This does not update edges to moved GC things which is handled
// via the other trace methods.
static void sweepAll(JSFreeOp* fop);
static void sweepAll(JS::GCContext* gcx);
// Add sweep group edges due to the presence of any debuggers.
[[nodiscard]] static bool findSweepGroupEdges(JSRuntime* rt);
// Remove the debugging information associated with a script.
static void removeDebugScript(JSFreeOp* fop, JSScript* script);
static void removeDebugScript(JS::GCContext* gcx, JSScript* script);
// Delete a Zone's debug script map. Called when a zone is destroyed.
static void deleteDebugScriptMap(DebugScriptMap* map);

View File

@ -15,7 +15,7 @@
#include "debugger/DebugAPI.h" // for DebugAPI
#include "debugger/Debugger.h" // for JSBreakpointSite, Breakpoint
#include "gc/Cell.h" // for TenuredCell
#include "gc/GCContext.h" // for JSFreeOp
#include "gc/GCContext.h" // for JS::GCContext
#include "gc/GCEnum.h" // for MemoryUse, MemoryUse::BreakpointSite
#include "gc/Marking.h" // for IsAboutToBeFinalized
#include "gc/Zone.h" // for Zone
@ -30,7 +30,7 @@
#include "vm/Stack.h" // for ActivationIterator, Activation
#include "gc/GC-inl.h" // for ZoneCellIter
#include "gc/GCContext-inl.h" // for JSFreeOp::free_
#include "gc/GCContext-inl.h" // for JS::GCContext::free_
#include "gc/Marking-inl.h" // for CheckGCThingAfterMovingGC
#include "gc/WeakMap-inl.h" // for WeakMap::remove
#include "vm/BytecodeIterator-inl.h" // for AllBytecodesIterable
@ -88,11 +88,11 @@ void DebugScriptObject::trace(JSTracer* trc, JSObject* obj) {
}
/* static */
void DebugScriptObject::finalize(JSFreeOp* fop, JSObject* obj) {
void DebugScriptObject::finalize(JS::GCContext* gcx, JSObject* obj) {
DebugScriptObject* object = &obj->as<DebugScriptObject>();
DebugScript* debugScript = object->debugScript();
if (debugScript) {
debugScript->delete_(fop, object);
debugScript->delete_(gcx, object);
}
}
@ -202,19 +202,19 @@ JSBreakpointSite* DebugScript::getOrCreateBreakpointSite(JSContext* cx,
}
/* static */
void DebugScript::destroyBreakpointSite(JSFreeOp* fop, JSScript* script,
void DebugScript::destroyBreakpointSite(JS::GCContext* gcx, JSScript* script,
jsbytecode* pc) {
DebugScript* debug = get(script);
JSBreakpointSite*& site = debug->breakpoints[script->pcToOffset(pc)];
MOZ_ASSERT(site);
MOZ_ASSERT(site->isEmpty());
site->delete_(fop);
site->delete_(gcx);
site = nullptr;
debug->numSites--;
if (!debug->needed()) {
DebugAPI::removeDebugScript(fop, script);
DebugAPI::removeDebugScript(gcx, script);
}
if (script->hasBaselineScript()) {
@ -223,7 +223,7 @@ void DebugScript::destroyBreakpointSite(JSFreeOp* fop, JSScript* script,
}
/* static */
void DebugScript::clearBreakpointsIn(JSFreeOp* fop, JSScript* script,
void DebugScript::clearBreakpointsIn(JS::GCContext* gcx, JSScript* script,
Debugger* dbg, JSObject* handler) {
MOZ_ASSERT(script);
// Breakpoints hold wrappers in the script's compartment for the handler. Make
@ -243,7 +243,7 @@ void DebugScript::clearBreakpointsIn(JSFreeOp* fop, JSScript* script,
nextbp = bp->nextInSite();
if ((!dbg || bp->debugger == dbg) &&
(!handler || bp->getHandler() == handler)) {
bp->remove(fop);
bp->remove(gcx);
}
}
}
@ -281,7 +281,7 @@ bool DebugScript::incrementStepperCount(JSContext* cx, HandleScript script) {
}
/* static */
void DebugScript::decrementStepperCount(JSFreeOp* fop, JSScript* script) {
void DebugScript::decrementStepperCount(JS::GCContext* gcx, JSScript* script) {
DebugScript* debug = get(script);
MOZ_ASSERT(debug);
MOZ_ASSERT(debug->stepperCount > 0);
@ -294,7 +294,7 @@ void DebugScript::decrementStepperCount(JSFreeOp* fop, JSScript* script) {
}
if (!debug->needed()) {
DebugAPI::removeDebugScript(fop, script);
DebugAPI::removeDebugScript(gcx, script);
}
}
}
@ -325,7 +325,7 @@ bool DebugScript::incrementGeneratorObserverCount(JSContext* cx,
}
/* static */
void DebugScript::decrementGeneratorObserverCount(JSFreeOp* fop,
void DebugScript::decrementGeneratorObserverCount(JS::GCContext* gcx,
JSScript* script) {
DebugScript* debug = get(script);
MOZ_ASSERT(debug);
@ -334,7 +334,7 @@ void DebugScript::decrementGeneratorObserverCount(JSFreeOp* fop,
debug->generatorObserverCount--;
if (!debug->needed()) {
DebugAPI::removeDebugScript(fop, script);
DebugAPI::removeDebugScript(gcx, script);
}
}
@ -348,7 +348,7 @@ void DebugScript::trace(JSTracer* trc) {
}
/* static */
void DebugAPI::removeDebugScript(JSFreeOp* fop, JSScript* script) {
void DebugAPI::removeDebugScript(JS::GCContext* gcx, JSScript* script) {
if (script->hasDebugScript()) {
if (IsAboutToBeFinalizedUnbarriered(script)) {
// The script is dying and all breakpoint data will be cleaned up.
@ -367,15 +367,15 @@ void DebugAPI::removeDebugScript(JSFreeOp* fop, JSScript* script) {
}
}
void DebugScript::delete_(JSFreeOp* fop, DebugScriptObject* owner) {
void DebugScript::delete_(JS::GCContext* gcx, DebugScriptObject* owner) {
for (size_t i = 0; i < codeLength; i++) {
JSBreakpointSite* site = breakpoints[i];
if (site) {
site->delete_(fop);
site->delete_(gcx);
}
}
fop->free_(owner, this, allocSize(codeLength), MemoryUse::ScriptDebugScript);
gcx->free_(owner, this, allocSize(codeLength), MemoryUse::ScriptDebugScript);
}
#ifdef JSGC_HASH_TABLE_CHECKS

View File

@ -85,7 +85,7 @@ class DebugScript {
}
void trace(JSTracer* trc);
void delete_(JSFreeOp* fop, DebugScriptObject* owner);
void delete_(JS::GCContext* gcx, DebugScriptObject* owner);
static DebugScript* get(JSScript* script);
static DebugScript* getOrCreate(JSContext* cx, HandleScript script);
@ -95,11 +95,11 @@ class DebugScript {
static JSBreakpointSite* getOrCreateBreakpointSite(JSContext* cx,
HandleScript script,
jsbytecode* pc);
static void destroyBreakpointSite(JSFreeOp* fop, JSScript* script,
static void destroyBreakpointSite(JS::GCContext* gcx, JSScript* script,
jsbytecode* pc);
static void clearBreakpointsIn(JSFreeOp* fop, JSScript* script, Debugger* dbg,
JSObject* handler);
static void clearBreakpointsIn(JS::GCContext* gcx, JSScript* script,
Debugger* dbg, JSObject* handler);
#ifdef DEBUG
static uint32_t getStepperCount(JSScript* script);
@ -113,7 +113,7 @@ class DebugScript {
*/
[[nodiscard]] static bool incrementStepperCount(JSContext* cx,
HandleScript script);
static void decrementStepperCount(JSFreeOp* fop, JSScript* script);
static void decrementStepperCount(JS::GCContext* gcx, JSScript* script);
/*
* Increment or decrement the generator observer count. If the count is
@ -123,7 +123,8 @@ class DebugScript {
*/
[[nodiscard]] static bool incrementGeneratorObserverCount(
JSContext* cx, HandleScript script);
static void decrementGeneratorObserverCount(JSFreeOp* fop, JSScript* script);
static void decrementGeneratorObserverCount(JS::GCContext* gcx,
JSScript* script);
};
using UniqueDebugScript = js::UniquePtr<DebugScript, JS::FreePolicy>;
@ -145,7 +146,7 @@ class DebugScriptObject : public NativeObject {
static const JSClassOps classOps_;
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
// A weak map from JSScripts to DebugScriptObjects.

View File

@ -41,7 +41,7 @@
#include "frontend/CompilationStencil.h" // for CompilationStencil
#include "frontend/Parser.h" // for Parser
#include "gc/GC.h" // for IterateScripts
#include "gc/GCContext.h" // for JSFreeOp
#include "gc/GCContext.h" // for JS::GCContext
#include "gc/GCMarker.h" // for GCMarker
#include "gc/GCRuntime.h" // for GCRuntime, AutoEnterIteration
#include "gc/HashUtil.h" // for DependentAddPtr
@ -399,9 +399,9 @@ void BreakpointSite::trace(JSTracer* trc) {
}
}
void BreakpointSite::finalize(JSFreeOp* fop) {
void BreakpointSite::finalize(JS::GCContext* gcx) {
while (!breakpoints.isEmpty()) {
breakpoints.begin()->delete_(fop);
breakpoints.begin()->delete_(gcx);
}
}
@ -440,18 +440,18 @@ void Breakpoint::trace(JSTracer* trc) {
TraceEdge(trc, &handler, "breakpoint handler");
}
void Breakpoint::delete_(JSFreeOp* fop) {
void Breakpoint::delete_(JS::GCContext* gcx) {
debugger->breakpoints.remove(this);
site->breakpoints.remove(this);
gc::Cell* cell = site->owningCell();
fop->delete_(cell, this, MemoryUse::Breakpoint);
gcx->delete_(cell, this, MemoryUse::Breakpoint);
}
void Breakpoint::remove(JSFreeOp* fop) {
void Breakpoint::remove(JS::GCContext* gcx) {
BreakpointSite* savedSite = site;
delete_(fop);
delete_(gcx);
savedSite->destroyIfEmpty(fop);
savedSite->destroyIfEmpty(gcx);
}
Breakpoint* Breakpoint::nextInDebugger() { return debuggerLink.mNext; }
@ -463,8 +463,8 @@ JSBreakpointSite::JSBreakpointSite(JSScript* script, jsbytecode* pc)
MOZ_ASSERT(!DebugAPI::hasBreakpointsAt(script, pc));
}
void JSBreakpointSite::remove(JSFreeOp* fop) {
DebugScript::destroyBreakpointSite(fop, script, pc);
void JSBreakpointSite::remove(JS::GCContext* gcx) {
DebugScript::destroyBreakpointSite(gcx, script, pc);
}
void JSBreakpointSite::trace(JSTracer* trc) {
@ -472,10 +472,10 @@ void JSBreakpointSite::trace(JSTracer* trc) {
TraceEdge(trc, &script, "breakpoint script");
}
void JSBreakpointSite::delete_(JSFreeOp* fop) {
BreakpointSite::finalize(fop);
void JSBreakpointSite::delete_(JS::GCContext* gcx) {
BreakpointSite::finalize(gcx);
fop->delete_(script, this, MemoryUse::BreakpointSite);
gcx->delete_(script, this, MemoryUse::BreakpointSite);
}
gc::Cell* JSBreakpointSite::owningCell() { return script; }
@ -494,14 +494,14 @@ void WasmBreakpointSite::trace(JSTracer* trc) {
TraceEdge(trc, &instanceObject, "breakpoint Wasm instance");
}
void WasmBreakpointSite::remove(JSFreeOp* fop) {
instanceObject->instance().destroyBreakpointSite(fop, offset);
void WasmBreakpointSite::remove(JS::GCContext* gcx) {
instanceObject->instance().destroyBreakpointSite(gcx, offset);
}
void WasmBreakpointSite::delete_(JSFreeOp* fop) {
BreakpointSite::finalize(fop);
void WasmBreakpointSite::delete_(JS::GCContext* gcx) {
BreakpointSite::finalize(gcx);
fop->delete_(instanceObject, this, MemoryUse::BreakpointSite);
gcx->delete_(instanceObject, this, MemoryUse::BreakpointSite);
}
gc::Cell* WasmBreakpointSite::owningCell() { return instanceObject; }
@ -3170,7 +3170,7 @@ static bool UpdateExecutionObservabilityOfScriptsInZone(
AutoSuppressProfilerSampling suppressProfilerSampling(cx);
JSFreeOp* fop = cx->runtime()->defaultFreeOp();
JS::GCContext* gcx = cx->runtime()->defaultFreeOp();
Vector<JSScript*> scripts(cx);
@ -3235,7 +3235,7 @@ static bool UpdateExecutionObservabilityOfScriptsInZone(
for (size_t i = 0; i < scripts.length(); i++) {
MOZ_ASSERT_IF(scripts[i]->isDebuggee(), observing);
if (!scripts[i]->jitScript()->active()) {
FinishDiscardBaselineScript(fop, scripts[i]);
FinishDiscardBaselineScript(gcx, scripts[i]);
}
scripts[i]->jitScript()->resetActive();
}
@ -3902,8 +3902,8 @@ void DebugAPI::traceFromRealm(JSTracer* trc, Realm* realm) {
}
/* static */
void DebugAPI::sweepAll(JSFreeOp* fop) {
JSRuntime* rt = fop->runtime();
void DebugAPI::sweepAll(JS::GCContext* gcx) {
JSRuntime* rt = gcx->runtime();
Debugger* next;
for (Debugger* dbg = rt->debuggerList().getFirst(); dbg; dbg = next) {
@ -3931,7 +3931,7 @@ void DebugAPI::sweepAll(JSFreeOp* fop) {
// isn't a frame entry to clear, and in the second case,
// removeDebuggeeGlobal below will iterate and remove the entries
// anyway, so things will be cleaned up properly.
Debugger::terminateDebuggerFrame(fop, dbg, frameObj, NullFramePtr(),
Debugger::terminateDebuggerFrame(gcx, dbg, frameObj, NullFramePtr(),
nullptr, &e);
}
}
@ -3945,13 +3945,13 @@ void DebugAPI::sweepAll(JSFreeOp* fop) {
e.popFront()) {
GlobalObject* global = e.front().unbarrieredGet();
if (debuggerDying || IsAboutToBeFinalizedUnbarriered(global)) {
dbg->removeDebuggeeGlobal(fop, e.front().unbarrieredGet(), &e,
dbg->removeDebuggeeGlobal(gcx, e.front().unbarrieredGet(), &e,
Debugger::FromSweep::Yes);
}
}
if (debuggerDying) {
fop->delete_(dbg->object, dbg, MemoryUse::Debugger);
gcx->delete_(dbg->object, dbg, MemoryUse::Debugger);
}
dbg = next;
@ -4574,12 +4574,12 @@ bool Debugger::CallData::getNewestFrame() {
}
bool Debugger::CallData::clearAllBreakpoints() {
JSFreeOp* fop = cx->defaultFreeOp();
JS::GCContext* gcx = cx->defaultFreeOp();
Breakpoint* nextbp;
for (Breakpoint* bp = dbg->firstBreakpoint(); bp; bp = nextbp) {
nextbp = bp->nextInDebugger();
bp->remove(fop);
bp->remove(gcx);
}
MOZ_ASSERT(!dbg->firstBreakpoint());
@ -4811,7 +4811,7 @@ static T* findDebuggerInVector(Debugger* dbg, Vector<T, 0, AP>* vec) {
return p;
}
void Debugger::removeDebuggeeGlobal(JSFreeOp* fop, GlobalObject* global,
void Debugger::removeDebuggeeGlobal(JS::GCContext* gcx, GlobalObject* global,
WeakGlobalObjectSet::Enum* debugEnum,
FromSweep fromSweep) {
// The caller might have found global by enumerating this->debuggees; if
@ -4837,7 +4837,7 @@ void Debugger::removeDebuggeeGlobal(JSFreeOp* fop, GlobalObject* global,
for (GeneratorWeakMap::Enum e(generatorFrames); !e.empty(); e.popFront()) {
AbstractGeneratorObject& genObj = *e.front().key();
if (&genObj.global() == global) {
terminateDebuggerFrame(fop, this, e.front().value(), NullFramePtr(),
terminateDebuggerFrame(gcx, this, e.front().value(), NullFramePtr(),
nullptr, &e);
}
}
@ -4846,7 +4846,7 @@ void Debugger::removeDebuggeeGlobal(JSFreeOp* fop, GlobalObject* global,
for (FrameMap::Enum e(frames); !e.empty(); e.popFront()) {
AbstractFramePtr frame = e.front().key();
if (frame.hasGlobal(global)) {
terminateDebuggerFrame(fop, this, e.front().value(), frame, &e);
terminateDebuggerFrame(gcx, this, e.front().value(), frame, &e);
}
}
@ -4878,7 +4878,7 @@ void Debugger::removeDebuggeeGlobal(JSFreeOp* fop, GlobalObject* global,
nextbp = bp->nextInDebugger();
if (bp->site->realm() == global->realm()) {
bp->remove(fop);
bp->remove(gcx);
}
}
MOZ_ASSERT_IF(debuggees.empty(), !firstBreakpoint());
@ -6483,7 +6483,7 @@ bool DebugAPI::inFrameMaps(AbstractFramePtr frame) {
/* static */
void Debugger::suspendGeneratorDebuggerFrames(JSContext* cx,
AbstractFramePtr frame) {
JSFreeOp* fop = cx->runtime()->defaultFreeOp();
JS::GCContext* gcx = cx->runtime()->defaultFreeOp();
forEachOnStackDebuggerFrame(
frame, [&](Debugger* dbg, DebuggerFrame* dbgFrame) {
dbg->frames.remove(frame);
@ -6496,17 +6496,17 @@ void Debugger::suspendGeneratorDebuggerFrames(JSContext* cx,
MOZ_ASSERT(p->value() == dbgFrame);
#endif
dbgFrame->suspend(fop);
dbgFrame->suspend(gcx);
});
}
/* static */
void Debugger::terminateDebuggerFrames(JSContext* cx, AbstractFramePtr frame) {
JSFreeOp* fop = cx->runtime()->defaultFreeOp();
JS::GCContext* gcx = cx->runtime()->defaultFreeOp();
forEachOnStackOrSuspendedDebuggerFrame(
cx, frame, [&](Debugger* dbg, DebuggerFrame* dbgFrame) {
Debugger::terminateDebuggerFrame(fop, dbg, dbgFrame, frame);
Debugger::terminateDebuggerFrame(gcx, dbg, dbgFrame, frame);
});
// If this is an eval frame, then from the debugger's perspective the
@ -6520,7 +6520,7 @@ void Debugger::terminateDebuggerFrames(JSContext* cx, AbstractFramePtr frame) {
/* static */
void Debugger::terminateDebuggerFrame(
JSFreeOp* fop, Debugger* dbg, DebuggerFrame* dbgFrame,
JS::GCContext* gcx, Debugger* dbg, DebuggerFrame* dbgFrame,
AbstractFramePtr frame, FrameMap::Enum* maybeFramesEnum,
GeneratorWeakMap::Enum* maybeGeneratorFramesEnum) {
// If we were not passed the frame, either we are destroying a frame early
@ -6547,7 +6547,7 @@ void Debugger::terminateDebuggerFrame(
}
}
dbgFrame->terminate(fop, frame);
dbgFrame->terminate(gcx, frame);
}
DebuggerDebuggeeLink* Debugger::getDebuggeeLink() {

View File

@ -792,7 +792,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
[[nodiscard]] bool addDebuggeeGlobal(JSContext* cx,
Handle<GlobalObject*> obj);
void removeDebuggeeGlobal(JSFreeOp* fop, GlobalObject* global,
void removeDebuggeeGlobal(JS::GCContext* gcx, GlobalObject* global,
WeakGlobalObjectSet::Enum* debugEnum,
FromSweep fromSweep);
@ -918,7 +918,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
* had on-stack data or a 'frames' entry and has never had an onStep handler.
*/
static void terminateDebuggerFrame(
JSFreeOp* fop, Debugger* dbg, DebuggerFrame* dbgFrame,
JS::GCContext* gcx, Debugger* dbg, DebuggerFrame* dbgFrame,
AbstractFramePtr frame, FrameMap::Enum* maybeFramesEnum = nullptr,
GeneratorWeakMap::Enum* maybeGeneratorFramesEnum = nullptr);
@ -1360,7 +1360,7 @@ struct Handler {
virtual void hold(JSObject* owner) = 0;
/* Report that this Handler is no longer held by owner. See comment above. */
virtual void drop(JSFreeOp* fop, JSObject* owner) = 0;
virtual void drop(JS::GCContext* gcx, JSObject* owner) = 0;
/*
* Trace the reference to the handler. This method will be called by the
@ -1429,7 +1429,7 @@ class BreakpointSite {
protected:
BreakpointSite() = default;
virtual ~BreakpointSite() = default;
void finalize(JSFreeOp* fop);
void finalize(JS::GCContext* gcx);
virtual gc::Cell* owningCell() = 0;
public:
@ -1438,10 +1438,10 @@ class BreakpointSite {
bool isEmpty() const;
virtual void trace(JSTracer* trc);
virtual void remove(JSFreeOp* fop) = 0;
void destroyIfEmpty(JSFreeOp* fop) {
virtual void remove(JS::GCContext* gcx) = 0;
void destroyIfEmpty(JS::GCContext* gcx) {
if (isEmpty()) {
remove(fop);
remove(gcx);
}
}
virtual Realm* realm() const = 0;
@ -1511,14 +1511,14 @@ class Breakpoint {
* it does not check for now-empty BreakpointSites, unneeded DebugScripts, or
* the like.
*/
void delete_(JSFreeOp* fop);
void delete_(JS::GCContext* gcx);
/**
* Remove this breakpoint. Unlink it from its Debugger's and BreakpointSite's
* lists, and if the BreakpointSite is now empty, clean that up and update JIT
* code as necessary.
*/
void remove(JSFreeOp* fop);
void remove(JS::GCContext* gcx);
Breakpoint* nextInDebugger();
Breakpoint* nextInSite();
@ -1534,8 +1534,8 @@ class JSBreakpointSite : public BreakpointSite {
JSBreakpointSite(JSScript* script, jsbytecode* pc);
void trace(JSTracer* trc) override;
void delete_(JSFreeOp* fop);
void remove(JSFreeOp* fop) override;
void delete_(JS::GCContext* gcx);
void remove(JS::GCContext* gcx) override;
Realm* realm() const override;
private:
@ -1551,8 +1551,8 @@ class WasmBreakpointSite : public BreakpointSite {
WasmBreakpointSite(WasmInstanceObject* instanceObject, uint32_t offset);
void trace(JSTracer* trc) override;
void delete_(JSFreeOp* fop);
void remove(JSFreeOp* fop) override;
void delete_(JS::GCContext* gcx);
void remove(JS::GCContext* gcx) override;
Realm* realm() const override;
private:

View File

@ -33,7 +33,7 @@
#include "frontend/BytecodeCompilation.h" // for CompileEvalScript
#include "gc/Barrier.h" // for HeapPtr
#include "gc/GC.h" // for MemoryUse
#include "gc/GCContext.h" // for JSFreeOp
#include "gc/GCContext.h" // for JS::GCContext
#include "gc/Marking.h" // for IsAboutToBeFinalized
#include "gc/Rooting.h" // for RootedDebuggerFrame
#include "gc/Tracer.h" // for TraceCrossCompartmentEdge
@ -109,8 +109,8 @@ void ScriptedOnStepHandler::hold(JSObject* owner) {
AddCellMemory(owner, allocSize(), MemoryUse::DebuggerOnStepHandler);
}
void ScriptedOnStepHandler::drop(JSFreeOp* fop, JSObject* owner) {
fop->delete_(owner, this, allocSize(), MemoryUse::DebuggerOnStepHandler);
void ScriptedOnStepHandler::drop(JS::GCContext* gcx, JSObject* owner) {
gcx->delete_(owner, this, allocSize(), MemoryUse::DebuggerOnStepHandler);
}
void ScriptedOnStepHandler::trace(JSTracer* tracer) {
@ -141,8 +141,8 @@ void ScriptedOnPopHandler::hold(JSObject* owner) {
AddCellMemory(owner, allocSize(), MemoryUse::DebuggerOnPopHandler);
}
void ScriptedOnPopHandler::drop(JSFreeOp* fop, JSObject* owner) {
fop->delete_(owner, this, allocSize(), MemoryUse::DebuggerOnPopHandler);
void ScriptedOnPopHandler::drop(JS::GCContext* gcx, JSObject* owner) {
gcx->delete_(owner, this, allocSize(), MemoryUse::DebuggerOnPopHandler);
}
void ScriptedOnPopHandler::trace(JSTracer* tracer) {
@ -402,18 +402,18 @@ bool DebuggerFrame::setGeneratorInfo(JSContext* cx, HandleDebuggerFrame frame,
return true;
}
void DebuggerFrame::terminate(JSFreeOp* fop, AbstractFramePtr frame) {
void DebuggerFrame::terminate(JS::GCContext* gcx, AbstractFramePtr frame) {
if (frameIterData()) {
// If no frame pointer was provided to decrement the stepper counter,
// then we must be terminating a generator, otherwise the stepper count
// would have no way to synchronize properly.
MOZ_ASSERT_IF(!frame, hasGeneratorInfo());
freeFrameIterData(fop);
freeFrameIterData(gcx);
if (frame && !hasGeneratorInfo() && onStepHandler()) {
// If we are terminating a non-generator frame that had a step handler,
// we need to decrement the counter to keep things in sync.
decrementStepperCounter(fop, frame);
decrementStepperCounter(gcx, frame);
}
}
@ -432,26 +432,26 @@ void DebuggerFrame::terminate(JSFreeOp* fop, AbstractFramePtr frame) {
// calls may.
if (!info->isGeneratorScriptAboutToBeFinalized()) {
JSScript* generatorScript = info->generatorScript();
DebugScript::decrementGeneratorObserverCount(fop, generatorScript);
DebugScript::decrementGeneratorObserverCount(gcx, generatorScript);
if (onStepHandler()) {
// If we are terminating a generator frame that had a step handler,
// we need to decrement the counter to keep things in sync.
decrementStepperCounter(fop, generatorScript);
decrementStepperCounter(gcx, generatorScript);
}
}
// 1) The DebuggerFrame must no longer point to the AbstractGeneratorObject.
setReservedSlot(GENERATOR_INFO_SLOT, UndefinedValue());
fop->delete_(this, info, MemoryUse::DebuggerFrameGeneratorInfo);
gcx->delete_(this, info, MemoryUse::DebuggerFrameGeneratorInfo);
}
void DebuggerFrame::suspend(JSFreeOp* fop) {
void DebuggerFrame::suspend(JS::GCContext* gcx) {
// There must be generator info because otherwise this would be the same
// overall behavior as terminate() except that here we do not properly
// adjust stepper counts.
MOZ_ASSERT(hasGeneratorInfo());
freeFrameIterData(fop);
freeFrameIterData(gcx);
}
/* static */
@ -780,7 +780,7 @@ bool DebuggerFrame::setOnStepHandler(JSContext* cx, HandleDebuggerFrame frame,
return true;
}
JSFreeOp* fop = cx->defaultFreeOp();
JS::GCContext* gcx = cx->defaultFreeOp();
if (frame->isOnStack()) {
AbstractFramePtr referent = DebuggerFrame::getReferent(frame);
@ -811,7 +811,7 @@ bool DebuggerFrame::setOnStepHandler(JSContext* cx, HandleDebuggerFrame frame,
// Now that the stepper counts and observability are set correctly, we can
// actually switch the handler.
if (prior) {
prior->drop(fop, frame);
prior->drop(gcx, frame);
}
if (handler) {
@ -859,22 +859,23 @@ bool DebuggerFrame::incrementStepperCounter(JSContext* cx,
return true;
}
void DebuggerFrame::decrementStepperCounter(JSFreeOp* fop,
void DebuggerFrame::decrementStepperCounter(JS::GCContext* gcx,
AbstractFramePtr referent) {
if (!referent.isWasmDebugFrame()) {
decrementStepperCounter(fop, referent.script());
decrementStepperCounter(gcx, referent.script());
return;
}
wasm::Instance* instance = referent.asWasmDebugFrame()->instance();
wasm::DebugFrame* wasmFrame = referent.asWasmDebugFrame();
// Single stepping toggled on->off.
instance->debug().decrementStepperCount(fop, wasmFrame->funcIndex());
instance->debug().decrementStepperCount(gcx, wasmFrame->funcIndex());
}
void DebuggerFrame::decrementStepperCounter(JSFreeOp* fop, JSScript* script) {
void DebuggerFrame::decrementStepperCounter(JS::GCContext* gcx,
JSScript* script) {
// Single stepping toggled on->off.
DebugScript::decrementStepperCount(fop, script);
DebugScript::decrementStepperCount(gcx, script);
}
/* static */
@ -1126,10 +1127,10 @@ void DebuggerFrame::setOnPopHandler(JSContext* cx, OnPopHandler* handler) {
return;
}
JSFreeOp* fop = cx->defaultFreeOp();
JS::GCContext* gcx = cx->defaultFreeOp();
if (prior) {
prior->drop(fop, this);
prior->drop(gcx, this);
}
if (handler) {
@ -1178,9 +1179,9 @@ void DebuggerFrame::setFrameIterData(FrameIter::Data* data) {
MemoryUse::DebuggerFrameIterData);
}
void DebuggerFrame::freeFrameIterData(JSFreeOp* fop) {
void DebuggerFrame::freeFrameIterData(JS::GCContext* gcx) {
if (FrameIter::Data* data = frameIterData()) {
fop->delete_(this, data, MemoryUse::DebuggerFrameIterData);
gcx->delete_(this, data, MemoryUse::DebuggerFrameIterData);
setReservedSlot(FRAME_ITER_SLOT, UndefinedValue());
}
}
@ -1196,8 +1197,8 @@ bool DebuggerFrame::replaceFrameIterData(JSContext* cx, const FrameIter& iter) {
}
/* static */
void DebuggerFrame::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void DebuggerFrame::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
DebuggerFrame& frameobj = obj->as<DebuggerFrame>();
@ -1208,11 +1209,11 @@ void DebuggerFrame::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(!frameobj.frameIterData());
OnStepHandler* onStepHandler = frameobj.onStepHandler();
if (onStepHandler) {
onStepHandler->drop(fop, &frameobj);
onStepHandler->drop(gcx, &frameobj);
}
OnPopHandler* onPopHandler = frameobj.onPopHandler();
if (onPopHandler) {
onPopHandler->drop(fop, &frameobj);
onPopHandler->drop(gcx, &frameobj);
}
}

View File

@ -50,7 +50,7 @@ class ScriptedOnStepHandler final : public OnStepHandler {
explicit ScriptedOnStepHandler(JSObject* object);
virtual JSObject* object() const override;
virtual void hold(JSObject* owner) override;
virtual void drop(JSFreeOp* fop, JSObject* owner) override;
virtual void drop(JS::GCContext* gcx, JSObject* owner) override;
virtual void trace(JSTracer* tracer) override;
virtual size_t allocSize() const override;
virtual bool onStep(JSContext* cx, HandleDebuggerFrame frame,
@ -83,7 +83,7 @@ class ScriptedOnPopHandler final : public OnPopHandler {
explicit ScriptedOnPopHandler(JSObject* object);
virtual JSObject* object() const override;
virtual void hold(JSObject* owner) override;
virtual void drop(JSFreeOp* fop, JSObject* owner) override;
virtual void drop(JS::GCContext* gcx, JSObject* owner) override;
virtual void trace(JSTracer* tracer) override;
virtual size_t allocSize() const override;
virtual bool onPop(JSContext* cx, HandleDebuggerFrame frame,
@ -242,7 +242,7 @@ class DebuggerFrame : public NativeObject {
* function will not otherwise disturb generatorFrames. Passing the enum
* allows this function to be used while iterating over generatorFrames.
*/
void clearGeneratorInfo(JSFreeOp* fop);
void clearGeneratorInfo(JS::GCContext* gcx);
/*
* Called after a generator/async frame is resumed, before exposing this
@ -261,7 +261,7 @@ class DebuggerFrame : public NativeObject {
static const JSPropertySpec properties_[];
static const JSFunctionSpec methods_[];
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
static AbstractFramePtr getReferent(HandleDebuggerFrame frame);
[[nodiscard]] static bool requireScriptReferent(JSContext* cx,
@ -275,18 +275,18 @@ class DebuggerFrame : public NativeObject {
AbstractFramePtr referent);
[[nodiscard]] bool incrementStepperCounter(JSContext* cx,
HandleScript script);
void decrementStepperCounter(JSFreeOp* fop, JSScript* script);
void decrementStepperCounter(JSFreeOp* fop, AbstractFramePtr referent);
void decrementStepperCounter(JS::GCContext* gcx, JSScript* script);
void decrementStepperCounter(JS::GCContext* gcx, AbstractFramePtr referent);
FrameIter::Data* frameIterData() const;
void setFrameIterData(FrameIter::Data*);
void freeFrameIterData(JSFreeOp* fop);
void freeFrameIterData(JS::GCContext* gcx);
public:
FrameIter getFrameIter(JSContext* cx);
void terminate(JSFreeOp* fop, AbstractFramePtr frame);
void suspend(JSFreeOp* fop);
void terminate(JS::GCContext* gcx, AbstractFramePtr frame);
void suspend(JS::GCContext* gcx);
[[nodiscard]] bool replaceFrameIterData(JSContext* cx, const FrameIter&);

View File

@ -329,7 +329,7 @@ class ArenaLists {
bool relocateArenas(Arena*& relocatedListOut, JS::GCReason reason,
js::SliceBudget& sliceBudget, gcstats::Statistics& stats);
void queueForegroundObjectsForSweep(JSFreeOp* fop);
void queueForegroundObjectsForSweep(JS::GCContext* gcx);
void queueForegroundThingsForSweep();
Arena* takeSweptEmptyArenas();

View File

@ -450,8 +450,8 @@ inline T* MovingTracer::onEdge(T* thing) {
}
void Zone::prepareForCompacting() {
JSFreeOp* fop = runtimeFromMainThread()->defaultFreeOp();
discardJitCode(fop);
JS::GCContext* gcx = runtimeFromMainThread()->defaultFreeOp();
discardJitCode(gcx);
}
void GCRuntime::sweepZoneAfterCompacting(MovingTracer* trc, Zone* zone) {

View File

@ -291,16 +291,16 @@ const AllocKind gc::slotsToThingKind[] = {
static_assert(std::size(slotsToThingKind) == SLOTS_TO_THING_KIND_LIMIT,
"We have defined a slot count for each kind.");
MOZ_THREAD_LOCAL(JSFreeOp*) js::TlsFreeOp;
MOZ_THREAD_LOCAL(JS::GCContext*) js::TlsGCContext;
JSFreeOp::JSFreeOp(JSRuntime* runtime, bool isMainThread)
JS::GCContext::GCContext(JSRuntime* runtime, bool isMainThread)
: runtime_(runtime), isMainThread_(isMainThread) {
MOZ_ASSERT_IF(isMainThread, CurrentThreadCanAccessRuntime(runtime));
}
JSFreeOp::~JSFreeOp() { MOZ_ASSERT(!hasJitCodeToPoison()); }
JS::GCContext::~GCContext() { MOZ_ASSERT(!hasJitCodeToPoison()); }
void JSFreeOp::poisonJitCode() {
void JS::GCContext::poisonJitCode() {
if (hasJitCodeToPoison()) {
jit::ExecutableAllocator::poisonCode(runtime(), jitPoisonRanges);
jitPoisonRanges.clearAndFree();
@ -810,10 +810,10 @@ bool GCRuntime::init(uint32_t maxbytes) {
MOZ_ASSERT(SystemPageSize());
Arena::checkLookupTables();
if (!TlsFreeOp.init()) {
if (!TlsGCContext.init()) {
return false;
}
TlsFreeOp.set(&mainThreadFreeOp.ref());
TlsGCContext.set(&mainThreadFreeOp.ref());
{
AutoLockGCBgAlloc lock(this);
@ -902,7 +902,7 @@ void GCRuntime::finish() {
FreeChunkPool(availableChunks_.ref());
FreeChunkPool(emptyChunks_.ref());
TlsFreeOp.set(nullptr);
TlsGCContext.set(nullptr);
gcprobes::Finish(this);
@ -1297,10 +1297,10 @@ void GCRuntime::removeFinalizeCallback(JSFinalizeCallback callback) {
EraseCallback(finalizeCallbacks.ref(), callback);
}
void GCRuntime::callFinalizeCallbacks(JSFreeOp* fop,
void GCRuntime::callFinalizeCallbacks(JS::GCContext* gcx,
JSFinalizeStatus status) const {
for (auto& p : finalizeCallbacks.ref()) {
p.op(fop, status, p.data);
p.op(gcx, status, p.data);
}
}
@ -1916,40 +1916,40 @@ void GCRuntime::queueBuffersForFreeAfterMinorGC(Nursery::BufferSet& buffers) {
std::swap(buffersToFreeAfterMinorGC.ref(), buffers);
}
void Realm::destroy(JSFreeOp* fop) {
JSRuntime* rt = fop->runtime();
void Realm::destroy(JS::GCContext* gcx) {
JSRuntime* rt = gcx->runtime();
if (auto callback = rt->destroyRealmCallback) {
callback(fop, this);
callback(gcx, this);
}
if (principals()) {
JS_DropPrincipals(rt->mainContextFromOwnThread(), principals());
}
// Bug 1560019: Malloc memory associated with a zone but not with a specific
// GC thing is not currently tracked.
fop->deleteUntracked(this);
gcx->deleteUntracked(this);
}
void Compartment::destroy(JSFreeOp* fop) {
JSRuntime* rt = fop->runtime();
void Compartment::destroy(JS::GCContext* gcx) {
JSRuntime* rt = gcx->runtime();
if (auto callback = rt->destroyCompartmentCallback) {
callback(fop, this);
callback(gcx, this);
}
// Bug 1560019: Malloc memory associated with a zone but not with a specific
// GC thing is not currently tracked.
fop->deleteUntracked(this);
gcx->deleteUntracked(this);
rt->gc.stats().sweptCompartment();
}
void Zone::destroy(JSFreeOp* fop) {
void Zone::destroy(JS::GCContext* gcx) {
MOZ_ASSERT(compartments().empty());
JSRuntime* rt = fop->runtime();
JSRuntime* rt = gcx->runtime();
if (auto callback = rt->destroyZoneCallback) {
callback(fop, this);
callback(gcx, this);
}
// Bug 1560019: Malloc memory associated with a zone but not with a specific
// GC thing is not currently tracked.
fop->deleteUntracked(this);
fop->runtime()->gc.stats().sweptZone();
gcx->deleteUntracked(this);
gcx->runtime()->gc.stats().sweptZone();
}
/*
@ -1961,7 +1961,7 @@ void Zone::destroy(JSFreeOp* fop) {
* sweepCompartments from deleting every compartment. Instead, it preserves an
* arbitrary compartment in the zone.
*/
void Zone::sweepCompartments(JSFreeOp* fop, bool keepAtleastOne,
void Zone::sweepCompartments(JS::GCContext* gcx, bool keepAtleastOne,
bool destroyingRuntime) {
MOZ_ASSERT(!compartments().empty());
MOZ_ASSERT_IF(destroyingRuntime, !keepAtleastOne);
@ -1977,13 +1977,13 @@ void Zone::sweepCompartments(JSFreeOp* fop, bool keepAtleastOne,
* still true, meaning all the other compartments were deleted.
*/
bool keepAtleastOneRealm = read == end && keepAtleastOne;
comp->sweepRealms(fop, keepAtleastOneRealm, destroyingRuntime);
comp->sweepRealms(gcx, keepAtleastOneRealm, destroyingRuntime);
if (!comp->realms().empty()) {
*write++ = comp;
keepAtleastOne = false;
} else {
comp->destroy(fop);
comp->destroy(gcx);
}
}
compartments().shrinkTo(write - compartments().begin());
@ -1991,7 +1991,7 @@ void Zone::sweepCompartments(JSFreeOp* fop, bool keepAtleastOne,
MOZ_ASSERT_IF(destroyingRuntime, compartments().empty());
}
void Compartment::sweepRealms(JSFreeOp* fop, bool keepAtleastOne,
void Compartment::sweepRealms(JS::GCContext* gcx, bool keepAtleastOne,
bool destroyingRuntime) {
MOZ_ASSERT(!realms().empty());
MOZ_ASSERT_IF(destroyingRuntime, !keepAtleastOne);
@ -2011,7 +2011,7 @@ void Compartment::sweepRealms(JSFreeOp* fop, bool keepAtleastOne,
*write++ = realm;
keepAtleastOne = false;
} else {
realm->destroy(fop);
realm->destroy(gcx);
}
}
realms().shrinkTo(write - realms().begin());
@ -2019,7 +2019,7 @@ void Compartment::sweepRealms(JSFreeOp* fop, bool keepAtleastOne,
MOZ_ASSERT_IF(destroyingRuntime, realms().empty());
}
void GCRuntime::sweepZones(JSFreeOp* fop, bool destroyingRuntime) {
void GCRuntime::sweepZones(JS::GCContext* gcx, bool destroyingRuntime) {
MOZ_ASSERT_IF(destroyingRuntime, numActiveZoneIters == 0);
if (numActiveZoneIters) {
@ -2043,13 +2043,13 @@ void GCRuntime::sweepZones(JSFreeOp* fop, bool destroyingRuntime) {
if (zoneIsDead) {
AutoSetThreadIsSweeping threadIsSweeping(zone);
zone->arenas.checkEmptyFreeLists();
zone->sweepCompartments(fop, false, destroyingRuntime);
zone->sweepCompartments(gcx, false, destroyingRuntime);
MOZ_ASSERT(zone->compartments().empty());
MOZ_ASSERT(zone->rttValueObjects().empty());
zone->destroy(fop);
zone->destroy(gcx);
continue;
}
zone->sweepCompartments(fop, true, destroyingRuntime);
zone->sweepCompartments(gcx, true, destroyingRuntime);
}
*write++ = zone;
}

View File

@ -41,7 +41,7 @@ extern void TraceRuntime(JSTracer* trc);
// Trace roots but don't evict the nursery first; used from DumpHeap.
extern void TraceRuntimeWithoutEviction(JSTracer* trc);
extern void ReleaseAllJITCode(JSFreeOp* op);
extern void ReleaseAllJITCode(JS::GCContext* gcx);
extern void PrepareForDebugGC(JSRuntime* rt);

View File

@ -89,15 +89,15 @@ void PreventGCDuringInteractiveDebug() { TlsContext.get()->suppressGC++; }
#endif
void js::ReleaseAllJITCode(JSFreeOp* fop) {
js::CancelOffThreadIonCompile(fop->runtime());
void js::ReleaseAllJITCode(JS::GCContext* gcx) {
js::CancelOffThreadIonCompile(gcx->runtime());
for (ZonesIter zone(fop->runtime(), SkipAtoms); !zone.done(); zone.next()) {
for (ZonesIter zone(gcx->runtime(), SkipAtoms); !zone.done(); zone.next()) {
zone->setPreservingCode(false);
zone->discardJitCode(fop);
zone->discardJitCode(gcx);
}
for (RealmsIter realm(fop->runtime()); !realm.done(); realm.next()) {
for (RealmsIter realm(gcx->runtime()); !realm.done(); realm.next()) {
if (jit::JitRealm* jitRealm = realm->jitRealm()) {
jitRealm->discardStubs();
}

View File

@ -12,7 +12,8 @@
#include "gc/ZoneAllocator.h"
#include "js/RefCounted.h"
inline void JSFreeOp::free_(Cell* cell, void* p, size_t nbytes, MemoryUse use) {
inline void JS::GCContext::free_(Cell* cell, void* p, size_t nbytes,
MemoryUse use) {
if (p) {
removeCellMemory(cell, nbytes, use);
js_free(p);
@ -20,15 +21,16 @@ inline void JSFreeOp::free_(Cell* cell, void* p, size_t nbytes, MemoryUse use) {
}
template <class T>
inline void JSFreeOp::release(Cell* cell, T* p, size_t nbytes, MemoryUse use) {
inline void JS::GCContext::release(Cell* cell, T* p, size_t nbytes,
MemoryUse use) {
if (p) {
removeCellMemory(cell, nbytes, use);
p->Release();
}
}
inline void JSFreeOp::removeCellMemory(Cell* cell, size_t nbytes,
MemoryUse use) {
inline void JS::GCContext::removeCellMemory(Cell* cell, size_t nbytes,
MemoryUse use) {
RemoveCellMemory(cell, nbytes, use, isCollecting());
}

View File

@ -14,7 +14,6 @@
#include "gc/GCEnum.h" // js::MemoryUse
#include "jit/ExecutableAllocator.h" // jit::JitPoisonRangeVector
#include "js/AllocPolicy.h" // SystemAllocPolicy
#include "js/MemoryFunctions.h" // JSFreeOp
#include "js/Utility.h" // AutoEnterOOMUnsafeRegion, js_free
#include "js/Vector.h" // js::Vector
@ -51,14 +50,19 @@ enum class GCUse {
} // namespace gc
} // namespace js
namespace JS {
/*
* A JSFreeOp can do one thing: free memory. For convenience, it has delete_
* convenience methods that also call destructors.
* GCContext is by GC operations that can run on or off the main thread.
*
* JSFreeOp is passed to finalizers and other sweep-phase hooks so that we do
* not need to pass a JSContext to those hooks.
* Its main function is to provide methods to free memory and update memory
* accounting. For convenience, it also has delete_ convenience methods that
* also call destructors.
*
* It is passed to finalizers and other sweep-phase hooks as JSContext is not
* available off the main thread.
*/
class JSFreeOp {
class GCContext {
using Cell = js::gc::Cell;
using MemoryUse = js::MemoryUse;
@ -75,7 +79,7 @@ class JSFreeOp {
js::gc::GCUse gcUse_ = js::gc::GCUse::None;
// The specific zone currently being swept, if any.
JS::Zone* gcSweepZone_ = nullptr;
Zone* gcSweepZone_ = nullptr;
// Whether this thread is currently manipulating possibly-gray GC things.
size_t isTouchingGrayThings_ = false;
@ -85,8 +89,8 @@ class JSFreeOp {
#endif
public:
explicit JSFreeOp(JSRuntime* maybeRuntime, bool isMainThread);
~JSFreeOp();
explicit GCContext(JSRuntime* maybeRuntime, bool isMainThread);
~GCContext();
JSRuntime* runtime() const {
MOZ_ASSERT(isMainThread_);
@ -102,7 +106,7 @@ class JSFreeOp {
#ifdef DEBUG
js::gc::GCUse gcUse() const { return gcUse_; }
JS::Zone* gcSweepZone() const { return gcSweepZone_; }
Zone* gcSweepZone() const { return gcSweepZone_; }
bool isTouchingGrayThings() const { return isTouchingGrayThings_; }
#endif
@ -189,26 +193,28 @@ class JSFreeOp {
void removeCellMemory(Cell* cell, size_t nbytes, MemoryUse use);
};
} // namespace JS
namespace js {
/* Thread Local Storage for storing the JSFreeOp for a thread. */
extern MOZ_THREAD_LOCAL(JSFreeOp*) TlsFreeOp;
/* Thread Local Storage for storing the GCContext for a thread. */
extern MOZ_THREAD_LOCAL(JS::GCContext*) TlsGCContext;
inline JSFreeOp* MaybeGetJSFreeOp() {
if (!TlsFreeOp.init()) {
inline JS::GCContext* MaybeGetGCContext() {
if (!TlsGCContext.init()) {
return nullptr;
}
return TlsFreeOp.get();
return TlsGCContext.get();
}
class MOZ_RAII AutoTouchingGrayThings {
public:
#ifdef DEBUG
AutoTouchingGrayThings() { TlsFreeOp.get()->isTouchingGrayThings_++; }
AutoTouchingGrayThings() { TlsGCContext.get()->isTouchingGrayThings_++; }
~AutoTouchingGrayThings() {
JSFreeOp* fop = TlsFreeOp.get();
MOZ_ASSERT(fop->isTouchingGrayThings_);
fop->isTouchingGrayThings_--;
JS::GCContext* gcx = TlsGCContext.get();
MOZ_ASSERT(gcx->isTouchingGrayThings_);
gcx->isTouchingGrayThings_--;
}
#else
AutoTouchingGrayThings() {}
@ -218,28 +224,28 @@ class MOZ_RAII AutoTouchingGrayThings {
#ifdef DEBUG
inline bool CurrentThreadIsGCMarking() {
JSFreeOp* fop = MaybeGetJSFreeOp();
return fop && fop->gcUse() == gc::GCUse::Marking;
JS::GCContext* gcx = MaybeGetGCContext();
return gcx && gcx->gcUse() == gc::GCUse::Marking;
}
inline bool CurrentThreadIsGCSweeping() {
JSFreeOp* fop = MaybeGetJSFreeOp();
return fop && fop->gcUse() == gc::GCUse::Sweeping;
JS::GCContext* gcx = MaybeGetGCContext();
return gcx && gcx->gcUse() == gc::GCUse::Sweeping;
}
inline bool CurrentThreadIsGCFinalizing() {
JSFreeOp* fop = MaybeGetJSFreeOp();
return fop && fop->gcUse() == gc::GCUse::Finalizing;
JS::GCContext* gcx = MaybeGetGCContext();
return gcx && gcx->gcUse() == gc::GCUse::Finalizing;
}
inline bool CurrentThreadIsTouchingGrayThings() {
JSFreeOp* fop = MaybeGetJSFreeOp();
return fop && fop->isTouchingGrayThings();
JS::GCContext* gcx = MaybeGetGCContext();
return gcx && gcx->isTouchingGrayThings();
}
inline bool CurrentThreadIsPerformingGC() {
JSFreeOp* fop = MaybeGetJSFreeOp();
return fop && fop->isCollecting();
JS::GCContext* gcx = MaybeGetGCContext();
return gcx && gcx->isCollecting();
}
#endif

View File

@ -233,25 +233,25 @@ struct MOZ_RAII AutoStopVerifyingBarriers {
#endif /* JS_GC_ZEAL */
class MOZ_RAII AutoPoisonFreedJitCode {
JSFreeOp* const fop;
JS::GCContext* const gcx;
public:
explicit AutoPoisonFreedJitCode(JSFreeOp* fop) : fop(fop) {}
~AutoPoisonFreedJitCode() { fop->poisonJitCode(); }
explicit AutoPoisonFreedJitCode(JS::GCContext* gcx) : gcx(gcx) {}
~AutoPoisonFreedJitCode() { gcx->poisonJitCode(); }
};
// Set/restore the performing GC flag for the current thread.
class MOZ_RAII AutoSetThreadIsPerformingGC {
JSFreeOp* fop;
JS::GCContext* gcx;
bool prev;
public:
AutoSetThreadIsPerformingGC()
: fop(TlsFreeOp.get()), prev(fop->isCollecting_) {
fop->isCollecting_ = true;
: gcx(TlsGCContext.get()), prev(gcx->isCollecting_) {
gcx->isCollecting_ = true;
}
~AutoSetThreadIsPerformingGC() { fop->isCollecting_ = prev; }
~AutoSetThreadIsPerformingGC() { gcx->isCollecting_ = prev; }
};
class MOZ_RAII AutoSetThreadGCUse {
@ -260,23 +260,23 @@ class MOZ_RAII AutoSetThreadGCUse {
explicit AutoSetThreadGCUse(GCUse use, JS::Zone* sweepZone = nullptr) {}
#else
explicit AutoSetThreadGCUse(GCUse use, JS::Zone* sweepZone = nullptr)
: fop(TlsFreeOp.get()),
prevUse(fop->gcUse_),
prevZone(fop->gcSweepZone_) {
MOZ_ASSERT(fop->isCollecting());
: gcx(TlsGCContext.get()),
prevUse(gcx->gcUse_),
prevZone(gcx->gcSweepZone_) {
MOZ_ASSERT(gcx->isCollecting());
MOZ_ASSERT_IF(sweepZone, use == GCUse::Sweeping);
fop->gcUse_ = use;
fop->gcSweepZone_ = sweepZone;
gcx->gcUse_ = use;
gcx->gcSweepZone_ = sweepZone;
}
~AutoSetThreadGCUse() {
fop->gcUse_ = prevUse;
fop->gcSweepZone_ = prevZone;
MOZ_ASSERT_IF(fop->gcUse() == GCUse::None, !fop->gcSweepZone());
gcx->gcUse_ = prevUse;
gcx->gcSweepZone_ = prevZone;
MOZ_ASSERT_IF(gcx->gcUse() == GCUse::None, !gcx->gcSweepZone());
}
private:
JSFreeOp* fop;
JS::GCContext* gcx;
GCUse prevUse;
JS::Zone* prevZone;
#endif

View File

@ -158,13 +158,13 @@ void js::GCParallelTask::runHelperThreadTask(AutoLockHelperThreadState& lock) {
setRunning(lock);
JSFreeOp freeOp(gc->rt, false);
MOZ_RELEASE_ASSERT(TlsFreeOp.init());
TlsFreeOp.set(&freeOp);
JS::GCContext gcx(gc->rt, false);
MOZ_RELEASE_ASSERT(TlsGCContext.init());
TlsGCContext.set(&gcx);
runTask(lock);
TlsFreeOp.set(nullptr);
TlsGCContext.set(nullptr);
setFinished(lock);
}

View File

@ -58,7 +58,7 @@ struct SweepAction {
// The arguments passed to each action.
struct Args {
GCRuntime* gc;
JSFreeOp* fop;
JS::GCContext* gcx;
SliceBudget& budget;
};
@ -789,53 +789,57 @@ class GCRuntime {
[[nodiscard]] bool findSweepGroupEdges();
void getNextSweepGroup();
void resetGrayList(Compartment* comp);
IncrementalProgress beginMarkingSweepGroup(JSFreeOp* fop,
IncrementalProgress beginMarkingSweepGroup(JS::GCContext* gcx,
SliceBudget& budget);
IncrementalProgress markGrayRootsInCurrentGroup(JSFreeOp* fop,
IncrementalProgress markGrayRootsInCurrentGroup(JS::GCContext* gcx,
SliceBudget& budget);
IncrementalProgress markGray(JSFreeOp* fop, SliceBudget& budget);
IncrementalProgress endMarkingSweepGroup(JSFreeOp* fop, SliceBudget& budget);
IncrementalProgress markGray(JS::GCContext* gcx, SliceBudget& budget);
IncrementalProgress endMarkingSweepGroup(JS::GCContext* gcx,
SliceBudget& budget);
void markIncomingGrayCrossCompartmentPointers();
IncrementalProgress beginSweepingSweepGroup(JSFreeOp* fop,
IncrementalProgress beginSweepingSweepGroup(JS::GCContext* gcx,
SliceBudget& budget);
void initBackgroundSweep(Zone* zone, JSFreeOp* fop,
void initBackgroundSweep(Zone* zone, JS::GCContext* gcx,
const FinalizePhase& phase);
IncrementalProgress markDuringSweeping(JSFreeOp* fop, SliceBudget& budget);
IncrementalProgress markDuringSweeping(JS::GCContext* gcx,
SliceBudget& budget);
void updateAtomsBitmap();
void sweepCCWrappers();
void sweepRealmGlobals();
void sweepEmbeddingWeakPointers(JSFreeOp* fop);
void sweepEmbeddingWeakPointers(JS::GCContext* gcx);
void sweepMisc();
void sweepCompressionTasks();
void sweepWeakMaps();
void sweepUniqueIds();
void sweepDebuggerOnMainThread(JSFreeOp* fop);
void sweepJitDataOnMainThread(JSFreeOp* fop);
void sweepDebuggerOnMainThread(JS::GCContext* gcx);
void sweepJitDataOnMainThread(JS::GCContext* gcx);
void sweepFinalizationObserversOnMainThread();
void traceWeakFinalizationObserverEdges(JSTracer* trc, Zone* zone);
void sweepWeakRefs();
IncrementalProgress endSweepingSweepGroup(JSFreeOp* fop, SliceBudget& budget);
IncrementalProgress endSweepingSweepGroup(JS::GCContext* gcx,
SliceBudget& budget);
IncrementalProgress performSweepActions(SliceBudget& sliceBudget);
void startSweepingAtomsTable();
IncrementalProgress sweepAtomsTable(JSFreeOp* fop, SliceBudget& budget);
IncrementalProgress sweepWeakCaches(JSFreeOp* fop, SliceBudget& budget);
IncrementalProgress finalizeAllocKind(JSFreeOp* fop, SliceBudget& budget);
bool foregroundFinalize(JSFreeOp* fop, Zone* zone, AllocKind thingKind,
IncrementalProgress sweepAtomsTable(JS::GCContext* gcx, SliceBudget& budget);
IncrementalProgress sweepWeakCaches(JS::GCContext* gcx, SliceBudget& budget);
IncrementalProgress finalizeAllocKind(JS::GCContext* gcx,
SliceBudget& budget);
bool foregroundFinalize(JS::GCContext* gcx, Zone* zone, AllocKind thingKind,
js::SliceBudget& sliceBudget,
SortedArenaList& sweepList);
IncrementalProgress sweepPropMapTree(JSFreeOp* fop, SliceBudget& budget);
IncrementalProgress sweepPropMapTree(JS::GCContext* gcx, SliceBudget& budget);
void endSweepPhase(bool lastGC);
void queueZonesAndStartBackgroundSweep(ZoneList& zones);
void sweepFromBackgroundThread(AutoLockHelperThreadState& lock);
void startBackgroundFree();
void freeFromBackgroundThread(AutoLockHelperThreadState& lock);
void sweepBackgroundThings(ZoneList& zones);
void backgroundFinalize(JSFreeOp* fop, Zone* zone, AllocKind kind,
void backgroundFinalize(JS::GCContext* gcx, Zone* zone, AllocKind kind,
Arena** empty);
void assertBackgroundSweepingFinished();
bool allCCVisibleZonesWereCollected();
void sweepZones(JSFreeOp* fop, bool destroyingRuntime);
void sweepZones(JS::GCContext* gcx, bool destroyingRuntime);
bool shouldDecommit() const;
void startDecommit();
void decommitEmptyChunks(const bool& cancel, AutoLockGC& lock);
@ -905,7 +909,7 @@ class GCRuntime {
void checkForCompartmentMismatches();
#endif
void callFinalizeCallbacks(JSFreeOp* fop, JSFinalizeStatus status) const;
void callFinalizeCallbacks(JS::GCContext* gcx, JSFinalizeStatus status) const;
void callWeakPointerZonesCallbacks(JSTracer* trc) const;
void callWeakPointerCompartmentCallbacks(JSTracer* trc,
JS::Compartment* comp) const;
@ -920,7 +924,7 @@ class GCRuntime {
// Embedders can use this zone however they wish.
MainThreadData<JS::Zone*> systemZone;
MainThreadData<JSFreeOp> mainThreadFreeOp;
MainThreadData<JS::GCContext> mainThreadFreeOp;
private:
// All zones in the runtime, except the atoms zone.

View File

@ -423,7 +423,7 @@ class alignas(ArenaSize) Arena {
inline size_t& atomBitmapStart();
template <typename T>
size_t finalize(JSFreeOp* fop, AllocKind thingKind, size_t thingSize);
size_t finalize(JS::GCContext* gcx, AllocKind thingKind, size_t thingSize);
static void staticAsserts();
static void checkLookupTables();

View File

@ -2745,12 +2745,12 @@ static inline void CheckIsMarkedThing(T* thing) {
// Allow the current thread access if it is sweeping or in sweep-marking, but
// try to check the zone. Some threads have access to all zones when sweeping.
JSFreeOp* fop = TlsFreeOp.get();
MOZ_ASSERT(fop->gcUse() != GCUse::Finalizing);
if (fop->gcUse() == GCUse::Sweeping || fop->gcUse() == GCUse::Marking) {
JS::GCContext* gcx = TlsGCContext.get();
MOZ_ASSERT(gcx->gcUse() != GCUse::Finalizing);
if (gcx->gcUse() == GCUse::Sweeping || gcx->gcUse() == GCUse::Marking) {
Zone* zone = thing->zoneFromAnyThread();
MOZ_ASSERT_IF(fop->gcSweepZone(),
fop->gcSweepZone() == zone || zone->isAtomsZone());
MOZ_ASSERT_IF(gcx->gcSweepZone(),
gcx->gcSweepZone() == zone || zone->isAtomsZone());
return;
}
@ -2797,7 +2797,7 @@ bool js::gc::IsAboutToBeFinalizedInternal(T* thing) {
// Permanent things are never finalized by non-owning runtimes. Zone state is
// unknown in this case.
#ifdef DEBUG
JSRuntime* rt = TlsFreeOp.get()->runtimeFromAnyThread();
JSRuntime* rt = TlsGCContext.get()->runtimeFromAnyThread();
MOZ_ASSERT_IF(IsOwnedByOtherRuntime(rt, thing), thing->isMarkedBlack());
#endif

View File

@ -1876,15 +1876,15 @@ bool js::Nursery::isSubChunkMode() const {
}
void js::Nursery::sweepMapAndSetObjects() {
auto fop = runtime()->defaultFreeOp();
auto gcx = runtime()->defaultFreeOp();
for (auto mapobj : mapsWithNurseryMemory_) {
MapObject::sweepAfterMinorGC(fop, mapobj);
MapObject::sweepAfterMinorGC(gcx, mapobj);
}
mapsWithNurseryMemory_.clearAndFree();
for (auto setobj : setsWithNurseryMemory_) {
SetObject::sweepAfterMinorGC(fop, setobj);
SetObject::sweepAfterMinorGC(gcx, setobj);
}
setsWithNurseryMemory_.clearAndFree();
}

View File

@ -91,7 +91,7 @@ static constexpr FinalizePhase BackgroundFinalizePhases[] = {
AllocKind::DICT_PROP_MAP}}};
template <typename T>
inline size_t Arena::finalize(JSFreeOp* fop, AllocKind thingKind,
inline size_t Arena::finalize(JS::GCContext* gcx, AllocKind thingKind,
size_t thingSize) {
/* Enforce requirements on size of T. */
MOZ_ASSERT(thingSize % CellAlignBytes == 0);
@ -125,7 +125,7 @@ inline size_t Arena::finalize(JSFreeOp* fop, AllocKind thingKind,
firstThingOrSuccessorOfLastMarkedThing = thing + thingSize;
nmarked++;
} else {
t->finalize(fop);
t->finalize(gcx);
AlwaysPoison(t, JS_SWEPT_TENURED_PATTERN, thingSize,
MemCheckKind::MakeUndefined);
gcprobes::TenuredFinalize(t);
@ -181,7 +181,7 @@ inline size_t Arena::finalize(JSFreeOp* fop, AllocKind thingKind,
// specified and inserting the others into the appropriate destination size
// bins.
template <typename T>
static inline bool FinalizeTypedArenas(JSFreeOp* fop, ArenaList& src,
static inline bool FinalizeTypedArenas(JS::GCContext* gcx, ArenaList& src,
SortedArenaList& dest,
AllocKind thingKind,
SliceBudget& budget) {
@ -191,7 +191,7 @@ static inline bool FinalizeTypedArenas(JSFreeOp* fop, ArenaList& src,
size_t thingsPerArena = Arena::thingsPerArena(thingKind);
while (Arena* arena = src.takeFirstArena()) {
size_t nmarked = arena->finalize<T>(fop, thingKind, thingSize);
size_t nmarked = arena->finalize<T>(gcx, thingKind, thingSize);
size_t nfree = thingsPerArena - nmarked;
if (nmarked) {
@ -212,13 +212,14 @@ static inline bool FinalizeTypedArenas(JSFreeOp* fop, ArenaList& src,
/*
* Finalize the list of areans.
*/
static bool FinalizeArenas(JSFreeOp* fop, ArenaList& src, SortedArenaList& dest,
AllocKind thingKind, SliceBudget& budget) {
static bool FinalizeArenas(JS::GCContext* gcx, ArenaList& src,
SortedArenaList& dest, AllocKind thingKind,
SliceBudget& budget) {
switch (thingKind) {
#define EXPAND_CASE(allocKind, traceKind, type, sizedType, bgFinal, nursery, \
compact) \
case AllocKind::allocKind: \
return FinalizeTypedArenas<type>(fop, src, dest, thingKind, budget);
return FinalizeTypedArenas<type>(gcx, src, dest, thingKind, budget);
FOR_EACH_ALLOCKIND(EXPAND_CASE)
#undef EXPAND_CASE
@ -227,7 +228,7 @@ static bool FinalizeArenas(JSFreeOp* fop, ArenaList& src, SortedArenaList& dest,
}
}
void GCRuntime::initBackgroundSweep(Zone* zone, JSFreeOp* fop,
void GCRuntime::initBackgroundSweep(Zone* zone, JS::GCContext* gcx,
const FinalizePhase& phase) {
gcstats::AutoPhase ap(stats(), phase.statsPhase);
for (auto kind : phase.kinds) {
@ -244,8 +245,8 @@ void ArenaLists::initBackgroundSweep(AllocKind thingKind) {
}
}
void GCRuntime::backgroundFinalize(JSFreeOp* fop, Zone* zone, AllocKind kind,
Arena** empty) {
void GCRuntime::backgroundFinalize(JS::GCContext* gcx, Zone* zone,
AllocKind kind, Arena** empty) {
MOZ_ASSERT(empty);
ArenaLists* lists = &zone->arenas;
@ -258,7 +259,7 @@ void GCRuntime::backgroundFinalize(JSFreeOp* fop, Zone* zone, AllocKind kind,
SortedArenaList finalizedSorted(Arena::thingsPerArena(kind));
auto unlimited = SliceBudget::unlimited();
FinalizeArenas(fop, arenas, finalizedSorted, kind, unlimited);
FinalizeArenas(gcx, arenas, finalizedSorted, kind, unlimited);
MOZ_ASSERT(arenas.isEmpty());
finalizedSorted.extractEmpty(empty);
@ -319,7 +320,7 @@ void GCRuntime::sweepBackgroundThings(ZoneList& zones) {
return;
}
JSFreeOp* fop = TlsFreeOp.get();
JS::GCContext* gcx = TlsGCContext.get();
// Sweep zones in order. The atoms zone must be finalized last as other
// zones may have direct pointers into it.
@ -335,7 +336,7 @@ void GCRuntime::sweepBackgroundThings(ZoneList& zones) {
// BackgroundFinalizePhases.
for (auto phase : BackgroundFinalizePhases) {
for (auto kind : phase.kinds) {
backgroundFinalize(fop, zone, kind, &emptyArenas);
backgroundFinalize(gcx, zone, kind, &emptyArenas);
}
}
@ -456,12 +457,12 @@ void GCRuntime::freeFromBackgroundThread(AutoLockHelperThreadState& lock) {
lifoBlocks.freeAll();
JSFreeOp* fop = TlsFreeOp.get();
JS::GCContext* gcx = TlsGCContext.get();
for (Nursery::BufferSet::Range r = buffers.all(); !r.empty();
r.popFront()) {
// Malloc memory associated with nursery objects is not tracked as these
// are assumed to be short lived.
fop->freeUntracked(r.front());
gcx->freeUntracked(r.front());
}
} while (!lifoBlocksToFree.ref().isEmpty() ||
!buffersToFreeAfterMinorGC.ref().empty());
@ -1050,7 +1051,7 @@ static inline void MaybeCheckWeakMapMarking(GCRuntime* gc) {
#endif
}
IncrementalProgress GCRuntime::beginMarkingSweepGroup(JSFreeOp* fop,
IncrementalProgress GCRuntime::beginMarkingSweepGroup(JS::GCContext* gcx,
SliceBudget& budget) {
MOZ_ASSERT(!markOnBackgroundThreadDuringSweeping);
MOZ_ASSERT(marker.isDrained());
@ -1076,7 +1077,7 @@ IncrementalProgress GCRuntime::beginMarkingSweepGroup(JSFreeOp* fop,
}
IncrementalProgress GCRuntime::markGrayRootsInCurrentGroup(
JSFreeOp* fop, SliceBudget& budget) {
JS::GCContext* gcx, SliceBudget& budget) {
gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::SWEEP_MARK);
AutoSetMarkColor setColorGray(marker, MarkColor::Gray);
@ -1085,7 +1086,8 @@ IncrementalProgress GCRuntime::markGrayRootsInCurrentGroup(
budget, gcstats::PhaseKind::SWEEP_MARK_GRAY);
}
IncrementalProgress GCRuntime::markGray(JSFreeOp* fop, SliceBudget& budget) {
IncrementalProgress GCRuntime::markGray(JS::GCContext* gcx,
SliceBudget& budget) {
gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::SWEEP_MARK);
if (markUntilBudgetExhausted(budget) == NotFinished) {
@ -1095,7 +1097,7 @@ IncrementalProgress GCRuntime::markGray(JSFreeOp* fop, SliceBudget& budget) {
return Finished;
}
IncrementalProgress GCRuntime::endMarkingSweepGroup(JSFreeOp* fop,
IncrementalProgress GCRuntime::endMarkingSweepGroup(JS::GCContext* gcx,
SliceBudget& budget) {
MOZ_ASSERT(!markOnBackgroundThreadDuringSweeping);
MOZ_ASSERT(marker.isDrained());
@ -1276,13 +1278,13 @@ void GCRuntime::joinTask(GCParallelTask& task,
task.joinWithLockHeld(lock);
}
void GCRuntime::sweepDebuggerOnMainThread(JSFreeOp* fop) {
void GCRuntime::sweepDebuggerOnMainThread(JS::GCContext* gcx) {
SweepingTracer trc(rt);
AutoLockStoreBuffer lock(&storeBuffer());
// Detach unreachable debuggers and global objects from each other.
// This can modify weakmaps and so must happen before weakmap sweeping.
DebugAPI::sweepAll(fop);
DebugAPI::sweepAll(gcx);
gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::SWEEP_COMPARTMENTS);
@ -1297,7 +1299,7 @@ void GCRuntime::sweepDebuggerOnMainThread(JSFreeOp* fop) {
}
}
void GCRuntime::sweepJitDataOnMainThread(JSFreeOp* fop) {
void GCRuntime::sweepJitDataOnMainThread(JS::GCContext* gcx) {
SweepingTracer trc(rt);
{
gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::SWEEP_JIT_DATA);
@ -1320,7 +1322,7 @@ void GCRuntime::sweepJitDataOnMainThread(JSFreeOp* fop) {
if (initialState != State::NotActive) {
gcstats::AutoPhase apdc(stats(), gcstats::PhaseKind::SWEEP_DISCARD_CODE);
for (SweepGroupZonesIter zone(this); !zone.done(); zone.next()) {
zone->discardJitCode(fop);
zone->discardJitCode(gcx);
}
}
@ -1407,13 +1409,13 @@ static void SweepAllWeakCachesOnMainThread(JSRuntime* rt) {
});
}
void GCRuntime::sweepEmbeddingWeakPointers(JSFreeOp* fop) {
void GCRuntime::sweepEmbeddingWeakPointers(JS::GCContext* gcx) {
using namespace gcstats;
AutoLockStoreBuffer lock(&storeBuffer());
AutoPhase ap(stats(), PhaseKind::FINALIZE_START);
callFinalizeCallbacks(fop, JSFINALIZE_GROUP_PREPARE);
callFinalizeCallbacks(gcx, JSFINALIZE_GROUP_PREPARE);
{
AutoPhase ap2(stats(), PhaseKind::WEAK_ZONES_CALLBACK);
callWeakPointerZonesCallbacks(&sweepingTracer);
@ -1426,10 +1428,10 @@ void GCRuntime::sweepEmbeddingWeakPointers(JSFreeOp* fop) {
}
}
}
callFinalizeCallbacks(fop, JSFINALIZE_GROUP_START);
callFinalizeCallbacks(gcx, JSFINALIZE_GROUP_START);
}
IncrementalProgress GCRuntime::beginSweepingSweepGroup(JSFreeOp* fop,
IncrementalProgress GCRuntime::beginSweepingSweepGroup(JS::GCContext* gcx,
SliceBudget& budget) {
/*
* Begin sweeping the group of zones in currentSweepGroup, performing
@ -1477,7 +1479,7 @@ IncrementalProgress GCRuntime::beginSweepingSweepGroup(JSFreeOp* fop,
AutoSetThreadIsSweeping threadIsSweeping;
// This must happen before sweeping realm globals.
sweepDebuggerOnMainThread(fop);
sweepDebuggerOnMainThread(gcx);
// FinalizationRegistry sweeping touches weak maps and so must not run in
// parallel with that. This triggers a read barrier and can add marking work
@ -1488,7 +1490,7 @@ IncrementalProgress GCRuntime::beginSweepingSweepGroup(JSFreeOp* fop,
// This must happen before updating embedding weak pointers.
sweepRealmGlobals();
sweepEmbeddingWeakPointers(fop);
sweepEmbeddingWeakPointers(gcx);
{
AutoLockHelperThreadState lock;
@ -1518,7 +1520,7 @@ IncrementalProgress GCRuntime::beginSweepingSweepGroup(JSFreeOp* fop,
{
AutoUnlockHelperThreadState unlock(lock);
sweepJitDataOnMainThread(fop);
sweepJitDataOnMainThread(gcx);
if (!canSweepWeakCachesOffThread) {
MOZ_ASSERT(sweepCacheTasks.empty());
@ -1540,7 +1542,7 @@ IncrementalProgress GCRuntime::beginSweepingSweepGroup(JSFreeOp* fop,
for (SweepGroupZonesIter zone(this); !zone.done(); zone.next()) {
for (const auto& phase : BackgroundFinalizePhases) {
initBackgroundSweep(zone, fop, phase);
initBackgroundSweep(zone, gcx, phase);
}
zone->arenas.queueForegroundThingsForSweep();
@ -1568,7 +1570,7 @@ bool GCRuntime::shouldYieldForZeal(ZealMode mode) {
}
#endif
IncrementalProgress GCRuntime::endSweepingSweepGroup(JSFreeOp* fop,
IncrementalProgress GCRuntime::endSweepingSweepGroup(JS::GCContext* gcx,
SliceBudget& budget) {
// This is to prevent a race between markTask checking the zone state and
// us changing it below.
@ -1585,7 +1587,7 @@ IncrementalProgress GCRuntime::endSweepingSweepGroup(JSFreeOp* fop,
{
gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::FINALIZE_END);
AutoLockStoreBuffer lock(&storeBuffer());
callFinalizeCallbacks(fop, JSFINALIZE_GROUP_END);
callFinalizeCallbacks(gcx, JSFINALIZE_GROUP_END);
}
/* Free LIFO blocks on a background thread if possible. */
@ -1626,7 +1628,7 @@ IncrementalProgress GCRuntime::endSweepingSweepGroup(JSFreeOp* fop,
return Finished;
}
IncrementalProgress GCRuntime::markDuringSweeping(JSFreeOp* fop,
IncrementalProgress GCRuntime::markDuringSweeping(JS::GCContext* gcx,
SliceBudget& budget) {
MOZ_ASSERT(markTask.isIdle());
@ -1677,7 +1679,7 @@ void GCRuntime::beginSweepPhase(JS::GCReason reason, AutoGCSession& session) {
sweepActions->assertFinished();
}
bool GCRuntime::foregroundFinalize(JSFreeOp* fop, Zone* zone,
bool GCRuntime::foregroundFinalize(JS::GCContext* gcx, Zone* zone,
AllocKind thingKind,
SliceBudget& sliceBudget,
SortedArenaList& sweepList) {
@ -1688,7 +1690,7 @@ bool GCRuntime::foregroundFinalize(JSFreeOp* fop, Zone* zone,
// finalizers for that allocation kind have run. Empty arenas are only
// released when everything in the zone has been swept (see
// GCRuntime::sweepBackgroundThings for more details).
if (!FinalizeArenas(fop, lists.collectingArenaList(thingKind), sweepList,
if (!FinalizeArenas(gcx, lists.collectingArenaList(thingKind), sweepList,
thingKind, sliceBudget)) {
// Copy the current contents of sweepList so that ArenaIter can find them.
lists.setIncrementalSweptArenas(thingKind, sweepList);
@ -1728,20 +1730,20 @@ IncrementalProgress GCRuntime::joinBackgroundMarkTask() {
}
template <typename T>
static void SweepThing(JSFreeOp* fop, T* thing) {
static void SweepThing(JS::GCContext* gcx, T* thing) {
if (!thing->isMarkedAny()) {
thing->sweep(fop);
thing->sweep(gcx);
}
}
template <typename T>
static bool SweepArenaList(JSFreeOp* fop, Arena** arenasToSweep,
static bool SweepArenaList(JS::GCContext* gcx, Arena** arenasToSweep,
SliceBudget& sliceBudget) {
while (Arena* arena = *arenasToSweep) {
MOZ_ASSERT(arena->zone->isGCSweeping());
for (ArenaCellIterUnderGC cell(arena); !cell.done(); cell.next()) {
SweepThing(fop, cell.as<T>());
SweepThing(gcx, cell.as<T>());
}
Arena* next = arena->next;
@ -1775,7 +1777,7 @@ void GCRuntime::startSweepingAtomsTable() {
}
}
IncrementalProgress GCRuntime::sweepAtomsTable(JSFreeOp* fop,
IncrementalProgress GCRuntime::sweepAtomsTable(JS::GCContext* gcx,
SliceBudget& budget) {
if (!atomsZone->isGCSweeping()) {
return Finished;
@ -1851,7 +1853,7 @@ void WeakCacheSweepIterator::settle() {
(sweepCache && sweepCache->needsIncrementalBarrier()));
}
IncrementalProgress GCRuntime::sweepWeakCaches(JSFreeOp* fop,
IncrementalProgress GCRuntime::sweepWeakCaches(JS::GCContext* gcx,
SliceBudget& budget) {
if (weakCachesToSweep.ref().isNothing()) {
return Finished;
@ -1878,7 +1880,7 @@ IncrementalProgress GCRuntime::sweepWeakCaches(JSFreeOp* fop,
return NotFinished;
}
IncrementalProgress GCRuntime::finalizeAllocKind(JSFreeOp* fop,
IncrementalProgress GCRuntime::finalizeAllocKind(JS::GCContext* gcx,
SliceBudget& budget) {
MOZ_ASSERT(sweepZone->isGCSweeping());
@ -1889,7 +1891,7 @@ IncrementalProgress GCRuntime::finalizeAllocKind(JSFreeOp* fop,
AutoSetThreadIsSweeping threadIsSweeping(sweepZone);
if (!foregroundFinalize(fop, sweepZone, sweepAllocKind, budget, sweepList)) {
if (!foregroundFinalize(gcx, sweepZone, sweepAllocKind, budget, sweepList)) {
return NotFinished;
}
@ -1899,7 +1901,7 @@ IncrementalProgress GCRuntime::finalizeAllocKind(JSFreeOp* fop,
return Finished;
}
IncrementalProgress GCRuntime::sweepPropMapTree(JSFreeOp* fop,
IncrementalProgress GCRuntime::sweepPropMapTree(JS::GCContext* gcx,
SliceBudget& budget) {
// Remove dead SharedPropMaps from the tree. This happens incrementally on the
// main thread. PropMaps are finalized later on the a background thread.
@ -1909,11 +1911,11 @@ IncrementalProgress GCRuntime::sweepPropMapTree(JSFreeOp* fop,
ArenaLists& al = sweepZone->arenas;
if (!SweepArenaList<CompactPropMap>(
fop, &al.gcCompactPropMapArenasToUpdate.ref(), budget)) {
gcx, &al.gcCompactPropMapArenasToUpdate.ref(), budget)) {
return NotFinished;
}
if (!SweepArenaList<NormalPropMap>(
fop, &al.gcNormalPropMapArenasToUpdate.ref(), budget)) {
gcx, &al.gcNormalPropMapArenasToUpdate.ref(), budget)) {
return NotFinished;
}
@ -2002,7 +2004,7 @@ namespace sweepaction {
// Implementation of the SweepAction interface that calls a method on GCRuntime.
class SweepActionCall final : public SweepAction {
using Method = IncrementalProgress (GCRuntime::*)(JSFreeOp* fop,
using Method = IncrementalProgress (GCRuntime::*)(JS::GCContext* gcx,
SliceBudget& budget);
Method method;
@ -2010,7 +2012,7 @@ class SweepActionCall final : public SweepAction {
public:
explicit SweepActionCall(Method m) : method(m) {}
IncrementalProgress run(Args& args) override {
return (args.gc->*method)(args.fop, args.budget);
return (args.gc->*method)(args.gcx, args.budget);
}
void assertFinished() const override {}
};
@ -2137,7 +2139,7 @@ class SweepActionForEach final : public SweepAction {
};
static UniquePtr<SweepAction> Call(IncrementalProgress (GCRuntime::*method)(
JSFreeOp* fop, SliceBudget& budget)) {
JS::GCContext* gcx, SliceBudget& budget)) {
return MakeUnique<SweepActionCall>(method);
}
@ -2228,8 +2230,8 @@ IncrementalProgress GCRuntime::performSweepActions(SliceBudget& budget) {
AutoMajorGCProfilerEntry s(this);
gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::SWEEP);
JSFreeOp* fop = rt->defaultFreeOp();
AutoPoisonFreedJitCode pjc(fop);
JS::GCContext* gcx = rt->defaultFreeOp();
AutoPoisonFreedJitCode pjc(gcx);
// Don't trigger pre-barriers when finalizing.
AutoDisableBarriers disableBarriers(this);
@ -2244,13 +2246,13 @@ IncrementalProgress GCRuntime::performSweepActions(SliceBudget& budget) {
MOZ_ASSERT(initialState <= State::Sweep);
MOZ_ASSERT_IF(initialState != State::Sweep, marker.isDrained());
if (initialState == State::Sweep &&
markDuringSweeping(fop, budget) == NotFinished) {
markDuringSweeping(gcx, budget) == NotFinished) {
return NotFinished;
}
// Then continue running sweep actions.
SweepAction::Args args{this, fop, budget};
SweepAction::Args args{this, gcx, budget};
IncrementalProgress sweepProgress = sweepActions->run(args);
IncrementalProgress markProgress = joinBackgroundMarkTask();

View File

@ -139,9 +139,9 @@ void ZoneAllocPolicy::decMemory(size_t nbytes) {
// Unfortunately we don't have enough context here to know whether we're being
// called on behalf of the collector so we have to do a TLS lookup to find
// out.
JSFreeOp* fop = TlsFreeOp.get();
JS::GCContext* gcx = TlsGCContext.get();
zone_->decNonGCMemory(this, nbytes, MemoryUse::ZoneAllocPolicy,
fop->isCollecting());
gcx->isCollecting());
}
JS::Zone::Zone(JSRuntime* rt, Kind kind)
@ -390,7 +390,7 @@ void Zone::checkStringWrappersAfterMovingGC() {
}
#endif
void Zone::discardJitCode(JSFreeOp* fop, const DiscardOptions& options) {
void Zone::discardJitCode(JS::GCContext* gcx, const DiscardOptions& options) {
if (!jitZone()) {
return;
}
@ -419,7 +419,7 @@ void Zone::discardJitCode(JSFreeOp* fop, const DiscardOptions& options) {
}
// Invalidate all Ion code in this zone.
jit::InvalidateAll(fop, this);
jit::InvalidateAll(gcx, this);
for (auto base = cellIterUnsafe<BaseScript>(); !base.done(); base.next()) {
jit::JitScript* jitScript = base->maybeJitScript();
@ -428,12 +428,12 @@ void Zone::discardJitCode(JSFreeOp* fop, const DiscardOptions& options) {
}
JSScript* script = base->asJSScript();
jit::FinishInvalidation(fop, script);
jit::FinishInvalidation(gcx, script);
// Discard baseline script if it's not marked as active.
if (options.discardBaselineCode) {
if (jitScript->hasBaselineScript() && !jitScript->active()) {
jit::FinishDiscardBaselineScript(fop, script);
jit::FinishDiscardBaselineScript(gcx, script);
}
}
@ -450,12 +450,12 @@ void Zone::discardJitCode(JSFreeOp* fop, const DiscardOptions& options) {
// releasing JIT code because we can't do this when the script still has
// JIT code.
if (options.discardJitScripts) {
script->maybeReleaseJitScript(fop);
script->maybeReleaseJitScript(gcx);
jitScript = script->maybeJitScript();
if (!jitScript) {
// Try to discard the ScriptCounts too.
if (!script->realm()->collectCoverageForDebug() &&
!fop->runtime()->profilingScripts) {
!gcx->runtime()->profilingScripts) {
script->destroyScriptCounts();
}
continue;

View File

@ -301,7 +301,7 @@ class Zone : public js::ZoneAllocator, public js::gc::GraphNodeBase<JS::Zone> {
[[nodiscard]] bool init();
void destroy(JSFreeOp* fop);
void destroy(JS::GCContext* gcx);
[[nodiscard]] bool findSweepGroupEdges(Zone* atomsZone);
@ -313,7 +313,7 @@ class Zone : public js::ZoneAllocator, public js::gc::GraphNodeBase<JS::Zone> {
bool resetPretenuredAllocSites = false;
};
void discardJitCode(JSFreeOp* fop,
void discardJitCode(JS::GCContext* gcx,
const DiscardOptions& options = DiscardOptions());
void resetAllocSitesAndInvalidate(bool resetNurserySites,
@ -405,7 +405,7 @@ class Zone : public js::ZoneAllocator, public js::gc::GraphNodeBase<JS::Zone> {
void sweepAfterMinorGC(JSTracer* trc);
void sweepUniqueIds();
void sweepCompartments(JSFreeOp* fop, bool keepAtleastOne, bool lastGC);
void sweepCompartments(JS::GCContext* gcx, bool keepAtleastOne, bool lastGC);
// Remove dead weak maps from gcWeakMapList_ and remove entries from the
// remaining weak maps whose keys are dead.

View File

@ -527,11 +527,11 @@ void BaselineScript::trace(JSTracer* trc) {
TraceEdge(trc, &method_, "baseline-method");
}
void BaselineScript::Destroy(JSFreeOp* fop, BaselineScript* script) {
void BaselineScript::Destroy(JS::GCContext* gcx, BaselineScript* script) {
MOZ_ASSERT(!script->hasPendingIonCompileTask());
// This allocation is tracked by JSScript::setBaselineScriptImpl.
fop->deleteUntracked(script);
gcx->deleteUntracked(script);
}
void JS::DeletePolicy<js::jit::BaselineScript>::operator()(
@ -959,13 +959,13 @@ void BaselineInterpreter::toggleCodeCoverageInstrumentation(bool enable) {
toggleCodeCoverageInstrumentationUnchecked(enable);
}
void jit::FinishDiscardBaselineScript(JSFreeOp* fop, JSScript* script) {
void jit::FinishDiscardBaselineScript(JS::GCContext* gcx, JSScript* script) {
MOZ_ASSERT(script->hasBaselineScript());
MOZ_ASSERT(!script->jitScript()->active());
BaselineScript* baseline =
script->jitScript()->clearBaselineScript(fop, script);
BaselineScript::Destroy(fop, baseline);
script->jitScript()->clearBaselineScript(gcx, script);
BaselineScript::Destroy(gcx, baseline);
}
void jit::AddSizeOfBaselineData(JSScript* script,

View File

@ -311,7 +311,7 @@ class alignas(uintptr_t) BaselineScript final : public TrailingArray {
size_t debugTrapEntries, size_t resumeEntries,
size_t traceLoggerToggleOffsetEntries);
static void Destroy(JSFreeOp* fop, BaselineScript* script);
static void Destroy(JS::GCContext* gcx, BaselineScript* script);
void trace(JSTracer* trc);
@ -431,7 +431,7 @@ bool CanBaselineInterpretScript(JSScript* script);
bool BaselineCompileFromBaselineInterpreter(JSContext* cx, BaselineFrame* frame,
uint8_t** res);
void FinishDiscardBaselineScript(JSFreeOp* fop, JSScript* script);
void FinishDiscardBaselineScript(JS::GCContext* gcx, JSScript* script);
void AddSizeOfBaselineData(JSScript* script, mozilla::MallocSizeOf mallocSizeOf,
size_t* data);

View File

@ -40,8 +40,8 @@ class RecompileInfo {
using RecompileInfoVector = JS::GCVector<RecompileInfo, 1, SystemAllocPolicy>;
// Called from Zone::discardJitCode().
void InvalidateAll(JSFreeOp* fop, JS::Zone* zone);
void FinishInvalidation(JSFreeOp* fop, JSScript* script);
void InvalidateAll(JS::GCContext* gcx, JS::Zone* zone);
void FinishInvalidation(JS::GCContext* gcx, JSScript* script);
// Add compilations involving |script| (outer script or inlined) to the vector.
void AddPendingInvalidation(jit::RecompileInfoVector& invalid,

View File

@ -634,10 +634,10 @@ void JitCode::traceChildren(JSTracer* trc) {
}
}
void JitCode::finalize(JSFreeOp* fop) {
void JitCode::finalize(JS::GCContext* gcx) {
// If this jitcode had a bytecode map, it must have already been removed.
#ifdef DEBUG
JSRuntime* rt = fop->runtime();
JSRuntime* rt = gcx->runtime();
if (hasBytecodeMap_) {
MOZ_ASSERT(rt->jitRuntime()->hasJitcodeGlobalTable());
MOZ_ASSERT(!rt->jitRuntime()->getJitcodeGlobalTable()->lookup(raw()));
@ -653,7 +653,7 @@ void JitCode::finalize(JSFreeOp* fop) {
// With W^X JIT code, reprotecting memory for each JitCode instance is
// slow, so we record the ranges and poison them later all at once. It's
// safe to ignore OOM here, it just means we won't poison the code.
if (fop->appendJitPoisonRange(JitPoisonRange(pool_, raw() - headerSize_,
if (gcx->appendJitPoisonRange(JitPoisonRange(pool_, raw() - headerSize_,
headerSize_ + bufferSize_))) {
pool_->addRef();
}
@ -940,7 +940,7 @@ const OsiIndex* IonScript::getOsiIndex(uint8_t* retAddr) const {
return getOsiIndex(disp);
}
void IonScript::Destroy(JSFreeOp* fop, IonScript* script) {
void IonScript::Destroy(JS::GCContext* gcx, IonScript* script) {
// Make sure there are no pointers into the IonScript's nursery objects list
// in the store buffer. Because this can be called during sweeping when
// discarding JIT code, we have to lock the store buffer when we find an
@ -952,13 +952,13 @@ void IonScript::Destroy(JSFreeOp* fop, IonScript* script) {
continue;
}
if (lock.isNothing()) {
lock.emplace(&fop->runtime()->gc.storeBuffer());
lock.emplace(&gcx->runtime()->gc.storeBuffer());
}
script->nurseryObjects()[i] = HeapPtrObject();
}
// This allocation is tracked by JSScript::setIonScriptImpl.
fop->deleteUntracked(script);
gcx->deleteUntracked(script);
}
void JS::DeletePolicy<js::jit::IonScript>::operator()(
@ -2299,7 +2299,7 @@ bool jit::IonCompileScriptForBaselineOSR(JSContext* cx, BaselineFrame* frame,
return true;
}
static void InvalidateActivation(JSFreeOp* fop,
static void InvalidateActivation(JS::GCContext* gcx,
const JitActivationIterator& activations,
bool invalidateAll) {
JitSpew(JitSpew_IonInvalidate, "BEGIN invalidating activation");
@ -2463,7 +2463,7 @@ static void InvalidateActivation(JSFreeOp* fop,
JitSpew(JitSpew_IonInvalidate, "END invalidating activation");
}
void jit::InvalidateAll(JSFreeOp* fop, Zone* zone) {
void jit::InvalidateAll(JS::GCContext* gcx, Zone* zone) {
// The caller should previously have cancelled off thread compilation.
#ifdef DEBUG
for (RealmsInZoneIter realm(zone); !realm.done(); realm.next()) {
@ -2477,7 +2477,7 @@ void jit::InvalidateAll(JSFreeOp* fop, Zone* zone) {
for (JitActivationIterator iter(cx); !iter.done(); ++iter) {
if (iter->compartment()->zone() == zone) {
JitSpew(JitSpew_IonInvalidate, "Invalidating all frames for GC");
InvalidateActivation(fop, iter, true);
InvalidateActivation(gcx, iter, true);
}
}
}
@ -2532,9 +2532,9 @@ void jit::Invalidate(JSContext* cx, const RecompileInfoVector& invalid,
return;
}
JSFreeOp* fop = cx->defaultFreeOp();
JS::GCContext* gcx = cx->defaultFreeOp();
for (JitActivationIterator iter(cx); !iter.done(); ++iter) {
InvalidateActivation(fop, iter, false);
InvalidateActivation(gcx, iter, false);
}
// Drop the references added above. If a script was never active, its
@ -2554,7 +2554,7 @@ void jit::Invalidate(JSContext* cx, const RecompileInfoVector& invalid,
ClearIonScriptAfterInvalidation(cx, info.script(), ionScript, resetUses);
}
ionScript->decrementInvalidationCount(fop);
ionScript->decrementInvalidationCount(gcx);
numInvalidations--;
}
@ -2622,18 +2622,18 @@ void jit::Invalidate(JSContext* cx, JSScript* script, bool resetUses,
Invalidate(cx, scripts, resetUses, cancelOffThread);
}
void jit::FinishInvalidation(JSFreeOp* fop, JSScript* script) {
void jit::FinishInvalidation(JS::GCContext* gcx, JSScript* script) {
if (!script->hasIonScript()) {
return;
}
// In all cases, null out jitScript->ionScript_ to avoid re-entry.
IonScript* ion = script->jitScript()->clearIonScript(fop, script);
IonScript* ion = script->jitScript()->clearIonScript(gcx, script);
// If this script has Ion code on the stack, invalidated() will return
// true. In this case we have to wait until destroying it.
if (!ion->invalidated()) {
jit::IonScript::Destroy(fop, ion);
jit::IonScript::Destroy(gcx, ion);
}
}

View File

@ -292,7 +292,7 @@ class alignas(8) IonScript final : public TrailingArray {
size_t osiIndices, size_t icEntries, size_t runtimeSize,
size_t safepointsSize);
static void Destroy(JSFreeOp* fop, IonScript* script);
static void Destroy(JS::GCContext* gcx, IonScript* script);
void trace(JSTracer* trc);
@ -423,11 +423,11 @@ class alignas(8) IonScript final : public TrailingArray {
size_t invalidationCount() const { return invalidationCount_; }
void incrementInvalidationCount() { invalidationCount_++; }
void decrementInvalidationCount(JSFreeOp* fop) {
void decrementInvalidationCount(JS::GCContext* gcx) {
MOZ_ASSERT(invalidationCount_);
invalidationCount_--;
if (!invalidationCount_) {
Destroy(fop, this);
Destroy(gcx, this);
}
}
IonCompilationId compilationId() const { return compilationId_; }

View File

@ -94,7 +94,7 @@ class JitCode : public gc::TenuredCellWithNonGCPointer<uint8_t> {
size_t headerSize() const { return headerSize_; }
void traceChildren(JSTracer* trc);
void finalize(JSFreeOp* fop);
void finalize(JS::GCContext* gcx);
void setInvalidated() { invalidated_ = true; }
void setHasBytecodeMap() { hasBytecodeMap_ = true; }

View File

@ -127,7 +127,7 @@ bool JSScript::createJitScript(JSContext* cx) {
return true;
}
void JSScript::maybeReleaseJitScript(JSFreeOp* fop) {
void JSScript::maybeReleaseJitScript(JS::GCContext* gcx) {
MOZ_ASSERT(hasJitScript());
if (zone()->jitZone()->keepJitScripts() || jitScript()->hasBaselineScript() ||
@ -135,35 +135,35 @@ void JSScript::maybeReleaseJitScript(JSFreeOp* fop) {
return;
}
releaseJitScript(fop);
releaseJitScript(gcx);
}
void JSScript::releaseJitScript(JSFreeOp* fop) {
void JSScript::releaseJitScript(JS::GCContext* gcx) {
MOZ_ASSERT(hasJitScript());
MOZ_ASSERT(!hasBaselineScript());
MOZ_ASSERT(!hasIonScript());
fop->removeCellMemory(this, jitScript()->allocBytes(), MemoryUse::JitScript);
gcx->removeCellMemory(this, jitScript()->allocBytes(), MemoryUse::JitScript);
JitScript::Destroy(zone(), jitScript());
warmUpData_.clearJitScript();
updateJitCodeRaw(fop->runtime());
updateJitCodeRaw(gcx->runtime());
}
void JSScript::releaseJitScriptOnFinalize(JSFreeOp* fop) {
void JSScript::releaseJitScriptOnFinalize(JS::GCContext* gcx) {
MOZ_ASSERT(hasJitScript());
if (hasIonScript()) {
IonScript* ion = jitScript()->clearIonScript(fop, this);
jit::IonScript::Destroy(fop, ion);
IonScript* ion = jitScript()->clearIonScript(gcx, this);
jit::IonScript::Destroy(gcx, ion);
}
if (hasBaselineScript()) {
BaselineScript* baseline = jitScript()->clearBaselineScript(fop, this);
jit::BaselineScript::Destroy(fop, baseline);
BaselineScript* baseline = jitScript()->clearBaselineScript(gcx, this);
jit::BaselineScript::Destroy(gcx, baseline);
}
releaseJitScript(fop);
releaseJitScript(gcx);
}
void JitScript::CachedIonData::trace(JSTracer* trc) {
@ -467,10 +467,10 @@ void JitScript::setBaselineScriptImpl(JSScript* script,
setBaselineScriptImpl(rt->defaultFreeOp(), script, baselineScript);
}
void JitScript::setBaselineScriptImpl(JSFreeOp* fop, JSScript* script,
void JitScript::setBaselineScriptImpl(JS::GCContext* gcx, JSScript* script,
BaselineScript* baselineScript) {
if (hasBaselineScript()) {
fop->removeCellMemory(script, baselineScript_->allocBytes(),
gcx->removeCellMemory(script, baselineScript_->allocBytes(),
MemoryUse::BaselineScript);
baselineScript_.set(script->zone(), nullptr);
}
@ -484,7 +484,7 @@ void JitScript::setBaselineScriptImpl(JSFreeOp* fop, JSScript* script,
}
script->resetWarmUpResetCounter();
script->updateJitCodeRaw(fop->runtime());
script->updateJitCodeRaw(gcx->runtime());
}
void JitScript::setIonScriptImpl(JSScript* script, IonScript* ionScript) {
@ -492,14 +492,14 @@ void JitScript::setIonScriptImpl(JSScript* script, IonScript* ionScript) {
setIonScriptImpl(rt->defaultFreeOp(), script, ionScript);
}
void JitScript::setIonScriptImpl(JSFreeOp* fop, JSScript* script,
void JitScript::setIonScriptImpl(JS::GCContext* gcx, JSScript* script,
IonScript* ionScript) {
MOZ_ASSERT_IF(ionScript != IonDisabledScriptPtr,
!baselineScript()->hasPendingIonCompileTask());
JS::Zone* zone = script->zone();
if (hasIonScript()) {
fop->removeCellMemory(script, ionScript_->allocBytes(),
gcx->removeCellMemory(script, ionScript_->allocBytes(),
MemoryUse::IonScript);
ionScript_.set(zone, nullptr);
}
@ -510,7 +510,7 @@ void JitScript::setIonScriptImpl(JSFreeOp* fop, JSScript* script,
AddCellMemory(script, ionScript_->allocBytes(), MemoryUse::IonScript);
}
script->updateJitCodeRaw(fop->runtime());
script->updateJitCodeRaw(gcx->runtime());
}
#ifdef JS_STRUCTURED_SPEW

View File

@ -33,8 +33,6 @@ class JS_PUBLIC_API JSScript;
class JS_PUBLIC_API JSTracer;
struct JS_PUBLIC_API JSContext;
class JSFreeOp;
namespace JS {
class Zone;
}
@ -468,7 +466,7 @@ class alignas(uintptr_t) JitScript final : public TrailingArray {
// Methods to set baselineScript_ to a BaselineScript*, nullptr, or
// BaselineDisabledScriptPtr.
void setBaselineScriptImpl(JSScript* script, BaselineScript* baselineScript);
void setBaselineScriptImpl(JSFreeOp* fop, JSScript* script,
void setBaselineScriptImpl(JS::GCContext* gcx, JSScript* script,
BaselineScript* baselineScript);
public:
@ -487,17 +485,18 @@ class alignas(uintptr_t) JitScript final : public TrailingArray {
setBaselineScriptImpl(script, baselineScript);
MOZ_ASSERT(hasBaselineScript());
}
[[nodiscard]] BaselineScript* clearBaselineScript(JSFreeOp* fop,
[[nodiscard]] BaselineScript* clearBaselineScript(JS::GCContext* gcx,
JSScript* script) {
BaselineScript* baseline = baselineScript();
setBaselineScriptImpl(fop, script, nullptr);
setBaselineScriptImpl(gcx, script, nullptr);
return baseline;
}
private:
// Methods to set ionScript_ to an IonScript*, nullptr, or one of the special
// Ion{Disabled,Compiling}ScriptPtr values.
void setIonScriptImpl(JSFreeOp* fop, JSScript* script, IonScript* ionScript);
void setIonScriptImpl(JS::GCContext* gcx, JSScript* script,
IonScript* ionScript);
void setIonScriptImpl(JSScript* script, IonScript* ionScript);
public:
@ -517,9 +516,10 @@ class alignas(uintptr_t) JitScript final : public TrailingArray {
setIonScriptImpl(script, ionScript);
MOZ_ASSERT(hasIonScript());
}
[[nodiscard]] IonScript* clearIonScript(JSFreeOp* fop, JSScript* script) {
[[nodiscard]] IonScript* clearIonScript(JS::GCContext* gcx,
JSScript* script) {
IonScript* ion = ionScript();
setIonScriptImpl(fop, script, nullptr);
setIonScriptImpl(gcx, script, nullptr);
return ion;
}

View File

@ -192,7 +192,7 @@ bool checkFinalizeStatus() {
return true;
}
static void FinalizeCallback(JSFreeOp* fop, JSFinalizeStatus status,
static void FinalizeCallback(JS::GCContext* gcx, JSFinalizeStatus status,
void* data) {
if (FinalizeCalls < BufSize) {
StatusBuffer[FinalizeCalls] = status;

View File

@ -42,10 +42,10 @@ BEGIN_TEST(testPinAcrossGC) {
return true;
}
static void FinalizeCallback(JSFreeOp* fop, JSFinalizeStatus status,
static void FinalizeCallback(JS::GCContext* gcx, JSFinalizeStatus status,
void* data) {
if (status == JSFINALIZE_GROUP_START) {
sw.strOk = js::gc::IsMarkedUnbarriered(fop->runtime(), sw.str);
sw.strOk = js::gc::IsMarkedUnbarriered(gcx->runtime(), sw.str);
}
}
END_TEST(testPinAcrossGC)

View File

@ -12,7 +12,7 @@ struct BarkWhenTracedClass {
static int traceCount;
static const JSClass class_;
static void finalize(JSFreeOp* fop, JSObject* obj) { finalizeCount++; }
static void finalize(JS::GCContext* gcx, JSObject* obj) { finalizeCount++; }
static void trace(JSTracer* trc, JSObject* obj) { traceCount++; }
static void reset() {
finalizeCount = 0;

View File

@ -358,7 +358,7 @@ bool BaseProxyHandler::isArray(JSContext* cx, HandleObject proxy,
void BaseProxyHandler::trace(JSTracer* trc, JSObject* proxy) const {}
void BaseProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const {}
void BaseProxyHandler::finalize(JS::GCContext* gcx, JSObject* proxy) const {}
size_t BaseProxyHandler::objectMoved(JSObject* proxy, JSObject* old) const {
return 0;

View File

@ -885,17 +885,17 @@ void ProxyObject::trace(JSTracer* trc, JSObject* obj) {
Proxy::trace(trc, obj);
}
static void proxy_Finalize(JSFreeOp* fop, JSObject* obj) {
static void proxy_Finalize(JS::GCContext* gcx, JSObject* obj) {
// Suppress a bogus warning about finalize().
JS::AutoSuppressGCAnalysis nogc;
MOZ_ASSERT(obj->is<ProxyObject>());
obj->as<ProxyObject>().handler()->finalize(fop, obj);
obj->as<ProxyObject>().handler()->finalize(gcx, obj);
if (!obj->as<ProxyObject>().usingInlineValueArray()) {
// Bug 1560019: This allocation is not tracked, but is only present when
// objects are swapped which is assumed to be relatively rare.
fop->freeUntracked(js::detail::GetProxyDataLayout(obj)->values());
gcx->freeUntracked(js::detail::GetProxyDataLayout(obj)->values());
}
}

View File

@ -564,12 +564,12 @@ class FileObject : public NativeObject {
return obj;
}
static void finalize(JSFreeOp* fop, JSObject* obj) {
static void finalize(JS::GCContext* gcx, JSObject* obj) {
FileObject* fileObj = &obj->as<FileObject>();
RCFile* file = fileObj->rcFile();
fop->removeCellMemory(obj, sizeof(*file), MemoryUse::FileObjectFile);
gcx->removeCellMemory(obj, sizeof(*file), MemoryUse::FileObjectFile);
if (file->release()) {
fop->deleteUntracked(file);
gcx->deleteUntracked(file);
}
}

View File

@ -4434,7 +4434,7 @@ struct WorkerInput {
: parentRuntime(parentRuntime), chars(std::move(chars)), length(length) {}
};
static void DestroyShellCompartmentPrivate(JSFreeOp* fop,
static void DestroyShellCompartmentPrivate(JS::GCContext* gcx,
JS::Compartment* compartment) {
auto priv = static_cast<ShellCompartmentPrivate*>(
JS_GetCompartmentPrivate(compartment));
@ -5376,7 +5376,7 @@ class XDRBufferObject : public NativeObject {
return !getReservedSlot(VECTOR_SLOT).isUndefined();
}
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
/*static */ const JSClassOps XDRBufferObject::classOps_ = {
@ -5419,10 +5419,10 @@ XDRBufferObject* XDRBufferObject::create(JSContext* cx,
return bufObj;
}
void XDRBufferObject::finalize(JSFreeOp* fop, JSObject* obj) {
void XDRBufferObject::finalize(JS::GCContext* gcx, JSObject* obj) {
XDRBufferObject* buf = &obj->as<XDRBufferObject>();
if (buf->hasData()) {
fop->delete_(buf, buf->data(), buf->data()->length(),
gcx->delete_(buf, buf->data(), buf->data()->length(),
MemoryUse::XDRBufferElements);
}
}
@ -7854,7 +7854,7 @@ class StreamCacheEntryObject : public NativeObject {
static const JSClassOps classOps_;
static const JSPropertySpec properties_;
static void finalize(JSFreeOp*, JSObject* obj) {
static void finalize(JS::GCContext* gcx, JSObject* obj) {
obj->as<StreamCacheEntryObject>().cache().Release();
}

View File

@ -101,7 +101,7 @@ void CheckGlobalLock<Lock, Helper>::check() const {
switch (Lock) {
case GlobalLock::GCLock:
TlsFreeOp.get()
TlsGCContext.get()
->runtimeFromAnyThread()
->gc.assertCurrentThreadHasLockedGC();
break;

View File

@ -1015,14 +1015,14 @@ bool UnmappedArgumentsObject::obj_enumerate(JSContext* cx, HandleObject obj) {
return true;
}
void ArgumentsObject::finalize(JSFreeOp* fop, JSObject* obj) {
void ArgumentsObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(!IsInsideNursery(obj));
ArgumentsObject& argsobj = obj->as<ArgumentsObject>();
if (argsobj.data()) {
fop->free_(&argsobj, argsobj.maybeRareData(),
gcx->free_(&argsobj, argsobj.maybeRareData(),
RareArgumentsData::bytesRequired(argsobj.initialLength()),
MemoryUse::RareArgumentsData);
fop->free_(&argsobj, argsobj.data(),
gcx->free_(&argsobj, argsobj.data(),
ArgumentsData::bytesRequired(argsobj.data()->numArgs),
MemoryUse::ArgumentsData);
}

View File

@ -437,7 +437,7 @@ class ArgumentsObject : public NativeObject {
: 0);
}
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
static void trace(JSTracer* trc, JSObject* obj);
static size_t objectMoved(JSObject* dst, JSObject* src);

View File

@ -934,13 +934,13 @@ ArrayBufferObject::FreeInfo* ArrayBufferObject::freeInfo() const {
return reinterpret_cast<FreeInfo*>(inlineDataPointer());
}
void ArrayBufferObject::releaseData(JSFreeOp* fop) {
void ArrayBufferObject::releaseData(JS::GCContext* gcx) {
switch (bufferKind()) {
case INLINE_DATA:
// Inline data doesn't require releasing.
break;
case MALLOCED:
fop->free_(this, dataPointer(), byteLength(),
gcx->free_(this, dataPointer(), byteLength(),
MemoryUse::ArrayBufferContents);
break;
case NO_DATA:
@ -952,12 +952,12 @@ void ArrayBufferObject::releaseData(JSFreeOp* fop) {
break;
case MAPPED:
gc::DeallocateMappedContent(dataPointer(), byteLength());
fop->removeCellMemory(this, associatedBytes(),
gcx->removeCellMemory(this, associatedBytes(),
MemoryUse::ArrayBufferContents);
break;
case WASM:
WasmArrayRawBuffer::Release(dataPointer());
fop->removeCellMemory(this, byteLength(), MemoryUse::ArrayBufferContents);
gcx->removeCellMemory(this, byteLength(), MemoryUse::ArrayBufferContents);
break;
case EXTERNAL:
if (freeInfo()->freeFunc) {
@ -1608,8 +1608,8 @@ void ArrayBufferObject::addSizeOfExcludingThis(
}
/* static */
void ArrayBufferObject::finalize(JSFreeOp* fop, JSObject* obj) {
obj->as<ArrayBufferObject>().releaseData(fop);
void ArrayBufferObject::finalize(JS::GCContext* gcx, JSObject* obj) {
obj->as<ArrayBufferObject>().releaseData(gcx);
}
/* static */

View File

@ -428,7 +428,7 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared {
}
bool hasInlineData() const { return dataPointer() == inlineDataPointer(); }
void releaseData(JSFreeOp* fop);
void releaseData(JS::GCContext* gcx);
BufferKind bufferKind() const {
return BufferKind(flags() & BUFFER_KIND_MASK);
@ -470,7 +470,7 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared {
Handle<ArrayBufferObject*> oldBuf,
MutableHandle<ArrayBufferObject*> newBuf, JSContext* cx);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
static BufferContents createMappedContents(int fd, size_t offset,
size_t length);

View File

@ -178,11 +178,11 @@ void BigInt::initializeDigitsToZero() {
std::uninitialized_fill_n(digs.begin(), digs.Length(), 0);
}
void BigInt::finalize(JSFreeOp* fop) {
void BigInt::finalize(JS::GCContext* gcx) {
MOZ_ASSERT(isTenured());
if (hasHeapDigits()) {
size_t size = digitLength() * sizeof(Digit);
fop->free_(this, heapDigits_, size, js::MemoryUse::BigIntDigits);
gcx->free_(this, heapDigits_, size, js::MemoryUse::BigIntDigits);
}
}

View File

@ -99,7 +99,7 @@ class BigInt final : public js::gc::CellWithLengthAndFlags {
js::gc::PostWriteBarrierImpl<BigInt>(cellp, prev, next);
}
void finalize(JSFreeOp* fop);
void finalize(JS::GCContext* gcx);
js::HashNumber hash() const;
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
size_t sizeOfExcludingThisInNursery(mozilla::MallocSizeOf mallocSizeOf) const;

View File

@ -348,7 +348,7 @@ class JS::Compartment {
public:
explicit Compartment(JS::Zone* zone, bool invisibleToDebugger);
void destroy(JSFreeOp* fop);
void destroy(JS::GCContext* gcx);
[[nodiscard]] inline bool wrap(JSContext* cx, JS::MutableHandleValue vp);
@ -420,7 +420,8 @@ class JS::Compartment {
static void traceIncomingCrossCompartmentEdgesForZoneGC(
JSTracer* trc, EdgeSelector whichEdges);
void sweepRealms(JSFreeOp* fop, bool keepAtleastOne, bool destroyingRuntime);
void sweepRealms(JS::GCContext* gcx, bool keepAtleastOne,
bool destroyingRuntime);
void sweepAfterMinorGC(JSTracer* trc);
void traceCrossCompartmentObjectWrapperEdges(JSTracer* trc);

View File

@ -172,7 +172,7 @@ const ClassSpec ErrorObject::classSpecs[JSEXN_ERROR_LIMIT] = {
#define IMPLEMENT_ERROR_CLASS_MAYBE_WASM_TRAP(name) \
IMPLEMENT_ERROR_CLASS_CORE(name, ErrorObject::RESERVED_SLOTS_MAYBE_WASM_TRAP)
static void exn_finalize(JSFreeOp* fop, JSObject* obj);
static void exn_finalize(JS::GCContext* gcx, JSObject* obj);
static const JSClassOps ErrorObjectClassOps = {
nullptr, // addProperty
@ -200,10 +200,10 @@ const JSClass ErrorObject::classes[JSEXN_ERROR_LIMIT] = {
IMPLEMENT_ERROR_CLASS(CompileError), IMPLEMENT_ERROR_CLASS(LinkError),
IMPLEMENT_ERROR_CLASS_MAYBE_WASM_TRAP(RuntimeError)};
static void exn_finalize(JSFreeOp* fop, JSObject* obj) {
static void exn_finalize(JS::GCContext* gcx, JSObject* obj) {
if (JSErrorReport* report = obj->as<ErrorObject>().getErrorReport()) {
// Bug 1560019: This allocation is not currently tracked.
fop->deleteUntracked(report);
gcx->deleteUntracked(report);
}
}

View File

@ -79,7 +79,7 @@ class GetterSetter : public gc::TenuredCellWithGCPointer<JSObject> {
void traceChildren(JSTracer* trc);
void finalize(JSFreeOp* fop) {
void finalize(JS::GCContext* gcx) {
// Nothing to do.
}
};

View File

@ -1021,10 +1021,10 @@ JSObject* GlobalObject::createAsyncIteratorPrototype(
return proto;
}
void GlobalObject::releaseData(JSFreeOp* fop) {
void GlobalObject::releaseData(JS::GCContext* gcx) {
GlobalObjectData* data = maybeData();
setReservedSlot(GLOBAL_DATA_SLOT, PrivateValue(nullptr));
fop->delete_(this, data, MemoryUse::GlobalObjectData);
gcx->delete_(this, data, MemoryUse::GlobalObjectData);
}
GlobalObjectData::GlobalObjectData(Zone* zone) : varNames(zone) {}

View File

@ -292,7 +292,7 @@ class GlobalObject : public NativeObject {
void traceData(JSTracer* trc, GlobalObject* global) {
data().trace(trc, global);
}
void releaseData(JSFreeOp* fop);
void releaseData(JS::GCContext* gcx);
void addSizeOfData(mozilla::MallocSizeOf mallocSizeOf,
JS::ClassInfo* info) const {

View File

@ -1230,10 +1230,10 @@ void PropertyIteratorObject::trace(JSTracer* trc, JSObject* obj) {
}
}
void PropertyIteratorObject::finalize(JSFreeOp* fop, JSObject* obj) {
void PropertyIteratorObject::finalize(JS::GCContext* gcx, JSObject* obj) {
if (NativeIterator* ni =
obj->as<PropertyIteratorObject>().getNativeIterator()) {
fop->free_(obj, ni, ni->allocationSize(), MemoryUse::NativeIterator);
gcx->free_(obj, ni, ni->allocationSize(), MemoryUse::NativeIterator);
}
}

View File

@ -407,7 +407,7 @@ class PropertyIteratorObject : public NativeObject {
private:
static void trace(JSTracer* trc, JSObject* obj);
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
};
class ArrayIteratorObject : public NativeObject {

View File

@ -302,7 +302,7 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext,
return *runtime_->wellKnownSymbols;
}
js::PropertyName* emptyString() { return runtime_->emptyString; }
JSFreeOp* defaultFreeOp() { return runtime_->defaultFreeOp(); }
JS::GCContext* defaultFreeOp() { return runtime_->defaultFreeOp(); }
uintptr_t stackLimit(JS::StackKind kind) { return nativeStackLimit[kind]; }
uintptr_t stackLimitForJitCode(JS::StackKind kind);
size_t gcSystemPageSize() { return js::gc::SystemPageSize(); }

View File

@ -78,7 +78,7 @@ js::NativeObject::calculateDynamicSlots(Shape* shape) {
shape->getObjectClass());
}
inline void JSObject::finalize(JSFreeOp* fop) {
inline void JSObject::finalize(JS::GCContext* gcx) {
js::probes::FinalizeObject(this);
#ifdef DEBUG
@ -94,7 +94,7 @@ inline void JSObject::finalize(JSFreeOp* fop) {
clasp->isNativeObject() ? &as<js::NativeObject>() : nullptr;
if (clasp->hasFinalize()) {
clasp->doFinalize(fop, this);
clasp->doFinalize(gcx, this);
}
if (!nobj) {
@ -104,13 +104,13 @@ inline void JSObject::finalize(JSFreeOp* fop) {
if (nobj->hasDynamicSlots()) {
js::ObjectSlots* slotsHeader = nobj->getSlotsHeader();
size_t size = js::ObjectSlots::allocSize(slotsHeader->capacity());
fop->free_(this, slotsHeader, size, js::MemoryUse::ObjectSlots);
gcx->free_(this, slotsHeader, size, js::MemoryUse::ObjectSlots);
}
if (nobj->hasDynamicElements()) {
js::ObjectElements* elements = nobj->getElementsHeader();
size_t size = elements->numAllocatedElements() * sizeof(js::HeapSlot);
fop->free_(this, nobj->getUnshiftedElementsHeader(), size,
gcx->free_(this, nobj->getUnshiftedElementsHeader(), size,
js::MemoryUse::ObjectElements);
}
}

View File

@ -438,7 +438,7 @@ class JSObject
MOZ_ALWAYS_INLINE JSNative callHook() const;
MOZ_ALWAYS_INLINE JSNative constructHook() const;
MOZ_ALWAYS_INLINE void finalize(JSFreeOp* fop);
MOZ_ALWAYS_INLINE void finalize(JS::GCContext* gcx);
public:
static bool nonNativeSetProperty(JSContext* cx, js::HandleObject obj,

View File

@ -127,7 +127,7 @@ void js::BaseScript::setEnclosingScope(Scope* enclosingScope) {
warmUpData_.initEnclosingScope(enclosingScope);
}
void js::BaseScript::finalize(JSFreeOp* fop) {
void js::BaseScript::finalize(JS::GCContext* gcx) {
// Scripts with bytecode may have optional data stored in per-runtime or
// per-zone maps. Note that a failed compilation must not have entries since
// the script itself will not be marked as having bytecode.
@ -141,7 +141,7 @@ void js::BaseScript::finalize(JSFreeOp* fop) {
script->destroyScriptCounts();
}
fop->runtime()->geckoProfiler().onScriptFinalized(this);
gcx->runtime()->geckoProfiler().onScriptFinalized(this);
#ifdef MOZ_VTUNE
if (zone()->scriptVTuneIdMap) {
@ -155,7 +155,7 @@ void js::BaseScript::finalize(JSFreeOp* fop) {
#ifdef JS_CACHEIR_SPEW
maybeUpdateWarmUpCount(script);
#endif
script->releaseJitScriptOnFinalize(fop);
script->releaseJitScriptOnFinalize(gcx);
}
#ifdef JS_CACHEIR_SPEW
@ -169,7 +169,7 @@ void js::BaseScript::finalize(JSFreeOp* fop) {
size_t size = data_->allocationSize();
AlwaysPoison(data_, JS_POISONED_JSSCRIPT_DATA_PATTERN, size,
MemCheckKind::MakeNoAccess);
fop->free_(this, data_, size, MemoryUse::ScriptPrivateData);
gcx->free_(this, data_, size, MemoryUse::ScriptPrivateData);
}
freeSharedData();
@ -692,13 +692,13 @@ void JSScript::resetScriptCounts() {
}
}
void ScriptSourceObject::finalize(JSFreeOp* fop, JSObject* obj) {
MOZ_ASSERT(fop->onMainThread());
void ScriptSourceObject::finalize(JS::GCContext* gcx, JSObject* obj) {
MOZ_ASSERT(gcx->onMainThread());
ScriptSourceObject* sso = &obj->as<ScriptSourceObject>();
sso->source()->Release();
// Clear the private value, calling the release hook if necessary.
sso->setPrivate(fop->runtime(), UndefinedValue());
sso->setPrivate(gcx->runtime(), UndefinedValue());
}
static const JSClassOps ScriptSourceObjectClassOps = {

View File

@ -1058,7 +1058,7 @@ class ScriptSourceObject : public NativeObject {
public:
static const JSClass class_;
static void finalize(JSFreeOp* fop, JSObject* obj);
static void finalize(JS::GCContext* gcx, JSObject* obj);
static ScriptSourceObject* create(JSContext* cx, ScriptSource* source);
@ -1576,7 +1576,7 @@ class BaseScript : public gc::TenuredCellWithNonGCPointer<uint8_t> {
static const JS::TraceKind TraceKind = JS::TraceKind::Script;
void traceChildren(JSTracer* trc);
void finalize(JSFreeOp* fop);
void finalize(JS::GCContext* gcx);
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) {
return mallocSizeOf(data_);
@ -1818,9 +1818,9 @@ class JSScript : public js::BaseScript {
/* Ensure the script has a JitScript. */
inline bool ensureHasJitScript(JSContext* cx, js::jit::AutoKeepJitScripts&);
void maybeReleaseJitScript(JSFreeOp* fop);
void releaseJitScript(JSFreeOp* fop);
void releaseJitScriptOnFinalize(JSFreeOp* fop);
void maybeReleaseJitScript(JS::GCContext* gcx);
void releaseJitScript(JS::GCContext* gcx);
void releaseJitScriptOnFinalize(JS::GCContext* gcx);
inline js::jit::BaselineScript* baselineScript() const;
inline js::jit::IonScript* ionScript() const;

View File

@ -1729,8 +1729,8 @@ bool IsPackedArray(JSObject* obj);
// Initialize an object's reserved slot with a private value pointing to
// malloc-allocated memory and associate the memory with the object.
//
// This call should be matched with a call to JSFreeOp::free_/delete_ in the
// object's finalizer to free the memory and update the memory accounting.
// This call should be matched with a call to JS::GCContext::free_/delete_ in
// the object's finalizer to free the memory and update the memory accounting.
inline void InitReservedSlot(NativeObject* obj, uint32_t slot, void* ptr,
size_t nbytes, MemoryUse use) {

Some files were not shown because too many files have changed in this diff Show More