Ignore:
Timestamp:
May 15, 2009, 3:40:11 PM (16 years ago)
Author:
[email protected]
Message:

2009-05-15 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Looking like MSVC doesn't like static variables in inline methods?
Make the state of the SSE2 check a static variable on the class
MacroAssemblerX86Common as a speculative build fix for Windows.

  • assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::convertInt32ToDouble): (JSC::MacroAssemblerX86Common::branchDouble): (JSC::MacroAssemblerX86Common::branchTruncateDoubleToInt32): (JSC::MacroAssemblerX86Common::isSSE2Present): (JSC::MacroAssemblerX86Common::):
  • jit/JIT.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/assembler/MacroAssemblerX86Common.h

    r43781 r43789  
    328328    void convertInt32ToDouble(RegisterID src, FPRegisterID dest)
    329329    {
     330        ASSERT(isSSE2Present());
    330331        m_assembler.cvtsi2sd_rr(src, dest);
    331332    }
     
    333334    Jump branchDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right)
    334335    {
     336        ASSERT(isSSE2Present());
    335337        m_assembler.ucomisd_rr(right, left);
    336338        return Jump(m_assembler.jCC(x86Condition(cond)));
     
    343345    Jump branchTruncateDoubleToInt32(FPRegisterID src, RegisterID dest)
    344346    {
     347        ASSERT(isSSE2Present());
    345348        m_assembler.cvttsd2si_rr(src, dest);
    346349        return branch32(Equal, dest, Imm32(0x80000000));
     
    707710    friend class MacroAssemblerX86;
    708711
    709 #if PLATFORM(X86_64)
    710 #ifndef NDEBUG
    711     static bool isSSE2Present() { return true; }
     712#if PLATFORM(X86)
     713#if PLATFORM(MAC)
     714
     715    // All X86 Macs are guaranteed to support at least SSE2,
     716    static bool isSSE2Present()
     717    {
     718        return true;
     719    }
     720
     721#else // PLATFORM(MAC)
     722
     723    enum SSE2CheckState {
     724        NotCheckedSSE2,
     725        HasSSE2,
     726        NoSSE2
     727    };
     728
     729    static bool isSSE2Present()
     730    {
     731        if (s_sse2CheckState == NotCheckedSSE2) {
     732            // Default the flags value to zero; if the compiler is
     733            // not MSVC or GCC we will read this as SSE2 not present.
     734            int flags = 0;
     735#if COMPILER(MSVC)
     736            _asm {
     737                mov eax, 1 // cpuid function 1 gives us the standard feature set
     738                cpuid;
     739                mov flags, edx;
     740            }
     741#elif COMPILER(GCC)
     742            asm (
     743                 "movl $0x1, %%eax;"
     744                 "pushl %%ebx;"
     745                 "cpuid;"
     746                 "popl %%ebx;"
     747                 "movl %%edx, %0;"
     748                 : "=g" (flags)
     749                 :
     750                 : "%eax", "%ecx", "%edx"
     751                 );
    712752#endif
    713 #else
     753            static const int SSE2FeatureBit = 1 << 26;
     754            s_sse2CheckState = (flags & SSE2FeatureBit) ? HasSSE2 : NoSSE2;
     755        }
     756        // Only check once.
     757        ASSERT(s_sse2CheckState != NotCheckedSSE2);
     758
     759        return s_sse2CheckState == HasSSE2;
     760    }
     761   
     762    static SSE2CheckState s_sse2CheckState;
     763
     764#endif // PLATFORM(MAC)
     765#elif !defined(NDEBUG) // PLATFORM(X86)
     766
     767    // On x86-64 we should never be checking for SSE2 in a non-debug build,
     768    // but non debug add this method to keep the asserts above happy.
    714769    static bool isSSE2Present()
    715770    {
    716 #if PLATFORM(MAC)
    717         // All X86 Macs are guaranteed to support at least SSE2
    718771        return true;
    719 #else
    720         static const int SSE2FeatureBit = 1 << 26;
    721         struct SSE2Check {
    722             SSE2Check()
    723             {
    724                 int flags;
    725 #if COMPILER(MSVC)
    726                 _asm {
    727                     mov eax, 1 // cpuid function 1 gives us the standard feature set
    728                     cpuid;
    729                     mov flags, edx;
    730                 }
    731 #elif COMPILER(GCC)
    732                 asm (
    733                      "movl $0x1, %%eax;"
    734                      "pushl %%ebx;"
    735                      "cpuid;"
    736                      "popl %%ebx;"
    737                      "movl %%edx, %0;"
    738                      : "=g" (flags)
    739                      :
    740                      : "%eax", "%ecx", "%edx"
    741                      );
    742 #else
    743                 flags = 0;
    744 #endif
    745                 present = (flags & SSE2FeatureBit) != 0;
    746             }
    747             bool present;
    748         };
    749         static SSE2Check check;
    750         return check.present;
    751 #endif // !PLATFORM(MAC)
    752     }
     772    }
     773
    753774#endif
    754775};
Note: See TracChangeset for help on using the changeset viewer.