From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- js/loader/ModuleLoadRequest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/loader/ModuleLoadRequest.cpp') diff --git a/js/loader/ModuleLoadRequest.cpp b/js/loader/ModuleLoadRequest.cpp index d90d41da58..7e188160fc 100644 --- a/js/loader/ModuleLoadRequest.cpp +++ b/js/loader/ModuleLoadRequest.cpp @@ -27,6 +27,9 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(ModuleLoadRequest) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ModuleLoadRequest, ScriptLoadRequest) + if (tmp->mWaitingParentRequest) { + tmp->mWaitingParentRequest->ChildModuleUnlinked(); + } NS_IMPL_CYCLE_COLLECTION_UNLINK(mLoader, mRootModule, mModuleScript, mImports, mWaitingParentRequest, mDynamicReferencingScript) @@ -230,6 +233,18 @@ void ModuleLoadRequest::LoadFinished() { mLoader->OnModuleLoadComplete(request); } +void ModuleLoadRequest::ChildModuleUnlinked() { + // This module was waiting for a child request, but the child reqeust + // got unlinked by CC and will never complete. + // It also means this module itself is also in the cycle, and will be + // unlinked or has already been unlinked, and will be collected. + // There's no need to normally finish the module request. + // Just reflect the awaiting imports count, so that the assertion in the + // destructor passes. + MOZ_ASSERT(mAwaitingImports > 0); + mAwaitingImports--; +} + void ModuleLoadRequest::SetDynamicImport(LoadedScript* aReferencingScript, JS::Handle aSpecifier, JS::Handle aPromise) { -- cgit v1.2.3