Bug 998158 - SpiderMonkey: Simplify setSSECheckState(). r=sstangl
authorDan Gohman <sunfish@mozilla.com>
Mon, 21 Apr 2014 17:35:00 -0700
changeset 179887 6c0b4353730f7b1d9b01026ba2a0a526d4a2d7ce
parent 179886 b5869e103bfac622d5f9ff8086dd7a0a87791599
child 179888 c1c947d321b932e7b46c87dbd7d11a91f93481f7
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerssstangl
bugs998158
milestone31.0a1
Bug 998158 - SpiderMonkey: Simplify setSSECheckState(). r=sstangl
js/src/assembler/assembler/MacroAssemblerX86Common.cpp
--- a/js/src/assembler/assembler/MacroAssemblerX86Common.cpp
+++ b/js/src/assembler/assembler/MacroAssemblerX86Common.cpp
@@ -26,18 +26,18 @@ bool MacroAssemblerX86Common::s_floating
 bool MacroAssemblerX86Common::s_SSE3Disabled = false;
 bool MacroAssemblerX86Common::s_SSE4Disabled = false;
 #endif
 
 void MacroAssemblerX86Common::setSSECheckState()
 {
     // Default the flags value to zero; if the compiler is
     // not MSVC or GCC we will read this as SSE2 not present.
-    volatile int flags_edx = 0;
-    volatile int flags_ecx = 0;
+    int flags_edx = 0;
+    int flags_ecx = 0;
 #if WTF_COMPILER_MSVC
 #if WTF_CPU_X86_64
     int cpuinfo[4];
 
     __cpuid(cpuinfo, 1);
     flags_ecx = cpuinfo[2];
     flags_edx = cpuinfo[3];
 #else
@@ -47,36 +47,31 @@ void MacroAssemblerX86Common::setSSEChec
         mov flags_ecx, ecx;
         mov flags_edx, edx;
     }
 #endif
 #elif WTF_COMPILER_GCC
 #if WTF_CPU_X86_64
     asm (
          "movl $0x1, %%eax;"
-         "pushq %%rbx;"
          "cpuid;"
-         "popq %%rbx;"
-         "movl %%ecx, %0;"
-         "movl %%edx, %1;"
-         : "=g" (flags_ecx), "=g" (flags_edx)
+         : "=c" (flags_ecx), "=d" (flags_edx)
          :
-         : "%eax", "%ecx", "%edx"
+         : "%eax", "%ebx"
          );
 #else
+    // On 32-bit x86, we must preserve ebx; the compiler needs it for PIC mode.
     asm (
          "movl $0x1, %%eax;"
          "pushl %%ebx;"
          "cpuid;"
          "popl %%ebx;"
-         "movl %%ecx, %0;"
-         "movl %%edx, %1;"
-         : "=g" (flags_ecx), "=g" (flags_edx)
+         : "=c" (flags_ecx), "=d" (flags_edx)
          :
-         : "%eax", "%ecx", "%edx"
+         : "%eax"
          );
 #endif
 #elif WTF_COMPILER_SUNCC
 #if WTF_CPU_X86_64
     asm (
          "movl $0x1, %%eax;"
          "pushq %%rbx;"
          "cpuid;"