Bug 1954644 - Part 9: Remove unnecessary cast. r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D242314
This commit is contained in:
Tooru Fujisawa
2025-03-22 04:03:56 +00:00
parent 3a0e4f5b62
commit bcc4c6ecf8

View File

@@ -483,13 +483,11 @@ nsresult ModuleLoaderBase::StartOrRestartModuleLoad(ModuleLoadRequest* aRequest,
// Check whether the module has been fetched or is currently being fetched, // Check whether the module has been fetched or is currently being fetched,
// and if so wait for it rather than starting a new fetch. // and if so wait for it rather than starting a new fetch.
ModuleLoadRequest* request = aRequest->AsModuleRequest();
if (aRestart == RestartRequest::No && if (aRestart == RestartRequest::No &&
ModuleMapContainsURL( ModuleMapContainsURL(
ModuleMapKey(request->mURI, aRequest->mModuleType))) { ModuleMapKey(aRequest->mURI, aRequest->mModuleType))) {
LOG(("ScriptLoadRequest (%p): Waiting for module fetch", aRequest)); LOG(("ScriptLoadRequest (%p): Waiting for module fetch", aRequest));
WaitForModuleFetch(request); WaitForModuleFetch(aRequest);
return NS_OK; return NS_OK;
} }
@@ -499,7 +497,7 @@ nsresult ModuleLoaderBase::StartOrRestartModuleLoad(ModuleLoadRequest* aRequest,
// We successfully started fetching a module so put its URL in the module // We successfully started fetching a module so put its URL in the module
// map and mark it as fetching. // map and mark it as fetching.
if (aRestart == RestartRequest::No) { if (aRestart == RestartRequest::No) {
SetModuleFetchStarted(aRequest->AsModuleRequest()); SetModuleFetchStarted(aRequest);
} }
return NS_OK; return NS_OK;
@@ -1357,20 +1355,19 @@ nsresult ModuleLoaderBase::EvaluateModuleInContext(
MarkerInnerWindowIdFromJSContext(aCx), MarkerInnerWindowIdFromJSContext(aCx),
profilerLabelString); profilerLabelString);
ModuleLoadRequest* request = aRequest->AsModuleRequest(); MOZ_ASSERT(aRequest->mModuleScript);
MOZ_ASSERT(request->mModuleScript); MOZ_ASSERT_IF(aRequest->HasScriptLoadContext(),
MOZ_ASSERT_IF(request->HasScriptLoadContext(), !aRequest->GetScriptLoadContext()->mCompileOrDecodeTask);
!request->GetScriptLoadContext()->mCompileOrDecodeTask);
ModuleScript* moduleScript = request->mModuleScript; ModuleScript* moduleScript = aRequest->mModuleScript;
if (moduleScript->HasErrorToRethrow()) { if (moduleScript->HasErrorToRethrow()) {
LOG(("ScriptLoadRequest (%p): module has error to rethrow", aRequest)); LOG(("ScriptLoadRequest (%p): module has error to rethrow", aRequest));
JS::Rooted<JS::Value> error(aCx, moduleScript->ErrorToRethrow()); JS::Rooted<JS::Value> error(aCx, moduleScript->ErrorToRethrow());
JS_SetPendingException(aCx, error); JS_SetPendingException(aCx, error);
// For a dynamic import, the promise is rejected. Otherwise an error // For a dynamic import, the promise is rejected. Otherwise an error
// is either reported by AutoEntryScript. // is either reported by AutoEntryScript.
if (request->IsDynamicImport()) { if (aRequest->IsDynamicImport()) {
FinishDynamicImport(aCx, request, NS_OK, nullptr); FinishDynamicImport(aCx, aRequest, NS_OK, nullptr);
} }
return NS_OK; return NS_OK;
} }
@@ -1383,16 +1380,16 @@ nsresult ModuleLoaderBase::EvaluateModuleInContext(
return NS_OK; return NS_OK;
} }
nsresult rv = InitDebuggerDataForModuleGraph(aCx, request); nsresult rv = InitDebuggerDataForModuleGraph(aCx, aRequest);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (request->HasScriptLoadContext()) { if (aRequest->HasScriptLoadContext()) {
TRACE_FOR_TEST(aRequest, "scriptloader_evaluate_module"); TRACE_FOR_TEST(aRequest, "scriptloader_evaluate_module");
} }
JS::Rooted<JS::Value> rval(aCx); JS::Rooted<JS::Value> rval(aCx);
mLoader->MaybePrepareModuleForBytecodeEncodingBeforeExecute(aCx, request); mLoader->MaybePrepareModuleForBytecodeEncodingBeforeExecute(aCx, aRequest);
bool ok = JS::ModuleEvaluate(aCx, module, &rval); bool ok = JS::ModuleEvaluate(aCx, module, &rval);
@@ -1400,7 +1397,7 @@ nsresult ModuleLoaderBase::EvaluateModuleInContext(
// unless the user cancels execution. // unless the user cancels execution.
MOZ_ASSERT_IF(ok, !JS_IsExceptionPending(aCx)); MOZ_ASSERT_IF(ok, !JS_IsExceptionPending(aCx));
if (!ok || IsModuleEvaluationAborted(request)) { if (!ok || IsModuleEvaluationAborted(aRequest)) {
LOG(("ScriptLoadRequest (%p): evaluation failed", aRequest)); LOG(("ScriptLoadRequest (%p): evaluation failed", aRequest));
// For a dynamic import, the promise is rejected. Otherwise an error is // For a dynamic import, the promise is rejected. Otherwise an error is
// reported by AutoEntryScript. // reported by AutoEntryScript.
@@ -1415,11 +1412,11 @@ nsresult ModuleLoaderBase::EvaluateModuleInContext(
evaluationPromise.set(&rval.toObject()); evaluationPromise.set(&rval.toObject());
} }
if (request->IsDynamicImport()) { if (aRequest->IsDynamicImport()) {
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
FinishDynamicImportAndReject(request, rv); FinishDynamicImportAndReject(aRequest, rv);
} else { } else {
FinishDynamicImport(aCx, request, NS_OK, evaluationPromise); FinishDynamicImport(aCx, aRequest, NS_OK, evaluationPromise);
} }
} else { } else {
// If this is not a dynamic import, and if the promise is rejected, // If this is not a dynamic import, and if the promise is rejected,
@@ -1432,7 +1429,7 @@ nsresult ModuleLoaderBase::EvaluateModuleInContext(
} }
} }
rv = mLoader->MaybePrepareModuleForBytecodeEncodingAfterExecute(request, rv = mLoader->MaybePrepareModuleForBytecodeEncodingAfterExecute(aRequest,
NS_OK); NS_OK);
mLoader->MaybeTriggerBytecodeEncoding(); mLoader->MaybeTriggerBytecodeEncoding();