Merge inbound to central r=merge a=merge FIREFOX_BETA_58_BASE
authorANDREEA PAVEL <apavel@mozilla.com>
Thu, 02 Nov 2017 15:30:14 +0200
changeset 389825 40a14ca1cf04
parent 389824 083a5838f76a (current diff)
parent 389808 725d13675a52 (diff)
child 389826 91e6ad83776b
child 389870 c019340bd9bd
child 389884 d621d36932cd
push id96921
push userapavel@mozilla.com
push dateThu, 02 Nov 2017 13:39:09 +0000
treeherdermozilla-inbound@91e6ad83776b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge, merge
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to central r=merge a=merge
--- a/dom/asmjscache/AsmJSCache.cpp
+++ b/dom/asmjscache/AsmJSCache.cpp
@@ -235,16 +235,104 @@ EvictEntries(nsIFile* aDirectory, const 
 
       usage.mFreed += fileSize;
     }
 
     entry.clear();
   }
 }
 
+/*******************************************************************************
+ * Client
+ ******************************************************************************/
+
+class Client
+  : public quota::Client
+{
+  static Client* sInstance;
+
+  bool mShutdownRequested;
+
+public:
+  Client();
+
+  static bool
+  IsShuttingDownOnBackgroundThread()
+  {
+    AssertIsOnBackgroundThread();
+
+    if (sInstance) {
+      return sInstance->IsShuttingDown();
+    }
+
+    return QuotaManager::IsShuttingDown();
+  }
+
+  static bool
+  IsShuttingDownOnNonBackgroundThread()
+  {
+    MOZ_ASSERT(!IsOnBackgroundThread());
+
+    return QuotaManager::IsShuttingDown();
+  }
+
+  bool
+  IsShuttingDown() const
+  {
+    AssertIsOnBackgroundThread();
+
+    return mShutdownRequested;
+  }
+
+  NS_INLINE_DECL_REFCOUNTING(Client, override)
+
+  Type
+  GetType() override;
+
+  nsresult
+  InitOrigin(PersistenceType aPersistenceType,
+             const nsACString& aGroup,
+             const nsACString& aOrigin,
+             const AtomicBool& aCanceled,
+             UsageInfo* aUsageInfo) override;
+
+  nsresult
+  GetUsageForOrigin(PersistenceType aPersistenceType,
+                    const nsACString& aGroup,
+                    const nsACString& aOrigin,
+                    const AtomicBool& aCanceled,
+                    UsageInfo* aUsageInfo) override;
+
+  void
+  OnOriginClearCompleted(PersistenceType aPersistenceType,
+                         const nsACString& aOrigin)
+                         override;
+
+  void
+  ReleaseIOThreadObjects() override;
+
+  void
+  AbortOperations(const nsACString& aOrigin) override;
+
+  void
+  AbortOperationsForProcess(ContentParentId aContentParentId) override;
+
+  void
+  StartIdleMaintenance() override;
+
+  void
+  StopIdleMaintenance() override;
+
+  void
+  ShutdownWorkThreads() override;
+
+private:
+  ~Client() override;
+};
+
 // FileDescriptorHolder owns a file descriptor and its memory mapping.
 // FileDescriptorHolder is derived by two runnable classes (that is,
 // (Parent|Child)Runnable.
 class FileDescriptorHolder : public Runnable
 {
 public:
   FileDescriptorHolder()
     : Runnable("dom::asmjscache::FileDescriptorHolder")
@@ -1039,16 +1127,20 @@ FindHashMatch(const Metadata& aMetadata,
 
 PAsmJSCacheEntryParent*
 AllocEntryParent(OpenMode aOpenMode,
                  WriteParams aWriteParams,
                  const PrincipalInfo& aPrincipalInfo)
 {
   AssertIsOnBackgroundThread();
 
+  if (NS_WARN_IF(Client::IsShuttingDownOnBackgroundThread())) {
+    return nullptr;
+  }
+
   if (NS_WARN_IF(aPrincipalInfo.type() == PrincipalInfo::TNullPrincipalInfo)) {
     MOZ_ASSERT(false);
     return nullptr;
   }
 
   RefPtr<ParentRunnable> runnable =
     new ParentRunnable(aPrincipalInfo, aOpenMode, aWriteParams);
 
@@ -1588,146 +1680,170 @@ CloseEntryForWrite(size_t aSize,
   // Flush to disk before writing the cookie (see OpenEntryForRead).
   if (PR_SyncMemMap(childRunnable->FileDesc(),
                     childRunnable->MappedMemory(),
                     childRunnable->FileSize()) == PR_SUCCESS) {
     *(AsmJSCookieType*)childRunnable->MappedMemory() = sAsmJSCookie;
   }
 }
 
-class Client : public quota::Client
+/*******************************************************************************
+ * Client
+ ******************************************************************************/
+
+Client* Client::sInstance = nullptr;
+
+Client::Client()
+  : mShutdownRequested(false)
 {
-  ~Client() override = default;
+  AssertIsOnBackgroundThread();
+  MOZ_ASSERT(!sInstance, "We expect this to be a singleton!");
 
-public:
-  NS_IMETHOD_(MozExternalRefCountType)
-  AddRef() override;
+  sInstance = this;
+}
+
+Client::~Client()
+{
+  AssertIsOnBackgroundThread();
+  MOZ_ASSERT(sInstance == this, "We expect this to be a singleton!");
+
+  sInstance = nullptr;
+}
+
+Client::Type
+Client::GetType()
+{
+  return ASMJS;
+}
 
-  NS_IMETHOD_(MozExternalRefCountType)
-  Release() override;
+nsresult
+Client::InitOrigin(PersistenceType aPersistenceType,
+                   const nsACString& aGroup,
+                   const nsACString& aOrigin,
+                   const AtomicBool& aCanceled,
+                   UsageInfo* aUsageInfo)
+{
+  if (!aUsageInfo) {
+    return NS_OK;
+  }
+  return GetUsageForOrigin(aPersistenceType,
+                           aGroup,
+                           aOrigin,
+                           aCanceled,
+                           aUsageInfo);
+}
 
-  Type
-  GetType() override
-  {
-    return ASMJS;
+nsresult
+Client::GetUsageForOrigin(PersistenceType aPersistenceType,
+                          const nsACString& aGroup,
+                          const nsACString& aOrigin,
+                          const AtomicBool& aCanceled,
+                          UsageInfo* aUsageInfo)
+{
+  QuotaManager* qm = QuotaManager::Get();
+  MOZ_ASSERT(qm, "We were being called by the QuotaManager");
+
+  nsCOMPtr<nsIFile> directory;
+  nsresult rv = qm->GetDirectoryForOrigin(aPersistenceType, aOrigin,
+                                          getter_AddRefs(directory));
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
   }
 
-  nsresult
-  InitOrigin(PersistenceType aPersistenceType,
-             const nsACString& aGroup,
-             const nsACString& aOrigin,
-             const AtomicBool& aCanceled,
-             UsageInfo* aUsageInfo) override
-  {
-    if (!aUsageInfo) {
-      return NS_OK;
-    }
-    return GetUsageForOrigin(aPersistenceType,
-                             aGroup,
-                             aOrigin,
-                             aCanceled,
-                             aUsageInfo);
+  MOZ_ASSERT(directory, "We're here because the origin directory exists");
+
+  rv = directory->Append(NS_LITERAL_STRING(ASMJSCACHE_DIRECTORY_NAME));
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
   }
 
-  nsresult
-  GetUsageForOrigin(PersistenceType aPersistenceType,
-                    const nsACString& aGroup,
-                    const nsACString& aOrigin,
-                    const AtomicBool& aCanceled,
-                    UsageInfo* aUsageInfo) override
-  {
-    QuotaManager* qm = QuotaManager::Get();
-    MOZ_ASSERT(qm, "We were being called by the QuotaManager");
+  DebugOnly<bool> exists;
+  MOZ_ASSERT(NS_SUCCEEDED(directory->Exists(&exists)) && exists);
+
+  nsCOMPtr<nsISimpleEnumerator> entries;
+  rv = directory->GetDirectoryEntries(getter_AddRefs(entries));
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
 
-    nsCOMPtr<nsIFile> directory;
-    nsresult rv = qm->GetDirectoryForOrigin(aPersistenceType, aOrigin,
-                                            getter_AddRefs(directory));
-    NS_ENSURE_SUCCESS(rv, rv);
-    MOZ_ASSERT(directory, "We're here because the origin directory exists");
-
-    rv = directory->Append(NS_LITERAL_STRING(ASMJSCACHE_DIRECTORY_NAME));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    DebugOnly<bool> exists;
-    MOZ_ASSERT(NS_SUCCEEDED(directory->Exists(&exists)) && exists);
+  bool hasMore;
+  while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
+         hasMore && !aCanceled) {
+    nsCOMPtr<nsISupports> entry;
+    rv = entries->GetNext(getter_AddRefs(entry));
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
 
-    nsCOMPtr<nsISimpleEnumerator> entries;
-    rv = directory->GetDirectoryEntries(getter_AddRefs(entries));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    bool hasMore;
-    while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
-           hasMore && !aCanceled) {
-      nsCOMPtr<nsISupports> entry;
-      rv = entries->GetNext(getter_AddRefs(entry));
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
-      NS_ENSURE_TRUE(file, NS_NOINTERFACE);
+    nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
+    if (NS_WARN_IF(!file)) {
+      return NS_NOINTERFACE;
+    }
 
-      int64_t fileSize;
-      rv = file->GetFileSize(&fileSize);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      MOZ_ASSERT(fileSize >= 0, "Negative size?!");
+    int64_t fileSize;
+    rv = file->GetFileSize(&fileSize);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
 
-      // Since the client is not explicitly storing files, append to database
-      // usage which represents implicit storage allocation.
-      aUsageInfo->AppendToDatabaseUsage(uint64_t(fileSize));
-    }
-    NS_ENSURE_SUCCESS(rv, rv);
+    MOZ_ASSERT(fileSize >= 0, "Negative size?!");
 
-    return NS_OK;
+    // Since the client is not explicitly storing files, append to database
+    // usage which represents implicit storage allocation.
+    aUsageInfo->AppendToDatabaseUsage(uint64_t(fileSize));
+  }
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
   }
 
-  void
-  OnOriginClearCompleted(PersistenceType aPersistenceType,
-                         const nsACString& aOrigin)
-                         override
-  { }
+  return NS_OK;
+}
 
-  void
-  ReleaseIOThreadObjects() override
-  { }
+void
+Client::OnOriginClearCompleted(PersistenceType aPersistenceType,
+                               const nsACString& aOrigin)
+{
+}
 
-  void
-  AbortOperations(const nsACString& aOrigin) override
-  { }
+void
+Client::ReleaseIOThreadObjects()
+{
+}
 
-  void
-  AbortOperationsForProcess(ContentParentId aContentParentId) override
-  { }
-
-  void
-  StartIdleMaintenance() override
-  { }
+void
+Client::AbortOperations(const nsACString& aOrigin)
+{
+}
 
-  void
-  StopIdleMaintenance() override
-  { }
+void
+Client::AbortOperationsForProcess(ContentParentId aContentParentId)
+{
+}
 
-  void
-  ShutdownWorkThreads() override
-  {
-    AssertIsOnBackgroundThread();
+void
+Client::StartIdleMaintenance()
+{
+}
 
-    if (sLiveParentActors) {
-      MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() {
-        return !sLiveParentActors;
-      }));
-    }
-  }
+void
+Client::StopIdleMaintenance()
+{
+}
 
-private:
-  nsAutoRefCnt mRefCnt;
-  NS_DECL_OWNINGTHREAD
-};
+void
+Client::ShutdownWorkThreads()
+{
+  AssertIsOnBackgroundThread();
 
-NS_IMPL_ADDREF(asmjscache::Client)
-NS_IMPL_RELEASE(asmjscache::Client)
+  if (sLiveParentActors) {
+    MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() {
+      return !sLiveParentActors;
+    }));
+  }
+}
 
 quota::Client*
 CreateClient()
 {
   return new Client();
 }
 
 } // namespace asmjscache
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -17979,21 +17979,32 @@ QuotaClient::StopIdleMaintenance()
 void
 QuotaClient::ShutdownWorkThreads()
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(!mShutdownRequested);
 
   mShutdownRequested = true;
 
+  // Shutdown maintenance thread pool (this spins the event loop until all
+  // threads are gone). This should release any maintenance related quota
+  // objects.
   if (mMaintenanceThreadPool) {
     mMaintenanceThreadPool->Shutdown();
     mMaintenanceThreadPool = nullptr;
   }
 
+  // Let any runnables dispatched from dying maintenance threads to be
+  // processed. This should release any maintenance related directory locks.
+  if (mCurrentMaintenance) {
+    MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() {
+      return !mCurrentMaintenance;
+    }));
+  }
+
   RefPtr<ConnectionPool> connectionPool = gConnectionPool.get();
   if (connectionPool) {
     connectionPool->Shutdown();
 
     gConnectionPool = nullptr;
   }
 
   RefPtr<FileHandleThreadPool> fileHandleThreadPool =
@@ -18307,17 +18318,18 @@ Maintenance::UnregisterDatabaseMaintenan
 }
 
 nsresult
 Maintenance::Start()
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(mState == State::Initial);
 
-  if (IsAborted()) {
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
+      IsAborted()) {
     return NS_ERROR_ABORT;
   }
 
   // Make sure that the IndexedDatabaseManager is running so that we can check
   // for low disk space mode.
 
   if (IndexedDatabaseManager::Get()) {
     OpenDirectory();
@@ -18331,17 +18343,18 @@ Maintenance::Start()
 }
 
 nsresult
 Maintenance::CreateIndexedDatabaseManager()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mState == State::CreateIndexedDatabaseManager);
 
-  if (IsAborted()) {
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
+      IsAborted()) {
     return NS_ERROR_ABORT;
   }
 
   IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
   if (NS_WARN_IF(!mgr)) {
     return NS_ERROR_FAILURE;
   }
 
@@ -18356,17 +18369,18 @@ nsresult
 Maintenance::OpenDirectory()
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(mState == State::Initial ||
              mState == State::IndexedDatabaseManagerOpen);
   MOZ_ASSERT(!mDirectoryLock);
   MOZ_ASSERT(QuotaManager::Get());
 
-  if (IsAborted()) {
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
+      IsAborted()) {
     return NS_ERROR_ABORT;
   }
 
   // Get a shared lock for <profile>/storage/*/*/idb
 
   mState = State::DirectoryOpenPending;
   QuotaManager::Get()->OpenDirectoryInternal(
                                            Nullable<PersistenceType>(),
@@ -18380,17 +18394,18 @@ Maintenance::OpenDirectory()
 
 nsresult
 Maintenance::DirectoryOpen()
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(mState == State::DirectoryOpenPending);
   MOZ_ASSERT(mDirectoryLock);
 
-  if (IsAborted()) {
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
+      IsAborted()) {
     return NS_ERROR_ABORT;
   }
 
   QuotaManager* quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   mState = State::DirectoryWorkOpen;
 
@@ -18410,17 +18425,18 @@ Maintenance::DirectoryWork()
 
   // The storage directory is structured like this:
   //
   //   <profile>/storage/<persistence>/<origin>/idb/*.sqlite
   //
   // We have to find all database files that match any persistence type and any
   // origin. We ignore anything out of the ordinary for now.
 
-  if (IsAborted()) {
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
+      IsAborted()) {
     return NS_ERROR_ABORT;
   }
 
   QuotaManager* quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   nsresult rv = quotaManager->EnsureStorageIsInitialized();
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -18749,16 +18765,21 @@ Maintenance::BeginDatabaseMaintenance()
           }
         }
       }
 
       return true;
     }
   };
 
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
+      IsAborted()) {
+    return NS_ERROR_ABORT;
+  }
+
   RefPtr<nsThreadPool> threadPool;
 
   for (DirectoryInfo& directoryInfo : mDirectoryInfos) {
     for (const nsString& databasePath : directoryInfo.mDatabasePaths) {
       if (Helper::IsSafeToRunMaintenance(databasePath)) {
         RefPtr<DatabaseMaintenance> databaseMaintenance =
           new DatabaseMaintenance(this,
                                   directoryInfo.mPersistenceType,
@@ -18935,36 +18956,37 @@ DatabaseMaintenance::PerformMaintenanceO
     ~AutoClose()
     {
       MOZ_ASSERT(mConnection);
 
       MOZ_ALWAYS_SUCCEEDS(mConnection->Close());
     }
   };
 
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
+      mMaintenance->IsAborted()) {
+    return;
+  }
+
   nsCOMPtr<nsIFile> databaseFile = GetFileForPath(mDatabasePath);
   MOZ_ASSERT(databaseFile);
 
   nsCOMPtr<mozIStorageConnection> connection;
   nsresult rv = GetStorageConnection(databaseFile,
                                      mPersistenceType,
                                      mGroup,
                                      mOrigin,
                                      TelemetryIdForFile(databaseFile),
                                      getter_AddRefs(connection));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
   AutoClose autoClose(connection);
 
-  if (mMaintenance->IsAborted()) {
-    return;
-  }
-
   AutoProgressHandler progressHandler(mMaintenance);
   if (NS_WARN_IF(NS_FAILED(progressHandler.Register(connection)))) {
     return;
   }
 
   bool databaseIsOk;
   rv = CheckIntegrity(connection, &databaseIsOk);
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -18973,30 +18995,22 @@ DatabaseMaintenance::PerformMaintenanceO
 
   if (NS_WARN_IF(!databaseIsOk)) {
     // XXX Handle this somehow! Probably need to clear all storage for the
     //     origin. Needs followup.
     MOZ_ASSERT(false, "Database corruption detected!");
     return;
   }
 
-  if (mMaintenance->IsAborted()) {
-    return;
-  }
-
   MaintenanceAction maintenanceAction;
   rv = DetermineMaintenanceAction(connection, databaseFile, &maintenanceAction);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
-  if (mMaintenance->IsAborted()) {
-    return;
-  }
-
   switch (maintenanceAction) {
     case MaintenanceAction::Nothing:
       break;
 
     case MaintenanceAction::IncrementalVacuum:
       IncrementalVacuum(connection);
       break;
 
@@ -19013,16 +19027,21 @@ nsresult
 DatabaseMaintenance::CheckIntegrity(mozIStorageConnection* aConnection,
                                     bool* aOk)
 {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!IsOnBackgroundThread());
   MOZ_ASSERT(aConnection);
   MOZ_ASSERT(aOk);
 
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
+      mMaintenance->IsAborted()) {
+    return NS_ERROR_ABORT;
+  }
+
   nsresult rv;
 
   // First do a full integrity_check. Scope statements tightly here because
   // later operations require zero live statements.
   {
     nsCOMPtr<mozIStorageStatement> stmt;
     rv = aConnection->CreateStatement(NS_LITERAL_CSTRING(
       "PRAGMA integrity_check(1);"
@@ -19130,16 +19149,21 @@ DatabaseMaintenance::DetermineMaintenanc
                                           MaintenanceAction* aMaintenanceAction)
 {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!IsOnBackgroundThread());
   MOZ_ASSERT(aConnection);
   MOZ_ASSERT(aDatabaseFile);
   MOZ_ASSERT(aMaintenanceAction);
 
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
+      mMaintenance->IsAborted()) {
+    return NS_ERROR_ABORT;
+  }
+
   int32_t schemaVersion;
   nsresult rv = aConnection->GetSchemaVersion(&schemaVersion);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Don't do anything if the schema version is less than 18; before that
   // version no databases had |auto_vacuum == INCREMENTAL| set and we didn't
@@ -19339,16 +19363,21 @@ DatabaseMaintenance::DetermineMaintenanc
 
 void
 DatabaseMaintenance::IncrementalVacuum(mozIStorageConnection* aConnection)
 {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!IsOnBackgroundThread());
   MOZ_ASSERT(aConnection);
 
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
+      mMaintenance->IsAborted()) {
+    return;
+  }
+
   nsresult rv = aConnection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
     "PRAGMA incremental_vacuum;"
   ));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 }
 
@@ -19356,16 +19385,21 @@ void
 DatabaseMaintenance::FullVacuum(mozIStorageConnection* aConnection,
                                 nsIFile* aDatabaseFile)
 {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!IsOnBackgroundThread());
   MOZ_ASSERT(aConnection);
   MOZ_ASSERT(aDatabaseFile);
 
+  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
+      mMaintenance->IsAborted()) {
+    return;
+  }
+
   nsresult rv = aConnection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
     "VACUUM;"
   ));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
   PRTime vacuumTime = PR_Now();
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -152,17 +152,16 @@ enum {
     JS_TELEMETRY_GC_MINOR_REASON,
     JS_TELEMETRY_GC_MINOR_REASON_LONG,
     JS_TELEMETRY_GC_MINOR_US,
     JS_TELEMETRY_GC_NURSERY_BYTES,
     JS_TELEMETRY_GC_PRETENURE_COUNT,
     JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT,
     JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_ADDONS,
     JS_TELEMETRY_ADDON_EXCEPTIONS,
-    JS_TELEMETRY_AOT_USAGE,
     JS_TELEMETRY_PRIVILEGED_PARSER_COMPILE_LAZY_AFTER_MS,
     JS_TELEMETRY_WEB_PARSER_COMPILE_LAZY_AFTER_MS,
     JS_TELEMETRY_END
 };
 
 typedef void
 (*JSAccumulateTelemetryDataCallback)(int id, uint32_t sample, const char* key);
 
--- a/js/src/wasm/WasmBinaryConstants.h
+++ b/js/src/wasm/WasmBinaryConstants.h
@@ -473,25 +473,16 @@ static const char SourceMappingURLSectio
 
 enum class NameType
 {
     Module                               = 0,
     Function                             = 1,
     Local                                = 2
 };
 
-// Telemetry sample values for the JS_AOT_USAGE key, indicating whether asm.js
-// or WebAssembly is used.
-
-enum class Telemetry
-{
-    ASMJS = 0,
-    WASM = 1
-};
-
 // These limits are agreed upon with other engines for consistency.
 
 static const unsigned MaxTypes               =  1000000;
 static const unsigned MaxFuncs               =  1000000;
 static const unsigned MaxImports             =   100000;
 static const unsigned MaxExports             =   100000;
 static const unsigned MaxGlobals             =  1000000;
 static const unsigned MaxDataSegments        =   100000;
--- a/js/src/wasm/WasmModule.cpp
+++ b/js/src/wasm/WasmModule.cpp
@@ -1215,19 +1215,16 @@ Module::instantiate(JSContext* cx,
     // still be live via edges created by initSegments or the start function.
 
     if (metadata().startFuncIndex) {
         FixedInvokeArgs<0> args(cx);
         if (!instance->instance().callExport(cx, *metadata().startFuncIndex, args))
             return false;
     }
 
-    uint32_t mode = uint32_t(metadata().isAsmJS() ? Telemetry::ASMJS : Telemetry::WASM);
-    cx->runtime()->addTelemetry(JS_TELEMETRY_AOT_USAGE, mode);
-
     JSUseCounter useCounter = metadata().isAsmJS() ? JSUseCounter::ASMJS : JSUseCounter::WASM;
     cx->runtime()->setUseCounter(instance, useCounter);
 
     if (cx->options().testWasmAwaitTier2())
         blockOnTier2Complete();
 
     return true;
 }
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2664,19 +2664,16 @@ AccumulateTelemetryCallback(int id, uint
         Telemetry::Accumulate(Telemetry::JS_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, sample);
         break;
       case JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_ADDONS:
         Telemetry::Accumulate(Telemetry::JS_DEPRECATED_LANGUAGE_EXTENSIONS_IN_ADDONS, sample);
         break;
       case JS_TELEMETRY_ADDON_EXCEPTIONS:
         Telemetry::Accumulate(Telemetry::JS_TELEMETRY_ADDON_EXCEPTIONS, nsDependentCString(key), sample);
         break;
-      case JS_TELEMETRY_AOT_USAGE:
-        Telemetry::Accumulate(Telemetry::JS_AOT_USAGE, sample);
-        break;
       case JS_TELEMETRY_PRIVILEGED_PARSER_COMPILE_LAZY_AFTER_MS:
         Telemetry::Accumulate(Telemetry::JS_PRIVILEGED_PARSER_COMPILE_LAZY_AFTER_MS, sample);
         break;
       case JS_TELEMETRY_WEB_PARSER_COMPILE_LAZY_AFTER_MS:
         Telemetry::Accumulate(Telemetry::JS_WEB_PARSER_COMPILE_LAZY_AFTER_MS, sample);
         break;
       default:
         MOZ_ASSERT_UNREACHABLE("Unexpected JS_TELEMETRY id");
--- a/netwerk/base/nsBufferedStreams.cpp
+++ b/netwerk/base/nsBufferedStreams.cpp
@@ -340,18 +340,16 @@ nsBufferedInputStream::Close()
     rv2 = nsBufferedStream::Close();
 
 #ifdef DEBUG
     if (NS_FAILED(rv2)) {
         NS_WARNING("(debug) Error: nsBufferedStream::Close() returned error (rv2) within nsBufferedInputStream::Close().");
     };
 #endif
 
-    mAsyncWaitCallback = nullptr;
-
     if (NS_FAILED(rv1)) {
         return rv1;
     }
     return rv2;
 }
 
 NS_IMETHODIMP
 nsBufferedInputStream::Available(uint64_t *result)
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -148,25 +148,27 @@ nsHtml5Parser::BlockParser()
 
 NS_IMETHODIMP_(void)
 nsHtml5Parser::UnblockParser()
 {
   MOZ_DIAGNOSTIC_ASSERT(mBlocked > 0);
   if (MOZ_LIKELY(mBlocked > 0)) {
     mBlocked--;
   }
-  if (MOZ_LIKELY(mBlocked == 0)) {
+  if (MOZ_LIKELY(mBlocked == 0) && mExecutor) {
     mExecutor->ContinueInterruptedParsingAsync();
   }
 }
 
 NS_IMETHODIMP_(void)
 nsHtml5Parser::ContinueInterruptedParsingAsync()
 {
-  mExecutor->ContinueInterruptedParsingAsync();
+  if (mExecutor) {
+    mExecutor->ContinueInterruptedParsingAsync();
+  }
 }
 
 NS_IMETHODIMP_(bool)
 nsHtml5Parser::IsParserEnabled()
 {
   return !mBlocked;
 }
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -13012,25 +13012,16 @@
     "alert_emails": ["firefox-dev@mozilla.org"],
     "bug_numbers": [1286118],
     "expires_in_version": "55",
     "kind": "enumerated",
     "keyed": true,
     "n_values": 6,
     "description": "Number of revoke actions on permissions in the control center, keyed by permission id. Values represent the permission type that was revoked. (0=unknown, 1=permanently allowed, 2=permanently blocked, 3=temporarily allowed, 4=temporarily blocked)"
   },
-  "JS_AOT_USAGE": {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["luke@mozilla.com", "bbouvier@mozilla.com"],
-    "bug_numbers": [1288778],
-    "expires_in_version": "60",
-    "kind": "enumerated",
-    "n_values": 4,
-    "description": "Counts the number of asm.js vs WebAssembly modules instanciations, at the time modules are getting instanciated."
-  },
   "TIME_TO_FIRST_CLICK_MS": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["hkirschner@mozilla.com"],
     "bug_numbers": [1307675, 1332511],
     "expires_in_version": "58",
     "kind": "exponential",
     "high": 50000,
     "n_buckets": 100,