Ignore:
Timestamp:
Nov 12, 2012, 5:55:42 PM (13 years ago)
Author:
[email protected]
Message:

Patching of jumps to stubs should use jump replacement rather than branch destination overwrite
https://bugs.webkit.org/show_bug.cgi?id=101909

Reviewed by Geoffrey Garen.

This saves a few instructions in inline cases, on those architectures where it is
easy to figure out where to put the jump replacement. Sub-1% speed-up across the
board.

  • assembler/MacroAssemblerARMv7.h:

(MacroAssemblerARMv7):
(JSC::MacroAssemblerARMv7::canJumpReplacePatchableBranchPtrWithPatch):
(JSC::MacroAssemblerARMv7::startOfPatchableBranchPtrWithPatch):
(JSC::MacroAssemblerARMv7::revertJumpReplacementToPatchableBranchPtrWithPatch):

  • assembler/MacroAssemblerX86.h:

(JSC::MacroAssemblerX86::canJumpReplacePatchableBranchPtrWithPatch):
(MacroAssemblerX86):
(JSC::MacroAssemblerX86::startOfPatchableBranchPtrWithPatch):
(JSC::MacroAssemblerX86::revertJumpReplacementToPatchableBranchPtrWithPatch):

  • assembler/MacroAssemblerX86_64.h:

(JSC::MacroAssemblerX86_64::canJumpReplacePatchableBranchPtrWithPatch):
(MacroAssemblerX86_64):
(JSC::MacroAssemblerX86_64::startOfPatchableBranchPtrWithPatch):
(JSC::MacroAssemblerX86_64::revertJumpReplacementToPatchableBranchPtrWithPatch):

  • assembler/RepatchBuffer.h:

(JSC::RepatchBuffer::startOfPatchableBranchPtrWithPatch):
(RepatchBuffer):
(JSC::RepatchBuffer::replaceWithJump):
(JSC::RepatchBuffer::revertJumpReplacementToPatchableBranchPtrWithPatch):

  • assembler/X86Assembler.h:

(X86Assembler):
(JSC::X86Assembler::revertJumpTo_movq_i64r):
(JSC::X86Assembler::revertJumpTo_cmpl_im_force32):
(X86InstructionFormatter):

  • bytecode/StructureStubInfo.h:
  • dfg/DFGRepatch.cpp:

(JSC::DFG::replaceWithJump):
(DFG):
(JSC::DFG::tryCacheGetByID):
(JSC::DFG::tryBuildGetByIDList):
(JSC::DFG::tryBuildGetByIDProtoList):
(JSC::DFG::tryCachePutByID):
(JSC::DFG::dfgResetGetByID):
(JSC::DFG::dfgResetPutByID):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/assembler/X86Assembler.h

    r133953 r134332  
    18841884    }
    18851885   
     1886#if CPU(X86_64)
     1887    static void revertJumpTo_movq_i64r(void* instructionStart, int64_t imm, RegisterID dst)
     1888    {
     1889        const int rexBytes = 1;
     1890        const int opcodeBytes = 1;
     1891        ASSERT(rexBytes + opcodeBytes <= maxJumpReplacementSize());
     1892        uint8_t* ptr = reinterpret_cast<uint8_t*>(instructionStart);
     1893        ptr[0] = PRE_REX | (1 << 3) | (dst >> 3);
     1894        ptr[1] = OP_MOV_EAXIv | (dst & 7);
     1895       
     1896        union {
     1897            uint64_t asWord;
     1898            uint8_t asBytes[8];
     1899        } u;
     1900        u.asWord = imm;
     1901        for (unsigned i = rexBytes + opcodeBytes; i < static_cast<unsigned>(maxJumpReplacementSize()); ++i)
     1902            ptr[i] = u.asBytes[i - rexBytes - opcodeBytes];
     1903    }
     1904#endif
     1905   
     1906    static void revertJumpTo_cmpl_im_force32(void* instructionStart, int32_t imm, int offset, RegisterID dst)
     1907    {
     1908        ASSERT_UNUSED(offset, !offset);
     1909        const int opcodeBytes = 1;
     1910        const int modRMBytes = 1;
     1911        ASSERT(opcodeBytes + modRMBytes <= maxJumpReplacementSize());
     1912        uint8_t* ptr = reinterpret_cast<uint8_t*>(instructionStart);
     1913        ptr[0] = OP_GROUP1_EvIz;
     1914        ptr[1] = (X86InstructionFormatter::ModRmMemoryNoDisp << 6) | (GROUP1_OP_CMP << 3) | dst;
     1915        union {
     1916            uint32_t asWord;
     1917            uint8_t asBytes[4];
     1918        } u;
     1919        u.asWord = imm;
     1920        for (unsigned i = opcodeBytes + modRMBytes; i < static_cast<unsigned>(maxJumpReplacementSize()); ++i)
     1921            ptr[i] = u.asBytes[i - opcodeBytes - modRMBytes];
     1922    }
     1923   
    18861924    static void replaceWithLoad(void* instructionStart)
    18871925    {
     
    19822020
    19832021    public:
     2022
     2023        enum ModRmMode {
     2024            ModRmMemoryNoDisp,
     2025            ModRmMemoryDisp8,
     2026            ModRmMemoryDisp32,
     2027            ModRmRegister,
     2028        };
    19842029
    19852030        // Legacy prefix bytes:
     
    23532398#endif
    23542399
    2355         enum ModRmMode {
    2356             ModRmMemoryNoDisp,
    2357             ModRmMemoryDisp8,
    2358             ModRmMemoryDisp32,
    2359             ModRmRegister,
    2360         };
    2361 
    23622400        void putModRm(ModRmMode mode, int reg, RegisterID rm)
    23632401        {
Note: See TracChangeset for help on using the changeset viewer.