Changeset 36462 in webkit for trunk/JavaScriptCore/VM/CTI.cpp


Ignore:
Timestamp:
Sep 15, 2008, 4:33:25 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-15 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

Inline code generation of eq_null/neq_null for CTI. Uses vptr checking for
StringObjectsThatAreMasqueradingAsBeingUndefined. In the long run, the
masquerading may be handled differently (through the StructureIDs - see bug
#20823).

1% on v8-tests.

  • VM/CTI.cpp: (JSC::CTI::emitJumpSlowCaseIfIsJSCell): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileSlowCases):
  • VM/CTI.h:
  • VM/Machine.cpp: (JSC::Machine::Machine): (JSC::Machine::cti_op_eq_null): (JSC::Machine::cti_op_neq_null):
  • VM/Machine.h: (JSC::Machine::doesMasqueradesAsUndefined):
  • kjs/JSWrapperObject.h: (JSC::JSWrapperObject::): (JSC::JSWrapperObject::JSWrapperObject):
  • kjs/StringObject.h: (JSC::StringObject::StringObject):
  • kjs/StringObjectThatMasqueradesAsUndefined.h: (JSC::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CTI.cpp

    r36427 r36462  
    318318}
    319319
     320ALWAYS_INLINE void CTI::emitJumpSlowCaseIfIsJSCell(X86Assembler::RegisterID reg, unsigned opcodeIndex)
     321{
     322    m_jit.testl_i32r(JSImmediate::TagMask, reg);
     323    m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJe(), opcodeIndex));
     324}
     325
    320326ALWAYS_INLINE void CTI::emitJumpSlowCaseIfNotJSCell(X86Assembler::RegisterID reg, unsigned opcodeIndex)
    321327{
     
    13901396        }
    13911397        case op_eq_null: {
    1392             emitGetPutArg(instruction[i + 2].u.operand, 0, X86::ecx);
    1393             emitCall(i, Machine::cti_op_eq_null);
    1394             emitPutResult(instruction[i + 1].u.operand);
     1398            emitGetArg(instruction[i + 2].u.operand, X86::edx);
     1399
     1400            // go to a slow case either if this is not an immediate, or if the immediate is not undefined/null.
     1401            emitJumpSlowCaseIfIsJSCell(X86::edx, i);
     1402            m_jit.andl_i32r(~JSImmediate::ExtendedTagBitUndefined, X86::edx);
     1403            m_jit.cmpl_i32r(JSImmediate::FullTagTypeNull, X86::edx);
     1404            m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i));
     1405
     1406            m_jit.movl_i32r(reinterpret_cast<uint32_t>(JSImmediate::trueImmediate()), X86::eax);
     1407            emitPutResult(instruction[i + 1].u.operand);
     1408
    13951409            i += 3;
    13961410            break;
    13971411        }
    13981412        case op_neq_null: {
    1399             emitGetPutArg(instruction[i + 2].u.operand, 0, X86::ecx);
    1400             emitCall(i, Machine::cti_op_neq_null);
    1401             emitPutResult(instruction[i + 1].u.operand);
     1413            emitGetArg(instruction[i + 2].u.operand, X86::edx);
     1414
     1415            // go to a slow case either if this is not an immediate, or if the immediate is not undefined/null.
     1416            emitJumpSlowCaseIfIsJSCell(X86::edx, i);
     1417            m_jit.andl_i32r(~JSImmediate::ExtendedTagBitUndefined, X86::edx);
     1418            m_jit.cmpl_i32r(JSImmediate::FullTagTypeNull, X86::edx);
     1419            m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i));
     1420
     1421            m_jit.movl_i32r(reinterpret_cast<uint32_t>(JSImmediate::falseImmediate()), X86::eax);
     1422            emitPutResult(instruction[i + 1].u.operand);
     1423
    14021424            i += 3;
    14031425            break;
     
    18481870        }
    18491871        CTI_COMPILE_BINARY_OP_SLOW_CASE(op_mul);
     1872        case op_eq_null: {
     1873            m_jit.link(iter->from, m_jit.label());
     1874
     1875            // Value is a JSCell - speculate false, check for StringObjectThatMasqueradesAsUndefined.
     1876            m_jit.movl_i32r(reinterpret_cast<uint32_t>(JSImmediate::falseImmediate()), X86::eax);
     1877            emitPutResult(instruction[i + 1].u.operand);
     1878            m_jit.cmpl_i32m(reinterpret_cast<unsigned>(m_machine->m_jsStringObjectThatMasqueradesAsUndefinedVptr), X86::edx);
     1879            m_jit.link(m_jit.emitUnlinkedJne(), m_labels[i + 3]);
     1880           
     1881            // Value is a StringObjectThatMasqueradesAsUndefined
     1882            m_jit.movl_i32r(reinterpret_cast<uint32_t>(JSImmediate::trueImmediate()), X86::eax);
     1883            emitPutResult(instruction[i + 1].u.operand);
     1884            m_jit.link(m_jit.emitUnlinkedJmp(), m_labels[i + 3]);
     1885
     1886            // Value is an immediate other than undefined/null
     1887            m_jit.link((++iter)->from, m_jit.label());
     1888            m_jit.movl_i32r(reinterpret_cast<uint32_t>(JSImmediate::falseImmediate()), X86::eax);
     1889            emitPutResult(instruction[i + 1].u.operand);
     1890           
     1891            i += 3;
     1892            break;
     1893        }
     1894        case op_neq_null: {
     1895            m_jit.link(iter->from, m_jit.label());
     1896
     1897            // Value is a JSCell - speculate false, check for StringObjectThatMasqueradesAsUndefined.
     1898            m_jit.movl_i32r(reinterpret_cast<uint32_t>(JSImmediate::trueImmediate()), X86::eax);
     1899            emitPutResult(instruction[i + 1].u.operand);
     1900            m_jit.cmpl_i32m(reinterpret_cast<unsigned>(m_machine->m_jsStringObjectThatMasqueradesAsUndefinedVptr), X86::edx);
     1901            m_jit.link(m_jit.emitUnlinkedJne(), m_labels[i + 3]);
     1902           
     1903            // Value is a StringObjectThatMasqueradesAsUndefined
     1904            m_jit.movl_i32r(reinterpret_cast<uint32_t>(JSImmediate::falseImmediate()), X86::eax);
     1905            emitPutResult(instruction[i + 1].u.operand);
     1906            m_jit.link(m_jit.emitUnlinkedJmp(), m_labels[i + 3]);
     1907
     1908            // Value is an immediate other than undefined/null
     1909            m_jit.link((++iter)->from, m_jit.label());
     1910            m_jit.movl_i32r(reinterpret_cast<uint32_t>(JSImmediate::trueImmediate()), X86::eax);
     1911            emitPutResult(instruction[i + 1].u.operand);
     1912           
     1913            i += 3;
     1914            break;
     1915        }
    18501916        default:
    18511917            ASSERT_NOT_REACHED();
Note: See TracChangeset for help on using the changeset viewer.