diff options
author | Shreyas Kalyan <shreyas.kalyan@10gen.com> | 2019-02-27 10:02:31 -0500 |
---|---|---|
committer | Shreyas Kalyan <shreyas.kalyan@10gen.com> | 2019-02-28 14:29:41 -0500 |
commit | 8bb32f15e153f037be28a6232a536f3478d4dc0d (patch) | |
tree | 6e6b1248042e4d3d99fc0b95832a7618b31a1fb4 | |
parent | 5f772b0b1139f4b9bbff098d4bcee59cf2e95cda (diff) | |
download | mongo-8bb32f15e153f037be28a6232a536f3478d4dc0d.tar.gz |
SERVER-39739 Migrate server parameters to IDL in src/mongo/scripting/mozjs/engine.cpp
-rw-r--r-- | src/mongo/scripting/SConscript | 5 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/engine.cpp | 21 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/engine.idl | 50 |
3 files changed, 62 insertions, 14 deletions
diff --git a/src/mongo/scripting/SConscript b/src/mongo/scripting/SConscript index 11a977b0afa..4dafbda2c75 100644 --- a/src/mongo/scripting/SConscript +++ b/src/mongo/scripting/SConscript @@ -25,6 +25,9 @@ env.Library( '$BUILD_DIR/mongo/shell/mongojs', '$BUILD_DIR/mongo/util/md5', ], + LIBDEPS_PRIVATE=[ + '$BUILD_DIR/mongo/idl/server_parameter', + ], ) env.Library( @@ -152,6 +155,7 @@ if usemozjs: 'mozjs/uri.cpp', 'mozjs/valuereader.cpp', 'mozjs/valuewriter.cpp', + env.Idlc('mozjs/engine.idl')[0], env.Idlc('mozjs/end_sessions.idl')[0], ], LIBDEPS=[ @@ -163,6 +167,7 @@ if usemozjs: LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/client/clientdriver_network', '$BUILD_DIR/third_party/shim_mozjs', + '$BUILD_DIR/mongo/idl/server_parameter', ], ) else: diff --git a/src/mongo/scripting/mozjs/engine.cpp b/src/mongo/scripting/mozjs/engine.cpp index 2396a13b6b2..c2010b4cf37 100644 --- a/src/mongo/scripting/mozjs/engine.cpp +++ b/src/mongo/scripting/mozjs/engine.cpp @@ -37,6 +37,7 @@ #include "mongo/db/operation_context.h" #include "mongo/db/server_parameters.h" +#include "mongo/scripting/mozjs/engine_gen.h" #include "mongo/scripting/mozjs/implscope.h" #include "mongo/scripting/mozjs/proxyscope.h" #include "mongo/util/log.h" @@ -47,14 +48,6 @@ void DisableExtraThreads(); namespace mongo { -namespace { - -MONGO_EXPORT_SERVER_PARAMETER(disableJavaScriptJIT, bool, true); -MONGO_EXPORT_SERVER_PARAMETER(javascriptProtection, bool, false); -MONGO_EXPORT_SERVER_PARAMETER(jsHeapLimitMB, int, 1100); - -} // namespace - void ScriptEngine::setup() { if (getGlobalScriptEngine()) return; @@ -125,27 +118,27 @@ void MozJSScriptEngine::interruptAll() { } void MozJSScriptEngine::enableJIT(bool value) { - disableJavaScriptJIT.store(!value); + gDisableJavaScriptJIT.store(!value); } bool MozJSScriptEngine::isJITEnabled() const { - return !disableJavaScriptJIT.load(); + return !gDisableJavaScriptJIT.load(); } void MozJSScriptEngine::enableJavaScriptProtection(bool value) { - javascriptProtection.store(value); + gJavascriptProtection.store(value); } bool MozJSScriptEngine::isJavaScriptProtectionEnabled() const { - return javascriptProtection.load(); + return gJavascriptProtection.load(); } int MozJSScriptEngine::getJSHeapLimitMB() const { - return jsHeapLimitMB.load(); + return gJSHeapLimitMB.load(); } void MozJSScriptEngine::setJSHeapLimitMB(int limit) { - jsHeapLimitMB.store(limit); + gJSHeapLimitMB.store(limit); } void MozJSScriptEngine::registerOperation(OperationContext* opCtx, MozJSImplScope* scope) { diff --git a/src/mongo/scripting/mozjs/engine.idl b/src/mongo/scripting/mozjs/engine.idl new file mode 100644 index 00000000000..6b98f7d28c5 --- /dev/null +++ b/src/mongo/scripting/mozjs/engine.idl @@ -0,0 +1,50 @@ +# Copyright (C) 2019-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + +server_parameters: + disableJavaScriptJIT: + description: "disable the Javascript Just In Time compiler" + set_at: [ startup, runtime ] + cpp_vartype: AtomicWord<bool> + cpp_varname: gDisableJavaScriptJIT + default: true + javascriptProtection: + description: "disable automatic JavaScript function marshalling" + set_at: [ startup, runtime ] + cpp_vartype: AtomicWord<bool> + cpp_varname: gJavascriptProtection + default: false + jsHeapLimitMB: + description: "set the js scope's heap size limit" + set_at: [ startup, runtime ] + cpp_vartype: AtomicWord<int> + cpp_varname: gJSHeapLimitMB + default: 1100 |