You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2021/11/26 10:25:06 UTC

[couchdb] branch feat/support-sm91-3.x-from-lostnet created (now 1d6a0f0)

This is an automated email from the ASF dual-hosted git repository.

jan pushed a change to branch feat/support-sm91-3.x-from-lostnet
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 1d6a0f0  feat(couchjs): add support for SpiderMonkey 91esr

This branch includes the following new commits:

     new 1d6a0f0  feat(couchjs): add support for SpiderMonkey 91esr

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[couchdb] 01/01: feat(couchjs): add support for SpiderMonkey 91esr

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch feat/support-sm91-3.x-from-lostnet
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 1d6a0f0ef1a613e511adaea497127b047dc3826d
Author: Will Young <lo...@gmail.com>
AuthorDate: Mon Nov 22 13:12:53 2021 +0100

    feat(couchjs): add support for SpiderMonkey 91esr
---
 src/couch/priv/couch_js/86/main.cpp | 41 ++++++++++++++++++++++---------------
 src/couch/priv/couch_js/86/util.cpp |  2 +-
 src/couch/rebar.config.script       | 12 ++++++++++-
 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 2914099..d75f119 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 cd120a0..b61c76a 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 86b6a58..a288a96 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