зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1367795 - Refactor some use of WeakCache r=sfink
This commit is contained in:
Родитель
1d691b821d
Коммит
8fbc82a162
|
@ -1022,7 +1022,7 @@ WasmInstanceObject::create(JSContext* cx,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<WeakScopeMap> scopes = js::MakeUnique<WeakScopeMap>(cx->zone());
|
||||
UniquePtr<ScopeMap> scopes = js::MakeUnique<ScopeMap>(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<WeakInstanceSet*>(getReservedSlot(OBSERVERS_SLOT).toPrivate());
|
||||
return *reinterpret_cast<InstanceSet*>(getReservedSlot(OBSERVERS_SLOT).toPrivate());
|
||||
}
|
||||
|
||||
WasmMemoryObject::WeakInstanceSet*
|
||||
WasmMemoryObject::InstanceSet*
|
||||
WasmMemoryObject::getOrCreateObservers(JSContext* cx)
|
||||
{
|
||||
if (!hasObservers()) {
|
||||
auto observers = MakeUnique<WeakInstanceSet>(cx->zone());
|
||||
auto observers = MakeUnique<InstanceSet>(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;
|
||||
|
||||
|
|
|
@ -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<uint32_t,
|
||||
using ScopeMap = JS::WeakCache<GCHashMap<uint32_t,
|
||||
ReadBarriered<WasmFunctionScope*>,
|
||||
DefaultHasher<uint32_t>,
|
||||
SystemAllocPolicy>;
|
||||
using WeakScopeMap = JS::WeakCache<ScopeMap>;
|
||||
WeakScopeMap& scopes() const;
|
||||
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<ReadBarrieredWasmInstanceObject,
|
||||
using InstanceSet = JS::WeakCache<GCHashSet<ReadBarrieredWasmInstanceObject,
|
||||
MovableCellHasher<ReadBarrieredWasmInstanceObject>,
|
||||
SystemAllocPolicy>;
|
||||
using WeakInstanceSet = JS::WeakCache<InstanceSet>;
|
||||
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;
|
||||
|
|
|
@ -31,13 +31,13 @@ namespace wasm {
|
|||
|
||||
class Table : public ShareableBase<Table>
|
||||
{
|
||||
using InstanceSet = GCHashSet<ReadBarrieredWasmInstanceObject,
|
||||
using InstanceSet = JS::WeakCache<GCHashSet<ReadBarrieredWasmInstanceObject,
|
||||
MovableCellHasher<ReadBarrieredWasmInstanceObject>,
|
||||
SystemAllocPolicy>;
|
||||
typedef UniquePtr<uint8_t[], JS::FreePolicy> UniqueByteArray;
|
||||
SystemAllocPolicy>>;
|
||||
using UniqueByteArray = UniquePtr<uint8_t[], JS::FreePolicy>;
|
||||
|
||||
ReadBarrieredWasmTableObject maybeObject_;
|
||||
JS::WeakCache<InstanceSet> observers_;
|
||||
InstanceSet observers_;
|
||||
UniqueByteArray array_;
|
||||
const TableKind kind_;
|
||||
uint32_t length_;
|
||||
|
|
Загрузка…
Ссылка в новой задаче