⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 237439 in webkit


Ignore:
Timestamp:
Oct 25, 2018, 5:11:33 PM (8 years ago)
Author:
Kocsen Chung
Message:

Revert r237373. rdar://problem/45567354

Location:
branches/safari-606-branch
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-606-branch/JSTests/ChangeLog

    r237373 r237439  
     12018-10-25  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Revert r237373. rdar://problem/45285669
     4
    152018-10-23  Kocsen Chung  <kocsen_chung@apple.com>
    26
  • branches/safari-606-branch/Source/JavaScriptCore/ChangeLog

    r237438 r237439  
     12018-10-25  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Revert r237373. rdar://problem/45285669
     4
    152018-10-25  Kocsen Chung  <kocsen_chung@apple.com>
    26
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/ARM64Assembler.h

    r237373 r237439  
    319319
    320320public:
    321     ARM64Assembler(
    322 #if CPU(ARM64E)
    323         unsigned randomNumber
    324 #endif
    325         )
     321    ARM64Assembler()
    326322        : m_indexOfLastWatchpoint(INT_MIN)
    327323        , m_indexOfTailOfLastWatchpoint(INT_MIN)
    328 #if CPU(ARM64E)
    329         , m_buffer(randomNumber)
    330 #endif
    331        
    332324    {
    333325    }
    … …  
    15631555    }
    15641556   
    1565     template <typename CopyFunction>
    1566     static void fillNops(void* base, size_t size, CopyFunction copy)
     1557    static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
    15671558    {
    15681559        RELEASE_ASSERT(!(size % sizeof(int32_t)));
    … …  
    15701561        for (int32_t* ptr = static_cast<int32_t*>(base); n--;) {
    15711562            int insn = nopPseudo();
    1572             copy(ptr++, &insn, sizeof(int));
     1563            if (isCopyingToExecutableMemory)
     1564                performJITMemcpy(ptr++, &insn, sizeof(int));
     1565            else
     1566                memcpy(ptr++, &insn, sizeof(int));
    15731567        }
    15741568    }
    … …  
    25752569    }
    25762570
     2571    void* unlinkedCode() { return m_buffer.data(); }
    25772572    size_t codeSize() const { return m_buffer.codeSize(); }
    25782573
    … …  
    26122607    }
    26132608
     2609    void linkJump(AssemblerLabel from, void* executableCode, AssemblerLabel to)
     2610    {
     2611        ASSERT(from.isSet());
     2612        ASSERT(to.isSet());
     2613        relinkJumpOrCall<false>(addressOf(from), addressOf(executableCode, from), addressOf(to));
     2614    }
     2615   
    26142616    static void linkJump(void* code, AssemblerLabel from, void* to)
    26152617    {
    … …  
    29642966    }
    29652967
    2966     typedef void* (*CopyFunction)(void*, const void*, size_t);
    2967 
    2968     static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to, CopyFunction copy)
     2968    static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to)
    29692969    {
    29702970        const int* fromInstruction = reinterpret_cast<const int*>(fromInstruction8);
    29712971        switch (record.linkType()) {
    29722972        case LinkJumpNoCondition:
    2973             linkJumpOrCall<false>(reinterpret_cast<int*>(from), fromInstruction, to, copy);
     2973            linkJumpOrCall<false>(reinterpret_cast<int*>(from), fromInstruction, to);
    29742974            break;
    29752975        case LinkJumpConditionDirect:
    2976             linkConditionalBranch<true>(record.condition(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
     2976            linkConditionalBranch<true>(record.condition(), reinterpret_cast<int*>(from), fromInstruction, to);
    29772977            break;
    29782978        case LinkJumpCondition:
    2979             linkConditionalBranch<false>(record.condition(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
     2979            linkConditionalBranch<false>(record.condition(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
    29802980            break;
    29812981        case LinkJumpCompareAndBranchDirect:
    2982             linkCompareAndBranch<true>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
     2982            linkCompareAndBranch<true>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to);
    29832983            break;
    29842984        case LinkJumpCompareAndBranch:
    2985             linkCompareAndBranch<false>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
     2985            linkCompareAndBranch<false>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
    29862986            break;
    29872987        case LinkJumpTestBitDirect:
    2988             linkTestAndBranch<true>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
     2988            linkTestAndBranch<true>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to);
    29892989            break;
    29902990        case LinkJumpTestBit:
    2991             linkTestAndBranch<false>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
     2991            linkTestAndBranch<false>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
    29922992            break;
    29932993        default:
    … …  
    30313031
    30323032    template<bool isCall>
    3033     static void linkJumpOrCall(int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy)
     3033    static void linkJumpOrCall(int* from, const int* fromInstruction, void* to)
    30343034    {
    30353035        bool link;
    … …  
    30473047
    30483048        int insn = unconditionalBranchImmediate(isCall, static_cast<int>(offset));
    3049         copy(from, &insn, sizeof(int));
     3049        performJITMemcpy(from, &insn, sizeof(int));
    30503050    }
    30513051
    30523052    template<bool isDirect>
    3053     static void linkCompareAndBranch(Condition condition, bool is64Bit, RegisterID rt, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy)
     3053    static void linkCompareAndBranch(Condition condition, bool is64Bit, RegisterID rt, int* from, const int* fromInstruction, void* to)
    30543054    {
    30553055        ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
    … …  
    30633063        if (useDirect || isDirect) {
    30643064            int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, condition == ConditionNE, static_cast<int>(offset), rt);
    3065             copy(from, &insn, sizeof(int));
     3065            performJITMemcpy(from, &insn, sizeof(int));
    30663066            if (!isDirect) {
    30673067                insn = nopPseudo();
    3068                 copy(from + 1, &insn, sizeof(int));
     3068                performJITMemcpy(from + 1, &insn, sizeof(int));
    30693069            }
    30703070        } else {
    30713071            int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, invert(condition) == ConditionNE, 2, rt);
    3072             copy(from, &insn, sizeof(int));
    3073             linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
     3072            performJITMemcpy(from, &insn, sizeof(int));
     3073            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to);
    30743074        }
    30753075    }
    30763076
    30773077    template<bool isDirect>
    3078     static void linkConditionalBranch(Condition condition, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy)
     3078    static void linkConditionalBranch(Condition condition, int* from, const int* fromInstruction, void* to)
    30793079    {
    30803080        ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
    … …  
    30883088        if (useDirect || isDirect) {
    30893089            int insn = conditionalBranchImmediate(static_cast<int>(offset), condition);
    3090             copy(from, &insn, sizeof(int));
     3090            performJITMemcpy(from, &insn, sizeof(int));
    30913091            if (!isDirect) {
    30923092                insn = nopPseudo();
    3093                 copy(from + 1, &insn, sizeof(int));
     3093                performJITMemcpy(from + 1, &insn, sizeof(int));
    30943094            }
    30953095        } else {
    30963096            int insn = conditionalBranchImmediate(2, invert(condition));
    3097             copy(from, &insn, sizeof(int));
    3098             linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
     3097            performJITMemcpy(from, &insn, sizeof(int));
     3098            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to);
    30993099        }
    31003100    }
    31013101
    31023102    template<bool isDirect>
    3103     static void linkTestAndBranch(Condition condition, unsigned bitNumber, RegisterID rt, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy)
     3103    static void linkTestAndBranch(Condition condition, unsigned bitNumber, RegisterID rt, int* from, const int* fromInstruction, void* to)
    31043104    {
    31053105        ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
    … …  
    31143114        if (useDirect || isDirect) {
    31153115            int insn = testAndBranchImmediate(condition == ConditionNE, static_cast<int>(bitNumber), static_cast<int>(offset), rt);
    3116             copy(from, &insn, sizeof(int));
     3116            performJITMemcpy(from, &insn, sizeof(int));
    31173117            if (!isDirect) {
    31183118                insn = nopPseudo();
    3119                 copy(from + 1, &insn, sizeof(int));
     3119                performJITMemcpy(from + 1, &insn, sizeof(int));
    31203120            }
    31213121        } else {
    31223122            int insn = testAndBranchImmediate(invert(condition) == ConditionNE, static_cast<int>(bitNumber), 2, rt);
    3123             copy(from, &insn, sizeof(int));
    3124             linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
     3123            performJITMemcpy(from, &insn, sizeof(int));
     3124            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to);
    31253125        }
    31263126    }
    … …  
    31783178    {
    31793179        return reinterpret_cast<int*>(static_cast<char*>(code) + label.m_offset);
     3180    }
     3181
     3182    int* addressOf(AssemblerLabel label)
     3183    {
     3184        return addressOf(m_buffer.data(), label);
    31803185    }
    31813186
    … …  
    37553760    }
    37563761
     3762    AssemblerBuffer m_buffer;
    37573763    Vector<LinkRecord, 0, UnsafeVectorOverflow> m_jumpsToLink;
    37583764    int m_indexOfLastWatchpoint;
    37593765    int m_indexOfTailOfLastWatchpoint;
    3760     AssemblerBuffer m_buffer;
    37613766
    37623767public:
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/ARMAssembler.h

    r237373 r237439  
    751751        }
    752752
    753         template <typename CopyFunction>
    754         static void fillNops(void* base, size_t size, CopyFunction copy)
    755         {
    756             UNUSED_PARAM(copy);
     753        static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
     754        {
     755            UNUSED_PARAM(isCopyingToExecutableMemory);
    757756            RELEASE_ASSERT(!(size % sizeof(int32_t)));
    758757
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r237438 r237439  
    20562056    }
    20572057
    2058     template <typename CopyFunction>
    2059     static void fillNops(void* base, size_t size, CopyFunction copy)
     2058    static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
    20602059    {
    20612060        RELEASE_ASSERT(!(size % sizeof(int16_t)));
    … …  
    20652064        for (size_t i = 0; i < num32s; i++) {
    20662065            const int32_t insn = nopPseudo32();
    2067             copy(ptr, &insn, sizeof(int32_t));
     2066            if (isCopyingToExecutableMemory)
     2067                performJITMemcpy(ptr, &insn, sizeof(int32_t));
     2068            else
     2069                memcpy(ptr, &insn, sizeof(int32_t));
    20682070            ptr += sizeof(int32_t);
    20692071        }
    … …  
    20742076        if (num16s) {
    20752077            const int16_t insn = nopPseudo16();
    2076             copy(ptr, &insn, sizeof(int16_t));
     2078            if (isCopyingToExecutableMemory)
     2079                performJITMemcpy(ptr, &insn, sizeof(int16_t));
     2080            else
     2081                memcpy(ptr, &insn, sizeof(int16_t));
    20772082        }
    20782083    }
    … …  
    22412246    }
    22422247
     2248    void* unlinkedCode() { return m_formatter.data(); }
    22432249    size_t codeSize() const { return m_formatter.codeSize(); }
    22442250
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h

    r237373 r237439  
    863863    }
    864864
     865    AssemblerType m_assembler;
     866   
    865867    template<PtrTag tag>
    866868    static void linkJump(void* code, Jump jump, CodeLocationLabel<tag> target)
    … …  
    961963    void emitNops(size_t memoryToFillWithNopsInBytes)
    962964    {
    963 #if CPU(ARM64)
    964         RELEASE_ASSERT(memoryToFillWithNopsInBytes % 4 == 0);
    965         for (unsigned i = 0; i < memoryToFillWithNopsInBytes / 4; ++i)
    966             m_assembler.nop();
    967 #else
    968965        AssemblerBuffer& buffer = m_assembler.buffer();
    969966        size_t startCodeSize = buffer.codeSize();
    970967        size_t targetCodeSize = startCodeSize + memoryToFillWithNopsInBytes;
    971968        buffer.ensureSpace(memoryToFillWithNopsInBytes);
    972         AssemblerType::fillNops(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes, memcpy);
     969        bool isCopyingToExecutableMemory = false;
     970        AssemblerType::fillNops(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes, isCopyingToExecutableMemory);
    973971        buffer.setCodeSize(targetCodeSize);
    974 #endif
    975972    }
    976973
    … …  
    987984    AbstractMacroAssembler()
    988985        : m_randomSource(0)
    989 #if CPU(ARM64E)
    990         , m_assembler(random())
    991 #else
    992         , m_assembler()
    993 #endif
    994986    {
    995987        invalidateAllTempRegisters();
    … …  
    1007999    bool m_randomSourceIsInitialized { false };
    10081000    WeakRandom m_randomSource;
    1009 public:
    1010     AssemblerType m_assembler;
    1011 protected:
    10121001
    10131002#if ENABLE(DFG_REGISTER_ALLOCATION_VALIDATION)
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/AssemblerBuffer.h

    r237373 r237439  
    3434#include <wtf/Assertions.h>
    3535#include <wtf/FastMalloc.h>
    36 #if CPU(ARM64E)
    37 #include <wtf/PtrTag.h>
    38 #endif
    3936#include <wtf/StdLibExtras.h>
    4037
    4138namespace JSC {
    42 
    43     class LinkBuffer;
    4439
    4540    struct AssemblerLabel {
    … …  
    146141    };
    147142
    148 #if CPU(ARM64E)
    149     class ARM64EHash {
    150     public:
    151         ARM64EHash(unsigned randomNumber)
    152             : m_hash(randomNumber)
    153             , m_randomSeed(randomNumber)
    154         { }
    155         ALWAYS_INLINE void update(unsigned value, uintptr_t index)
    156         {
    157             m_hash = tagInt((static_cast<uintptr_t>(value) + m_hash) ^ (m_hash >> 32), static_cast<PtrTag>(index));
    158         }
    159         uintptr_t hash() const { return m_hash; }
    160         unsigned randomSeed() const { return m_randomSeed; }
    161     private:
    162         uintptr_t m_hash;
    163         unsigned m_randomSeed;
    164     };
    165 #endif
    166 
    167143    class AssemblerBuffer {
    168144    public:
    169         AssemblerBuffer(
    170 #if CPU(ARM64E)
    171             unsigned randomNumber
    172 #endif
    173         )
     145        AssemblerBuffer()
    174146            : m_storage()
    175147            , m_index(0)
    176 #if CPU(ARM64E)
    177             , m_hash(randomNumber)
    178 #endif
    179148        {
    180149        }
    … …  
    196165        }
    197166
    198 #if !CPU(ARM64)
    199167        void putByteUnchecked(int8_t value) { putIntegralUnchecked(value); }
    200168        void putByte(int8_t value) { putIntegral(value); }
    201169        void putShortUnchecked(int16_t value) { putIntegralUnchecked(value); }
    202170        void putShort(int16_t value) { putIntegral(value); }
     171        void putIntUnchecked(int32_t value) { putIntegralUnchecked(value); }
     172        void putInt(int32_t value) { putIntegral(value); }
    203173        void putInt64Unchecked(int64_t value) { putIntegralUnchecked(value); }
    204174        void putInt64(int64_t value) { putIntegral(value); }
    205 #endif
    206         void putIntUnchecked(int32_t value) { putIntegralUnchecked(value); }
    207         void putInt(int32_t value) { putIntegral(value); }
     175
     176        void* data() const
     177        {
     178            return m_storage.buffer();
     179        }
    208180
    209181        size_t codeSize() const
    … …  
    212184        }
    213185
    214 #if !CPU(ARM64)
    215186        void setCodeSize(size_t index)
    216187        {
    … …  
    221192            ASSERT(m_index <= m_storage.capacity());
    222193        }
    223 #endif
    224194
    225195        AssemblerLabel label() const
    … …  
    239209        // LocalWriter *CANNOT* be mixed with other types of access to AssemblerBuffer.
    240210        // AssemblerBuffer cannot be used until its LocalWriter goes out of scope.
    241 #if !CPU(ARM64) // If we ever need to use this on arm64e, we would need to make the checksum aware of this.
    242211        class LocalWriter {
    243212        public:
    … …  
    282251#endif
    283252        };
    284 #endif // !CPU(ARM64)
    285 
    286 #if CPU(ARM64E)
    287         ARM64EHash hash() const { return m_hash; }
    288 #endif
    289 
    290 #if !CPU(ARM64) // If we were to define this on arm64e, we'd need a way to update the hash as we write directly into the buffer.
    291         void* data() const { return m_storage.buffer(); }
    292 #endif
    293 
    294253
    295254    protected:
    … …  
    308267        void putIntegralUnchecked(IntegralType value)
    309268        {
    310 #if CPU(ARM64)
    311             static_assert(sizeof(value) == 4, "");
    312 #if CPU(ARM64E)
    313             m_hash.update(value, m_index);
    314 #endif
    315 #endif
    316269            ASSERT(isAvailable(sizeof(IntegralType)));
    317270            *reinterpret_cast_ptr<IntegralType*>(m_storage.buffer() + m_index) = value;
    … …  
    319272        }
    320273
     274        void append(const char* data, int size)
     275        {
     276            if (!isAvailable(size))
     277                grow(size);
     278
     279            memcpy(m_storage.buffer() + m_index, data, size);
     280            m_index += size;
     281        }
     282
     283        void grow(int extraCapacity = 0)
     284        {
     285            m_storage.grow(extraCapacity);
     286        }
     287
    321288    private:
    322         void grow(int extraCapacity = 0)
    323         {
    324             m_storage.grow(extraCapacity);
    325         }
    326 
    327289        NEVER_INLINE void outOfLineGrow()
    328290        {
    … …  
    330292        }
    331293
    332 #if !CPU(ARM64)
    333294        friend LocalWriter;
    334 #endif
    335         friend LinkBuffer;
    336295
    337296        AssemblerData m_storage;
    338297        unsigned m_index;
    339 #if CPU(ARM64E)
    340         ARM64EHash m_hash;
    341 #endif
    342298    };
    343299
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/LinkBuffer.cpp

    r237437 r237439  
    110110    uint8_t* inData = reinterpret_cast<uint8_t*>(m_assemblerStorage.buffer());
    111111
     112    AssemblerData outBuffer(m_size);
     113
     114    uint8_t* outData = reinterpret_cast<uint8_t*>(outBuffer.buffer());
    112115    uint8_t* codeOutData = m_code.dataLocation<uint8_t*>();
    113 #if CPU(ARM64E)
    114     const ARM64EHash assemblerBufferHash = macroAssembler.m_assembler.buffer().hash();
    115     ARM64EHash verifyUncompactedHash(assemblerBufferHash.randomSeed());
    116     uint8_t* outData = codeOutData;
    117 #else
    118     AssemblerData outBuffer(m_size);
    119     uint8_t* outData = reinterpret_cast<uint8_t*>(outBuffer.buffer());
    120 #endif
    121116
    122117    int readPtr = 0;
    123118    int writePtr = 0;
    124119    unsigned jumpCount = jumpsToLink.size();
    125 
    126 #if CPU(ARM64E)
    127     os_thread_self_restrict_rwx_to_rw();
    128 #endif
    129 
    130120    if (m_shouldPerformBranchCompaction) {
    131121        for (unsigned i = 0; i < jumpCount; ++i) {
    … …  
    141131            ASSERT(!(readPtr % 2));
    142132            ASSERT(!(writePtr % 2));
    143 #if CPU(ARM64E)
    144             unsigned index = readPtr;
    145 #endif
    146             while (copySource != copyEnd) {
    147                 InstructionType insn = *copySource++;
    148 #if CPU(ARM64E)
    149                 static_assert(sizeof(InstructionType) == 4, "");
    150                 verifyUncompactedHash.update(insn, index);
    151                 index += sizeof(InstructionType);
    152 #endif
    153                 *copyDst++ = insn;
    154             }
     133            while (copySource != copyEnd)
     134                *copyDst++ = *copySource++;
    155135            recordLinkOffsets(m_assemblerStorage, readPtr, jumpsToLink[i].from(), offset);
    156136            readPtr += regionSize;
    … …  
    183163        }
    184164    }
    185 
    186165    // Copy everything after the last jump
    187     {
    188         InstructionType* dst = bitwise_cast<InstructionType*>(outData + writePtr);
    189         InstructionType* src = bitwise_cast<InstructionType*>(inData + readPtr);
    190         size_t bytes = initialSize - readPtr;
    191 
    192         RELEASE_ASSERT(bitwise_cast<uintptr_t>(dst) % sizeof(InstructionType) == 0);
    193         RELEASE_ASSERT(bitwise_cast<uintptr_t>(src) % sizeof(InstructionType) == 0);
    194         RELEASE_ASSERT(bytes % sizeof(InstructionType) == 0);
    195 
    196 #if CPU(ARM64E)
    197         unsigned index = readPtr;
    198 #endif
    199 
    200         for (size_t i = 0; i < bytes; i += sizeof(InstructionType)) {
    201             InstructionType insn = *src++;
    202 #if CPU(ARM64E)
    203             verifyUncompactedHash.update(insn, index);
    204             index += sizeof(InstructionType);
    205 #endif
    206             *dst++ = insn;
    207         }
    208     }
    209 
    210 #if CPU(ARM64E)
    211     if (verifyUncompactedHash.hash() != assemblerBufferHash.hash()) {
    212         dataLogLn("Hashes don't match: ", RawPointer(bitwise_cast<void*>(verifyUncompactedHash.hash())), " ", RawPointer(bitwise_cast<void*>(assemblerBufferHash.hash())));
    213         dataLogLn("Crashing!");
    214         CRASH();
    215     }
    216 #endif
    217 
     166    memcpy(outData + writePtr, inData + readPtr, initialSize - readPtr);
    218167    recordLinkOffsets(m_assemblerStorage, readPtr, initialSize, readPtr - writePtr);
    219168       
    220169    for (unsigned i = 0; i < jumpCount; ++i) {
    221 #if CPU(ARM64E)
    222         auto memcpyFunction = memcpy;
    223 #else
    224         auto memcpyFunction = performJITMemcpy;
    225 #endif
    226 
    227170        uint8_t* location = codeOutData + jumpsToLink[i].from();
    228171        uint8_t* target = codeOutData + jumpsToLink[i].to() - executableOffsetFor(jumpsToLink[i].to());
    229         MacroAssembler::link(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target, memcpyFunction);
    230     }
     172        MacroAssembler::link(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target);
     173    }
     174
     175    jumpsToLink.clear();
    231176
    232177    size_t compactSize = writePtr + initialSize - readPtr;
    233     if (!m_executableMemory) {
    234         size_t nopSizeInBytes = initialSize - compactSize;
    235         MacroAssembler::AssemblerType_T::fillNops(outData + compactSize, nopSizeInBytes, memcpy);
    236     }
    237 
    238 #if CPU(ARM64E)
    239     os_thread_self_restrict_rwx_to_rx();
    240 #endif
    241 
    242178    if (m_executableMemory) {
    243179        m_size = compactSize;
    244180        m_executableMemory->shrink(m_size);
    245     }
    246 
    247 #if !CPU(ARM64E)
    248     ASSERT(codeOutData != outData);
     181    } else {
     182        size_t nopSizeInBytes = initialSize - compactSize;
     183        bool isCopyingToExecutableMemory = false;
     184        MacroAssembler::AssemblerType_T::fillNops(outData + compactSize, nopSizeInBytes, isCopyingToExecutableMemory);
     185    }
     186
    249187    performJITMemcpy(codeOutData, outData, m_size);
    250 #else
    251     ASSERT(codeOutData == outData);
    252 #endif
    253 
    254     jumpsToLink.clear();
    255188
    256189#if DUMP_LINK_STATISTICS
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/MIPSAssembler.h

    r237373 r237439  
    265265    }
    266266   
    267     template <typename CopyFunction>
    268     static void fillNops(void* base, size_t size, CopyFunction copy)
    269     {
    270         UNUSED_PARAM(copy);
     267    static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
     268    {
     269        UNUSED_PARAM(isCopyingToExecutableMemory);
    271270        RELEASE_ASSERT(!(size % sizeof(int32_t)));
    272271
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h

    r237373 r237439  
    8080
    8181    Vector<LinkRecord, 0, UnsafeVectorOverflow>& jumpsToLink() { return m_assembler.jumpsToLink(); }
     82    void* unlinkedCode() { return m_assembler.unlinkedCode(); }
    8283    static bool canCompact(JumpType jumpType) { return Assembler::canCompact(jumpType); }
    8384    static JumpLinkType computeJumpType(JumpType jumpType, const uint8_t* from, const uint8_t* to) { return Assembler::computeJumpType(jumpType, from, to); }
    8485    static JumpLinkType computeJumpType(LinkRecord& record, const uint8_t* from, const uint8_t* to) { return Assembler::computeJumpType(record, from, to); }
    8586    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); }
     87    static void link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction, uint8_t* to) { return Assembler::link(record, from, fromInstruction, to); }
    8888
    8989    static const Scale ScalePtr = TimesEight;
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r237438 r237439  
    6666
    6767    Vector<LinkRecord, 0, UnsafeVectorOverflow>& jumpsToLink() { return m_assembler.jumpsToLink(); }
     68    void* unlinkedCode() { return m_assembler.unlinkedCode(); }
    6869    static bool canCompact(JumpType jumpType) { return ARMv7Assembler::canCompact(jumpType); }
    6970    static JumpLinkType computeJumpType(JumpType jumpType, const uint8_t* from, const uint8_t* to) { return ARMv7Assembler::computeJumpType(jumpType, from, to); }
  • branches/safari-606-branch/Source/JavaScriptCore/assembler/X86Assembler.h

    r237373 r237439  
    39033903    }
    39043904
    3905     template <typename CopyFunction>
    3906     static void fillNops(void* base, size_t size, CopyFunction copy)
    3907     {
    3908         UNUSED_PARAM(copy);
     3905    static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
     3906    {
     3907        UNUSED_PARAM(isCopyingToExecutableMemory);
    39093908#if CPU(X86_64)
    39103909        static const uint8_t nops[10][10] = {
  • branches/safari-606-branch/Source/WTF/ChangeLog

    r237373 r237439  
     12018-10-25  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Revert r237373. rdar://problem/45285669
     4
    152018-10-23  Kocsen Chung  <kocsen_chung@apple.com>
    26
  • branches/safari-606-branch/Source/WTF/wtf/PtrTag.h

    r237373 r237439  
    148148inline PtrType untagCFunctionPtr(PtrType ptr) { return ptr; }
    149149
    150 template <typename IntType>
    151 inline IntType tagInt(IntType ptrInt, PtrTag)
    152 {
    153     static_assert(sizeof(IntType) == sizeof(uintptr_t), "");
    154     return ptrInt;
    155 }
    156 
    157150template<typename PtrType> void assertIsCFunctionPtr(PtrType) { }
    158151template<typename PtrType> void assertIsNullOrCFunctionPtr(PtrType) { }
    … …  
    192185using WTF::tagCFunctionPtr;
    193186using WTF::untagCFunctionPtr;
    194 using WTF::tagInt;
    195187
    196188using WTF::assertIsCFunctionPtr;
Note: See TracChangeset for help on using the changeset viewer.