From 1d78b17e21049044a56e71dcb70063b486180b91 Mon Sep 17 00:00:00 2001 From: "Wesley W. Garland" Date: Fri, 24 Jul 2009 17:41:42 +0800 Subject: [PATCH] Bug 502696 js_CompareAndSwap on sparc should not use PRLock() r=jorendorff sr=benjamin --- configure.in | 15 --------------- js/src/Makefile.in | 18 +++--------------- js/src/configure.in | 15 --------------- js/src/jslock.cpp | 38 +++++++++++++++++++------------------- js/src/jslock.h | 6 +++--- 5 files changed, 25 insertions(+), 67 deletions(-) diff --git a/configure.in b/configure.in index 1a8dacde9b61..b903ce5a5490 100644 --- a/configure.in +++ b/configure.in @@ -6291,21 +6291,6 @@ MOZ_ARG_DISABLE_BOOL(zipwriter, MOZ_ZIPWRITER=1 ) AC_SUBST(MOZ_ZIPWRITER) -dnl ======================================================== -dnl = Enable Ultrasparc specific optimizations for JS -dnl ======================================================== -MOZ_ARG_ENABLE_BOOL(js-ultrasparc, -[ --enable-js-ultrasparc Use UltraSPARC optimizations in JS], - JS_ULTRASPARC_OPTS=1, - JS_ULTRASPARC_OPTS= ) - -dnl only enable option for ultrasparcs -if test `echo "$target_os" | grep -c \^solaris 2>/dev/null` = 0 -o \ - "$OS_TEST" != "sun4u"; then - JS_ULTRASPARC_OPTS= -fi -AC_SUBST(JS_ULTRASPARC_OPTS) - dnl ======================================================== dnl = Hildon and OSSO checks dnl ======================================================== diff --git a/js/src/Makefile.in b/js/src/Makefile.in index 38a2a00a6c15..1653c69c0e45 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -275,15 +275,6 @@ EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DIST)/lib) endif endif -# When using gcc the assembly is inlined in the C-file (see jslock.cpp) -ifeq ($(OS_ARCH),SunOS) -ifneq (86,$(findstring 86,$(OS_TEST))) -ifndef GNU_CC -ASFILES = lock_$(OS_ARCH).s -endif -endif -endif - ifndef BUILD_OPT MOCHAFILE = 1 endif @@ -437,15 +428,12 @@ endif ifeq ($(OS_ARCH),SunOS) ifeq ($(TARGET_CPU),sparc) -ifdef JS_ULTRASPARC_OPTS -DEFINES += -DULTRA_SPARC ifdef GNU_CC -CFLAGS += -Wa,-xarch=v8plus,-DULTRA_SPARC,-P,-L,-D_ASM,-D__STDC__=0 -CXXFLAGS += -Wa,-xarch=v8plus,-DULTRA_SPARC,-P,-L,-D_ASM,-D__STDC__=0,-K,PIC +CFLAGS += -mcpu=v9 +CXXFLAGS += -mcpu=v9 else -ASFLAGS += -xarch=v8plus -DULTRA_SPARC -P -L -D_ASM -D__STDC__=0 -K PIC +ASFLAGS += -xarch=v8plus -P -L -D_ASM -D__STDC__=0 -K PIC endif # GNU_CC -endif # JS_ULTRASPARC_OPTS endif ifeq ($(OS_RELEASE),4.1) diff --git a/js/src/configure.in b/js/src/configure.in index 28988a115a9e..4d28a3fbd7cd 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -3905,21 +3905,6 @@ dnl = dnl ======================================================== MOZ_ARG_HEADER(Individual module options) -dnl ======================================================== -dnl = Enable Ultrasparc specific optimizations for JS -dnl ======================================================== -MOZ_ARG_ENABLE_BOOL(js-ultrasparc, -[ --enable-js-ultrasparc Use UltraSPARC optimizations in JS], - JS_ULTRASPARC_OPTS=1, - JS_ULTRASPARC_OPTS= ) - -dnl only enable option for ultrasparcs -if test `echo "$target_os" | grep -c \^solaris 2>/dev/null` = 0 -o \ - "$OS_TEST" != "sun4u"; then - JS_ULTRASPARC_OPTS= -fi -AC_SUBST(JS_ULTRASPARC_OPTS) - dnl ======================================================== dnl = dnl = Debugging Options diff --git a/js/src/jslock.cpp b/js/src/jslock.cpp index aaa975f66dca..1b16140a1bd1 100644 --- a/js/src/jslock.cpp +++ b/js/src/jslock.cpp @@ -59,6 +59,11 @@ #define ReadWord(W) (W) +#if !defined(__GNUC__) +# define __asm__ asm +# define __volatile__ volatile +#endif + /* Implement NativeCompareAndSwap. */ #if defined(_WIN32) && defined(_M_IX86) @@ -97,7 +102,7 @@ NativeCompareAndSwap(jsword *w, jsword ov, jsword nv) return OSAtomicCompareAndSwapPtrBarrier(ov, nv, w); } -#elif defined(__GNUC__) && defined(__i386__) +#elif defined(__i386) && (defined(__GNUC__) || defined(__SUNPRO_CC)) /* Note: This fails on 386 cpus, cmpxchgl is a >= 486 instruction */ static JS_ALWAYS_INLINE int @@ -116,7 +121,8 @@ NativeCompareAndSwap(jsword *w, jsword ov, jsword nv) return (int)res; } -#elif defined(__GNUC__) && defined(__x86_64__) +#elif defined(__x86_64) && (defined(__GNUC__) || defined(__SUNPRO_CC)) + static JS_ALWAYS_INLINE int NativeCompareAndSwap(jsword *w, jsword ov, jsword nv) { @@ -133,30 +139,24 @@ NativeCompareAndSwap(jsword *w, jsword ov, jsword nv) return (int)res; } -#elif defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC) +#elif defined(__sparc) && (defined(__GNUC__) || defined(__SUNPRO_CC)) static JS_ALWAYS_INLINE int NativeCompareAndSwap(jsword *w, jsword ov, jsword nv) { -#if defined(__GNUC__) unsigned int res; - JS_ASSERT(ov != nv); - asm volatile ("\ -stbar\n\ -cas [%1],%2,%3\n\ -cmp %2,%3\n\ -be,a 1f\n\ -mov 1,%0\n\ -mov 0,%0\n\ -1:" + + __asm__ __volatile__ ( + "stbar\n" + "cas [%1],%2,%3\n" + "cmp %2,%3\n" + "be,a 1f\n" + "mov 1,%0\n" + "mov 0,%0\n" + "1:" : "=r" (res) : "r" (w), "r" (ov), "r" (nv)); return (int)res; -#else /* !__GNUC__ */ - extern int compare_and_swap(jsword*, jsword, jsword); - JS_ASSERT(ov != nv); - return compare_and_swap(w, ov, nv); -#endif } #elif defined(AIX) @@ -210,7 +210,7 @@ js_CompareAndSwap(jsword *w, jsword ov, jsword nv) #elif defined(NSPR_LOCK) # ifdef __GNUC__ -# warning "js_CompareAndSwap is implemented using NSSP lock" +# warning "js_CompareAndSwap is implemented using NSPR lock" # endif JSBool diff --git a/js/src/jslock.h b/js/src/jslock.h index e466131861e7..76b27a25cd18 100644 --- a/js/src/jslock.h +++ b/js/src/jslock.h @@ -55,9 +55,9 @@ JS_BEGIN_EXTERN_C #ifdef JS_THREADSAFE #if (defined(_WIN32) && defined(_M_IX86)) || \ - (defined(__GNUC__) && defined(__i386__)) || \ - (defined(__GNUC__) && defined(__x86_64__)) || \ - (defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)) || \ + (defined(__i386) && (defined(__GNUC__) || defined(__SUNPRO_CC))) || \ + (defined(__x86_64) && (defined(__GNUC__) || defined(__SUNPRO_CC))) || \ + (defined(__sparc) && (defined(__GNUC__) || defined(__SUNPRO_CC))) || \ defined(AIX) || \ defined(USE_ARM_KUSER) # define JS_HAS_NATIVE_COMPARE_AND_SWAP 1