Bug 1465693 - Disallow toggling werror in the JS shell when there are off-thread jobs. r=jonco

This commit is contained in:
Jan de Mooij 2018-06-22 11:15:51 +02:00
parent 82b85b177c
commit ecac9eb954
2 changed files with 19 additions and 5 deletions

View File

@ -0,0 +1,7 @@
// |jit-test| error:toggle werror
if (helperThreadCount() === 0)
throw "toggle werror";
options("werror");
offThreadCompileScript("function f(){return 1;''}");
options("werror");
runOffThreadScript();

View File

@ -1481,15 +1481,22 @@ Options(JSContext* cx, unsigned argc, Value* vp)
if (!opt.encodeUtf8(cx, str))
return false;
if (strcmp(opt.ptr(), "strict") == 0)
if (strcmp(opt.ptr(), "strict") == 0) {
JS::ContextOptionsRef(cx).toggleExtraWarnings();
else if (strcmp(opt.ptr(), "werror") == 0)
} else if (strcmp(opt.ptr(), "werror") == 0) {
// Disallow toggling werror when there are off-thread jobs, to avoid
// confusing CompileError::throwError.
ShellContext* sc = GetShellContext(cx);
if (!sc->offThreadJobs.empty()) {
JS_ReportErrorASCII(cx, "can't toggle werror when there are off-thread jobs");
return false;
}
JS::ContextOptionsRef(cx).toggleWerror();
else if (strcmp(opt.ptr(), "throw_on_asmjs_validation_failure") == 0)
} else if (strcmp(opt.ptr(), "throw_on_asmjs_validation_failure") == 0) {
JS::ContextOptionsRef(cx).toggleThrowOnAsmJSValidationFailure();
else if (strcmp(opt.ptr(), "strict_mode") == 0)
} else if (strcmp(opt.ptr(), "strict_mode") == 0) {
JS::ContextOptionsRef(cx).toggleStrictMode();
else {
} else {
JS_ReportErrorUTF8(cx,
"unknown option name '%s'."
" The valid names are strict,"