summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Dashti <mdashti@gmail.com>2022-05-17 01:10:54 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-17 01:45:25 +0000
commit13ec926abfad8452f9e44196d5592577d245032e (patch)
tree2687b1152f2024edd3a582df8d85e33436de8c19
parent3b4067a108295b079c3d43027caffe2e2c66d7d0 (diff)
downloadmongo-13ec926abfad8452f9e44196d5592577d245032e.tar.gz
SERVER-66498 Disabled Baseline JIT for MozJS
-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 64a44667c49..4cac3bbc9ff 100644
--- a/src/mongo/scripting/mozjs/implscope.cpp
+++ b/src/mongo/scripting/mozjs/implscope.cpp
@@ -315,10 +315,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*)>>(
@@ -327,6 +323,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)
@@ -335,6 +340,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)
@@ -345,6 +359,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()));