Changeset 135330 in webkit


Ignore:
Timestamp:
Nov 20, 2012 4:22:08 PM (11 years ago)
Author:
fpizlo@apple.com
Message:

DFG should be able to cache closure calls (part 1/2)
https://bugs.webkit.org/show_bug.cgi?id=102662

Reviewed by Gavin Barraclough.

Add ability to revert a jump replacement back to
branchPtrWithPatch(Condition, RegisterID, TrustedImmPtr). This is meant to be
a mandatory piece of functionality for all assemblers. I also renamed some of
the functions for reverting jump replacements back to
patchableBranchPtrWithPatch(Condition, Address, TrustedImmPtr), so as to avoid
confusion.

  • assembler/ARMv7Assembler.h:

(JSC::ARMv7Assembler::BadReg):
(ARMv7Assembler):
(JSC::ARMv7Assembler::revertJumpTo_movT3):

  • assembler/LinkBuffer.h:

(JSC):

  • assembler/MacroAssemblerARMv7.h:

(JSC::MacroAssemblerARMv7::startOfBranchPtrWithPatchOnRegister):
(MacroAssemblerARMv7):
(JSC::MacroAssemblerARMv7::revertJumpReplacementToBranchPtrWithPatch):
(JSC::MacroAssemblerARMv7::startOfPatchableBranchPtrWithPatchOnAddress):

  • assembler/MacroAssemblerX86.h:

(JSC::MacroAssemblerX86::startOfBranchPtrWithPatchOnRegister):
(MacroAssemblerX86):
(JSC::MacroAssemblerX86::startOfPatchableBranchPtrWithPatchOnAddress):
(JSC::MacroAssemblerX86::revertJumpReplacementToBranchPtrWithPatch):

  • assembler/MacroAssemblerX86_64.h:

(JSC::MacroAssemblerX86_64::startOfBranchPtrWithPatchOnRegister):
(JSC::MacroAssemblerX86_64::startOfPatchableBranchPtrWithPatchOnAddress):
(MacroAssemblerX86_64):
(JSC::MacroAssemblerX86_64::revertJumpReplacementToBranchPtrWithPatch):

  • assembler/RepatchBuffer.h:

(JSC::RepatchBuffer::startOfBranchPtrWithPatchOnRegister):
(RepatchBuffer):
(JSC::RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress):
(JSC::RepatchBuffer::revertJumpReplacementToBranchPtrWithPatch):

  • assembler/X86Assembler.h:

(JSC::X86Assembler::revertJumpTo_cmpl_ir_force32):
(X86Assembler):

  • dfg/DFGRepatch.cpp:

(JSC::DFG::replaceWithJump):
(JSC::DFG::dfgResetGetByID):
(JSC::DFG::dfgResetPutByID):

Location:
trunk/Source/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r135286 r135330  
     12012-11-20  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG should be able to cache closure calls (part 1/2)
     4        https://bugs.webkit.org/show_bug.cgi?id=102662
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Add ability to revert a jump replacement back to
     9        branchPtrWithPatch(Condition, RegisterID, TrustedImmPtr). This is meant to be
     10        a mandatory piece of functionality for all assemblers. I also renamed some of
     11        the functions for reverting jump replacements back to
     12        patchableBranchPtrWithPatch(Condition, Address, TrustedImmPtr), so as to avoid
     13        confusion.
     14
     15        * assembler/ARMv7Assembler.h:
     16        (JSC::ARMv7Assembler::BadReg):
     17        (ARMv7Assembler):
     18        (JSC::ARMv7Assembler::revertJumpTo_movT3):
     19        * assembler/LinkBuffer.h:
     20        (JSC):
     21        * assembler/MacroAssemblerARMv7.h:
     22        (JSC::MacroAssemblerARMv7::startOfBranchPtrWithPatchOnRegister):
     23        (MacroAssemblerARMv7):
     24        (JSC::MacroAssemblerARMv7::revertJumpReplacementToBranchPtrWithPatch):
     25        (JSC::MacroAssemblerARMv7::startOfPatchableBranchPtrWithPatchOnAddress):
     26        * assembler/MacroAssemblerX86.h:
     27        (JSC::MacroAssemblerX86::startOfBranchPtrWithPatchOnRegister):
     28        (MacroAssemblerX86):
     29        (JSC::MacroAssemblerX86::startOfPatchableBranchPtrWithPatchOnAddress):
     30        (JSC::MacroAssemblerX86::revertJumpReplacementToBranchPtrWithPatch):
     31        * assembler/MacroAssemblerX86_64.h:
     32        (JSC::MacroAssemblerX86_64::startOfBranchPtrWithPatchOnRegister):
     33        (JSC::MacroAssemblerX86_64::startOfPatchableBranchPtrWithPatchOnAddress):
     34        (MacroAssemblerX86_64):
     35        (JSC::MacroAssemblerX86_64::revertJumpReplacementToBranchPtrWithPatch):
     36        * assembler/RepatchBuffer.h:
     37        (JSC::RepatchBuffer::startOfBranchPtrWithPatchOnRegister):
     38        (RepatchBuffer):
     39        (JSC::RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress):
     40        (JSC::RepatchBuffer::revertJumpReplacementToBranchPtrWithPatch):
     41        * assembler/X86Assembler.h:
     42        (JSC::X86Assembler::revertJumpTo_cmpl_ir_force32):
     43        (X86Assembler):
     44        * dfg/DFGRepatch.cpp:
     45        (JSC::DFG::replaceWithJump):
     46        (JSC::DFG::dfgResetGetByID):
     47        (JSC::DFG::dfgResetPutByID):
     48
    1492012-11-20  Yong Li  <yoli@rim.com>
    250
  • trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r135286 r135330  
    11/*
    2  * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2010, 2012 Apple Inc. All rights reserved.
    33 * Copyright (C) 2010 University of Szeged
    44 *
     
    508508
    509509    // ARMv7, Appx-A.6.3
    510     bool BadReg(RegisterID reg)
     510    static bool BadReg(RegisterID reg)
    511511    {
    512512        return (reg == ARMRegisters::sp) || (reg == ARMRegisters::pc);
     
    12621262        m_formatter.twoWordOp5i6Imm4Reg4EncodedImm(OP_MOV_imm_T3, imm.m_value.imm4, rd, imm);
    12631263    }
     1264   
     1265    static void revertJumpTo_movT3(void* instructionStart, RegisterID rd, ARMThumbImmediate imm)
     1266    {
     1267        ASSERT(imm.isValid());
     1268        ASSERT(!imm.isEncodedImm());
     1269        ASSERT(!BadReg(rd));
     1270       
     1271        uint16_t* address = static_cast<uint16_t*>(instructionStart);
     1272        address[0] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOV_imm_T3, imm);
     1273        address[1] = twoWordOp5i6Imm4Reg4EncodedImmSecond(rd, imm);
     1274        cacheFlush(address, sizeof(uint16_t) * 2);
     1275    }
    12641276
    12651277    ALWAYS_INLINE void mov(RegisterID rd, ARMThumbImmediate imm)
  • trunk/Source/JavaScriptCore/assembler/LinkBuffer.h

    r129272 r135330  
    289289
    290290#define FINALIZE_DFG_CODE(linkBufferReference, dataLogArgumentsForHeading)  \
    291     FINALIZE_CODE_IF(Options::showDFGDisassembly(), linkBufferReference, dataLogArgumentsForHeading)
     291    FINALIZE_CODE_IF((Options::showDisassembly() || Options::showDFGDisassembly()), linkBufferReference, dataLogArgumentsForHeading)
    292292
    293293} // namespace JSC
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r134358 r135330  
    17621762    static bool canJumpReplacePatchableBranchPtrWithPatch() { return false; }
    17631763   
    1764     static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr)
     1764    static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
     1765    {
     1766        const unsigned twoWordOpSize = 4;
     1767        return label.labelAtOffset(-twoWordOpSize * 2);
     1768    }
     1769   
     1770    static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue)
     1771    {
     1772        ARMv7Assembler::revertJumpTo_movT3(instructionStart.dataLocation(), dataTempRegister, ARMThumbImmediate::makeUInt16(reinterpret_cast<uintptr_t>(initialValue) & 0xffff));
     1773    }
     1774   
     1775    static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr)
    17651776    {
    17661777        UNREACHABLE_FOR_PLATFORM();
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h

    r134332 r135330  
    256256    static bool canJumpReplacePatchableBranchPtrWithPatch() { return true; }
    257257   
    258     static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label)
     258    static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
     259    {
     260        const int opcodeBytes = 1;
     261        const int modRMBytes = 1;
     262        const int immediateBytes = 4;
     263        const int totalBytes = opcodeBytes + modRMBytes + immediateBytes;
     264        ASSERT(totalBytes >= maxJumpReplacementSize());
     265        return label.labelAtOffset(-totalBytes);
     266    }
     267   
     268    static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label)
    259269    {
    260270        const int opcodeBytes = 1;
     
    267277    }
    268278   
     279    static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID reg, void* initialValue)
     280    {
     281        X86Assembler::revertJumpTo_cmpl_ir_force32(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), reg);
     282    }
     283
    269284    static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, Address address, void* initialValue)
    270285    {
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h

    r134332 r135330  
    588588    static bool canJumpReplacePatchableBranchPtrWithPatch() { return true; }
    589589   
    590     static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label)
     590    static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
    591591    {
    592592        const int rexBytes = 1;
     
    598598    }
    599599   
     600    static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label)
     601    {
     602        return startOfBranchPtrWithPatchOnRegister(label);
     603    }
     604   
    600605    static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, Address, void* initialValue)
     606    {
     607        X86Assembler::revertJumpTo_movq_i64r(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), scratchRegister);
     608    }
     609
     610    static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue)
    601611    {
    602612        X86Assembler::revertJumpTo_movq_i64r(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), scratchRegister);
  • trunk/Source/JavaScriptCore/assembler/RepatchBuffer.h

    r134332 r135330  
    142142    }
    143143
    144     static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label)
     144    static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
    145145    {
    146         return MacroAssembler::startOfPatchableBranchPtrWithPatch(label);
     146        return MacroAssembler::startOfBranchPtrWithPatchOnRegister(label);
     147    }
     148   
     149    static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label)
     150    {
     151        return MacroAssembler::startOfPatchableBranchPtrWithPatchOnAddress(label);
    147152    }
    148153   
     
    155160    // immediate after calling this. But I'm fine with that, since this just feels
    156161    // less yucky.
     162    void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, MacroAssembler::RegisterID reg, void* value)
     163    {
     164        MacroAssembler::revertJumpReplacementToBranchPtrWithPatch(instructionStart, reg, value);
     165    }
     166
    157167    void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, MacroAssembler::Address address, void* value)
    158168    {
  • trunk/Source/JavaScriptCore/assembler/X86Assembler.h

    r134332 r135330  
    19041904#endif
    19051905   
     1906    static void revertJumpTo_cmpl_ir_force32(void* instructionStart, int32_t imm, RegisterID dst)
     1907    {
     1908        const int opcodeBytes = 1;
     1909        const int modRMBytes = 1;
     1910        ASSERT(opcodeBytes + modRMBytes <= maxJumpReplacementSize());
     1911        uint8_t* ptr = reinterpret_cast<uint8_t*>(instructionStart);
     1912        ptr[0] = OP_GROUP1_EvIz;
     1913        ptr[1] = (X86InstructionFormatter::ModRmRegister << 6) | (GROUP1_OP_CMP << 3) | dst;
     1914        union {
     1915            uint32_t asWord;
     1916            uint8_t asBytes[4];
     1917        } u;
     1918        u.asWord = imm;
     1919        for (unsigned i = opcodeBytes + modRMBytes; i < static_cast<unsigned>(maxJumpReplacementSize()); ++i)
     1920            ptr[i] = u.asBytes[i - opcodeBytes - modRMBytes];
     1921    }
     1922   
    19061923    static void revertJumpTo_cmpl_im_force32(void* instructionStart, int32_t imm, int offset, RegisterID dst)
    19071924    {
  • trunk/Source/JavaScriptCore/dfg/DFGRepatch.cpp

    r134332 r135330  
    119119    if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) {
    120120        repatchBuffer.replaceWithJump(
    121             RepatchBuffer::startOfPatchableBranchPtrWithPatch(
     121            RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress(
    122122                stubInfo.callReturnLocation.dataLabelPtrAtOffset(
    123123                    -(intptr_t)stubInfo.patch.dfg.deltaCheckImmToCall)),
     
    11431143    if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) {
    11441144        repatchBuffer.revertJumpReplacementToPatchableBranchPtrWithPatch(
    1145             RepatchBuffer::startOfPatchableBranchPtrWithPatch(structureLabel),
     1145            RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress(structureLabel),
    11461146            MacroAssembler::Address(
    11471147                static_cast<MacroAssembler::RegisterID>(stubInfo.patch.dfg.baseGPR),
     
    11771177    if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) {
    11781178        repatchBuffer.revertJumpReplacementToPatchableBranchPtrWithPatch(
    1179             RepatchBuffer::startOfPatchableBranchPtrWithPatch(structureLabel),
     1179            RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress(structureLabel),
    11801180            MacroAssembler::Address(
    11811181                static_cast<MacroAssembler::RegisterID>(stubInfo.patch.dfg.baseGPR),
Note: See TracChangeset for help on using the changeset viewer.