зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1803984 - Part 2: Add assertion that we only remove unlinked modules from the map r=allstarschh
It would not be correct to remove modules that were already linked or evaluated. Depends on D178298 Differential Revision: https://phabricator.services.mozilla.com/D178787
This commit is contained in:
Родитель
53e105ef77
Коммит
71cd073308
|
@ -454,7 +454,14 @@ nsresult ModuleLoaderBase::GetFetchedModuleURLs(nsTArray<nsCString>& aURLs) {
|
|||
}
|
||||
|
||||
bool ModuleLoaderBase::RemoveFetchedModule(nsIURI* aURL) {
|
||||
MOZ_ASSERT(IsModuleFetched(aURL));
|
||||
#if defined(MOZ_DIAGNOSTIC_ASSERT_ENABLED)
|
||||
RefPtr<ModuleScript> ms;
|
||||
MOZ_ALWAYS_TRUE(mFetchedModules.Get(aURL, getter_AddRefs(ms)));
|
||||
if (ms && ms->ModuleRecord()) {
|
||||
JS::AssertModuleUnlinked(ms->ModuleRecord());
|
||||
}
|
||||
#endif
|
||||
|
||||
return mFetchedModules.Remove(aURL);
|
||||
}
|
||||
|
||||
|
|
|
@ -314,6 +314,8 @@ class ModuleLoaderBase : public nsISupports {
|
|||
|
||||
nsresult GetFetchedModuleURLs(nsTArray<nsCString>& aURLs);
|
||||
|
||||
// Removed a fetched module from the module map. Asserts that the module is
|
||||
// unlinked. Extreme care should be taken when calling this method.
|
||||
bool RemoveFetchedModule(nsIURI* aURL);
|
||||
|
||||
// Internal methods.
|
||||
|
|
|
@ -299,6 +299,11 @@ extern JS_PUBLIC_API JSObject* GetModuleEnvironment(
|
|||
*/
|
||||
extern JS_PUBLIC_API void ClearModuleEnvironment(JSObject* moduleObj);
|
||||
|
||||
/*
|
||||
* Diagnostic assert that the module is has status |Unlinked|.
|
||||
*/
|
||||
extern JS_PUBLIC_API void AssertModuleUnlinked(JSObject* moduleObj);
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif // js_Modules_h
|
||||
|
|
|
@ -289,6 +289,14 @@ JS_PUBLIC_API void JS::ClearModuleEnvironment(JSObject* moduleObj) {
|
|||
}
|
||||
}
|
||||
|
||||
JS_PUBLIC_API void JS::AssertModuleUnlinked(JSObject* moduleObj) {
|
||||
MOZ_ASSERT(moduleObj);
|
||||
AssertHeapIsIdle();
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(moduleObj->as<ModuleObject>().status() ==
|
||||
ModuleStatus::Unlinked);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal implementation
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче