Changeset 249449 in webkit


Ignore:
Timestamp:
Sep 3, 2019, 6:47:02 PM (6 years ago)
Author:
mark.lam@apple.com
Message:

Remove the need to pass performJITMemcpy as a pointer.
https://bugs.webkit.org/show_bug.cgi?id=201413

Reviewed by Michael Saboff.

We want performJITMemcpy to always be inlined. In this patch, we also clean up
some template parameters to use enums instead of booleans to better document the
intent of the code.

  • assembler/ARM64Assembler.h:

(JSC::ARM64Assembler::fillNops):
(JSC::ARM64Assembler::linkJump):
(JSC::ARM64Assembler::linkCall):
(JSC::ARM64Assembler::relinkJump):
(JSC::ARM64Assembler::relinkCall):
(JSC::ARM64Assembler::link):
(JSC::ARM64Assembler::linkJumpOrCall):
(JSC::ARM64Assembler::linkCompareAndBranch):
(JSC::ARM64Assembler::linkConditionalBranch):
(JSC::ARM64Assembler::linkTestAndBranch):
(JSC::ARM64Assembler::relinkJumpOrCall):
(JSC::ARM64Assembler::CopyFunction::CopyFunction): Deleted.
(JSC::ARM64Assembler::CopyFunction::operator()): Deleted.

  • assembler/ARMv7Assembler.h:

(JSC::ARMv7Assembler::fillNops):
(JSC::ARMv7Assembler::link):
(JSC::ARMv7Assembler::linkJumpT1):
(JSC::ARMv7Assembler::linkJumpT2):
(JSC::ARMv7Assembler::linkJumpT3):
(JSC::ARMv7Assembler::linkJumpT4):
(JSC::ARMv7Assembler::linkConditionalJumpT4):
(JSC::ARMv7Assembler::linkBX):
(JSC::ARMv7Assembler::linkConditionalBX):

  • assembler/AbstractMacroAssembler.h:

(JSC::AbstractMacroAssembler::emitNops):

  • assembler/LinkBuffer.cpp:

(JSC::LinkBuffer::copyCompactAndLinkCode):

  • assembler/MIPSAssembler.h:

(JSC::MIPSAssembler::fillNops):

  • assembler/MacroAssemblerARM64.h:

(JSC::MacroAssemblerARM64::link):

  • assembler/MacroAssemblerARMv7.h:

(JSC::MacroAssemblerARMv7::link):

  • assembler/X86Assembler.h:

(JSC::X86Assembler::fillNops):

  • jit/ExecutableAllocator.h:

(JSC::performJITMemcpy):

  • runtime/JSCPtrTag.h:
Location:
trunk/Source/JavaScriptCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r249445 r249449  
     12019-09-03  Mark Lam  <mark.lam@apple.com>
     2
     3        Remove the need to pass performJITMemcpy as a pointer.
     4        https://bugs.webkit.org/show_bug.cgi?id=201413
     5
     6        Reviewed by Michael Saboff.
     7
     8        We want performJITMemcpy to always be inlined.  In this patch, we also clean up
     9        some template parameters to use enums instead of booleans to better document the
     10        intent of the code.
     11
     12        * assembler/ARM64Assembler.h:
     13        (JSC::ARM64Assembler::fillNops):
     14        (JSC::ARM64Assembler::linkJump):
     15        (JSC::ARM64Assembler::linkCall):
     16        (JSC::ARM64Assembler::relinkJump):
     17        (JSC::ARM64Assembler::relinkCall):
     18        (JSC::ARM64Assembler::link):
     19        (JSC::ARM64Assembler::linkJumpOrCall):
     20        (JSC::ARM64Assembler::linkCompareAndBranch):
     21        (JSC::ARM64Assembler::linkConditionalBranch):
     22        (JSC::ARM64Assembler::linkTestAndBranch):
     23        (JSC::ARM64Assembler::relinkJumpOrCall):
     24        (JSC::ARM64Assembler::CopyFunction::CopyFunction): Deleted.
     25        (JSC::ARM64Assembler::CopyFunction::operator()): Deleted.
     26        * assembler/ARMv7Assembler.h:
     27        (JSC::ARMv7Assembler::fillNops):
     28        (JSC::ARMv7Assembler::link):
     29        (JSC::ARMv7Assembler::linkJumpT1):
     30        (JSC::ARMv7Assembler::linkJumpT2):
     31        (JSC::ARMv7Assembler::linkJumpT3):
     32        (JSC::ARMv7Assembler::linkJumpT4):
     33        (JSC::ARMv7Assembler::linkConditionalJumpT4):
     34        (JSC::ARMv7Assembler::linkBX):
     35        (JSC::ARMv7Assembler::linkConditionalBX):
     36        * assembler/AbstractMacroAssembler.h:
     37        (JSC::AbstractMacroAssembler::emitNops):
     38        * assembler/LinkBuffer.cpp:
     39        (JSC::LinkBuffer::copyCompactAndLinkCode):
     40        * assembler/MIPSAssembler.h:
     41        (JSC::MIPSAssembler::fillNops):
     42        * assembler/MacroAssemblerARM64.h:
     43        (JSC::MacroAssemblerARM64::link):
     44        * assembler/MacroAssemblerARMv7.h:
     45        (JSC::MacroAssemblerARMv7::link):
     46        * assembler/X86Assembler.h:
     47        (JSC::X86Assembler::fillNops):
     48        * jit/ExecutableAllocator.h:
     49        (JSC::performJITMemcpy):
     50        * runtime/JSCPtrTag.h:
     51
    1522019-09-03  Devin Rousso  <drousso@apple.com>
    253
  • trunk/Source/JavaScriptCore/assembler/ARM64Assembler.h

    r247799 r249449  
    14951495    }
    14961496   
    1497     template <typename CopyFunction>
    1498     static void fillNops(void* base, size_t size, CopyFunction copy)
     1497    enum BranchTargetType { DirectBranch, IndirectBranch  };
     1498    using CopyFunction = void*(&)(void*, const void*, size_t);
     1499
     1500    template <CopyFunction copy>
     1501    static void fillNops(void* base, size_t size)
    14991502    {
    15001503        RELEASE_ASSERT(!(size % sizeof(int32_t)));
     
    25532556    {
    25542557        ASSERT(from.isSet());
    2555         relinkJumpOrCall<false>(addressOf(code, from), addressOf(code, from), to);
     2558        relinkJumpOrCall<BranchType_JMP>(addressOf(code, from), addressOf(code, from), to);
    25562559    }
    25572560
     
    25592562    {
    25602563        ASSERT(from.isSet());
    2561         linkJumpOrCall<true>(addressOf(code, from) - 1, addressOf(code, from) - 1, to);
     2564        linkJumpOrCall<BranchType_CALL>(addressOf(code, from) - 1, addressOf(code, from) - 1, to);
    25622565    }
    25632566
     
    27552758    static void relinkJump(void* from, void* to)
    27562759    {
    2757         relinkJumpOrCall<false>(reinterpret_cast<int*>(from), reinterpret_cast<const int*>(from), to);
     2760        relinkJumpOrCall<BranchType_JMP>(reinterpret_cast<int*>(from), reinterpret_cast<const int*>(from), to);
    27582761        cacheFlush(from, sizeof(int));
    27592762    }
     
    27662769    static void relinkCall(void* from, void* to)
    27672770    {
    2768         relinkJumpOrCall<true>(reinterpret_cast<int*>(from) - 1, reinterpret_cast<const int*>(from) - 1, to);
     2771        relinkJumpOrCall<BranchType_CALL>(reinterpret_cast<int*>(from) - 1, reinterpret_cast<const int*>(from) - 1, to);
    27692772        cacheFlush(reinterpret_cast<int*>(from) - 1, sizeof(int));
    27702773    }
     
    29112914    }
    29122915
    2913 #if CPU(ARM64E)
    2914     class CopyFunction {
    2915         typedef void* (*Func)(void*, const void*, size_t);
    2916     public:
    2917         CopyFunction(Func func)
    2918             : m_func(func)
    2919         {
    2920             assertIsNullOrTaggedWith(func, CopyFunctionPtrTag);
    2921         }
    2922 
    2923         void* operator()(void* dst, const void* src, size_t size)
    2924         {
    2925             return ptrauth_auth_function(m_func, ptrauth_key_process_dependent_code, CopyFunctionPtrTag)(dst, src, size);
    2926         }
    2927 
    2928     private:
    2929         Func m_func;
    2930     };
    2931 #else
    2932     typedef void* (*CopyFunction)(void*, const void*, size_t);
    2933 #endif
    2934 
    2935     static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to, CopyFunction copy)
     2916    template<CopyFunction copy>
     2917    static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to)
    29362918    {
    29372919        const int* fromInstruction = reinterpret_cast<const int*>(fromInstruction8);
    29382920        switch (record.linkType()) {
    29392921        case LinkJumpNoCondition:
    2940             linkJumpOrCall<false>(reinterpret_cast<int*>(from), fromInstruction, to, copy);
     2922            linkJumpOrCall<BranchType_JMP, copy>(reinterpret_cast<int*>(from), fromInstruction, to);
    29412923            break;
    29422924        case LinkJumpConditionDirect:
    2943             linkConditionalBranch<true>(record.condition(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
     2925            linkConditionalBranch<DirectBranch, copy>(record.condition(), reinterpret_cast<int*>(from), fromInstruction, to);
    29442926            break;
    29452927        case LinkJumpCondition:
    2946             linkConditionalBranch<false>(record.condition(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
     2928            linkConditionalBranch<IndirectBranch, copy>(record.condition(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
    29472929            break;
    29482930        case LinkJumpCompareAndBranchDirect:
    2949             linkCompareAndBranch<true>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
     2931            linkCompareAndBranch<DirectBranch, copy>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to);
    29502932            break;
    29512933        case LinkJumpCompareAndBranch:
    2952             linkCompareAndBranch<false>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
     2934            linkCompareAndBranch<IndirectBranch, copy>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
    29532935            break;
    29542936        case LinkJumpTestBitDirect:
    2955             linkTestAndBranch<true>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
     2937            linkTestAndBranch<DirectBranch, copy>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to);
    29562938            break;
    29572939        case LinkJumpTestBit:
    2958             linkTestAndBranch<false>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
     2940            linkTestAndBranch<IndirectBranch, copy>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
    29592941            break;
    29602942        default:
     
    29972979    }
    29982980
    2999     template<bool isCall>
    3000     static void linkJumpOrCall(int* from, const int* fromInstruction, void* to, CopyFunction copy = tagCFunctionPtr<CopyFunctionPtrTag>(performJITMemcpy))
    3001     {
     2981    template<BranchType type, CopyFunction copy = performJITMemcpy>
     2982    static void linkJumpOrCall(int* from, const int* fromInstruction, void* to)
     2983    {
     2984        static_assert(type == BranchType_JMP || type == BranchType_CALL, "");
     2985
    30022986        bool link;
    30032987        int imm26;
     
    30052989
    30062990        ASSERT_UNUSED(isUnconditionalBranchImmediateOrNop, isUnconditionalBranchImmediateOrNop);
     2991        constexpr bool isCall = (type == BranchType_CALL);
    30072992        ASSERT_UNUSED(isCall, (link == isCall) || disassembleNop(from));
    30082993        ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
     
    30183003    }
    30193004
    3020     template<bool isDirect>
    3021     static void linkCompareAndBranch(Condition condition, bool is64Bit, RegisterID rt, int* from, const int* fromInstruction, void* to, CopyFunction copy = tagCFunctionPtr<CopyFunctionPtrTag>(performJITMemcpy))
     3005    template<BranchTargetType type, CopyFunction copy = performJITMemcpy>
     3006    static void linkCompareAndBranch(Condition condition, bool is64Bit, RegisterID rt, int* from, const int* fromInstruction, void* to)
    30223007    {
    30233008        ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
     
    30273012
    30283013        bool useDirect = isInt<19>(offset);
    3029         ASSERT(!isDirect || useDirect);
    3030 
    3031         if (useDirect || isDirect) {
     3014        ASSERT(type == IndirectBranch || useDirect);
     3015
     3016        if (useDirect || type == DirectBranch) {
    30323017            int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, condition == ConditionNE, static_cast<int>(offset), rt);
    30333018            RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from);
    30343019            copy(from, &insn, sizeof(int));
    3035             if (!isDirect) {
     3020            if (type == IndirectBranch) {
    30363021                insn = nopPseudo();
    30373022                RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from + 1) == (from + 1));
     
    30423027            RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from);
    30433028            copy(from, &insn, sizeof(int));
    3044             linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
     3029            linkJumpOrCall<BranchType_JMP, copy>(from + 1, fromInstruction + 1, to);
    30453030        }
    30463031    }
    30473032
    3048     template<bool isDirect>
    3049     static void linkConditionalBranch(Condition condition, int* from, const int* fromInstruction, void* to, CopyFunction copy = tagCFunctionPtr<CopyFunctionPtrTag>(performJITMemcpy))
     3033    template<BranchTargetType type, CopyFunction copy = performJITMemcpy>
     3034    static void linkConditionalBranch(Condition condition, int* from, const int* fromInstruction, void* to)
    30503035    {
    30513036        ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
     
    30553040
    30563041        bool useDirect = isInt<19>(offset);
    3057         ASSERT(!isDirect || useDirect);
    3058 
    3059         if (useDirect || isDirect) {
     3042        ASSERT(type == IndirectBranch || useDirect);
     3043
     3044        if (useDirect || type == DirectBranch) {
    30603045            int insn = conditionalBranchImmediate(static_cast<int>(offset), condition);
    30613046            RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from);
    30623047            copy(from, &insn, sizeof(int));
    3063             if (!isDirect) {
     3048            if (type == IndirectBranch) {
    30643049                insn = nopPseudo();
    30653050                RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from + 1) == (from + 1));
     
    30703055            RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from);
    30713056            copy(from, &insn, sizeof(int));
    3072             linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
     3057            linkJumpOrCall<BranchType_JMP, copy>(from + 1, fromInstruction + 1, to);
    30733058        }
    30743059    }
    30753060
    3076     template<bool isDirect>
    3077     static void linkTestAndBranch(Condition condition, unsigned bitNumber, RegisterID rt, int* from, const int* fromInstruction, void* to, CopyFunction copy = tagCFunctionPtr<CopyFunctionPtrTag>(performJITMemcpy))
     3061    template<BranchTargetType type, CopyFunction copy = performJITMemcpy>
     3062    static void linkTestAndBranch(Condition condition, unsigned bitNumber, RegisterID rt, int* from, const int* fromInstruction, void* to)
    30783063    {
    30793064        ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
     
    30843069
    30853070        bool useDirect = isInt<14>(offset);
    3086         ASSERT(!isDirect || useDirect);
    3087 
    3088         if (useDirect || isDirect) {
     3071        ASSERT(type == IndirectBranch || useDirect);
     3072
     3073        if (useDirect || type == DirectBranch) {
    30893074            int insn = testAndBranchImmediate(condition == ConditionNE, static_cast<int>(bitNumber), static_cast<int>(offset), rt);
    30903075            RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from);
    30913076            copy(from, &insn, sizeof(int));
    3092             if (!isDirect) {
     3077            if (type == IndirectBranch) {
    30933078                insn = nopPseudo();
    30943079                RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from + 1) == (from + 1));
     
    30993084            RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(from) == from);
    31003085            copy(from, &insn, sizeof(int));
    3101             linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
     3086            linkJumpOrCall<BranchType_JMP, copy>(from + 1, fromInstruction + 1, to);
    31023087        }
    31033088    }
    31043089
    3105     template<bool isCall>
     3090    template<BranchType type>
    31063091    static void relinkJumpOrCall(int* from, const int* fromInstruction, void* to)
    31073092    {
    3108         if (!isCall && disassembleNop(from)) {
     3093        static_assert(type == BranchType_JMP || type == BranchType_CALL, "");
     3094        if ((type == BranchType_JMP) && disassembleNop(from)) {
    31093095            unsigned op01;
    31103096            int imm19;
     
    31143100            if (isConditionalBranchImmediate) {
    31153101                ASSERT_UNUSED(op01, !op01);
    3116                 ASSERT_UNUSED(isCall, !isCall);
     3102                ASSERT(type == BranchType_JMP);
    31173103
    31183104                if (imm19 == 8)
    31193105                    condition = invert(condition);
    31203106
    3121                 linkConditionalBranch<false>(condition, from - 1, fromInstruction - 1, to);
     3107                linkConditionalBranch<IndirectBranch>(condition, from - 1, fromInstruction - 1, to);
    31223108                return;
    31233109            }
     
    31323118                    op = !op;
    31333119
    3134                 linkCompareAndBranch<false>(op ? ConditionNE : ConditionEQ, opSize == Datasize_64, rt, from - 1, fromInstruction - 1, to);
     3120                linkCompareAndBranch<IndirectBranch>(op ? ConditionNE : ConditionEQ, opSize == Datasize_64, rt, from - 1, fromInstruction - 1, to);
    31353121                return;
    31363122            }
     
    31443130                    op = !op;
    31453131
    3146                 linkTestAndBranch<false>(op ? ConditionNE : ConditionEQ, bitNumber, rt, from - 1, fromInstruction - 1, to);
     3132                linkTestAndBranch<IndirectBranch>(op ? ConditionNE : ConditionEQ, bitNumber, rt, from - 1, fromInstruction - 1, to);
    31473133                return;
    31483134            }
    31493135        }
    31503136
    3151         linkJumpOrCall<isCall>(from, fromInstruction, to);
     3137        linkJumpOrCall<type>(from, fromInstruction, to);
    31523138    }
    31533139
  • trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r247097 r249449  
    11/*
    2  * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009-2019 Apple Inc. All rights reserved.
    33 * Copyright (C) 2010 University of Szeged
    44 *
     
    19701970    }
    19711971
    1972     template <typename CopyFunction>
    1973     static void fillNops(void* base, size_t size, CopyFunction copy)
     1972    using CopyFunction = void*(&)(void*, const void*, size_t);
     1973
     1974    template <CopyFunction copy>
     1975    static void fillNops(void* base, size_t size)
    19741976    {
    19751977        RELEASE_ASSERT(!(size % sizeof(int16_t)));
     
    21242126    }
    21252127
    2126     typedef void* (*CopyFunction)(void*, const void*, size_t);
    2127 
    2128     static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to, CopyFunction copy)
     2128    template<CopyFunction copy>
     2129    static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to)
    21292130    {
    21302131        const uint16_t* fromInstruction = reinterpret_cast_ptr<const uint16_t*>(fromInstruction8);
    21312132        switch (record.linkType()) {
    21322133        case LinkJumpT1:
    2133             linkJumpT1(record.condition(), reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to, copy);
     2134            linkJumpT1<copy>(record.condition(), reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to);
    21342135            break;
    21352136        case LinkJumpT2:
    2136             linkJumpT2(reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to, copy);
     2137            linkJumpT2<copy>(reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to);
    21372138            break;
    21382139        case LinkJumpT3:
    2139             linkJumpT3(record.condition(), reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to, copy);
     2140            linkJumpT3<copy>(record.condition(), reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to);
    21402141            break;
    21412142        case LinkJumpT4:
    2142             linkJumpT4(reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to, copy);
     2143            linkJumpT4<copy>(reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to);
    21432144            break;
    21442145        case LinkConditionalJumpT4:
    2145             linkConditionalJumpT4(record.condition(), reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to, copy);
     2146            linkConditionalJumpT4<copy>(record.condition(), reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to);
    21462147            break;
    21472148        case LinkConditionalBX:
    2148             linkConditionalBX(record.condition(), reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to, copy);
     2149            linkConditionalBX<copy>(record.condition(), reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to);
    21492150            break;
    21502151        case LinkBX:
    2151             linkBX(reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to, copy);
     2152            linkBX<copy>(reinterpret_cast_ptr<uint16_t*>(from), fromInstruction, to);
    21522153            break;
    21532154        default:
     
    25992600        return ((relative << 7) >> 7) == relative;
    26002601    }
    2601    
    2602     static void linkJumpT1(Condition cond, uint16_t* writeTarget, const uint16_t* instruction, void* target, CopyFunction copy = performJITMemcpy)
     2602
     2603    template<CopyFunction copy = performJITMemcpy>
     2604    static void linkJumpT1(Condition cond, uint16_t* writeTarget, const uint16_t* instruction, void* target)
    26032605    {
    26042606        // FIMXE: this should be up in the MacroAssembler layer. :-(       
     
    26182620        copy(writeTarget - 1, &newInstruction, sizeof(uint16_t));
    26192621    }
    2620    
    2621     static void linkJumpT2(uint16_t* writeTarget, const uint16_t* instruction, void* target, CopyFunction copy = performJITMemcpy)
     2622
     2623    template<CopyFunction copy = performJITMemcpy>
     2624    static void linkJumpT2(uint16_t* writeTarget, const uint16_t* instruction, void* target)
    26222625    {
    26232626        // FIMXE: this should be up in the MacroAssembler layer. :-(       
     
    26382641    }
    26392642   
    2640     static void linkJumpT3(Condition cond, uint16_t* writeTarget, const uint16_t* instruction, void* target, CopyFunction copy = performJITMemcpy)
     2643    template<CopyFunction copy = performJITMemcpy>
     2644    static void linkJumpT3(Condition cond, uint16_t* writeTarget, const uint16_t* instruction, void* target)
    26412645    {
    26422646        // FIMXE: this should be up in the MacroAssembler layer. :-(
     
    26552659    }
    26562660   
    2657     static void linkJumpT4(uint16_t* writeTarget, const uint16_t* instruction, void* target, CopyFunction copy = performJITMemcpy)
     2661    template<CopyFunction copy = performJITMemcpy>
     2662    static void linkJumpT4(uint16_t* writeTarget, const uint16_t* instruction, void* target)
    26582663    {
    26592664        // FIMXE: this should be up in the MacroAssembler layer. :-(       
     
    26742679        copy(writeTarget - 2, instructions, 2 * sizeof(uint16_t));
    26752680    }
    2676    
    2677     static void linkConditionalJumpT4(Condition cond, uint16_t* writeTarget, const uint16_t* instruction, void* target, CopyFunction copy = performJITMemcpy)
     2681
     2682    template<CopyFunction copy = performJITMemcpy>
     2683    static void linkConditionalJumpT4(Condition cond, uint16_t* writeTarget, const uint16_t* instruction, void* target)
    26782684    {
    26792685        // FIMXE: this should be up in the MacroAssembler layer. :-(       
     
    26832689        uint16_t newInstruction = ifThenElse(cond) | OP_IT;
    26842690        copy(writeTarget - 3, &newInstruction, sizeof(uint16_t));
    2685         linkJumpT4(writeTarget, instruction, target, copy);
    2686     }
    2687    
    2688     static void linkBX(uint16_t* writeTarget, const uint16_t* instruction, void* target, CopyFunction copy = performJITMemcpy)
     2691        linkJumpT4<copy>(writeTarget, instruction, target);
     2692    }
     2693
     2694    template<CopyFunction copy = performJITMemcpy>
     2695    static void linkBX(uint16_t* writeTarget, const uint16_t* instruction, void* target)
    26892696    {
    26902697        // FIMXE: this should be up in the MacroAssembler layer. :-(
     
    27052712        copy(writeTarget - 5, instructions, 5 * sizeof(uint16_t));
    27062713    }
    2707    
    2708     static void linkConditionalBX(Condition cond, uint16_t* writeTarget, const uint16_t* instruction, void* target, CopyFunction copy = performJITMemcpy)
     2714
     2715    template<CopyFunction copy = performJITMemcpy>
     2716    static void linkConditionalBX(Condition cond, uint16_t* writeTarget, const uint16_t* instruction, void* target)
    27092717    {
    27102718        // FIMXE: this should be up in the MacroAssembler layer. :-(       
  • trunk/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h

    r248546 r249449  
    960960    }
    961961
     962#if COMPILER(GCC)
     963    // Workaround for GCC demanding that memcpy "must be the name of a function with external linkage".
     964    static void* memcpy(void* dst, const void* src, size_t size)
     965    {
     966        return std::memcpy(dst, src, size);
     967    }
     968#endif
     969
    962970    void emitNops(size_t memoryToFillWithNopsInBytes)
    963971    {
     
    971979        size_t targetCodeSize = startCodeSize + memoryToFillWithNopsInBytes;
    972980        buffer.ensureSpace(memoryToFillWithNopsInBytes);
    973         AssemblerType::fillNops(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes, memcpy);
     981        AssemblerType::template fillNops<memcpy>(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes);
    974982        buffer.setCodeSize(targetCodeSize);
    975983#endif
  • trunk/Source/JavaScriptCore/assembler/LinkBuffer.cpp

    r247799 r249449  
    229229    recordLinkOffsets(m_assemblerStorage, readPtr, initialSize, readPtr - writePtr);
    230230       
    231 #if CPU(ARM64E) && ENABLE(FAST_JIT_PERMISSIONS)
    232     auto memcpyFunction = tagCFunctionPtr<CopyFunctionPtrTag>(memcpy);
    233 #else
    234     auto memcpyFunction = tagCFunctionPtr<CopyFunctionPtrTag>(performJITMemcpy);
    235 #endif
    236231    for (unsigned i = 0; i < jumpCount; ++i) {
    237232        uint8_t* location = codeOutData + jumpsToLink[i].from();
    238233        uint8_t* target = codeOutData + jumpsToLink[i].to() - executableOffsetFor(jumpsToLink[i].to());
    239         MacroAssembler::link(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target, memcpyFunction);
     234#if CPU(ARM64E) && ENABLE(FAST_JIT_PERMISSIONS)
     235        MacroAssembler::link<memcpy>(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target);
     236#else
     237        MacroAssembler::link<performJITMemcpy>(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target);
     238#endif
    240239    }
    241240
     
    243242    if (!m_executableMemory) {
    244243        size_t nopSizeInBytes = initialSize - compactSize;
    245         MacroAssembler::AssemblerType_T::fillNops(outData + compactSize, nopSizeInBytes, memcpy);
     244#if CPU(ARM64E) && ENABLE(FAST_JIT_PERMISSIONS)
     245        Assembler::fillNops<memcpy>(outData + compactSize, nopSizeInBytes);
     246#else
     247        Assembler::fillNops<performJITMemcpy>(outData + compactSize, nopSizeInBytes);
     248#endif
    246249    }
    247250
  • trunk/Source/JavaScriptCore/assembler/MIPSAssembler.h

    r247097 r249449  
    163163    }
    164164   
    165     template <typename CopyFunction>
    166     static void fillNops(void* base, size_t size, CopyFunction copy)
     165    using CopyFunction = void*(&)(void*, const void*, size_t);
     166
     167    template <CopyFunction copy>
     168    static void fillNops(void* base, size_t size)
    167169    {
    168170        UNUSED_PARAM(copy);
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h

    r248878 r249449  
    8484    static JumpLinkType computeJumpType(LinkRecord& record, const uint8_t* from, const uint8_t* to) { return Assembler::computeJumpType(record, from, to); }
    8585    static int jumpSizeDelta(JumpType jumpType, JumpLinkType jumpLinkType) { return Assembler::jumpSizeDelta(jumpType, jumpLinkType); }
    86     template <typename CopyFunction>
    87     static void link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction, uint8_t* to, CopyFunction copy) { return Assembler::link(record, from, fromInstruction, to, copy); }
     86    template <Assembler::CopyFunction copy>
     87    static void link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction, uint8_t* to) { return Assembler::link<copy>(record, from, fromInstruction, to); }
    8888
    8989    static const Scale ScalePtr = TimesEight;
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r248686 r249449  
    7070    static JumpLinkType computeJumpType(LinkRecord& record, const uint8_t* from, const uint8_t* to) { return ARMv7Assembler::computeJumpType(record, from, to); }
    7171    static int jumpSizeDelta(JumpType jumpType, JumpLinkType jumpLinkType) { return ARMv7Assembler::jumpSizeDelta(jumpType, jumpLinkType); }
    72     template <typename CopyFunction>
    73     static void link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction, uint8_t* to, CopyFunction copy) { return ARMv7Assembler::link(record, from, fromInstruction, to, copy); }
     72    template <Assembler::CopyFunction copy>
     73    static void link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction, uint8_t* to) { return ARMv7Assembler::link<copy>(record, from, fromInstruction, to); }
    7474
    7575    struct ArmAddress {
  • trunk/Source/JavaScriptCore/assembler/X86Assembler.h

    r247889 r249449  
    39533953    }
    39543954
    3955     template <typename CopyFunction>
    3956     static void fillNops(void* base, size_t size, CopyFunction copy)
     3955    using CopyFunction = void*(&)(void*, const void*, size_t);
     3956
     3957    template <CopyFunction copy>
     3958    static void fillNops(void* base, size_t size)
    39573959    {
    39583960        UNUSED_PARAM(copy);
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h

    r244470 r249449  
    123123#endif // ENABLE(SEPARATED_WX_HEAP)
    124124
    125 static inline void* performJITMemcpy(void *dst, const void *src, size_t n)
     125static ALWAYS_INLINE void* performJITMemcpy(void *dst, const void *src, size_t n)
    126126{
    127127#if CPU(ARM64)
  • trunk/Source/JavaScriptCore/runtime/JSCPtrTag.h

    r248192 r249449  
    3636    v(B3CompilationPtrTag) \
    3737    v(BytecodePtrTag) \
    38     v(CopyFunctionPtrTag) \
    3938    v(DOMJITFunctionPtrTag) \
    4039    v(DisassemblyPtrTag) \
Note: See TracChangeset for help on using the changeset viewer.