diff options
Diffstat (limited to 'dom/script/ScriptLoader.cpp')
-rw-r--r-- | dom/script/ScriptLoader.cpp | 90 |
1 files changed, 8 insertions, 82 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 736bb4349..cf7f06e71 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -726,11 +726,6 @@ ScriptLoader::StartFetchingModuleDependencies(ModuleLoadRequest* aRequest) MOZ_ASSERT(aRequest->mModuleScript); MOZ_ASSERT(!aRequest->IsReadyToRun()); - if (aRequest->mModuleScript->InstantiationFailed()) { - aRequest->LoadFailed(); - return; - } - aRequest->mProgress = ModuleLoadRequest::Progress::FetchingImports; nsCOMArray<nsIURI> urls; @@ -825,12 +820,6 @@ HostResolveImportedModule(JSContext* aCx, unsigned argc, JS::Value* vp) return HandleModuleNotFound(aCx, script, string); } - if (ms->InstantiationFailed()) { - JS::Rooted<JS::Value> exception(aCx, ms->Exception()); - JS_SetPendingException(aCx, exception); - return false; - } - *vp = JS::ObjectValue(*ms->ModuleRecord()); return true; } @@ -866,68 +855,6 @@ ScriptLoader::ProcessLoadedModuleTree(ModuleLoadRequest* aRequest) } } -bool -ScriptLoader::InstantiateModuleTree(ModuleLoadRequest* aRequest) -{ - // Perform eager instantiation of the loaded module tree. - - MOZ_ASSERT(aRequest); - - ModuleScript* ms = aRequest->mModuleScript; - MOZ_ASSERT(ms); - if (!ms || !ms->ModuleRecord()) { - return false; - } - - AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.Init(ms->ModuleRecord()))) { - return false; - } - - nsresult rv = EnsureModuleResolveHook(jsapi.cx()); - NS_ENSURE_SUCCESS(rv, false); - - JS::Rooted<JSObject*> module(jsapi.cx(), ms->ModuleRecord()); - bool ok = NS_SUCCEEDED(nsJSUtils::ModuleInstantiate(jsapi.cx(), module)); - - JS::RootedValue exception(jsapi.cx()); - if (!ok) { - MOZ_ASSERT(jsapi.HasException()); - if (!jsapi.StealException(&exception)) { - return false; - } - MOZ_ASSERT(!exception.isUndefined()); - } - - // Mark this module and any uninstantiated dependencies found via depth-first - // search as instantiated and record any error. - - mozilla::Vector<ModuleLoadRequest*, 1> requests; - if (!requests.append(aRequest)) { - return false; - } - - while (!requests.empty()) { - ModuleLoadRequest* request = requests.popCopy(); - ModuleScript* ms = request->mModuleScript; - if (!ms->IsUninstantiated()) { - continue; - } - - ms->SetInstantiationResult(exception); - - for (auto import : request->mImports) { - if (import->mModuleScript->IsUninstantiated() && - !requests.append(import)) - { - return false; - } - } - } - - return true; -} - nsresult ScriptLoader::StartLoad(ScriptLoadRequest *aRequest, const nsAString &aType, bool aScriptFromHead) @@ -1941,18 +1868,17 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) } if (aRequest->IsModuleRequest()) { + rv = EnsureModuleResolveHook(aes.cx()); + NS_ENSURE_SUCCESS(rv, rv); + ModuleLoadRequest* request = aRequest->AsModuleRequest(); MOZ_ASSERT(request->mModuleScript); MOZ_ASSERT(!request->mOffThreadToken); - ModuleScript* ms = request->mModuleScript; - MOZ_ASSERT(!ms->IsUninstantiated()); - if (ms->InstantiationFailed()) { - JS::Rooted<JS::Value> exception(aes.cx(), ms->Exception()); - JS_SetPendingException(aes.cx(), exception); - rv = NS_ERROR_FAILURE; - } else { - JS::Rooted<JSObject*> module(aes.cx(), ms->ModuleRecord()); - MOZ_ASSERT(module); + JS::Rooted<JSObject*> module(aes.cx(), + request->mModuleScript->ModuleRecord()); + MOZ_ASSERT(module); + rv = nsJSUtils::ModuleInstantiate(aes.cx(), module); + if (NS_SUCCEEDED(rv)) { rv = nsJSUtils::ModuleEvaluate(aes.cx(), module); } } else { |