Bug 1096651 - Avoid using random bits when determining SSE3/SSE4 availability for the JIT. r=luke, a=lmandel
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 13 Nov 2014 09:23:40 +0900
changeset 226054 3e5cb63660bd
parent 226053 e685be9bd4d6
child 226055 4ccd3e117f5d
push id4126
push userryanvm@gmail.com
push date2014-11-13 21:00 +0000
treeherdermozilla-beta@3e5cb63660bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke, lmandel
bugs1096651
milestone34.0
Bug 1096651 - Avoid using random bits when determining SSE3/SSE4 availability for the JIT. r=luke, a=lmandel
js/src/jit/shared/Assembler-x86-shared.cpp
--- a/js/src/jit/shared/Assembler-x86-shared.cpp
+++ b/js/src/jit/shared/Assembler-x86-shared.cpp
@@ -156,17 +156,21 @@ CPUInfo::SetSSEVersion()
          "movl $0x1, %%eax;"
          "cpuid;"
          : "=c" (flagsECX), "=d" (flagsEDX)
          :
          : "%eax", "%ebx"
          );
 # else
     // On x86, preserve ebx. The compiler needs it for PIC mode.
+    // Some older processors don't fill the ecx register with cpuid, so clobber
+    // it before calling cpuid, so that there's no risk of picking random bits
+    // indicating SSE3/SSE4 are present.
     asm (
+         "xor %%ecx, %%ecx;"
          "movl $0x1, %%eax;"
          "pushl %%ebx;"
          "cpuid;"
          "popl %%ebx;"
          : "=c" (flagsECX), "=d" (flagsEDX)
          :
          : "%eax"
          );