Commit b549c013 authored by Mihai Alexandru Michis's avatar Mihai Alexandru Michis
Browse files

Backed out changeset 25e500b64866 (bug 1656974) for causing failures in TestStartupCache

CLOSED TREE
parent 639b2bd0
Loading
Loading
Loading
Loading
+4 −17
Original line number Diff line number Diff line
@@ -197,6 +197,7 @@ nsresult StartupCache::FullyInitSingleton() {

StaticRefPtr<StartupCache> StartupCache::gStartupCache;
ProcessType sProcessType;
bool StartupCache::gShutdownInitiated;
bool StartupCache::gIgnoreDiskCache;
bool StartupCache::gFoundDiskCacheOnInit;

@@ -206,7 +207,6 @@ StartupCache::StartupCache()
    : mLock("StartupCache::mLock"),
      mDirty(false),
      mWrittenOnce(false),
      mStartupFinished(false),
      mCurTableReferenced(false),
      mLoaded(false),
      mFullyInitialized(false),
@@ -822,10 +822,6 @@ Result<Ok, nsresult> StartupCache::DecompressEntry(StartupCacheEntry& aEntry) {
bool StartupCache::HasEntry(const char* id) {
  AUTO_PROFILER_LABEL("StartupCache::HasEntry", OTHER);

  if (mStartupFinished) {
    return false;
  }

  MutexAutoLock lock(mLock);

  MOZ_ASSERT(
@@ -841,12 +837,6 @@ nsresult StartupCache::GetBuffer(const char* id, const char** outbuf,
  auto telemetry =
      MakeScopeExit([&label] { Telemetry::AccumulateCategorical(label); });

  // Exit here, ensuring we collect a cache miss for telemetry, but before we
  // lock. No need to potentially hang waiting on the write thread.
  if (mStartupFinished) {
    return NS_ERROR_NOT_AVAILABLE;
  }

  MutexAutoLock lock(mLock);
  if (!mLoaded) {
    return NS_ERROR_NOT_AVAILABLE;
@@ -915,7 +905,7 @@ nsresult StartupCache::GetBuffer(const char* id, const char** outbuf,
// Client gives ownership of inbuf.
nsresult StartupCache::PutBuffer(const char* id, UniquePtr<char[]>&& inbuf,
                                 uint32_t len, bool isFromChildProcess) {
  if (mStartupFinished) {
  if (StartupCache::gShutdownInitiated) {
    return NS_ERROR_NOT_AVAILABLE;
  }

@@ -1249,6 +1239,7 @@ void StartupCache::MaybeInitShutdownWrite() {
  if (mWriteTimer) {
    mWriteTimer->Cancel();
  }
  gShutdownInitiated = true;

  MaybeWriteOffMainThread();
}
@@ -1357,11 +1348,6 @@ void StartupCache::MaybeWriteOffMainThread() {
    return;
  }

  // If we're scheduling the cache to be written, then whether it's because
  // we're shutting down, or because our write timer has finished, it's safe
  // to say that we shouldn't think of ourselves as "starting up" anymore.
  mStartupFinished = true;

  if (mWrittenOnce) {
    return;
  }
@@ -1396,6 +1382,7 @@ nsresult StartupCacheListener::Observe(nsISupports* subject, const char* topic,
  if (strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
    // Do not leave the thread running past xpcom shutdown
    sc->WaitOnPrefetchThread();
    StartupCache::gShutdownInitiated = true;
    // Note that we don't do anything special for the background write
    // task; we expect the threadpool to finish running any tasks already
    // posted to it prior to shutdown. FastShutdown will call
+1 −1
Original line number Diff line number Diff line
@@ -438,7 +438,6 @@ class StartupCache : public nsIMemoryReporter {

  Atomic<bool> mDirty;
  Atomic<bool> mWrittenOnce;
  Atomic<bool> mStartupFinished;
  bool mCurTableReferenced;
  bool mLoaded;
  bool mFullyInitialized;
@@ -448,6 +447,7 @@ class StartupCache : public nsIMemoryReporter {
  size_t mCacheEntriesBaseOffset;

  static StaticRefPtr<StartupCache> gStartupCache;
  static bool gShutdownInitiated;
  static bool gIgnoreDiskCache;
  static bool gFoundDiskCacheOnInit;