diff --git a/js/src/wasm/WasmJS.cpp b/js/src/wasm/WasmJS.cpp index c871ec964367..1d07b0d065fe 100644 --- a/js/src/wasm/WasmJS.cpp +++ b/js/src/wasm/WasmJS.cpp @@ -1022,7 +1022,7 @@ WasmInstanceObject::create(JSContext* cx, return nullptr; } - UniquePtr scopes = js::MakeUnique(cx->zone()); + UniquePtr scopes = js::MakeUnique(cx->zone()); if (!scopes || !scopes->init()) { ReportOutOfMemory(cx); return nullptr; @@ -1143,10 +1143,10 @@ WasmInstanceObject::exports() const return *(ExportMap*)getReservedSlot(EXPORTS_SLOT).toPrivate(); } -WasmInstanceObject::WeakScopeMap& +WasmInstanceObject::ScopeMap& WasmInstanceObject::scopes() const { - return *(WeakScopeMap*)getReservedSlot(SCOPES_SLOT).toPrivate(); + return *(ScopeMap*)getReservedSlot(SCOPES_SLOT).toPrivate(); } static bool @@ -1440,18 +1440,18 @@ WasmMemoryObject::hasObservers() const return !getReservedSlot(OBSERVERS_SLOT).isUndefined(); } -WasmMemoryObject::WeakInstanceSet& +WasmMemoryObject::InstanceSet& WasmMemoryObject::observers() const { MOZ_ASSERT(hasObservers()); - return *reinterpret_cast(getReservedSlot(OBSERVERS_SLOT).toPrivate()); + return *reinterpret_cast(getReservedSlot(OBSERVERS_SLOT).toPrivate()); } -WasmMemoryObject::WeakInstanceSet* +WasmMemoryObject::InstanceSet* WasmMemoryObject::getOrCreateObservers(JSContext* cx) { if (!hasObservers()) { - auto observers = MakeUnique(cx->zone()); + auto observers = MakeUnique(cx->zone()); if (!observers || !observers->init()) { ReportOutOfMemory(cx); return nullptr; @@ -1478,7 +1478,7 @@ WasmMemoryObject::addMovingGrowObserver(JSContext* cx, WasmInstanceObject* insta { MOZ_ASSERT(movingGrowable()); - WeakInstanceSet* observers = getOrCreateObservers(cx); + InstanceSet* observers = getOrCreateObservers(cx); if (!observers) return false; diff --git a/js/src/wasm/WasmJS.h b/js/src/wasm/WasmJS.h index b6925132caad..8cacb6752d32 100644 --- a/js/src/wasm/WasmJS.h +++ b/js/src/wasm/WasmJS.h @@ -167,12 +167,11 @@ class WasmInstanceObject : public NativeObject // WeakScopeMap maps from function index to js::Scope. This maps is weak // to avoid holding scope objects alive. The scopes are normally created // during debugging. - using ScopeMap = GCHashMap, - DefaultHasher, - SystemAllocPolicy>; - using WeakScopeMap = JS::WeakCache; - WeakScopeMap& scopes() const; + using ScopeMap = JS::WeakCache, + DefaultHasher, + SystemAllocPolicy>>; + ScopeMap& scopes() const; public: static const unsigned RESERVED_SLOTS = 4; @@ -222,13 +221,12 @@ class WasmMemoryObject : public NativeObject static bool growImpl(JSContext* cx, const CallArgs& args); static bool grow(JSContext* cx, unsigned argc, Value* vp); - using InstanceSet = GCHashSet, - SystemAllocPolicy>; - using WeakInstanceSet = JS::WeakCache; + using InstanceSet = JS::WeakCache, + SystemAllocPolicy>>; bool hasObservers() const; - WeakInstanceSet& observers() const; - WeakInstanceSet* getOrCreateObservers(JSContext* cx); + InstanceSet& observers() const; + InstanceSet* getOrCreateObservers(JSContext* cx); public: static const unsigned RESERVED_SLOTS = 2; diff --git a/js/src/wasm/WasmTable.h b/js/src/wasm/WasmTable.h index 6c955fc72d5c..64369386ca1a 100644 --- a/js/src/wasm/WasmTable.h +++ b/js/src/wasm/WasmTable.h @@ -31,13 +31,13 @@ namespace wasm { class Table : public ShareableBase { - using InstanceSet = GCHashSet, - SystemAllocPolicy>; - typedef UniquePtr UniqueByteArray; + using InstanceSet = JS::WeakCache, + SystemAllocPolicy>>; + using UniqueByteArray = UniquePtr; ReadBarrieredWasmTableObject maybeObject_; - JS::WeakCache observers_; + InstanceSet observers_; UniqueByteArray array_; const TableKind kind_; uint32_t length_;