Ignore:
Timestamp:
Apr 28, 2009, 9:54:47 PM (16 years ago)
Author:
[email protected]
Message:

Bring back r42969, this time with correct codegen

Reviewed by Gavin Barraclough.

Add logic to the codegen for right shift to avoid jumping to a helper function
when shifting a small floating point value.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITArithmetic.cpp

    r42978 r42982  
    4545using namespace std;
    4646
     47#if PLATFORM(MAC)
     48
     49static inline bool isSSE2Present()
     50{
     51    return true; // All X86 Macs are guaranteed to support at least SSE2
     52}
     53
     54#else
     55
     56static bool isSSE2Present()
     57{
     58    static const int SSE2FeatureBit = 1 << 26;
     59    struct SSE2Check {
     60        SSE2Check()
     61        {
     62            int flags;
     63#if COMPILER(MSVC)
     64            _asm {
     65                mov eax, 1 // cpuid function 1 gives us the standard feature set
     66                cpuid;
     67                mov flags, edx;
     68            }
     69#elif COMPILER(GCC)
     70            asm (
     71                 "movl $0x1, %%eax;"
     72                 "pushl %%ebx;"
     73                 "cpuid;"
     74                 "popl %%ebx;"
     75                 "movl %%edx, %0;"
     76                 : "=g" (flags)
     77                 :
     78                 : "%eax", "%ecx", "%edx"
     79                 );
     80#else
     81            flags = 0;
     82#endif
     83            present = (flags & SSE2FeatureBit) != 0;
     84        }
     85        bool present;
     86    };
     87    static SSE2Check check;
     88    return check.present;
     89}
     90
     91#endif
     92
    4793namespace JSC {
    4894
     
    103149    } else {
    104150        emitGetVirtualRegisters(op1, regT0, op2, regT2);
    105         emitJumpSlowCaseIfNotImmediateInteger(regT0);
     151        if (isSSE2Present()) {
     152            Jump lhsIsInt = emitJumpIfImmediateInteger(regT0);
     153#if USE(ALTERNATE_JSIMMEDIATE)
     154            addSlowCase(emitJumpIfNotImmediateNumber(regT0));
     155            __ movq_rr(regT0, X86::xmm0);
     156#else
     157            emitJumpSlowCaseIfNotJSCell(regT0, op1);
     158            addSlowCase(checkStructure(regT0, m_globalData->numberStructure.get()));
     159            __ movsd_mr(FIELD_OFFSET(JSNumberCell, m_value), regT0, X86::xmm0);
     160#endif
     161            __ cvttsd2si_rr(X86::xmm0, regT0);
     162            addSlowCase(branch32(Equal, regT0, Imm32(0x80000000)));
     163#if !USE(ALTERNATE_JSIMMEDIATE)
     164            add32(regT0, regT0);
     165            addSlowCase(__ jo());
     166#endif
     167            lhsIsInt.link(this);
     168        } else
     169            emitJumpSlowCaseIfNotImmediateInteger(regT0);
    106170        emitJumpSlowCaseIfNotImmediateInteger(regT2);
    107171        emitFastArithImmToInt(regT2);
     
    124188    emitPutVirtualRegister(result);
    125189}
    126 void JIT::compileFastArithSlow_op_rshift(unsigned result, unsigned, unsigned op2, Vector<SlowCaseEntry>::iterator& iter)
     190void JIT::compileFastArithSlow_op_rshift(unsigned result, unsigned op1, unsigned op2, Vector<SlowCaseEntry>::iterator& iter)
    127191{
    128192    linkSlowCase(iter);
     
    130194        emitPutJITStubArgFromVirtualRegister(op2, 2, regT2);
    131195    else {
    132         linkSlowCase(iter);
     196        if (isSSE2Present()) {
     197#if USE(ALTERNATE_JSIMMEDIATE)
     198            linkSlowCase(iter);
     199#else
     200            linkSlowCaseIfNotJSCell(iter, op1);
     201            linkSlowCase(iter);
     202            linkSlowCase(iter);
     203#endif
     204            linkSlowCase(iter);
     205            // We're reloading op1 to regT0 as we can no longer guarantee that
     206            // we have not munged the operand.  It may have already been shifted
     207            // correctly, but it still will not have been tagged.
     208            emitGetVirtualRegister(op1, regT0);
     209        } else {
     210            linkSlowCase(iter);
     211            linkSlowCase(iter);
     212        }
    133213        emitPutJITStubArg(regT2, 2);
    134214    }
     
    600680typedef X86Assembler::XMMRegisterID XMMRegisterID;
    601681
    602 #if PLATFORM(MAC)
    603 
    604 static inline bool isSSE2Present()
    605 {
    606     return true; // All X86 Macs are guaranteed to support at least SSE2
    607 }
    608 
    609 #else
    610 
    611 static bool isSSE2Present()
    612 {
    613     static const int SSE2FeatureBit = 1 << 26;
    614     struct SSE2Check {
    615         SSE2Check()
    616         {
    617             int flags;
    618 #if COMPILER(MSVC)
    619             _asm {
    620                 mov eax, 1 // cpuid function 1 gives us the standard feature set
    621                 cpuid;
    622                 mov flags, edx;
    623             }
    624 #elif COMPILER(GCC)
    625             asm (
    626                 "movl $0x1, %%eax;"
    627                 "pushl %%ebx;"
    628                 "cpuid;"
    629                 "popl %%ebx;"
    630                 "movl %%edx, %0;"
    631                 : "=g" (flags)
    632                 :
    633                 : "%eax", "%ecx", "%edx"
    634             );
    635 #else
    636             flags = 0;
    637 #endif
    638             present = (flags & SSE2FeatureBit) != 0;
    639         }
    640         bool present;
    641     };
    642     static SSE2Check check;
    643     return check.present;
    644 }
    645 
    646 #endif
    647682
    648683void JIT::compileBinaryArithOp(OpcodeID opcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes types)
Note: See TracChangeset for help on using the changeset viewer.