b=429387, add --with-arm-kuser; use it in JS, and pass it down to NSPR's configure; r=shaver,r=ted
authorVladimir Vukicevic <vladimir@pobox.com>
Wed, 04 Jun 2008 14:14:11 -0700
changeset 15258 38c53b644dc456ad235ee703c48ef6e36aa3c8ed
parent 15257 9dbbd177bc93a1548361a712a66c8ae9ec5658f1
child 15259 18db7f35dab4fddbf89a2346cae940e7bfdbcdb8
push idunknown
push userunknown
push dateunknown
reviewersshaver, ted
bugs429387
milestone1.9.1a1pre
b=429387, add --with-arm-kuser; use it in JS, and pass it down to NSPR's configure; r=shaver,r=ted
configure.in
js/src/jslock.cpp
js/src/jslock.h
--- a/configure.in
+++ b/configure.in
@@ -4251,16 +4251,28 @@ MOZ_ARG_WITH_STRING(java-include-path,
     JAVA_INCLUDE_PATH=$withval)
 
 JAVA_BIN_PATH=
 MOZ_ARG_WITH_STRING(java-bin-path,
 [  --with-java-bin-path=dir   Location of Java binaries (java, javac, jar)],
     JAVA_BIN_PATH=$withval)
 
 dnl ========================================================
+dnl Use ARM userspace kernel helpers; tell NSPR to enable
+dnl their usage and use them in spidermonkey.
+dnl ========================================================
+MOZ_ARG_WITH_BOOL(arm-kuser,
+[  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
+    USE_ARM_KUSER=1,
+    USE_ARM_KUSER=)
+if test -n "$USE_ARM_KUSER"; then
+   AC_DEFINE(USE_ARM_KUSER)
+fi
+
+dnl ========================================================
 dnl =
 dnl = Application
 dnl =
 dnl ========================================================
 
 MOZ_ARG_HEADER(Application)
 
 BUILD_STATIC_LIBS=
@@ -8259,16 +8271,19 @@ if test -z "$MOZ_NATIVE_NSPR" || test "$
         ac_configure_args="$ac_configure_args --enable-optimize"
     fi
     if test "$OS_ARCH" = "WINNT" && test "$NS_TRACE_MALLOC"; then
        ac_configure_args="$ac_configure_args --enable-debug --disable-optimize"
     fi
     if test -n "$HAVE_64BIT_OS"; then
         ac_configure_args="$ac_configure_args --enable-64bit"
     fi
+    if test -n "$USE_ARM_KUSER"; then
+        ac_configure_args="$ac_configure_args --with-arm-kuser"
+    fi
     AC_OUTPUT_SUBDIRS(nsprpub)
     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
 fi
 
 if test -z "$MOZ_NATIVE_NSPR"; then
     # Hack to deal with the fact that we use NSPR_CFLAGS everywhere
     AC_MSG_WARN([Recreating autoconf.mk with updated nspr-config output])
     if test ! "$VACPP" && test "$OS_ARCH" != "WINNT" && test "$OS_ARCH" != "WINCE"; then
--- a/js/src/jslock.cpp
+++ b/js/src/jslock.cpp
@@ -173,16 +173,34 @@ 1:"
 #include <sys/atomic_op.h>
 
 static JS_INLINE int
 js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
 {
     return !_check_lock((atomic_p)w, ov, nv);
 }
 
+#elif defined(USE_ARM_KUSER)
+
+/* See https://bugzilla.mozilla.org/show_bug.cgi?id=429387 for a
+ * description of this ABI; this is a function provided at a fixed
+ * location by the kernel in the memory space of each process.
+ */
+typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr);
+#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
+
+JS_STATIC_ASSERT(sizeof(jsword) == sizeof(int));
+
+static JS_INLINE int
+js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
+{
+    volatile int *vp = (volatile int*)w;
+    return !__kernel_cmpxchg(ov, nv, vp);
+}
+
 #else
 
 #error "Define NSPR_LOCK if your platform lacks a compare-and-swap instruction."
 
 #endif /* arch-tests */
 
 #endif /* !NSPR_LOCK */
 
--- a/js/src/jslock.h
+++ b/js/src/jslock.h
@@ -221,17 +221,17 @@ extern void js_SetScopeInfo(JSScope *sco
         JSRuntime *_rt = (cx)->runtime;                                       \
         JS_LOCK_RUNTIME_VOID(_rt, e);                                         \
     JS_END_MACRO
 
 #if defined(JS_USE_ONLY_NSPR_LOCKS) ||                                        \
     !( (defined(_WIN32) && defined(_M_IX86)) ||                               \
        (defined(__GNUC__) && defined(__i386__)) ||                            \
        (defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)) ||        \
-       defined(AIX) )
+       defined(AIX) || defined(USE_ARM_KUSER))
 
 #define NSPR_LOCK 1
 
 #undef JS_LOCK0
 #undef JS_UNLOCK0
 #define JS_LOCK0(P,M)   (JS_ACQUIRE_LOCK(((JSLock*)(P)->fat)), (P)->owner = (M))
 #define JS_UNLOCK0(P,M) ((P)->owner = 0, JS_RELEASE_LOCK(((JSLock*)(P)->fat)))