summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Dashti <mdashti@gmail.com>2022-05-17 04:52:12 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-17 05:15:08 +0000
commitdd511e91404b42167b7f2b8229069e489981a93b (patch)
tree9a6119860ced177b23d86526d41d9ce7440dd456
parent33f01c2958726b51900c98b3976002f80c8907e6 (diff)
downloadmongo-dd511e91404b42167b7f2b8229069e489981a93b.tar.gz
SERVER-66498 Disable Baseline JIT for MozJS
(cherry picked from commit 13ec926abfad8452f9e44196d5592577d245032e)
-rw-r--r--src/mongo/scripting/mozjs/implscope.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp
index 6c90fd85505..69296c9a5bb 100644
--- a/src/mongo/scripting/mozjs/implscope.cpp
+++ b/src/mongo/scripting/mozjs/implscope.cpp
@@ -313,10 +313,6 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine,
if (gFirstRuntimeCreated) {
// If we've already made a runtime, just proceed
lk.unlock();
- } else {
- // If this is the first one, hold the lock until after the first
- // one's done
- gFirstRuntimeCreated = true;
}
_context = std::unique_ptr<JSContext, std::function<void(JSContext*)>>(
@@ -325,6 +321,15 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine,
// We turn on a variety of optimizations if the jit is enabled
if (engine->isJITEnabled()) {
+ if (!gFirstRuntimeCreated) {
+ // The process-wide baseline JIT is enabled as part of creating the first JS
+ // runtime. If JIT is later disabled for a specific JS runtime, then the ION JIT
+ // engine gets disabled, but the baseline JIT is still enabled.
+ JS_SetGlobalJitCompilerOption(_context.get(), JSJITCOMPILER_BASELINE_ENABLE, 1);
+ JS_SetGlobalJitCompilerOption(
+ _context.get(), JSJITCOMPILER_BASELINE_INTERPRETER_ENABLE, 1);
+ JS_SetGlobalJitCompilerOption(_context.get(), JSJITCOMPILER_ION_ENABLE, 1);
+ }
JS::ContextOptionsRef(_context.get())
.setAsmJS(true)
.setThrowOnAsmJSValidationFailure(true)
@@ -333,6 +338,15 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine,
.setWasmIon(true)
.setAsyncStack(false);
} else {
+ if (!gFirstRuntimeCreated) {
+ // The process-wide baseline JIT is disabled as part of creating the first JS
+ // runtime. If JIT is later enabled for a specific JS runtime, then the ION JIT
+ // engine gets enabled.
+ JS_SetGlobalJitCompilerOption(_context.get(), JSJITCOMPILER_BASELINE_ENABLE, 0);
+ JS_SetGlobalJitCompilerOption(
+ _context.get(), JSJITCOMPILER_BASELINE_INTERPRETER_ENABLE, 0);
+ JS_SetGlobalJitCompilerOption(_context.get(), JSJITCOMPILER_ION_ENABLE, 0);
+ }
JS::ContextOptionsRef(_context.get())
.setAsmJS(false)
.setThrowOnAsmJSValidationFailure(false)
@@ -343,6 +357,12 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine,
.setAsyncStack(false);
}
+ if (!gFirstRuntimeCreated) {
+ // If this is the first one, hold the lock until after the first
+ // one's done
+ gFirstRuntimeCreated = true;
+ }
+
uassert(ErrorCodes::JSInterpreterFailure,
"UseInternalJobQueues",
js::UseInternalJobQueues(_context.get()));