tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit fb06302042ba9edd6781f1598837b4eb4858dfa8
parent 1b4989c103a7eae40b2475c60cdb5f51c3cac4fa
Author: Tooru Fujisawa <arai_a@mac.com>
Date:   Wed, 26 Nov 2025 04:10:52 +0000

Bug 1907011 - Part 7: Update the most of the remaining usage of "bytecode" and update document. r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D273960

Diffstat:
Mdom/script/ScriptLoadHandler.cpp | 30+++++++++++++++---------------
Mdom/script/ScriptLoadHandler.h | 4++--
Mdom/script/ScriptLoader.cpp | 128+++++++++++++++++++++++++++++++++++++------------------------------------------
Mdom/script/ScriptLoader.h | 6+++---
Mjs/loader/LoadedScript.cpp | 4++--
Mjs/loader/LoadedScript.h | 7++++---
Mjs/loader/ModuleLoaderBase.cpp | 1-
Mjs/loader/ModuleLoaderBase.h | 6+++---
Mjs/loader/ScriptLoadRequest.h | 27+++++++++++++--------------
9 files changed, 102 insertions(+), 111 deletions(-)

diff --git a/dom/script/ScriptLoadHandler.cpp b/dom/script/ScriptLoadHandler.cpp @@ -311,7 +311,7 @@ nsresult ScriptLoadHandler::MaybeDecodeSRI(uint32_t* sriLength) { if (NS_FAILED(mSRIStatus)) { // We are unable to decode the hash contained in the alternate data which - // contains the bytecode, or it does not use the same algorithm. + // contains the serialized Stencil, or it does not use the same algorithm. LOG( ("ScriptLoadHandler::MaybeDecodeSRI, failed to decode SRI, restart " "request")); @@ -422,13 +422,13 @@ ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader, } } else { MOZ_ASSERT(mRequest->IsSerializedStencil()); - JS::TranscodeBuffer& bytecode = mRequest->SRIAndSerializedStencil(); - if (!bytecode.append(aData, aDataLength)) { + JS::TranscodeBuffer& buf = mRequest->SRIAndSerializedStencil(); + if (!buf.append(aData, aDataLength)) { return NS_ERROR_OUT_OF_MEMORY; } - LOG(("ScriptLoadRequest (%p): Bytecode length = %u", mRequest.get(), - unsigned(bytecode.length()))); + LOG(("ScriptLoadRequest (%p): SRIAndSerializedStencil length = %u", + mRequest.get(), unsigned(buf.length()))); // If we abort while decoding the SRI, we fallback on explicitly // requesting the source. Thus, we should not continue in @@ -442,30 +442,30 @@ ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader, return channelRequest->Cancel(mScriptLoader->RestartLoad(mRequest)); } - // The bytecode cache always starts with the SRI hash, thus even if there - // is no SRI data verifier instance, we still want to skip the hash. + // The serialized stencil always starts with the SRI hash, thus even if + // there is no SRI data verifier instance, we still want to skip the hash. uint32_t sriLength; - rv = SRICheckDataVerifier::DataSummaryLength( - bytecode.length(), bytecode.begin(), &sriLength); + rv = SRICheckDataVerifier::DataSummaryLength(buf.length(), buf.begin(), + &sriLength); if (NS_FAILED(rv)) { return channelRequest->Cancel(mScriptLoader->RestartLoad(mRequest)); } mRequest->SetSRILength(sriLength); - Vector<uint8_t> compressedBytecode; - // mRequest has the compressed bytecode, but will be filled with the - // uncompressed bytecode - compressedBytecode.swap(bytecode); + Vector<uint8_t> compressed; + // mRequest has the compressed data, but will be filled with the + // uncompressed data + compressed.swap(buf); if (!JS::loader::ScriptBytecodeDecompress( - compressedBytecode, mRequest->GetSRILength(), bytecode)) { + compressed, mRequest->GetSRILength(), buf)) { return NS_ERROR_UNEXPECTED; } } } // Everything went well, keep the CacheInfoChannel alive such that we can - // later save the bytecode on the cache entry. + // later save the serialized stencil on the cache entry. // we have to mediate and use mRequest. rv = mScriptLoader->OnStreamComplete(aLoader, mRequest, aStatus, mSRIStatus, mSRIDataVerifier.get()); diff --git a/dom/script/ScriptLoadHandler.h b/dom/script/ScriptLoadHandler.h @@ -107,8 +107,8 @@ class ScriptLoadHandler final : public nsIIncrementalStreamLoaderObserver, uint32_t aDataLength, bool aEndOfStream); /* - * When streaming bytecode, we have the opportunity to fallback early if SRI - * does not match the expectation of the document. + * When streaming serialized Stencil, we have the opportunity to fallback + * early if SRI does not match the expectation of the document. * * If SRI hash is decoded, `sriLength` is set to the length of the hash. */ diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp @@ -115,7 +115,7 @@ LazyLogModule ScriptLoader::gScriptLoaderLog("ScriptLoader"); MOZ_LOG_TEST(ScriptLoader::gScriptLoaderLog, mozilla::LogLevel::Debug) // Alternate Data MIME type used by the ScriptLoader to register that we want to -// store bytecode without reading it. +// store the disk cache without reading it. static constexpr auto kNullMimeType = "javascript/null"_ns; ///////////////////////////////////////////////////////////// @@ -600,7 +600,7 @@ nsresult ScriptLoader::RestartLoad(ScriptLoadRequest* aRequest) { aRequest->GetScriptLoadContext()->NotifyRestart(mDocument); // Start a new channel from which we explicitly request to stream the source - // instead of the bytecode. + // instead of the serialized stencil. aRequest->mFetchSourceOnly = true; nsresult rv; if (aRequest->IsModuleRequest()) { @@ -728,29 +728,30 @@ static void PrepareLoadInfoForScriptLoading(nsIChannel* aChannel, // static void ScriptLoader::PrepareCacheInfoChannel(nsIChannel* aChannel, ScriptLoadRequest* aRequest) { - // To avoid decoding issues, the build-id is part of the bytecode MIME type + // To avoid decoding issues, the build-id is part of the disk cache MIME type // constant. aRequest->getLoadedScript()->DropDiskCacheReference(); nsCOMPtr<nsICacheInfoChannel> cic(do_QueryInterface(aChannel)); if (cic && StaticPrefs::dom_script_loader_bytecode_cache_enabled()) { MOZ_ASSERT(!IsWebExtensionRequest(aRequest), - "Can not bytecode cache WebExt code"); + "Web extension scripts are not compatible with the disk cache"); if (!aRequest->mFetchSourceOnly) { // Inform the HTTP cache that we prefer to have information coming from - // the bytecode cache instead of the sources, if such entry is already - // registered. - LOG(("ScriptLoadRequest (%p): Maybe request bytecode", aRequest)); + // the serialized stencil disk cache instead of the sources, if such entry + // is already registered. + LOG(("ScriptLoadRequest (%p): Maybe request the disk cache", aRequest)); cic->PreferAlternativeDataType( ScriptLoader::BytecodeMimeTypeFor(aRequest), ""_ns, nsICacheInfoChannel::PreferredAlternativeDataDeliveryType::ASYNC); } else { // If we are explicitly loading from the sources, such as after a - // restarted request, we might still want to save the bytecode after. + // restarted request, we might still want to save to the disk cache after. // // The following tell the cache to look for an alternative data type which - // does not exist, such that we can later save the bytecode with a - // different alternative data type. - LOG(("ScriptLoadRequest (%p): Request saving bytecode later", aRequest)); + // does not exist, such that we can later save the serialized Stencil + // with a different alternative data type. + LOG(("ScriptLoadRequest (%p): Request saving to the disk cache later", + aRequest)); cic->PreferAlternativeDataType( kNullMimeType, ""_ns, nsICacheInfoChannel::PreferredAlternativeDataDeliveryType::ASYNC); @@ -1979,7 +1980,7 @@ class OffThreadCompilationCompleteTask : public Task { scriptSourceString = "ScriptCompileOffThread"; } else { MOZ_ASSERT(mRequest->IsSerializedStencil()); - scriptSourceString = "BytecodeDecodeOffThread"; + scriptSourceString = "DecodeStencilOffThread"; } nsAutoCString profilerLabelString; @@ -2021,7 +2022,7 @@ class OffThreadCompilationCompleteTask : public Task { // Stencil API, and also the thread management on the consumer side // (bug 1846160). static constexpr size_t OffThreadMinimumTextLength = 5 * 1000; -static constexpr size_t OffThreadMinimumBytecodeLength = 5 * 1000; +static constexpr size_t OffThreadMinimumSerializedStencilLength = 5 * 1000; nsresult ScriptLoader::AttemptOffThreadScriptCompile( ScriptLoadRequest* aRequest, bool* aCouldCompileOut) { @@ -2084,7 +2085,7 @@ nsresult ScriptLoader::AttemptOffThreadScriptCompile( JS::TranscodeRange range = aRequest->SerializedStencil(); if (!StaticPrefs::javascript_options_parallel_parsing() || - range.length() < OffThreadMinimumBytecodeLength) { + range.length() < OffThreadMinimumSerializedStencilLength) { return NS_OK; } } @@ -2531,13 +2532,13 @@ nsresult ScriptLoader::ProcessRequest(ScriptLoadRequest* aRequest) { aRequest->GetScriptLoadContext()->MaybeCancelOffThreadScript(); } - // Free any source data, but keep the bytecode content as we might have to + // Free any source data, but keep the serialized Stencil as we might have to // save it later. aRequest->ClearScriptSource(); if (aRequest->IsSerializedStencil()) { - // We received bytecode as input, thus we were decoding, and we will not be - // encoding the bytecode once more. We can safely clear the content of this - // buffer. + // We received serialized Stencil as input, thus we were decoding, and we + // will not be encoding it once more. We can safely clear the content of + // this buffer. aRequest->DropSRIOrSRIAndSerializedStencil(); } @@ -2844,7 +2845,7 @@ void ScriptLoader::CalculateCacheFlag(ScriptLoadRequest* aRequest) { return; } - // If the script is too small/large, do not attempt at creating a bytecode + // If the script is too small/large, do not attempt at creating a disk // cache for this script, as the overhead of parsing it might not be worth the // effort. if (strategy.mHasSourceLengthMin) { @@ -2867,7 +2868,7 @@ void ScriptLoader::CalculateCacheFlag(ScriptLoadRequest* aRequest) { } // Check that we loaded the cache entry a few times before attempting any - // bytecode-cache optimization, such that we do not waste time on entry which + // disk cache optimization, such that we do not waste time on entry which // are going to be dropped soon. if (strategy.mHasFetchCountMin) { uint32_t fetchCount = 0; @@ -3059,14 +3060,14 @@ nsresult ScriptLoader::EvaluateScriptElement(ScriptLoadRequest* aRequest) { // Decode a script contained in a buffer. static void Decode(JSContext* aCx, JS::CompileOptions& aCompileOptions, - const JS::TranscodeRange& aBytecodeBuf, + const JS::TranscodeRange& aRange, RefPtr<JS::Stencil>& aStencil, ErrorResult& aRv) { JS::DecodeOptions decodeOptions(aCompileOptions); decodeOptions.borrowBuffer = true; MOZ_ASSERT(aCompileOptions.noScriptRval); - JS::TranscodeResult tr = JS::DecodeStencil(aCx, decodeOptions, aBytecodeBuf, - getter_AddRefs(aStencil)); + JS::TranscodeResult tr = + JS::DecodeStencil(aCx, decodeOptions, aRange, getter_AddRefs(aStencil)); // These errors are external parameters which should be handled before the // decoding phase, and which are the only reasons why you might want to // fallback on decoding failures. @@ -3130,7 +3131,7 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource( if (aRequest->IsSerializedStencil()) { if (aRequest->GetScriptLoadContext()->mCompileOrDecodeTask) { - LOG(("ScriptLoadRequest (%p): Decode Bytecode & instantiate and Execute", + LOG(("ScriptLoadRequest (%p): Decode & instantiate and Execute", aRequest)); RefPtr<JS::Stencil> stencil; JS::InstantiationStorage storage; @@ -3148,8 +3149,8 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource( aDebuggerPrivateValue, aDebuggerIntroductionScript, aRv, &storage); } else { - LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute", aRequest)); - AUTO_PROFILER_MARKER_TEXT("BytecodeDecodeMainThread", JS, + LOG(("ScriptLoadRequest (%p): Decode and Execute", aRequest)); + AUTO_PROFILER_MARKER_TEXT("DecodeStencilMainThread", JS, MarkerInnerWindowIdFromJSContext(aCx), profilerLabelString); @@ -3166,7 +3167,7 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource( } // We do not expect to be saving anything when we already have some - // bytecode. + // serialized Stencil. MOZ_ASSERT(!aRequest->getLoadedScript()->HasDiskCacheReference()); return; } @@ -3411,17 +3412,7 @@ nsresult ScriptLoader::MaybePrepareForDiskCacheAfterExecute( } TRACE_FOR_TEST(aRequest, "diskcache:register"); - // Bytecode-encoding branch is used for 2 purposes right now: - // * If the request is stencil, reflect delazifications to cached stencil - // * otherwise, encode the initial stencil and delazifications - // - // For latter case, check that the TranscodeBuffer which is going to - // receive the encoded bytecode only contains the SRI, and nothing more. - // - // NOTE: This assertion will fail once we start encoding more data after the - // first encode. - MOZ_ASSERT_IF(!aRequest->IsCachedStencil(), - aRequest->GetSRILength() == aRequest->SRI().length()); + MOZ_ASSERT(aRequest->GetSRILength() == aRequest->SRI().length()); RegisterForDiskCache(aRequest); return aRv; @@ -3536,9 +3527,10 @@ nsresult ScriptLoader::EvaluateScript(nsIGlobalObject* aGlobalObject, // dispatch test-only event. rv = MaybePrepareForDiskCacheAfterExecute(aRequest, rv); - // Even if we are not saving the bytecode of the current script, we have - // to trigger the encoding of the bytecode, as the current script can - // call functions of a script for which we are recording the bytecode. + // Even if we are not saving the current script to the disk cache, we have + // to trigger the disk cache encoding, as the current script can be blocking + // the other encoding, or the current script can delazify more functions + // which we are recording the disk cache. LOG(("ScriptLoadRequest (%p): ScriptLoader = %p", aRequest, this)); MaybeUpdateDiskCache(); @@ -3562,7 +3554,7 @@ void ScriptLoader::RegisterForDiskCache(ScriptLoadRequest* aRequest) { MOZ_ASSERT(aRequest->getLoadedScript()->HasDiskCacheReference()); MOZ_DIAGNOSTIC_ASSERT(!aRequest->isInList()); MOZ_ASSERT(!IsWebExtensionRequest(aRequest), - "Bytecode for web extension content scrips is not cached"); + "Web extension scripts are not compatible with the disk cache"); mDiskCacheQueue.AppendElement(aRequest->getLoadedScript()); } @@ -3582,17 +3574,17 @@ void ScriptLoader::Destroy() { } void ScriptLoader::MaybeUpdateDiskCache() { - // We wait for the load event to be fired before saving the bytecode of - // any script to the cache. It is quite common to have load event - // listeners trigger more JavaScript execution, that we want to save as - // part of this start-up bytecode cache. + // We wait for the load event to be fired before saving any script to the + // disk cache. It is quite common to have load event listeners trigger more + // JavaScript execution, that we want to save as part of disk cache, to + // improve the load time in subsequent loads. if (!mLoadEventFired) { LOG(("ScriptLoader (%p): Wait for the load-end event to fire.", this)); return; } - // Wait until all scripts are loaded before saving the bytecode, such that - // we capture most of the intialization of the page. + // Wait until all scripts are loaded before saving to the disk cache, such + // that we capture most of the intialization of the page. if (HasPendingRequests()) { LOG(("ScriptLoader (%p): Wait for other pending request to finish.", this)); return; @@ -3608,21 +3600,20 @@ void ScriptLoader::MaybeUpdateDiskCache() { // If we already gave up, ensure that we are not going to enqueue any script, // and that we finalize them properly. if (mGiveUpDiskCaching) { - LOG(("ScriptLoader (%p): Keep giving-up bytecode encoding.", this)); + LOG(("ScriptLoader (%p): Keep giving-up saving to the disk cache.", this)); GiveUpDiskCaching(); return; } - // No need to fire any event if there is no bytecode to be saved. + // No need to fire any event if there is no script to be saved. if (mDiskCacheQueue.IsEmpty()) { LOG(("ScriptLoader (%p): No script in queue to be saved to the disk.", this)); return; } - // Create a new runnable dedicated to encoding the content of the bytecode of - // all enqueued scripts when the document is idle. In case of failure, we - // give-up on encoding the bytecode. + // Create a new runnable dedicated to encoding all enqueued scripts when the + // document is idle. In case of failure, we give-up on saving the disk cache. nsCOMPtr<nsIRunnable> encoder = NewRunnableMethod( "ScriptLoader::UpdateCache", this, &ScriptLoader::UpdateDiskCache); if (NS_FAILED(NS_DispatchToCurrentThreadQueue(encoder.forget(), @@ -3631,12 +3622,12 @@ void ScriptLoader::MaybeUpdateDiskCache() { return; } - LOG(("ScriptLoader (%p): Schedule bytecode encoding.", this)); + LOG(("ScriptLoader (%p): Schedule the disk cache encoding.", this)); } void ScriptLoader::UpdateDiskCache() { MOZ_ASSERT(!mCache); - LOG(("ScriptLoader (%p): Start bytecode encoding.", this)); + LOG(("ScriptLoader (%p): Start the disk cache encoding.", this)); // If any script got added in the previous loop cycle, wait until all // remaining script executions are completed, such that we capture most of @@ -3648,15 +3639,15 @@ void ScriptLoader::UpdateDiskCache() { JS::FrontendContext* fc = JS::NewFrontendContext(); if (!fc) { LOG( - ("ScriptLoader (%p): Cannot create FrontendContext for bytecode " + ("ScriptLoader (%p): Cannot create FrontendContext for the disk cache " "encoding.", this)); return; } for (auto& loadedScript : mDiskCacheQueue) { - // The bytecode encoding is performed only when there was no - // bytecode stored in the necko cache. + // The encoding is performed only when there was no disk cache stored in + // the necko cache. if (!loadedScript->HasDiskCacheReference()) { continue; } @@ -3711,7 +3702,7 @@ bool ScriptLoader::EncodeAndCompress( // We don't care the error and just give up encoding. JS::ClearFrontendErrors(aFc); - LOG(("LoadedScript (%p): Cannot serialize bytecode", aLoadedScript)); + LOG(("LoadedScript (%p): Cannot encode stencil", aLoadedScript)); return false; } @@ -3723,7 +3714,7 @@ bool ScriptLoader::EncodeAndCompress( if (aCompressed.length() >= UINT32_MAX) { LOG( - ("LoadedScript (%p): Bytecode cache is too large to be decoded " + ("LoadedScript (%p): Serialized stencil is too large to be decoded " "correctly.", aLoadedScript)); return false; @@ -3747,7 +3738,7 @@ bool ScriptLoader::SaveToDiskCache( static_cast<int64_t>(aCompressed.length()), getter_AddRefs(output)); if (NS_FAILED(rv)) { LOG( - ("LoadedScript (%p): Cannot open bytecode cache (rv = %X, output " + ("LoadedScript (%p): Cannot open the disk cache (rv = %X, output " "= %p)", aLoadedScript, unsigned(rv), output.get())); return false; @@ -3763,7 +3754,7 @@ bool ScriptLoader::SaveToDiskCache( rv = output->Write(reinterpret_cast<const char*>(aCompressed.begin()), aCompressed.length(), &n); LOG( - ("LoadedScript (%p): Write bytecode cache (rv = %X, length = %u, " + ("LoadedScript (%p): Write the disk cache (rv = %X, length = %u, " "written = %u)", aLoadedScript, unsigned(rv), unsigned(aCompressed.length()), n)); if (NS_FAILED(rv)) { @@ -3787,7 +3778,8 @@ void ScriptLoader::GiveUpDiskCaching() { mGiveUpDiskCaching = true; for (auto& loadedScript : mDiskCacheQueue) { - LOG(("LoadedScript (%p): Cannot serialize bytecode", loadedScript.get())); + LOG(("LoadedScript (%p): Giving up encoding the disk cache", + loadedScript.get())); TRACE_FOR_TEST(loadedScript, "diskcache:giveup"); loadedScript->DropDiskCacheReference(); @@ -4140,7 +4132,7 @@ nsresult ScriptLoader::OnStreamComplete( // If we are loading from source, store the cache info channel and // save the computed SRI hash or a dummy SRI hash in case we are going to - // save the bytecode of this script in the cache. + // save the this script in the disk cache. if (aRequest->IsSource() && StaticPrefs::dom_script_loader_bytecode_cache_enabled()) { aRequest->getLoadedScript()->mCacheInfo = cacheInfo; @@ -4164,10 +4156,10 @@ nsresult ScriptLoader::OnStreamComplete( } if (NS_FAILED(rv)) { - // When loading bytecode, we verify the SRI hash. If it does not match the - // one from the document we restart the load, forcing us to load the source - // instead. If this happens do not remove the current request from script - // loader's data structures or fire any events. + // When loading the disk cache, we verify the SRI hash. If it does not match + // the one from the document we restart the load, forcing us to load the + // source instead. If this happens do not remove the current request from + // script loader's data structures or fire any events. if (aChannelStatus != NS_BINDING_RETARGETED) { HandleLoadError(aRequest, rv); } diff --git a/dom/script/ScriptLoader.h b/dom/script/ScriptLoader.h @@ -681,7 +681,7 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface { // Instantiate classic script from one of the following data: // * text source - // * encoded bytecode + // * serialized stencil // * cached stencil void InstantiateClassicScriptFromAny( JSContext* aCx, JS::CompileOptions& aCompileOptions, @@ -691,7 +691,7 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface { // Instantiate classic script from one of the following data: // * text source - // * encoded bytecode + // * serialized stencil // // aStencilOut is set to the compiled stencil. void InstantiateClassicScriptFromMaybeEncodedSource( @@ -768,7 +768,7 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface { Vector<uint8_t>& aCompressed); /** - * Save the bytecode to the necko cache. + * Save the serialized and maybe-compressed stencil to the necko cache. */ static bool SaveToDiskCache(const JS::loader::LoadedScript* aLoadedScript, const Vector<uint8_t>& aCompressed); diff --git a/js/loader/LoadedScript.cpp b/js/loader/LoadedScript.cpp @@ -76,8 +76,8 @@ LoadedScript::LoadedScript(const LoadedScript& aOther) mStencil(aOther.mStencil) { MOZ_ASSERT(mFetchOptions); MOZ_ASSERT(mURI); - // NOTE: This is only for the stencil case. - // The script text and the bytecode are not reflected. + // NOTE: This is only for the cached stencil case. + // The script text and the serialized stencil are not reflected. MOZ_DIAGNOSTIC_ASSERT(aOther.mDataType == DataType::eCachedStencil); MOZ_DIAGNOSTIC_ASSERT(mStencil); MOZ_ASSERT(!mScriptData); diff --git a/js/loader/LoadedScript.h b/js/loader/LoadedScript.h @@ -436,11 +436,12 @@ class LoadedScript : public nsIMemoryReporter { // Holds the stencil for the script. This field is used in all DataType. RefPtr<Stencil> mStencil; - // The cache info channel used when saving the bytecode to the necko cache. + // The cache info channel used when saving the serialized Stencil to the + // necko cache. // // This field is populated if the cache is enabled and this is either - // IsTextSource() or IsCachedStencil(), and it's cleared after saving the - // bytecode (Thus, used only once). + // IsTextSource() or IsCachedStencil(), and it's cleared after saving to the + // necko cache, and thus, this field is used only once. nsCOMPtr<nsICacheInfoChannel> mCacheInfo; }; diff --git a/js/loader/ModuleLoaderBase.cpp b/js/loader/ModuleLoaderBase.cpp @@ -1570,7 +1570,6 @@ nsresult ModuleLoaderBase::EvaluateModuleInContext( } } - // TODO: Bug 1973321: Prepare Bytecode encoding for dynamic import rv = mLoader->MaybePrepareModuleForDiskCacheAfterExecute(aRequest, NS_OK); mLoader->MaybeUpdateDiskCache(); diff --git a/js/loader/ModuleLoaderBase.h b/js/loader/ModuleLoaderBase.h @@ -342,12 +342,12 @@ 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 - // called if CanStartLoad returned true. + // Start the process of fetching module source or serialized stencil. This is + // only called if CanStartLoad returned true. virtual nsresult StartFetch(ModuleLoadRequest* aRequest) = 0; // Create a JS module for a fetched module request. This might compile source - // text or decode cached bytecode. + // text or decode stencil. virtual nsresult CompileFetchedModule( JSContext* aCx, Handle<JSObject*> aGlobal, CompileOptions& aOptions, ModuleLoadRequest* aRequest, MutableHandle<JSObject*> aModuleOut) = 0; diff --git a/js/loader/ScriptLoadRequest.h b/js/loader/ScriptLoadRequest.h @@ -47,14 +47,18 @@ class ScriptLoadRequestList; /* * ScriptLoadRequest * - * ScriptLoadRequest is a generic representation of a JavaScript script that - * will be loaded by a Script/Module loader. This representation is used by the - * DOM ScriptLoader and will be used by workers and MOZJSComponentLoader. + * ScriptLoadRequest is a generic representation of a request/response for + * JavaScript file that will be loaded by a Script/Module loader. This + * representation is used by the following: + * - DOM ScriptLoader / ModuleLoader + * - worker ScriptLoader / ModuleLoader + * - worklet ScriptLoader + * - SyncModuleLoader * - * The ScriptLoadRequest contains information about the kind of script (classic - * or module), the URI, and the ScriptFetchOptions associated with the script. - * It is responsible for holding the script data once the fetch is complete, or - * if the request is cached, the bytecode. + * The ScriptLoadRequest contains information specific to the current request, + * such as the kind of script (classic, module, etc), and the reference to the + * LoadedScript which contains the information independent of the current + * request, such as the URI, the ScriptFetchOptions, etc. * * Relationship to ScriptLoadContext: * @@ -273,7 +277,7 @@ class ScriptLoadRequest : public nsISupports, // Are we still waiting for a load to complete? State mState; - // Request source, not cached bytecode. + // Request source, not cached serialized Stencil. bool mFetchSourceOnly : 1; // Becomes true if this has source map url. @@ -325,12 +329,7 @@ class ScriptLoadRequest : public nsISupports, // worklets as the file name in compile options. nsAutoCString mURL; - // The loaded script holds the source / bytecode which is loaded. - // - // Currently it is used to hold information which are needed by the Debugger. - // Soon it would be used as a way to dissociate the LoadRequest from the - // loaded value, such that multiple request referring to the same content - // would share the same loaded script. + // The loaded script holds the data which can be shared among similar requests RefPtr<LoadedScript> mLoadedScript; // LoadContext for augmenting the load depending on the loading