couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r800750 - in /couchdb/trunk: configure.ac share/www/script/test/show_documents.js src/couchdb/couch_js.c
Date Tue, 04 Aug 2009 12:28:59 GMT
Author: jan
Date: Tue Aug  4 12:28:58 2009
New Revision: 800750

URL: http://svn.apache.org/viewvc?rev=800750&view=rev
Log:
add compile-time conditionals to support the upcoming Spidermonkey 1.8, swap searching for
libjs and libmozjs, patch by Alessandro Decina, closes COUCHDB-288

Modified:
    couchdb/trunk/configure.ac
    couchdb/trunk/share/www/script/test/show_documents.js
    couchdb/trunk/src/couchdb/couch_js.c

Modified: couchdb/trunk/configure.ac
URL: http://svn.apache.org/viewvc/couchdb/trunk/configure.ac?rev=800750&r1=800749&r2=800750&view=diff
==============================================================================
--- couchdb/trunk/configure.ac (original)
+++ couchdb/trunk/configure.ac Tue Aug  4 12:28:58 2009
@@ -85,8 +85,8 @@
 # manually linking libm is requred for FreeBSD 7.0
 LDFLAGS="$FLAGS -lm $LDFLAGS"
 
-AC_CHECK_LIB([js], [JS_NewContext], [], [
-    AC_CHECK_LIB([mozjs], [JS_NewContext], [], [
+AC_CHECK_LIB([mozjs], [JS_NewContext], [], [
+    AC_CHECK_LIB([js], [JS_NewContext], [], [
         AC_MSG_ERROR([Could not find the js library.
 
 Is the Mozilla SpiderMonkey library installed?])])])

Modified: couchdb/trunk/share/www/script/test/show_documents.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/show_documents.js?rev=800750&r1=800749&r2=800750&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/show_documents.js (original)
+++ couchdb/trunk/share/www/script/test/show_documents.js Tue Aug  4 12:28:58 2009
@@ -112,7 +112,7 @@
             // Becase Safari can't stand to see that dastardly
             // E4X outside of a string. Outside of tests you
             // can just use E4X literals.
-            this.eval('xml.node.@foo = doc.word');
+            eval('xml.node.@foo = doc.word');
             return {
               body: xml
             };

Modified: couchdb/trunk/src/couchdb/couch_js.c
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_js.c?rev=800750&r1=800749&r2=800750&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_js.c (original)
+++ couchdb/trunk/src/couchdb/couch_js.c Tue Aug  4 12:28:58 2009
@@ -213,7 +213,8 @@
         JS_ReportOutOfMemory(context);
         return JS_FALSE;
     }
-
+    JS_SetContextThread(sub_context);
+    JS_BeginRequest(sub_context);
     src = JS_GetStringChars(str);
     srclen = JS_GetStringLength(str);
 
@@ -229,13 +230,15 @@
         *rval = OBJECT_TO_JSVAL(sandbox);
         ok = JS_TRUE;
     } else {
-        ok = JS_EvaluateUCScript(sub_context, sandbox, src, srclen, NULL, -1,
+        ok = JS_EvaluateUCScript(sub_context, sandbox, src, srclen, NULL, 0,
                                  rval);
         ok = JS_TRUE;
     }
 
 out:
+    JS_EndRequest(sub_context);
     JS_DestroyContext(sub_context);
+    JS_ClearContextThread(sub_context);
     return ok;
 }
 
@@ -395,6 +398,7 @@
 
 static uint32 gBranchCount = 0;
 
+#if JS_VERSION <= 170
 static JSBool
 BranchCallback(JSContext *context, JSScript *script) {
     if ((++gBranchCount & 0x3fff) == 1) {
@@ -402,6 +406,16 @@
     }
     return JS_TRUE;
 }
+#else
+static JSBool
+OperationCallback(JSContext *context)
+{
+    if ((++gBranchCount & 0x3fff) == 1) {
+        JS_MaybeGC(context);
+    }
+    return JS_TRUE;
+}
+#endif
 
 static void
 PrintError(JSContext *context, const char *message, JSErrorReport *report) {
@@ -1211,9 +1225,16 @@
     context = JS_NewContext(runtime, gStackChunkSize);
     if (!context)
         return 1;
+    JS_SetContextThread(context);
+    JS_BeginRequest(context);
+    /* FIXME: https://bugzilla.mozilla.org/show_bug.cgi?id=477187 */
     JS_SetErrorReporter(context, PrintError);
+#if JS_VERSION <= 170
     JS_SetBranchCallback(context, BranchCallback);
     JS_ToggleOptions(context, JSOPTION_NATIVE_BRANCH_CALLBACK);
+#else
+    JS_SetOperationCallback(context, OperationCallback);
+#endif
     JS_ToggleOptions(context, JSOPTION_XML);
 
     global = JS_NewObject(context, NULL, NULL, NULL);
@@ -1243,8 +1264,9 @@
     }
 
     ExecuteScript(context, global, argv[1]);
-
+    JS_EndRequest(context);
     JS_DestroyContext(context);
+    JS_ClearContextThread(context);
     JS_DestroyRuntime(runtime);
     JS_ShutDown();
 



Mime
View raw message