Bug 759683 - Check for -mssse3 instead of inconditionally using it. r=glandium
authorLandry Breuil <landry@openbsd.org>
Fri, 01 Jun 2012 15:12:09 -0700
changeset 97071 fca2f3541a720d92dfe79e4063c7341c22aa5806
parent 97070 1a22fee1faad8431de56db12fd820072f14fdb8b
child 97072 ebafa3d97c191009ddb410833ef19ba1fd847f23
push idunknown
push userunknown
push dateunknown
reviewersglandium
bugs759683
milestone15.0a1
Bug 759683 - Check for -mssse3 instead of inconditionally using it. r=glandium
config/autoconf.mk.in
configure.in
gfx/skia/Makefile.in
gfx/skia/patches/0012-Bug-759683-make-ssse3-conditional.patch
gfx/skia/patches/README
gfx/skia/src/opts/opts_check_SSE2.cpp
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -655,16 +655,17 @@ MOZ_CAN_RUN_PROGRAMS = @MOZ_CAN_RUN_PROG
 HAVE_DTRACE= @HAVE_DTRACE@
 
 VISIBILITY_FLAGS = @VISIBILITY_FLAGS@
 WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCLUDES@
 
 HAVE_ARM_SIMD = @HAVE_ARM_SIMD@
 HAVE_ARM_NEON = @HAVE_ARM_NEON@
 HAVE_GCC_ALIGN_ARG_POINTER = @HAVE_GCC_ALIGN_ARG_POINTER@
+HAVE_COMPILER_FLAG_MSSSE3 = @HAVE_COMPILER_FLAG_MSSSE3@
 
 MOZ_THEME_FASTSTRIPE = @MOZ_THEME_FASTSTRIPE@
 
 MOZ_SERVICES_SYNC = @MOZ_SERVICES_SYNC@
 
 MOZ_WEBAPP_RUNTIME = @MOZ_WEBAPP_RUNTIME@
 
 MOZ_OFFICIAL_BRANDING = @MOZ_OFFICIAL_BRANDING@
--- a/configure.in
+++ b/configure.in
@@ -1708,16 +1708,27 @@ if test "$GNU_CC"; then
     _SAVE_LDFLAGS=$LDFLAGS
     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
                   AC_MSG_RESULT([no])
                   LDFLAGS=$_SAVE_LDFLAGS)
     _MOZ_RTTI_FLAGS_ON=-frtti
     _MOZ_RTTI_FLAGS_OFF=-fno-rtti
 
+    # Check for -mssse3 on $CC
+    AC_MSG_CHECKING([for -mssse3 option to $CC])
+    HAVE_COMPILER_FLAG_MSSSE3=
+    _SAVE_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -mssse3"
+    AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
+                     [HAVE_COMPILER_FLAG_MSSSE3=1],
+                     AC_MSG_RESULT([no]))
+    CFLAGS=$_SAVE_CFLAGS
+    AC_SUBST(HAVE_COMPILER_FLAG_MSSSE3)
+
     # Turn on GNU-specific warnings:
     # -Wall - turn on a lot of warnings
     # -pedantic - this is turned on below
     # -Wpointer-arith - enabled with -pedantic, but good to have even if not
     # -Wdeclaration-after-statement - MSVC doesn't like these
     # -Werror=return-type - catches missing returns, zero false positives
     # -Wtype-limits - catches overflow bugs, few false positives
     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
--- a/gfx/skia/Makefile.in
+++ b/gfx/skia/Makefile.in
@@ -355,22 +355,25 @@ CPPSRCS += \
 	SkFontHost_sandbox_none.cpp \
 	SkTime_win.cpp \
 	$(NULL)
 endif
 
 ifneq (,$(INTEL_ARCHITECTURE))
 CPPSRCS += \
 	SkBitmapProcState_opts_SSE2.cpp \
-	SkBitmapProcState_opts_SSSE3.cpp \
 	SkBlitRect_opts_SSE2.cpp \
 	SkBlitRow_opts_SSE2.cpp \
 	SkUtils_opts_SSE2.cpp \
 	opts_check_SSE2.cpp \
 	$(NULL)
+ifdef HAVE_COMPILER_FLAG_MSSSE3
+DEFINES += -DSK_BUILD_SSSE3
+CPPSRCS += SkBitmapProcState_opts_SSSE3.cpp
+endif
 else
 ifeq ($(CPU_ARCH)_$(GNU_CC),arm_1)
 CPPSRCS += \
 	SkBitmapProcState_opts_arm.cpp \
 	SkBlitRow_opts_arm.cpp \
 	opts_check_arm.cpp \
 	$(NULL)
 SSRCS += memset.arm.S
new file mode 100644
--- /dev/null
+++ b/gfx/skia/patches/0012-Bug-759683-make-ssse3-conditional.patch
@@ -0,0 +1,22 @@
+diff --git a/gfx/skia/src/opts/opts_check_SSE2.cpp b/gfx/skia/src/opts/opts_check_SSE2.cpp
+--- a/gfx/skia/src/opts/opts_check_SSE2.cpp
++++ b/gfx/skia/src/opts/opts_check_SSE2.cpp
+@@ -91,17 +91,17 @@ static bool cachedHasSSE2() {
+ 
+ static bool cachedHasSSSE3() {
+     static bool gHasSSSE3 = hasSSSE3();
+     return gHasSSSE3;
+ }
+ 
+ void SkBitmapProcState::platformProcs() {
+     if (cachedHasSSSE3()) {
+-#if !defined(SK_BUILD_FOR_ANDROID)
++#if defined(SK_BUILD_SSSE3)
+         // Disable SSSE3 optimization for Android x86
+         if (fSampleProc32 == S32_opaque_D32_filter_DX) {
+             fSampleProc32 = S32_opaque_D32_filter_DX_SSSE3;
+         } else if (fSampleProc32 == S32_alpha_D32_filter_DX) {
+             fSampleProc32 = S32_alpha_D32_filter_DX_SSSE3;
+         }
+ 
+         if (fSampleProc32 == S32_opaque_D32_filter_DXDY) {
--- a/gfx/skia/patches/README
+++ b/gfx/skia/patches/README
@@ -9,8 +9,9 @@ 0003-SkUserConfig-for-Mozilla.patch
 0004-Bug-722011-Fix-trailing-commas-in-enums.patch
 0005-Bug-731384-Fix-clang-SK_OVERRIDE.patch
 0006-Bug-751814-ARM-EDSP-ARMv6-Skia-fixes.patch
 0007-Bug-719872-Old-Android-FontHost.patch
 0008-Bug-687188-Skia-radial-gradients.patch
 0009-Bug-755869-FreeBSD-Hurd.patch
 0010-Bug-689069-ARM-Opts.patch
 0011-Bug-719575-Fix-clang-build.patch
+0012-Bug-759683-make-ssse3-conditional.patch
--- a/gfx/skia/src/opts/opts_check_SSE2.cpp
+++ b/gfx/skia/src/opts/opts_check_SSE2.cpp
@@ -91,17 +91,17 @@ static bool cachedHasSSE2() {
 
 static bool cachedHasSSSE3() {
     static bool gHasSSSE3 = hasSSSE3();
     return gHasSSSE3;
 }
 
 void SkBitmapProcState::platformProcs() {
     if (cachedHasSSSE3()) {
-#if !defined(SK_BUILD_FOR_ANDROID)
+#if defined(SK_BUILD_SSSE3)
         // Disable SSSE3 optimization for Android x86
         if (fSampleProc32 == S32_opaque_D32_filter_DX) {
             fSampleProc32 = S32_opaque_D32_filter_DX_SSSE3;
         } else if (fSampleProc32 == S32_alpha_D32_filter_DX) {
             fSampleProc32 = S32_alpha_D32_filter_DX_SSSE3;
         }
 
         if (fSampleProc32 == S32_opaque_D32_filter_DXDY) {