From 9f0a6e5946837244c3763585fd1c56edee853397 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Tue, 26 Apr 2022 12:40:48 +0000 Subject: [PATCH] Bug 1766274 - Part 3: Rename CompileOrFinishModuleScript to CompileFetchedModule r=yulia I was less sure of this one, but I think 'finish' is confusing here. Better names welcome. Depends on D144597 Differential Revision: https://phabricator.services.mozilla.com/D144599 --- dom/script/ModuleLoader.cpp | 15 ++++++++------- dom/script/ModuleLoader.h | 2 +- js/loader/ModuleLoaderBase.cpp | 2 +- js/loader/ModuleLoaderBase.h | 8 +++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/dom/script/ModuleLoader.cpp b/dom/script/ModuleLoader.cpp index 51d9fa9c2a8c..6308699b6fe6 100644 --- a/dom/script/ModuleLoader.cpp +++ b/dom/script/ModuleLoader.cpp @@ -136,9 +136,9 @@ void ModuleLoader::OnModuleLoadComplete(ModuleLoadRequest* aRequest) { aRequest->GetScriptLoadContext()->MaybeUnblockOnload(); } -nsresult ModuleLoader::CompileOrFinishModuleScript( +nsresult ModuleLoader::CompileFetchedModule( JSContext* aCx, JS::Handle aGlobal, JS::CompileOptions& aOptions, - ModuleLoadRequest* aRequest, JS::MutableHandle aModule) { + ModuleLoadRequest* aRequest, JS::MutableHandle aModuleOut) { if (aRequest->GetScriptLoadContext()->mWasCompiledOMT) { JS::Rooted storage(aCx); @@ -161,9 +161,9 @@ nsresult ModuleLoader::CompileOrFinishModuleScript( } JS::InstantiateOptions instantiateOptions(aOptions); - aModule.set(JS::InstantiateModuleStencil(aCx, instantiateOptions, stencil, - storage.address())); - if (!aModule) { + aModuleOut.set(JS::InstantiateModuleStencil(aCx, instantiateOptions, + stencil, storage.address())); + if (!aModuleOut) { return NS_ERROR_FAILURE; } @@ -214,8 +214,9 @@ nsresult ModuleLoader::CompileOrFinishModuleScript( } JS::InstantiateOptions instantiateOptions(aOptions); - aModule.set(JS::InstantiateModuleStencil(aCx, instantiateOptions, stencil)); - if (!aModule) { + aModuleOut.set( + JS::InstantiateModuleStencil(aCx, instantiateOptions, stencil)); + if (!aModuleOut) { return NS_ERROR_FAILURE; } diff --git a/dom/script/ModuleLoader.h b/dom/script/ModuleLoader.h index 9cca0bbcfae5..d4a3a25c824d 100644 --- a/dom/script/ModuleLoader.h +++ b/dom/script/ModuleLoader.h @@ -55,7 +55,7 @@ class ModuleLoader final : public JS::loader::ModuleLoaderBase { void OnModuleLoadComplete(ModuleLoadRequest* aRequest) override; - nsresult CompileOrFinishModuleScript( + nsresult CompileFetchedModule( JSContext* aCx, JS::Handle aGlobal, JS::CompileOptions& aOptions, ModuleLoadRequest* aRequest, JS::MutableHandle aModuleScript) override; diff --git a/js/loader/ModuleLoaderBase.cpp b/js/loader/ModuleLoaderBase.cpp index 2afb7bad5422..a904434adff6 100644 --- a/js/loader/ModuleLoaderBase.cpp +++ b/js/loader/ModuleLoaderBase.cpp @@ -478,7 +478,7 @@ nsresult ModuleLoaderBase::CreateModuleScript(ModuleLoadRequest* aRequest) { if (NS_SUCCEEDED(rv)) { JS::Rooted global(cx, mGlobalObject->GetGlobalJSObject()); - rv = CompileOrFinishModuleScript(cx, global, options, aRequest, &module); + rv = CompileFetchedModule(cx, global, options, aRequest, &module); } MOZ_ASSERT(NS_SUCCEEDED(rv) == (module != nullptr)); diff --git a/js/loader/ModuleLoaderBase.h b/js/loader/ModuleLoaderBase.h index 948f51acba72..03a9a152b1bd 100644 --- a/js/loader/ModuleLoaderBase.h +++ b/js/loader/ModuleLoaderBase.h @@ -127,14 +127,16 @@ class ModuleLoaderBase : public nsISupports { // NS_OK to abort load without returning an error. virtual bool CanStartLoad(ModuleLoadRequest* aRequest, nsresult* aRvOut) = 0; - // Start the process of fetching module source or bytecode. This is only + // Start the process of fetching module source (or bytecode). This is only // called if CanStartLoad returned true. virtual nsresult StartFetch(ModuleLoadRequest* aRequest) = 0; - virtual nsresult CompileOrFinishModuleScript( + // Create a JS module for a fetched module request. This might compile source + // text or decode cached bytecode. + virtual nsresult CompileFetchedModule( JSContext* aCx, JS::Handle aGlobal, JS::CompileOptions& aOptions, ModuleLoadRequest* aRequest, - JS::MutableHandle aModuleScript) = 0; + JS::MutableHandle aModuleOut) = 0; // Called when a module script has been loaded, including imports. virtual void OnModuleLoadComplete(ModuleLoadRequest* aRequest) = 0;