зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1633239 - make the bitfields on CacheStorageService atomic. r=valentin,necko-reviewers
this is only a hypothetical fix to the underlying issue since we don't have a clean trace. Differential Revision: https://phabricator.services.mozilla.com/D103057
This commit is contained in:
Родитель
87d023b4d2
Коммит
316b5113e0
|
@ -64,11 +64,12 @@ typedef nsClassHashtable<nsCStringHashKey, CacheEntryTable> GlobalEntryTables;
|
|||
*/
|
||||
static GlobalEntryTables* sGlobalEntryTables;
|
||||
|
||||
CacheMemoryConsumer::CacheMemoryConsumer(uint32_t aFlags)
|
||||
: mReportedMemoryConsumption(0), mFlags(aFlags) {}
|
||||
CacheMemoryConsumer::CacheMemoryConsumer(uint32_t aFlags) {
|
||||
StoreFlags(aFlags);
|
||||
}
|
||||
|
||||
void CacheMemoryConsumer::DoMemoryReport(uint32_t aCurrentSize) {
|
||||
if (!(mFlags & DONT_REPORT) && CacheStorageService::Self()) {
|
||||
if (!(LoadFlags() & DONT_REPORT) && CacheStorageService::Self()) {
|
||||
CacheStorageService::Self()->OnMemoryConsumptionChange(this, aCurrentSize);
|
||||
}
|
||||
}
|
||||
|
@ -1278,13 +1279,13 @@ void CacheStorageService::OnMemoryConsumptionChange(
|
|||
LOG(("CacheStorageService::OnMemoryConsumptionChange [consumer=%p, size=%u]",
|
||||
aConsumer, aCurrentMemoryConsumption));
|
||||
|
||||
uint32_t savedMemorySize = aConsumer->mReportedMemoryConsumption;
|
||||
uint32_t savedMemorySize = aConsumer->LoadReportedMemoryConsumption();
|
||||
if (savedMemorySize == aCurrentMemoryConsumption) return;
|
||||
|
||||
// Exchange saved size with current one.
|
||||
aConsumer->mReportedMemoryConsumption = aCurrentMemoryConsumption;
|
||||
aConsumer->StoreReportedMemoryConsumption(aCurrentMemoryConsumption);
|
||||
|
||||
bool usingDisk = !(aConsumer->mFlags & CacheMemoryConsumer::MEMORY_ONLY);
|
||||
bool usingDisk = !(aConsumer->LoadFlags() & CacheMemoryConsumer::MEMORY_ONLY);
|
||||
bool overLimit = Pool(usingDisk).OnMemoryConsumptionChange(
|
||||
savedMemorySize, aCurrentMemoryConsumption);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "nsProxyRelease.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/AtomicBitfields.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -43,8 +44,12 @@ class CacheEntryHandle;
|
|||
class CacheMemoryConsumer {
|
||||
private:
|
||||
friend class CacheStorageService;
|
||||
uint32_t mReportedMemoryConsumption : 30;
|
||||
uint32_t mFlags : 2;
|
||||
// clang-format off
|
||||
MOZ_ATOMIC_BITFIELDS(mAtomicBitfields, 32, (
|
||||
(uint32_t, ReportedMemoryConsumption, 30),
|
||||
(uint32_t, Flags, 2)
|
||||
))
|
||||
// clang-format on
|
||||
|
||||
private:
|
||||
CacheMemoryConsumer() = delete;
|
||||
|
|
Загрузка…
Ссылка в новой задаче