Changeset 39422 in webkit for trunk/JavaScriptCore/jit/JIT.cpp


Ignore:
Timestamp:
Dec 20, 2008, 2:11:31 AM (16 years ago)
Author:
[email protected]
Message:

2008-12-20 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Port optimized property access generation to the MacroAssembler.

  • assembler/MacroAssembler.h: (JSC::MacroAssembler::AbsoluteAddress::AbsoluteAddress): (JSC::MacroAssembler::DataLabelPtr::repatch): (JSC::MacroAssembler::DataLabel32::DataLabel32): (JSC::MacroAssembler::DataLabel32::repatch): (JSC::MacroAssembler::Label::operator X86Assembler::JmpDst): (JSC::MacroAssembler::Jump::repatch): (JSC::MacroAssembler::JumpList::empty): (JSC::MacroAssembler::RepatchBuffer::link): (JSC::MacroAssembler::add32): (JSC::MacroAssembler::and32): (JSC::MacroAssembler::sub32): (JSC::MacroAssembler::loadPtrWithAddressRepatch): (JSC::MacroAssembler::storePtrWithAddressRepatch): (JSC::MacroAssembler::push): (JSC::MacroAssembler::ja32): (JSC::MacroAssembler::jePtr): (JSC::MacroAssembler::jnePtr): (JSC::MacroAssembler::jnePtrWithRepatch): (JSC::MacroAssembler::align): (JSC::MacroAssembler::differenceBetween):
  • assembler/X86Assembler.h: (JSC::X86Assembler::movl_rm_disp32): (JSC::X86Assembler::movl_mr_disp32): (JSC::X86Assembler::X86InstructionFormatter::oneByteOp_disp32): (JSC::X86Assembler::X86InstructionFormatter::memoryModRM):
  • jit/JIT.cpp: (JSC::ctiRepatchCallByReturnAddress): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JIT.h:
  • jit/JITPropertyAccess.cpp: (JSC::JIT::compileGetByIdHotPath): (JSC::JIT::compileGetByIdSlowCase): (JSC::JIT::compilePutByIdHotPath): (JSC::JIT::compilePutByIdSlowCase): (JSC::resizePropertyStorage): (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::patchGetByIdSelf): (JSC::JIT::patchPutByIdReplace): (JSC::JIT::privateCompilePatchGetArrayLength): (JSC::JIT::privateCompileGetByIdSelf): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdSelfList): (JSC::JIT::privateCompileGetByIdProtoList): (JSC::JIT::privateCompileGetByIdChainList): (JSC::JIT::privateCompileGetByIdChain): (JSC::JIT::privateCompilePutByIdReplace):
  • wtf/RefCounted.h: (WTF::RefCountedBase::addressOfCount):
File:
1 edited

Legend:

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

    r39391 r39422  
    4141#endif
    4242
    43 #define __ m_assembler.
    44 
    4543using namespace std;
    4644
     
    199197void ctiRepatchCallByReturnAddress(void* where, void* what)
    200198{
    201     (static_cast<void**>(where))[-1] = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(what) - reinterpret_cast<uintptr_t>(where));
     199    MacroAssembler::Jump::repatch(where, what);
    202200}
    203201
     
    348346                emitCTICall(Interpreter::cti_op_end);
    349347            emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
    350             __ push_m(RegisterFile::ReturnPC * static_cast<int>(sizeof(Register)), callFrameRegister);
    351             __ ret();
     348            push(Address(callFrameRegister, RegisterFile::ReturnPC * static_cast<int>(sizeof(Register))));
     349            ret();
    352350            NEXT_OPCODE(op_end);
    353351        }
     
    588586
    589587            // Return.
    590             __ push_r(X86::edx);
    591             __ ret();
     588            push(X86::edx);
     589            ret();
    592590
    593591            NEXT_OPCODE(op_ret);
     
    18071805
    18081806    // Could use a pop_m, but would need to offset the following instruction if so.
    1809     __ pop_r(X86::ecx);
     1807    pop(X86::ecx);
    18101808    emitPutToCallFrameHeader(X86::ecx, RegisterFile::ReturnPC);
    18111809
     
    19221920#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
    19231921    // (1) The first function provides fast property access for array length
    1924     X86Assembler::JmpDst arrayLengthBegin = __ align(16);
     1922    Label arrayLengthBegin = align();
     1923
     1924    // Check eax is an array
     1925    Jump array_failureCases1 = emitJumpIfNotJSCell(X86::eax);
     1926    Jump array_failureCases2 = jnePtr(Address(X86::eax), ImmPtr(m_interpreter->m_jsArrayVptr));
     1927
     1928    // Checks out okay! - get the length from the storage
     1929    loadPtr(Address(X86::eax, FIELD_OFFSET(JSArray, m_storage)), X86::eax);
     1930    load32(Address(X86::eax, FIELD_OFFSET(ArrayStorage, m_length)), X86::eax);
     1931
     1932    Jump array_failureCases3 = ja32(X86::eax, Imm32(JSImmediate::maxImmediateInt));
     1933
     1934    add32(X86::eax, X86::eax);
     1935    add32(Imm32(1), X86::eax);
    19251936   
    1926     // Check eax is an array
    1927     X86Assembler::JmpSrc array_failureCases1 = emitJumpIfNotJSCell(X86::eax);
    1928     __ cmpl_im(reinterpret_cast<unsigned>(m_interpreter->m_jsArrayVptr), 0, X86::eax);
    1929     X86Assembler::JmpSrc array_failureCases2 = __ jne();
    1930 
    1931     // Checks out okay! - get the length from the storage
    1932     __ movl_mr(FIELD_OFFSET(JSArray, m_storage), X86::eax, X86::eax);
    1933     __ movl_mr(FIELD_OFFSET(ArrayStorage, m_length), X86::eax, X86::eax);
    1934 
    1935     __ cmpl_ir(JSImmediate::maxImmediateInt, X86::eax);
    1936     X86Assembler::JmpSrc array_failureCases3 = __ ja();
    1937 
    1938     __ addl_rr(X86::eax, X86::eax);
    1939     __ addl_ir(1, X86::eax);
     1937    ret();
     1938
     1939    // (2) The second function provides fast property access for string length
     1940    Label stringLengthBegin = align();
     1941
     1942    // Check eax is a string
     1943    Jump string_failureCases1 = emitJumpIfNotJSCell(X86::eax);
     1944    Jump string_failureCases2 = jnePtr(Address(X86::eax), ImmPtr(m_interpreter->m_jsStringVptr));
     1945
     1946    // Checks out okay! - get the length from the Ustring.
     1947    loadPtr(Address(X86::eax, FIELD_OFFSET(JSString, m_value) + FIELD_OFFSET(UString, m_rep)), X86::eax);
     1948    load32(Address(X86::eax, FIELD_OFFSET(UString::Rep, len)), X86::eax);
     1949
     1950    Jump string_failureCases3 = ja32(X86::eax, Imm32(JSImmediate::maxImmediateInt));
     1951
     1952    add32(X86::eax, X86::eax);
     1953    add32(Imm32(1), X86::eax);
    19401954   
    1941     __ ret();
    1942 
    1943     // (2) The second function provides fast property access for string length
    1944     X86Assembler::JmpDst stringLengthBegin = __ align(16);
    1945 
    1946     // Check eax is a string
    1947     X86Assembler::JmpSrc string_failureCases1 = emitJumpIfNotJSCell(X86::eax);
    1948     __ cmpl_im(reinterpret_cast<unsigned>(m_interpreter->m_jsStringVptr), 0, X86::eax);
    1949     X86Assembler::JmpSrc string_failureCases2 = __ jne();
    1950 
    1951     // Checks out okay! - get the length from the Ustring.
    1952     __ movl_mr(FIELD_OFFSET(JSString, m_value) + FIELD_OFFSET(UString, m_rep), X86::eax, X86::eax);
    1953     __ movl_mr(FIELD_OFFSET(UString::Rep, len), X86::eax, X86::eax);
    1954 
    1955     __ cmpl_ir(JSImmediate::maxImmediateInt, X86::eax);
    1956     X86Assembler::JmpSrc string_failureCases3 = __ ja();
    1957 
    1958     __ addl_rr(X86::eax, X86::eax);
    1959     __ addl_ir(1, X86::eax);
    1960    
    1961     __ ret();
     1955    ret();
    19621956#endif
    19631957
    19641958    // (3) Trampolines for the slow cases of op_call / op_call_eval / op_construct.
    19651959   
    1966     X86Assembler::JmpDst virtualCallPreLinkBegin = __ align(16);
    1967 
     1960    Label virtualCallPreLinkBegin = align();
     1961
     1962#define __ m_assembler.
    19681963    // Load the callee CodeBlock* into eax
    19691964    __ movl_mr(FIELD_OFFSET(JSFunction, m_body), X86::ecx, X86::eax);
     
    20031998    __ jmp_r(X86::eax);
    20041999
    2005     X86Assembler::JmpDst virtualCallLinkBegin = __ align(16);
     2000    Label virtualCallLinkBegin = align();
    20062001
    20072002    // Load the callee CodeBlock* into eax
     
    20422037    __ jmp_r(X86::eax);
    20432038
    2044     X86Assembler::JmpDst virtualCallBegin = __ align(16);
     2039    Label virtualCallBegin = align();
    20452040
    20462041    // Load the callee CodeBlock* into eax
     
    20772072
    20782073    // All trampolines constructed! copy the code, link up calls, and set the pointers on the Machine object.
    2079     m_interpreter->m_executablePool = m_globalData->poolForSize(__ size());
    2080     void* code = __ executableCopy(m_interpreter->m_executablePool.get());
     2074    m_interpreter->m_executablePool = m_globalData->poolForSize(m_assembler.size());
     2075    void* code = m_assembler.executableCopy(m_interpreter->m_executablePool.get());
     2076    RepatchBuffer repatchBuffer(code);
    20812077
    20822078#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
    2083     X86Assembler::link(code, array_failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
    2084     X86Assembler::link(code, array_failureCases2, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
    2085     X86Assembler::link(code, array_failureCases3, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
    2086     X86Assembler::link(code, string_failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
    2087     X86Assembler::link(code, string_failureCases2, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
    2088     X86Assembler::link(code, string_failureCases3, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
    2089 
    2090     m_interpreter->m_ctiArrayLengthTrampoline = X86Assembler::getRelocatedAddress(code, arrayLengthBegin);
    2091     m_interpreter->m_ctiStringLengthTrampoline = X86Assembler::getRelocatedAddress(code, stringLengthBegin);
    2092 #endif   
    2093 
     2079    repatchBuffer.link(array_failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
     2080    repatchBuffer.link(array_failureCases2, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
     2081    repatchBuffer.link(array_failureCases3, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
     2082    repatchBuffer.link(string_failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
     2083    repatchBuffer.link(string_failureCases2, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
     2084    repatchBuffer.link(string_failureCases3, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
     2085
     2086    m_interpreter->m_ctiArrayLengthTrampoline = repatchBuffer.addressOf(arrayLengthBegin);
     2087    m_interpreter->m_ctiStringLengthTrampoline = repatchBuffer.addressOf(stringLengthBegin);
     2088#endif
    20942089    X86Assembler::link(code, callArityCheck1, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
    20952090    X86Assembler::link(code, callArityCheck2, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
     
    21012096    X86Assembler::link(code, callLazyLinkCall, reinterpret_cast<void*>(Interpreter::cti_vm_lazyLinkCall));
    21022097
    2103     m_interpreter->m_ctiVirtualCallPreLink = X86Assembler::getRelocatedAddress(code, virtualCallPreLinkBegin);
    2104     m_interpreter->m_ctiVirtualCallLink = X86Assembler::getRelocatedAddress(code, virtualCallLinkBegin);
    2105     m_interpreter->m_ctiVirtualCall = X86Assembler::getRelocatedAddress(code, virtualCallBegin);
     2098    m_interpreter->m_ctiVirtualCallPreLink = repatchBuffer.addressOf(virtualCallPreLinkBegin);
     2099    m_interpreter->m_ctiVirtualCallLink = repatchBuffer.addressOf(virtualCallLinkBegin);
     2100    m_interpreter->m_ctiVirtualCall = repatchBuffer.addressOf(virtualCallBegin);
    21062101}
    21072102
Note: See TracChangeset for help on using the changeset viewer.