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


Ignore:
Timestamp:
Feb 10, 2009, 8:57:08 PM (16 years ago)
Author:
[email protected]
Message:

2009-02-10 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Reduce use of void* / reinterpret_cast in JIT repatching code,
add strong types for Calls and for the various types of pointers
we retain into the JIT generated instruction stream.

No performance impact.

  • assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImmPtr::ImmPtr): (JSC::AbstractMacroAssembler::ImmPtr::asIntptr): (JSC::AbstractMacroAssembler::Imm32::Imm32): (JSC::AbstractMacroAssembler::Label::Label): (JSC::AbstractMacroAssembler::DataLabelPtr::DataLabelPtr): (JSC::AbstractMacroAssembler::Call::Call): (JSC::AbstractMacroAssembler::Call::link): (JSC::AbstractMacroAssembler::Call::linkTo): (JSC::AbstractMacroAssembler::Jump::Jump): (JSC::AbstractMacroAssembler::Jump::linkTo): (JSC::AbstractMacroAssembler::CodeLocationCommon::CodeLocationCommon): (JSC::AbstractMacroAssembler::CodeLocationCommon::operator bool): (JSC::AbstractMacroAssembler::CodeLocationCommon::reset): (JSC::AbstractMacroAssembler::CodeLocationLabel::CodeLocationLabel): (JSC::AbstractMacroAssembler::CodeLocationLabel::addressForSwitch): (JSC::AbstractMacroAssembler::CodeLocationLabel::addressForExceptionHandler): (JSC::AbstractMacroAssembler::CodeLocationLabel::addressForJSR): (JSC::AbstractMacroAssembler::CodeLocationLabel::getJumpDestination): (JSC::AbstractMacroAssembler::CodeLocationJump::CodeLocationJump): (JSC::AbstractMacroAssembler::CodeLocationJump::relink): (JSC::AbstractMacroAssembler::CodeLocationCall::CodeLocationCall): (JSC::AbstractMacroAssembler::CodeLocationCall::relink): (JSC::AbstractMacroAssembler::CodeLocationCall::calleeReturnAddressValue): (JSC::AbstractMacroAssembler::CodeLocationDataLabel32::CodeLocationDataLabel32): (JSC::AbstractMacroAssembler::CodeLocationDataLabel32::repatch): (JSC::AbstractMacroAssembler::CodeLocationDataLabelPtr::CodeLocationDataLabelPtr): (JSC::AbstractMacroAssembler::CodeLocationDataLabelPtr::repatch): (JSC::AbstractMacroAssembler::ProcessorReturnAddress::ProcessorReturnAddress): (JSC::AbstractMacroAssembler::ProcessorReturnAddress::relinkCallerToFunction): (JSC::AbstractMacroAssembler::ProcessorReturnAddress::operator void*): (JSC::AbstractMacroAssembler::PatchBuffer::entry): (JSC::AbstractMacroAssembler::PatchBuffer::trampolineAt): (JSC::AbstractMacroAssembler::PatchBuffer::link): (JSC::AbstractMacroAssembler::PatchBuffer::linkTailRecursive): (JSC::AbstractMacroAssembler::PatchBuffer::patch): (JSC::AbstractMacroAssembler::PatchBuffer::locationOf): (JSC::AbstractMacroAssembler::PatchBuffer::returnAddressOffset): (JSC::AbstractMacroAssembler::differenceBetween): (JSC::::CodeLocationCommon::labelAtOffset): (JSC::::CodeLocationCommon::jumpAtOffset): (JSC::::CodeLocationCommon::callAtOffset): (JSC::::CodeLocationCommon::dataLabelPtrAtOffset): (JSC::::CodeLocationCommon::dataLabel32AtOffset):
  • assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::call):
  • assembler/X86Assembler.h: (JSC::X86Assembler::getCallReturnOffset):
  • bytecode/CodeBlock.h: (JSC::CallLinkInfo::CallLinkInfo): (JSC::getStructureStubInfoReturnLocation): (JSC::getCallLinkInfoReturnLocation):
  • bytecode/Instruction.h: (JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set): (JSC::PolymorphicAccessStructureList::PolymorphicAccessStructureList):
  • bytecode/JumpTable.h: (JSC::StringJumpTable::ctiForValue): (JSC::SimpleJumpTable::ctiForValue):
  • bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::StructureStubInfo):
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitCatch): (JSC::prepareJumpTableForStringSwitch):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::cti_op_get_by_id_self_fail): (JSC::getPolymorphicAccessStructureListSlot): (JSC::Interpreter::cti_op_throw): (JSC::Interpreter::cti_op_switch_imm): (JSC::Interpreter::cti_op_switch_char): (JSC::Interpreter::cti_op_switch_string): (JSC::Interpreter::cti_vm_throw):
  • jit/JIT.cpp: (JSC::ctiSetReturnAddress): (JSC::ctiPatchCallByReturnAddress): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JIT.h: (JSC::CallRecord::CallRecord): (JSC::JIT::compileGetByIdSelf): (JSC::JIT::compileGetByIdProto): (JSC::JIT::compileGetByIdChain): (JSC::JIT::compilePutByIdReplace): (JSC::JIT::compilePutByIdTransition): (JSC::JIT::compilePatchGetArrayLength): (JSC::JIT::emitCTICall):
  • jit/JITCall.cpp: (JSC::JIT::unlinkCall): (JSC::JIT::linkCall):
  • jit/JITInlineMethods.h: (JSC::JIT::emitNakedCall): (JSC::JIT::emitCTICall_internal):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::compileGetByIdSlowCase): (JSC::JIT::compilePutByIdSlowCase): (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):
File:
1 edited

Legend:

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

    r40813 r40846  
    201201#endif
    202202
    203 void ctiSetReturnAddress(void** where, void* what)
     203void ctiSetReturnAddress(void** addressOfReturnAddress, void* newDestinationToReturnTo)
    204204{
    205     *where = what;
     205    *addressOfReturnAddress = newDestinationToReturnTo;
    206206}
    207207
    208 void ctiPatchCallByReturnAddress(void* where, void* what)
     208void ctiPatchCallByReturnAddress(MacroAssembler::ProcessorReturnAddress returnAddress, void* newCalleeFunction)
    209209{
    210     MacroAssembler::Jump::patch(where, what);
     210    returnAddress.relinkCallerToFunction(newCalleeFunction);
    211211}
    212212
     
    16791679            ASSERT(record.jumpTable.simpleJumpTable->branchOffsets.size() == record.jumpTable.simpleJumpTable->ctiOffsets.size());
    16801680
    1681             record.jumpTable.simpleJumpTable->ctiDefault = patchBuffer.addressOf(m_labels[bytecodeIndex + 3 + record.defaultOffset]);
     1681            record.jumpTable.simpleJumpTable->ctiDefault = patchBuffer.locationOf(m_labels[bytecodeIndex + 3 + record.defaultOffset]);
    16821682
    16831683            for (unsigned j = 0; j < record.jumpTable.simpleJumpTable->branchOffsets.size(); ++j) {
    16841684                unsigned offset = record.jumpTable.simpleJumpTable->branchOffsets[j];
    1685                 record.jumpTable.simpleJumpTable->ctiOffsets[j] = offset ? patchBuffer.addressOf(m_labels[bytecodeIndex + 3 + offset]) : record.jumpTable.simpleJumpTable->ctiDefault;
     1685                record.jumpTable.simpleJumpTable->ctiOffsets[j] = offset ? patchBuffer.locationOf(m_labels[bytecodeIndex + 3 + offset]) : record.jumpTable.simpleJumpTable->ctiDefault;
    16861686            }
    16871687        } else {
    16881688            ASSERT(record.type == SwitchRecord::String);
    16891689
    1690             record.jumpTable.stringJumpTable->ctiDefault = patchBuffer.addressOf(m_labels[bytecodeIndex + 3 + record.defaultOffset]);
     1690            record.jumpTable.stringJumpTable->ctiDefault = patchBuffer.locationOf(m_labels[bytecodeIndex + 3 + record.defaultOffset]);
    16911691
    16921692            StringJumpTable::StringOffsetTable::iterator end = record.jumpTable.stringJumpTable->offsetTable.end();           
    16931693            for (StringJumpTable::StringOffsetTable::iterator it = record.jumpTable.stringJumpTable->offsetTable.begin(); it != end; ++it) {
    16941694                unsigned offset = it->second.branchOffset;
    1695                 it->second.ctiOffset = offset ? patchBuffer.addressOf(m_labels[bytecodeIndex + 3 + offset]) : record.jumpTable.stringJumpTable->ctiDefault;
     1695                it->second.ctiOffset = offset ? patchBuffer.locationOf(m_labels[bytecodeIndex + 3 + offset]) : record.jumpTable.stringJumpTable->ctiDefault;
    16961696            }
    16971697        }
     
    17001700    for (size_t i = 0; i < m_codeBlock->numberOfExceptionHandlers(); ++i) {
    17011701        HandlerInfo& handler = m_codeBlock->exceptionHandler(i);
    1702         handler.nativeCode = patchBuffer.addressOf(m_labels[handler.target]);
     1702        handler.nativeCode = patchBuffer.locationOf(m_labels[handler.target]);
    17031703    }
    17041704
     
    17161716    // Link absolute addresses for jsr
    17171717    for (Vector<JSRInfo>::iterator iter = m_jsrSites.begin(); iter != m_jsrSites.end(); ++iter)
    1718         patchBuffer.setPtr(iter->storeLocation, patchBuffer.addressOf(iter->target));
     1718        patchBuffer.patch(iter->storeLocation, patchBuffer.locationOf(iter->target).addressForJSR());
    17191719
    17201720    for (unsigned i = 0; i < m_codeBlock->numberOfStructureStubInfos(); ++i) {
    17211721        StructureStubInfo& info = m_codeBlock->structureStubInfo(i);
    17221722#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
    1723         info.callReturnLocation = patchBuffer.addressOf(m_propertyAccessCompilationInfo[i].callReturnLocation);
    1724         info.hotPathBegin = patchBuffer.addressOf(m_propertyAccessCompilationInfo[i].hotPathBegin);
     1723        info.callReturnLocation = patchBuffer.locationOf(m_propertyAccessCompilationInfo[i].callReturnLocation);
     1724        info.hotPathBegin = patchBuffer.locationOf(m_propertyAccessCompilationInfo[i].hotPathBegin);
    17251725#else
    17261726        info.callReturnLocation = 0;
     
    17311731        CallLinkInfo& info = m_codeBlock->callLinkInfo(i);
    17321732#if ENABLE(JIT_OPTIMIZE_CALL)
    1733         info.callReturnLocation = patchBuffer.addressOf(m_callStructureStubCompilationInfo[i].callReturnLocation);
    1734         info.hotPathBegin = patchBuffer.addressOf(m_callStructureStubCompilationInfo[i].hotPathBegin);
    1735         info.hotPathOther = patchBuffer.addressOf(m_callStructureStubCompilationInfo[i].hotPathOther);
    1736         info.coldPathOther = patchBuffer.addressOf(m_callStructureStubCompilationInfo[i].coldPathOther);
     1733        info.callReturnLocation = patchBuffer.locationOf(m_callStructureStubCompilationInfo[i].callReturnLocation);
     1734        info.hotPathBegin = patchBuffer.locationOf(m_callStructureStubCompilationInfo[i].hotPathBegin);
     1735        info.hotPathOther = patchBuffer.locationOf(m_callStructureStubCompilationInfo[i].hotPathOther);
     1736        info.coldPathOther = patchBuffer.locationOf(m_callStructureStubCompilationInfo[i].coldPathOther);
    17371737#else
    17381738        info.callReturnLocation = 0;
     
    17961796    pop(X86::ebx);
    17971797    restoreArgumentReference();
    1798     Jump callJSFunction1 = call();
     1798    Call callJSFunction1 = call();
    17991799    emitGetJITStubArg(1, X86::ecx);
    18001800    emitGetJITStubArg(3, X86::edx);
     
    18081808    emitPutJITStubArg(X86::eax, 4);
    18091809    restoreArgumentReference();
    1810     Jump callArityCheck1 = call();
     1810    Call callArityCheck1 = call();
    18111811    move(X86::edx, callFrameRegister);
    18121812    emitGetJITStubArg(1, X86::ecx);
     
    18201820    emitPutJITStubArg(X86::ebx, 2);
    18211821    restoreArgumentReference();
    1822     Jump callDontLazyLinkCall = call();
     1822    Call callDontLazyLinkCall = call();
    18231823    push(X86::ebx);
    18241824
     
    18331833    pop(X86::ebx);
    18341834    restoreArgumentReference();
    1835     Jump callJSFunction2 = call();
     1835    Call callJSFunction2 = call();
    18361836    emitGetJITStubArg(1, X86::ecx);
    18371837    emitGetJITStubArg(3, X86::edx);
     
    18451845    emitPutJITStubArg(X86::eax, 4);
    18461846    restoreArgumentReference();
    1847     Jump callArityCheck2 = call();
     1847    Call callArityCheck2 = call();
    18481848    move(X86::edx, callFrameRegister);
    18491849    emitGetJITStubArg(1, X86::ecx);
     
    18571857    emitPutJITStubArg(X86::ebx, 2);
    18581858    restoreArgumentReference();
    1859     Jump callLazyLinkCall = call();
     1859    Call callLazyLinkCall = call();
    18601860    push(X86::ebx);
    18611861
     
    18701870    pop(X86::ebx);
    18711871    restoreArgumentReference();
    1872     Jump callJSFunction3 = call();
     1872    Call callJSFunction3 = call();
    18731873    emitGetJITStubArg(1, X86::ecx);
    18741874    emitGetJITStubArg(3, X86::edx);
     
    18821882    emitPutJITStubArg(X86::eax, 4);
    18831883    restoreArgumentReference();
    1884     Jump callArityCheck3 = call();
     1884    Call callArityCheck3 = call();
    18851885    move(X86::edx, callFrameRegister);
    18861886    emitGetJITStubArg(1, X86::ecx);
     
    19021902
    19031903#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
    1904     patchBuffer.link(array_failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
    1905     patchBuffer.link(array_failureCases2, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
    1906     patchBuffer.link(array_failureCases3, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_array_fail));
    1907     patchBuffer.link(string_failureCases1, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
    1908     patchBuffer.link(string_failureCases2, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
    1909     patchBuffer.link(string_failureCases3, reinterpret_cast<void*>(Interpreter::cti_op_get_by_id_string_fail));
    1910 
    1911     m_interpreter->m_ctiArrayLengthTrampoline = patchBuffer.addressOf(arrayLengthBegin);
    1912     m_interpreter->m_ctiStringLengthTrampoline = patchBuffer.addressOf(stringLengthBegin);
    1913 #endif
    1914     patchBuffer.link(callArityCheck1, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
    1915     patchBuffer.link(callArityCheck2, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
    1916     patchBuffer.link(callArityCheck3, reinterpret_cast<void*>(Interpreter::cti_op_call_arityCheck));
    1917     patchBuffer.link(callJSFunction1, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
    1918     patchBuffer.link(callJSFunction2, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
    1919     patchBuffer.link(callJSFunction3, reinterpret_cast<void*>(Interpreter::cti_op_call_JSFunction));
    1920     patchBuffer.link(callDontLazyLinkCall, reinterpret_cast<void*>(Interpreter::cti_vm_dontLazyLinkCall));
    1921     patchBuffer.link(callLazyLinkCall, reinterpret_cast<void*>(Interpreter::cti_vm_lazyLinkCall));
    1922 
    1923     m_interpreter->m_ctiVirtualCallPreLink = patchBuffer.addressOf(virtualCallPreLinkBegin);
    1924     m_interpreter->m_ctiVirtualCallLink = patchBuffer.addressOf(virtualCallLinkBegin);
    1925     m_interpreter->m_ctiVirtualCall = patchBuffer.addressOf(virtualCallBegin);
     1904    patchBuffer.linkTailRecursive(array_failureCases1, Interpreter::cti_op_get_by_id_array_fail);
     1905    patchBuffer.linkTailRecursive(array_failureCases2, Interpreter::cti_op_get_by_id_array_fail);
     1906    patchBuffer.linkTailRecursive(array_failureCases3, Interpreter::cti_op_get_by_id_array_fail);
     1907    patchBuffer.linkTailRecursive(string_failureCases1, Interpreter::cti_op_get_by_id_string_fail);
     1908    patchBuffer.linkTailRecursive(string_failureCases2, Interpreter::cti_op_get_by_id_string_fail);
     1909    patchBuffer.linkTailRecursive(string_failureCases3, Interpreter::cti_op_get_by_id_string_fail);
     1910
     1911    m_interpreter->m_ctiArrayLengthTrampoline = patchBuffer.trampolineAt(arrayLengthBegin);
     1912    m_interpreter->m_ctiStringLengthTrampoline = patchBuffer.trampolineAt(stringLengthBegin);
     1913#endif
     1914    patchBuffer.link(callArityCheck1, Interpreter::cti_op_call_arityCheck);
     1915    patchBuffer.link(callArityCheck2, Interpreter::cti_op_call_arityCheck);
     1916    patchBuffer.link(callArityCheck3, Interpreter::cti_op_call_arityCheck);
     1917    patchBuffer.link(callJSFunction1, Interpreter::cti_op_call_JSFunction);
     1918    patchBuffer.link(callJSFunction2, Interpreter::cti_op_call_JSFunction);
     1919    patchBuffer.link(callJSFunction3, Interpreter::cti_op_call_JSFunction);
     1920    patchBuffer.link(callDontLazyLinkCall, Interpreter::cti_vm_dontLazyLinkCall);
     1921    patchBuffer.link(callLazyLinkCall, Interpreter::cti_vm_lazyLinkCall);
     1922
     1923    m_interpreter->m_ctiVirtualCallPreLink = patchBuffer.trampolineAt(virtualCallPreLinkBegin);
     1924    m_interpreter->m_ctiVirtualCallLink = patchBuffer.trampolineAt(virtualCallLinkBegin);
     1925    m_interpreter->m_ctiVirtualCall = patchBuffer.trampolineAt(virtualCallBegin);
    19261926}
    19271927
Note: See TracChangeset for help on using the changeset viewer.