commit 9d70740b321a36fa7de37c336381b32aa7eb045a
parent 6ed00c0dbe515e550ac024afd61873c1aa5883fd
Author: Tooru Fujisawa <arai_a@mac.com>
Date: Wed, 29 Oct 2025 09:37:23 +0000
Bug 1994617 - Part 2: Add CachingPlan::NotCacheable. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D270102
Diffstat:
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp
@@ -2700,7 +2700,7 @@ void ScriptLoader::CalculateCacheFlag(ScriptLoadRequest* aRequest) {
aRequest->AsModuleRequest()->mModuleType != JS::ModuleType::JavaScript) {
LOG(("ScriptLoadRequest (%p): Bytecode-cache: Skip all: JSON module",
aRequest));
- aRequest->MarkSkippedAllCaching();
+ aRequest->MarkNotCacheable();
MOZ_ASSERT(!aRequest->getLoadedScript()->HasDiskCacheReference());
MOZ_ASSERT_IF(aRequest->IsSource(), aRequest->SRIAndBytecode().empty());
return;
@@ -3278,6 +3278,12 @@ ScriptLoader::CacheBehavior ScriptLoader::GetCacheBehavior(
void ScriptLoader::TryCacheRequest(ScriptLoadRequest* aRequest) {
MOZ_ASSERT(aRequest->HasStencil());
+
+ if (aRequest->IsMarkedNotCacheable()) {
+ aRequest->ClearStencil();
+ return;
+ }
+
CacheBehavior cacheBehavior = GetCacheBehavior(aRequest);
if (cacheBehavior == CacheBehavior::DoNothing) {
diff --git a/js/loader/ScriptLoadRequest.h b/js/loader/ScriptLoadRequest.h
@@ -181,6 +181,19 @@ class ScriptLoadRequest : public nsISupports,
return PassedConditionForDiskCache() || PassedConditionForMemoryCache();
}
+ void MarkNotCacheable() {
+ mDiskCachingPlan = CachingPlan::NotCacheable;
+ mMemoryCachingPlan = CachingPlan::NotCacheable;
+ }
+
+ bool IsMarkedNotCacheable() const {
+ MOZ_ASSERT_IF(mDiskCachingPlan == CachingPlan::NotCacheable,
+ mMemoryCachingPlan == CachingPlan::NotCacheable);
+ MOZ_ASSERT_IF(mDiskCachingPlan != CachingPlan::NotCacheable,
+ mMemoryCachingPlan != CachingPlan::NotCacheable);
+ return mDiskCachingPlan == CachingPlan::NotCacheable;
+ }
+
void MarkSkippedDiskCaching() {
MOZ_ASSERT(mDiskCachingPlan == CachingPlan::Uninitialized ||
mDiskCachingPlan == CachingPlan::PassedCondition);
@@ -259,7 +272,11 @@ class ScriptLoadRequest : public nsISupports,
// This is not yet considered for caching.
Uninitialized,
- // This is marked for skipping the caching.
+ // This request is not cacheable (e.g. inline script, JSON module).
+ NotCacheable,
+
+ // This request is cacheable, but is marked for skipping due to
+ // not passing conditions.
Skipped,
// This fits the condition for the caching (e.g. file size, fetch count).