зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1224038 - Part 1: Add infallible versions of uid and hashcode getters; r=sfink
--HG-- extra : rebase_source : 5cc9c195abd671ce06ba196b7da7c7b8c29fde08
This commit is contained in:
Родитель
6f6428dad2
Коммит
f5c3cac3ba
|
@ -125,11 +125,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>
|
||||
|
@ -154,10 +150,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*>;
|
||||
|
|
|
@ -360,12 +360,16 @@ struct Zone : public JS::shadow::Zone,
|
|||
unsigned gcLastZoneGroupIndex;
|
||||
#endif
|
||||
|
||||
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.
|
||||
MOZ_WARN_UNUSED_RESULT 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;
|
||||
}
|
||||
|
||||
|
@ -390,10 +394,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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче