summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Young <lost.networking@gmail.com>2021-11-22 13:12:53 +0100
committerJan Lehnardt <jan@apache.org>2021-11-26 11:24:45 +0100
commit1d6a0f0ef1a613e511adaea497127b047dc3826d (patch)
treea4279cdd479f14a685feb0a0667170d84e9bb09f
parent9391bf0c0514dd81d2e0ea4d69b03cb1e2760606 (diff)
downloadcouchdb-1d6a0f0ef1a613e511adaea497127b047dc3826d.tar.gz
feat(couchjs): add support for SpiderMonkey 91esr
-rw-r--r--src/couch/priv/couch_js/86/main.cpp41
-rw-r--r--src/couch/priv/couch_js/86/util.cpp2
-rw-r--r--src/couch/rebar.config.script12
3 files changed, 37 insertions, 18 deletions
diff --git a/src/couch/priv/couch_js/86/main.cpp b/src/couch/priv/couch_js/86/main.cpp
index 291409944..d75f119b2 100644
--- a/src/couch/priv/couch_js/86/main.cpp
+++ b/src/couch/priv/couch_js/86/main.cpp
@@ -186,6 +186,8 @@ quit(JSContext* cx, unsigned int argc, JS::Value* vp)
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
int exit_code = args[0].toInt32();;
+ JS_DestroyContext(cx);
+ JS_ShutDown();
exit(exit_code);
}
@@ -254,20 +256,7 @@ static JSSecurityCallbacks security_callbacks = {
nullptr
};
-
-int
-main(int argc, const char* argv[])
-{
- JSContext* cx = NULL;
- int i;
-
- couch_args* args = couch_parse_args(argc, argv);
-
- JS_Init();
- cx = JS_NewContext(args->stack_size);
- if(cx == NULL)
- return 1;
-
+int runWithContext(JSContext* cx, couch_args* args) {
JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_BASELINE_ENABLE, 0);
JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_ENABLE, 0);
@@ -293,7 +282,7 @@ main(int argc, const char* argv[])
if(couch_load_funcs(cx, global, global_functions) != true)
return 1;
- for(i = 0 ; args->scripts[i] ; i++) {
+ for(int i = 0 ; args->scripts[i] ; i++) {
const char* filename = args->scripts[i];
// Compile and run
@@ -336,6 +325,26 @@ main(int argc, const char* argv[])
// Give the GC a chance to run.
JS_MaybeGC(cx);
}
-
return 0;
}
+
+int
+main(int argc, const char* argv[])
+{
+ JSContext* cx = NULL;
+ int ret;
+
+ couch_args* args = couch_parse_args(argc, argv);
+
+ JS_Init();
+ cx = JS_NewContext(args->stack_size);
+ if(cx == NULL) {
+ JS_ShutDown();
+ return 1;
+ }
+ ret = runWithContext(cx, args);
+ JS_DestroyContext(cx);
+ JS_ShutDown();
+
+ return ret;
+}
diff --git a/src/couch/priv/couch_js/86/util.cpp b/src/couch/priv/couch_js/86/util.cpp
index cd120a03f..b61c76ad2 100644
--- a/src/couch/priv/couch_js/86/util.cpp
+++ b/src/couch/priv/couch_js/86/util.cpp
@@ -330,7 +330,7 @@ void
couch_oom(JSContext* cx, void* data)
{
fprintf(stderr, "out of memory\n");
- exit(1);
+ _Exit(1);
}
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
index 86b6a5872..a288a96eb 100644
--- a/src/couch/rebar.config.script
+++ b/src/couch/rebar.config.script
@@ -65,6 +65,8 @@ SMVsn = case lists:keyfind(spidermonkey_version, 1, CouchConfig) of
"78";
{_, "86"} ->
"86";
+ {_, "91"} ->
+ "91";
undefined ->
"1.8.5";
{_, Unsupported} ->
@@ -89,6 +91,8 @@ ConfigH = [
CouchJSConfig = case SMVsn of
"78" ->
"priv/couch_js/86/config.h";
+ "91" ->
+ "priv/couch_js/86/config.h";
_ ->
"priv/couch_js/" ++ SMVsn ++ "/config.h"
end.
@@ -148,6 +152,11 @@ end.
{
"-DXP_UNIX -I/usr/include/mozjs-86 -I/usr/local/include/mozjs-86 -I/opt/homebrew/include/mozjs-86/ -std=c++17 -Wno-invalid-offsetof",
"-L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-86 -lm"
+ };
+ {unix, _} when SMVsn == "91" ->
+ {
+ "-DXP_UNIX -I/usr/include/mozjs-91 -I/usr/local/include/mozjs-91 -I/opt/homebrew/include/mozjs-91/ -std=c++17 -Wno-invalid-offsetof",
+ "-L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-91 -lm"
}
end.
@@ -156,7 +165,8 @@ CouchJSSrc = case SMVsn of
"60" -> ["priv/couch_js/60/*.cpp"];
"68" -> ["priv/couch_js/68/*.cpp"];
"78" -> ["priv/couch_js/86/*.cpp"];
- "86" -> ["priv/couch_js/86/*.cpp"]
+ "86" -> ["priv/couch_js/86/*.cpp"];
+ "91" -> ["priv/couch_js/86/*.cpp"]
end.
CouchJSEnv = case SMVsn of