Bug 1359653: Part 4 - Fallback to the default JS version when decoding regexps off-thread. r=shu
When decoding off-thread, we can't safely access the JS runtime to get the
current JS version, and doing so causes failed assertions.
MozReview-Commit-ID: Lra437aa8SM
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -1441,16 +1441,19 @@ JSVersion
JSContext::findVersion()
{
if (JSScript* script = currentScript(nullptr, ALLOW_CROSS_COMPARTMENT))
return script->getVersion();
if (compartment() && compartment()->behaviors().version() != JSVERSION_UNKNOWN)
return compartment()->behaviors().version();
+ if (!CurrentThreadCanAccessRuntime(runtime()))
+ return JSVERSION_DEFAULT;
+
return runtime()->defaultVersion();
}
#ifdef DEBUG
JS::AutoCheckRequestDepth::AutoCheckRequestDepth(JSContext* cxArg)
: cx(cxArg->helperThread() ? nullptr : cxArg)
{