Bug 1752209 - Put cahe type into the cache key in StartupCache/ScriptPreloader. r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D143576
This commit is contained in:
Tooru Fujisawa
2022-04-13 14:08:07 +00:00
parent a014ff84f2
commit 0f5fc5d26f
7 changed files with 89 additions and 30 deletions

View File

@@ -81,7 +81,8 @@ mozJSSubScriptLoader::~mozJSSubScriptLoader() = default;
NS_IMPL_ISUPPORTS(mozJSSubScriptLoader, mozIJSSubScriptLoader)
#define JSSUB_CACHE_PREFIX(aType) "jssubloader/" aType
#define JSSUB_CACHE_PREFIX(aScopeType, aCompilationTarget) \
"jssubloader/" aScopeType "/" aCompilationTarget
static void SubscriptCachePath(JSContext* cx, nsIURI* uri,
JS::HandleObject targetObj,
@@ -89,9 +90,9 @@ static void SubscriptCachePath(JSContext* cx, nsIURI* uri,
// StartupCache must distinguish between non-syntactic vs global when
// computing the cache key.
if (!JS_IsGlobalObject(targetObj)) {
PathifyURI(JSSUB_CACHE_PREFIX("non-syntactic"), uri, cachePath);
PathifyURI(JSSUB_CACHE_PREFIX("non-syntactic", "script"), uri, cachePath);
} else {
PathifyURI(JSSUB_CACHE_PREFIX("global"), uri, cachePath);
PathifyURI(JSSUB_CACHE_PREFIX("global", "script"), uri, cachePath);
}
}