Bug 1608839 - Guard against disabling all wasm compilers. r=decoder

If a script is trying to disable a compiler and that is the last compiler enabled, then throw.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Lars T Hansen 2020-01-18 19:03:20 +00:00
Родитель e076e40ab1
Коммит dd8e3684e6
1 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -4492,6 +4492,32 @@ static bool SetJitCompilerOption(JSContext* cx, unsigned argc, Value* vp) {
}
}
// Throw if trying to disable all the Wasm compilers. The logic here is that
// if we're trying to disable a compiler that is currently enabled and that is
// the last compiler enabled then we must throw.
if ((opt == JSJITCOMPILER_WASM_JIT_BASELINE ||
opt == JSJITCOMPILER_WASM_JIT_ION ||
opt == JSJITCOMPILER_WASM_JIT_CRANELIFT) &&
number == 0) {
uint32_t baseline, ion, cranelift;
MOZ_ALWAYS_TRUE(JS_GetGlobalJitCompilerOption(
cx, JSJITCOMPILER_WASM_JIT_BASELINE, &baseline));
MOZ_ALWAYS_TRUE(
JS_GetGlobalJitCompilerOption(cx, JSJITCOMPILER_WASM_JIT_ION, &ion));
MOZ_ALWAYS_TRUE(JS_GetGlobalJitCompilerOption(
cx, JSJITCOMPILER_WASM_JIT_CRANELIFT, &cranelift));
if (baseline + ion + cranelift == 1) {
if ((opt == JSJITCOMPILER_WASM_JIT_BASELINE && baseline) ||
(opt == JSJITCOMPILER_WASM_JIT_ION && ion) ||
(opt == JSJITCOMPILER_WASM_JIT_CRANELIFT && cranelift)) {
JS_ReportErrorASCII(
cx,
"Disabling all the Wasm compilers at runtime is not supported.");
return false;
}
}
}
// JIT compiler options are process-wide, so we have to stop off-thread
// compilations for all runtimes to avoid races.
HelperThreadState().waitForAllThreads();