Bug 1398601 - Add global/non-syntactic prefix to subscript loader cache r=kmag

We want to be able to store scripts compiled with or without
non-syntactic support in cache when we toggle JSM global sharing. In
current code this script is cloned on execution, but with JSM global
sharing we have would hit assertions.

MozReview-Commit-ID: 2pVTTxLpx6S
This commit is contained in:
Ted Campbell
2017-09-12 18:05:08 -04:00
parent 86544fc96a
commit b1ad77750a

View File

@@ -40,6 +40,8 @@ using namespace xpc;
using namespace mozilla;
using namespace mozilla::dom;
#define JSSUB_CACHE_PREFIX(aType) "jssubloader/" aType
class MOZ_STACK_CLASS LoadSubScriptOptions : public OptionsBase {
public:
explicit LoadSubScriptOptions(JSContext* cx = xpc_GetSafeJSContext(),
@@ -205,9 +207,11 @@ EvalScript(JSContext* cx,
}
if (script && (startupCache || preloadCache)) {
nsAutoCString cachePath;
bool hasNonSyntacticScope = !JS_IsGlobalObject(targetObj);
nsAutoCString cachePath(hasNonSyntacticScope ? JSSUB_CACHE_PREFIX("non-syntactic")
: JSSUB_CACHE_PREFIX("global"));
JSVersion version = JS_GetVersion(cx);
cachePath.AppendPrintf("jssubloader/%d", version);
cachePath.AppendPrintf("/%d", version);
PathifyURI(uri, cachePath);
nsCString uriStr;