bug 676585 - fixes for compiling js on arm-apple-darwin. r=mrosenberg
authorTed Mielczarek <ted.mielczarek@gmail.com>
Wed, 21 Apr 2010 12:26:23 -0400
changeset 75802 06defc1b425097d4a95bb28f0ee254d38b186c36
parent 75640 b7c8af20e4009560b86cb6b84d7025b62ceaaa25
child 75803 4d17fe7b47b6ea39d1d6becebc7b080242fe2691
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmrosenberg
bugs676585
milestone9.0a1
bug 676585 - fixes for compiling js on arm-apple-darwin. r=mrosenberg
js/src/assembler/jit/ExecutableAllocator.h
js/src/assembler/wtf/Platform.h
js/src/configure.in
js/src/jstracer.cpp
js/src/nanojit/CodeAlloc.cpp
js/src/nanojit/njcpudetect.h
--- a/js/src/assembler/jit/ExecutableAllocator.h
+++ b/js/src/assembler/jit/ExecutableAllocator.h
@@ -369,17 +369,17 @@ public:
 #else
         intptr_t end = reinterpret_cast<intptr_t>(code) + size;
         __builtin___clear_cache(reinterpret_cast<char*>(code), reinterpret_cast<char*>(end));
 #endif
 #else
         _flush_cache(reinterpret_cast<char*>(code), size, BCACHE);
 #endif
     }
-#elif WTF_CPU_ARM_THUMB2 && WTF_OS_IOS
+#elif WTF_CPU_ARM && WTF_OS_IOS
     static void cacheFlush(void* code, size_t size)
     {
         sys_dcache_flush(code, size);
         sys_icache_invalidate(code, size);
     }
 #elif WTF_CPU_ARM_THUMB2 && WTF_IOS
     static void cacheFlush(void* code, size_t size)
     {
--- a/js/src/assembler/wtf/Platform.h
+++ b/js/src/assembler/wtf/Platform.h
@@ -324,17 +324,17 @@
 #else
 #define WTF_THUMB_ARCH_VERSION 0
 #endif
 
 
 /* WTF_CPU_ARMV5_OR_LOWER - ARM instruction set v5 or earlier */
 /* On ARMv5 and below the natural alignment is required. 
    And there are some other differences for v5 or earlier. */
-#if !defined(ARMV5_OR_LOWER) && WTF_CPU_ARM && WTF_ARM_ARCH_VERSION >= 6
+#if !defined(ARMV5_OR_LOWER) && WTF_CPU_ARM && !(WTF_ARM_ARCH_VERSION >= 6)
 #define WTF_CPU_ARMV5_OR_LOWER 1
 #endif
 
 
 /* WTF_CPU_ARM_TRADITIONAL - Thumb2 is not available, only traditional ARM (v4 or greater) */
 /* WTF_CPU_ARM_THUMB2 - Thumb2 instruction set is available */
 /* Only one of these will be defined. */
 #if !defined(WTF_CPU_ARM_TRADITIONAL) && !defined(WTF_CPU_ARM_THUMB2)
@@ -1110,17 +1110,18 @@
 #endif
 
 #if ENABLE_JIT || ENABLE_YARR_JIT
 #define ENABLE_ASSEMBLER 1
 #endif
 /* Setting this flag prevents the assembler from using RWX memory; this may improve
    security but currectly comes at a significant performance cost. */
 #if WTF_PLATFORM_IOS
-#define ENABLE_ASSEMBLER_WX_EXCLUSIVE 1
+//XXX: this doesn't currently compile in the spidermonkey build
+#define ENABLE_ASSEMBLER_WX_EXCLUSIVE 0
 #endif
 
 /* Pick which allocator to use; we only need an executable allocator if the assembler is compiled in.
    On x86-64 we use a single fixed mmap, on other platforms we mmap on demand. */
 #if ENABLE_ASSEMBLER
 #if WTF_CPU_X86_64
 #define ENABLE_EXECUTABLE_ALLOCATOR_FIXED 1
 #else
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -1114,16 +1114,17 @@ dnl ====================================
 dnl Check for MacOS deployment target version
 dnl ========================================================
 
 MOZ_ARG_ENABLE_STRING(macos-target,
                       [  --enable-macos-target=VER (default=10.5)
                           Set the minimum MacOS version needed at runtime],
                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
 
+if test "$target_cpu" != "arm"; then
 case "$target" in
 *-darwin*)
     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
         dnl Use the specified value
         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
     else
         dnl No value specified on the command line or in the environment,
         dnl use architecture minimum.
@@ -1136,16 +1137,17 @@ case "$target" in
             ;;
           x86_64)
             export MACOSX_DEPLOYMENT_TARGET=10.6
             ;;
         esac
     fi
     ;;
 esac
+fi
 
 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
 
 dnl ========================================================
 dnl = Mac OS X SDK support
 dnl ========================================================
 MACOS_SDK_DIR=
 NEXT_ROOT=
@@ -2004,22 +2006,32 @@ case "$target" in
     _PEDANTIC=
     CFLAGS="$CFLAGS -fpascal-strings -fno-common"
     CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common"
     DLL_SUFFIX=".dylib"
     DSO_LDOPTS=''
     STRIP="$STRIP -x -S"
     _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
-    LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
+    LDFLAGS="$LDFLAGS -lobjc"
     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
     # The ExceptionHandling framework is needed for Objective-C exception
     # logging code in nsObjCExceptions.h. Currently we only use that in debug
     # builds.
-    MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"
+    _SAVE_LDFLAGS=$LDFLAGS
+     AC_MSG_CHECKING([for -framework ExceptionHandling])
+    LDFLAGS="$LDFLAGS -framework ExceptionHandling"
+    AC_TRY_LINK(,[return 0;],
+                ac_cv_have_framework_exceptionhandling="yes",
+                ac_cv_have_framework_exceptionhandling="no")
+    AC_MSG_RESULT([$ac_cv_have_framework_exceptionhandling])
+    if test  "$ac_cv_have_framework_exceptionhandling" = "yes"; then
+      MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
+    fi
+    LDFLAGS=$_SAVE_LDFLAGS
     # Debug builds should always have frame pointers
     MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer"
 
     if test "x$lto_is_enabled" = "xyes"; then
         echo "Skipping -dead_strip because lto is enabled."
     dnl DTrace and -dead_strip don't interact well. See bug 403132.
     dnl ===================================================================
     elif test "x$enable_dtrace" = "xyes"; then
@@ -4378,16 +4390,19 @@ dnl ====================================
 dnl Defaults
 case "${CPU_ARCH}-${OS_TARGET}" in
 arm-Android)
     MOZ_THUMB=yes
     MOZ_ARCH=armv7-a
     MOZ_FPU=vfp
     MOZ_FLOAT_ABI=softfp
     ;;
+arm-Darwin)
+    MOZ_THUMB=yes
+    ;;
 arm-*)
     if test -n "$MOZ_PLATFORM_MAEMO"; then
         MOZ_THUMB=no
         MOZ_ARCH=armv7-a
         MOZ_FLOAT_ABI=softfp
     fi
     if test "$MOZ_PLATFORM_MAEMO" = 6; then
         MOZ_THUMB=yes
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -7620,16 +7620,22 @@ static bool
 arm_check_vfp()
 {
     if (!arm_tests_initialized)
         arm_read_auxv();
 
     return arm_has_vfp;
 }
 
+#elif defined(__APPLE__)
+// Hardcoded for now, revisit in the future
+static unsigned int
+arm_check_arch() { return 6; }
+static bool
+arm_check_vfp() { return true; }
 #else
 #warning Not sure how to check for architecture variant on your platform. Assuming ARMv4.
 static unsigned int
 arm_check_arch() { return 4; }
 static bool
 arm_check_vfp() { return false; }
 #endif
 
--- a/js/src/nanojit/CodeAlloc.cpp
+++ b/js/src/nanojit/CodeAlloc.cpp
@@ -253,19 +253,23 @@ namespace nanojit
     }
 
     void CodeAlloc::flushICache(CodeList* &blocks) {
         for (CodeList *b = blocks; b != 0; b = b->next)
             flushICache(b->start(), b->size());
     }
 
 #if defined(AVMPLUS_UNIX) && defined(NANOJIT_ARM)
+#if defined(__APPLE__)
+#include <libkern/OSCacheControl.h>
+#else
 #include <asm/unistd.h>
 extern "C" void __clear_cache(char *BEG, char *END);
 #endif
+#endif
 
 #if defined(AVMPLUS_UNIX) && defined(NANOJIT_MIPS)
 #include <asm/cachectl.h>
 extern  "C" int cacheflush(char *addr, int nbytes, int cache);
 #endif
 
 #ifdef AVMPLUS_SPARC
 // Note: the linux #define provided by the compiler.
@@ -345,16 +349,20 @@ extern  "C" void sync_instruction_memory
         cacheflush((char *)start, len, BCACHE);
     }
 
 #elif defined AVMPLUS_UNIX
     #ifdef ANDROID
     void CodeAlloc::flushICache(void *start, size_t len) {
         cacheflush((int)start, (int)start + len, 0);
     }
+    #elif defined(AVMPLUS_ARM) && defined(__APPLE__)
+    void CodeAlloc::flushICache(void *start, size_t len) {
+        sys_dcache_flush(start, len);
+    }
     #else
     // fixme: __clear_cache is a libgcc feature, test for libgcc or gcc
     void CodeAlloc::flushICache(void *start, size_t len) {
         __clear_cache((char*)start, (char*)start + len);
     }
     #endif
 #endif // AVMPLUS_MAC && NANOJIT_PPC
 
--- a/js/src/nanojit/njcpudetect.h
+++ b/js/src/nanojit/njcpudetect.h
@@ -71,16 +71,17 @@
         defined(__ARM_ARCH_7M__) || \
         defined(__ARM_ARCH_7R__) || \
         defined(_ARM_ARCH_7)
 
     #define NJ_COMPILER_ARM_ARCH 7
 
 #elif   defined(__ARM_ARCH_6__) || \
         defined(__ARM_ARCH_6J__) || \
+        defined(__ARM_ARCH_6K__) || \
         defined(__ARM_ARCH_6T2__) || \
         defined(__ARM_ARCH_6Z__) || \
         defined(__ARM_ARCH_6ZK__) || \
         defined(__ARM_ARCH_6M__) || \
         defined(_ARM_ARCH_6)
 
     #define NJ_COMPILER_ARM_ARCH 6