mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1224038 - Part 1: Add infallible versions of uid and hashcode getters; r=sfink
This commit is contained in:
parent
20437ce530
commit
f220b52540
@ -123,11 +123,7 @@ MovableCellHasher<T>::hash(const Lookup& l)
|
||||
MOZ_ASSERT(CurrentThreadCanAccessZone(l->zoneFromAnyThread()) ||
|
||||
l->zoneFromAnyThread()->isSelfHostingZone());
|
||||
|
||||
HashNumber hn;
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
if (!l->zoneFromAnyThread()->getHashCode(l, &hn))
|
||||
oomUnsafe.crash("failed to get a stable hash code");
|
||||
return hn;
|
||||
return l->zoneFromAnyThread()->getHashCodeInfallible(l);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -152,10 +148,7 @@ MovableCellHasher<T>::match(const Key& k, const Lookup& l)
|
||||
MOZ_ASSERT(zone->hasUniqueId(l));
|
||||
|
||||
// Since both already have a uid (from hash), the get is infallible.
|
||||
uint64_t uidK, uidL;
|
||||
MOZ_ALWAYS_TRUE(zone->getUniqueId(k, &uidK));
|
||||
MOZ_ALWAYS_TRUE(zone->getUniqueId(l, &uidL));
|
||||
return uidK == uidL;
|
||||
return zone->getUniqueIdInfallible(k) == zone->getUniqueIdInfallible(l);
|
||||
}
|
||||
|
||||
template struct MovableCellHasher<JSObject*>;
|
||||
|
@ -359,12 +359,16 @@ struct Zone : public JS::shadow::Zone,
|
||||
|
||||
mozilla::DebugOnly<unsigned> gcLastZoneGroupIndex;
|
||||
|
||||
static js::HashNumber UniqueIdToHash(uint64_t uid) {
|
||||
return js::HashNumber(uid >> 32) ^ js::HashNumber(uid & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
// Creates a HashNumber based on getUniqueId. Returns false on OOM.
|
||||
bool getHashCode(js::gc::Cell* cell, js::HashNumber* hashp) {
|
||||
uint64_t uid;
|
||||
if (!getUniqueId(cell, &uid))
|
||||
return false;
|
||||
*hashp = js::HashNumber(uid >> 32) ^ js::HashNumber(uid & 0xFFFFFFFF);
|
||||
*hashp = UniqueIdToHash(uid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -389,10 +393,19 @@ struct Zone : public JS::shadow::Zone,
|
||||
// If the cell was in the nursery, hopefully unlikely, then we need to
|
||||
// tell the nursery about it so that it can sweep the uid if the thing
|
||||
// does not get tenured.
|
||||
return runtimeFromAnyThread()->gc.nursery.addedUniqueIdToCell(cell);
|
||||
}
|
||||
|
||||
js::HashNumber getHashCodeInfallible(js::gc::Cell* cell) {
|
||||
return UniqueIdToHash(getUniqueIdInfallible(cell));
|
||||
}
|
||||
|
||||
uint64_t getUniqueIdInfallible(js::gc::Cell* cell) {
|
||||
uint64_t uid;
|
||||
js::AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
if (!runtimeFromAnyThread()->gc.nursery.addedUniqueIdToCell(cell))
|
||||
oomUnsafe.crash("failed to allocate tracking data for a nursery uid");
|
||||
return true;
|
||||
if (!getUniqueId(cell, &uid))
|
||||
oomUnsafe.crash("failed to allocate uid");
|
||||
return uid;
|
||||
}
|
||||
|
||||
// Return true if this cell has a UID associated with it.
|
||||
|
Loading…
Reference in New Issue
Block a user