Open Bug 1689214 Opened 3 years ago Updated 2 years ago

nsBaseHashtable::SizeOfExcludingThis and SizeOfIncludingThis can't be instantiated

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

People

(Reporter: janv, Unassigned)

References

Details

These methods can't be instantiated because nsBaseHashtableET currently lacks SizeOfExcludingThis/SizeOfIncludingThis implementation.

See Also: → 1755292

I tried the obvious thing here:

size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
  return KeyClass::SizeOfExcludingThis(aMallocSizeOf) +
         mData.SizeOfExcludingThis(mData);
}

(SizeOfIncludingThis isn't needed because the storage of the entry will be accounted for by the hashtable itself.)

Unfortunately, this isn't sufficient. We need to also handle the case where SizeOfExcludingThis is defined for only the key or only the data. The alternative would be to make people define useless SizeOfExcludingThis methods for classes that don't entrain any storage, but that sounds really annoying.

We even already rely on this, for the field CacheStorageService::mPurgeTimeStamps, which has type nsTHashMap<nsCStringHashKey, mozilla::TimeStamp>. This works right now because nsBaseHashtableET inherits from the key type, and nsCStringHashKey has a SizeOfExcludingThis method defined.

You need to log in before you can comment on or make changes to this bug.