Title: [237439] branches/safari-606-branch

Diff

Modified: branches/safari-606-branch/JSTests/ChangeLog (237438 => 237439)


--- branches/safari-606-branch/JSTests/ChangeLog	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/JSTests/ChangeLog	2018-10-26 00:11:33 UTC (rev 237439)
@@ -1,3 +1,7 @@
+2018-10-25  Kocsen Chung  <[email protected]>
+
+        Revert r237373. rdar://problem/45285669
+
 2018-10-23  Kocsen Chung  <[email protected]>
 
         Cherry-pick r236589. rdar://problem/45285669

Modified: branches/safari-606-branch/Source/_javascript_Core/ChangeLog (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/ChangeLog	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/ChangeLog	2018-10-26 00:11:33 UTC (rev 237439)
@@ -1,5 +1,9 @@
 2018-10-25  Kocsen Chung  <[email protected]>
 
+        Revert r237373. rdar://problem/45285669
+
+2018-10-25  Kocsen Chung  <[email protected]>
+
         Revert r236604. rdar://problem/45285669
 
 2018-10-25  Kocsen Chung  <[email protected]>

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/ARM64Assembler.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/ARM64Assembler.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/ARM64Assembler.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -318,17 +318,9 @@
     static constexpr bool isZr(RegisterID reg) { return ARM64Registers::isZr(reg); }
 
 public:
-    ARM64Assembler(
-#if CPU(ARM64E)
-        unsigned randomNumber
-#endif 
-        )
+    ARM64Assembler()
         : m_indexOfLastWatchpoint(INT_MIN)
         , m_indexOfTailOfLastWatchpoint(INT_MIN)
-#if CPU(ARM64E)
-        , m_buffer(randomNumber)
-#endif
-        
     {
     }
     
@@ -1562,14 +1554,16 @@
         insn(nopPseudo());
     }
     
-    template <typename CopyFunction>
-    static void fillNops(void* base, size_t size, CopyFunction copy)
+    static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
     {
         RELEASE_ASSERT(!(size % sizeof(int32_t)));
         size_t n = size / sizeof(int32_t);
         for (int32_t* ptr = static_cast<int32_t*>(base); n--;) {
             int insn = nopPseudo();
-            copy(ptr++, &insn, sizeof(int));
+            if (isCopyingToExecutableMemory)
+                performJITMemcpy(ptr++, &insn, sizeof(int));
+            else
+                memcpy(ptr++, &insn, sizeof(int));
         }
     }
     
@@ -2574,6 +2568,7 @@
         return b.m_offset - a.m_offset;
     }
 
+    void* unlinkedCode() { return m_buffer.data(); }
     size_t codeSize() const { return m_buffer.codeSize(); }
 
     static unsigned getCallReturnOffset(AssemblerLabel call)
@@ -2611,6 +2606,13 @@
         m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset, type, condition, bitNumber, compareRegister));
     }
 
+    void linkJump(AssemblerLabel from, void* executableCode, AssemblerLabel to)
+    {
+        ASSERT(from.isSet());
+        ASSERT(to.isSet());
+        relinkJumpOrCall<false>(addressOf(from), addressOf(executableCode, from), addressOf(to));
+    }
+    
     static void linkJump(void* code, AssemblerLabel from, void* to)
     {
         ASSERT(from.isSet());
@@ -2963,32 +2965,30 @@
         return m_jumpsToLink;
     }
 
-    typedef void* (*CopyFunction)(void*, const void*, size_t);
-
-    static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to, CopyFunction copy)
+    static void ALWAYS_INLINE link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction8, uint8_t* to)
     {
         const int* fromInstruction = reinterpret_cast<const int*>(fromInstruction8);
         switch (record.linkType()) {
         case LinkJumpNoCondition:
-            linkJumpOrCall<false>(reinterpret_cast<int*>(from), fromInstruction, to, copy);
+            linkJumpOrCall<false>(reinterpret_cast<int*>(from), fromInstruction, to);
             break;
         case LinkJumpConditionDirect:
-            linkConditionalBranch<true>(record.condition(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
+            linkConditionalBranch<true>(record.condition(), reinterpret_cast<int*>(from), fromInstruction, to);
             break;
         case LinkJumpCondition:
-            linkConditionalBranch<false>(record.condition(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
+            linkConditionalBranch<false>(record.condition(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
             break;
         case LinkJumpCompareAndBranchDirect:
-            linkCompareAndBranch<true>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
+            linkCompareAndBranch<true>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to);
             break;
         case LinkJumpCompareAndBranch:
-            linkCompareAndBranch<false>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
+            linkCompareAndBranch<false>(record.condition(), record.is64Bit(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
             break;
         case LinkJumpTestBitDirect:
-            linkTestAndBranch<true>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to, copy);
+            linkTestAndBranch<true>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from), fromInstruction, to);
             break;
         case LinkJumpTestBit:
-            linkTestAndBranch<false>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to, copy);
+            linkTestAndBranch<false>(record.condition(), record.bitNumber(), record.compareRegister(), reinterpret_cast<int*>(from) - 1, fromInstruction - 1, to);
             break;
         default:
             ASSERT_NOT_REACHED();
@@ -3030,7 +3030,7 @@
     }
 
     template<bool isCall>
-    static void linkJumpOrCall(int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy)
+    static void linkJumpOrCall(int* from, const int* fromInstruction, void* to)
     {
         bool link;
         int imm26;
@@ -3046,11 +3046,11 @@
         ASSERT(static_cast<int>(offset) == offset);
 
         int insn = unconditionalBranchImmediate(isCall, static_cast<int>(offset));
-        copy(from, &insn, sizeof(int));
+        performJITMemcpy(from, &insn, sizeof(int));
     }
 
     template<bool isDirect>
-    static void linkCompareAndBranch(Condition condition, bool is64Bit, RegisterID rt, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy)
+    static void linkCompareAndBranch(Condition condition, bool is64Bit, RegisterID rt, int* from, const int* fromInstruction, void* to)
     {
         ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
         ASSERT(!(reinterpret_cast<intptr_t>(to) & 3));
@@ -3062,20 +3062,20 @@
 
         if (useDirect || isDirect) {
             int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, condition == ConditionNE, static_cast<int>(offset), rt);
-            copy(from, &insn, sizeof(int));
+            performJITMemcpy(from, &insn, sizeof(int));
             if (!isDirect) {
                 insn = nopPseudo();
-                copy(from + 1, &insn, sizeof(int));
+                performJITMemcpy(from + 1, &insn, sizeof(int));
             }
         } else {
             int insn = compareAndBranchImmediate(is64Bit ? Datasize_64 : Datasize_32, invert(condition) == ConditionNE, 2, rt);
-            copy(from, &insn, sizeof(int));
-            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
+            performJITMemcpy(from, &insn, sizeof(int));
+            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to);
         }
     }
 
     template<bool isDirect>
-    static void linkConditionalBranch(Condition condition, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy)
+    static void linkConditionalBranch(Condition condition, int* from, const int* fromInstruction, void* to)
     {
         ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
         ASSERT(!(reinterpret_cast<intptr_t>(to) & 3));
@@ -3087,20 +3087,20 @@
 
         if (useDirect || isDirect) {
             int insn = conditionalBranchImmediate(static_cast<int>(offset), condition);
-            copy(from, &insn, sizeof(int));
+            performJITMemcpy(from, &insn, sizeof(int));
             if (!isDirect) {
                 insn = nopPseudo();
-                copy(from + 1, &insn, sizeof(int));
+                performJITMemcpy(from + 1, &insn, sizeof(int));
             }
         } else {
             int insn = conditionalBranchImmediate(2, invert(condition));
-            copy(from, &insn, sizeof(int));
-            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
+            performJITMemcpy(from, &insn, sizeof(int));
+            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to);
         }
     }
 
     template<bool isDirect>
-    static void linkTestAndBranch(Condition condition, unsigned bitNumber, RegisterID rt, int* from, const int* fromInstruction, void* to, CopyFunction copy = performJITMemcpy)
+    static void linkTestAndBranch(Condition condition, unsigned bitNumber, RegisterID rt, int* from, const int* fromInstruction, void* to)
     {
         ASSERT(!(reinterpret_cast<intptr_t>(from) & 3));
         ASSERT(!(reinterpret_cast<intptr_t>(to) & 3));
@@ -3113,15 +3113,15 @@
 
         if (useDirect || isDirect) {
             int insn = testAndBranchImmediate(condition == ConditionNE, static_cast<int>(bitNumber), static_cast<int>(offset), rt);
-            copy(from, &insn, sizeof(int));
+            performJITMemcpy(from, &insn, sizeof(int));
             if (!isDirect) {
                 insn = nopPseudo();
-                copy(from + 1, &insn, sizeof(int));
+                performJITMemcpy(from + 1, &insn, sizeof(int));
             }
         } else {
             int insn = testAndBranchImmediate(invert(condition) == ConditionNE, static_cast<int>(bitNumber), 2, rt);
-            copy(from, &insn, sizeof(int));
-            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to, copy);
+            performJITMemcpy(from, &insn, sizeof(int));
+            linkJumpOrCall<false>(from + 1, fromInstruction + 1, to);
         }
     }
 
@@ -3179,6 +3179,11 @@
         return reinterpret_cast<int*>(static_cast<char*>(code) + label.m_offset);
     }
 
+    int* addressOf(AssemblerLabel label)
+    {
+        return addressOf(m_buffer.data(), label);
+    }
+
     static RegisterID disassembleXOrSp(int reg) { return reg == 31 ? ARM64Registers::sp : static_cast<RegisterID>(reg); }
     static RegisterID disassembleXOrZr(int reg) { return reg == 31 ? ARM64Registers::zr : static_cast<RegisterID>(reg); }
     static RegisterID disassembleXOrZrOrSp(bool useZr, int reg) { return reg == 31 ? (useZr ? ARM64Registers::zr : ARM64Registers::sp) : static_cast<RegisterID>(reg); }
@@ -3754,10 +3759,10 @@
 #endif
     }
 
+    AssemblerBuffer m_buffer;
     Vector<LinkRecord, 0, UnsafeVectorOverflow> m_jumpsToLink;
     int m_indexOfLastWatchpoint;
     int m_indexOfTailOfLastWatchpoint;
-    AssemblerBuffer m_buffer;
 
 public:
     static constexpr ptrdiff_t MAX_POINTER_BITS = 48;

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/ARMAssembler.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/ARMAssembler.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/ARMAssembler.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -750,10 +750,9 @@
             m_buffer.putInt(NOP);
         }
 
-        template <typename CopyFunction>
-        static void fillNops(void* base, size_t size, CopyFunction copy)
+        static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
         {
-            UNUSED_PARAM(copy);
+            UNUSED_PARAM(isCopyingToExecutableMemory);
             RELEASE_ASSERT(!(size % sizeof(int32_t)));
 
             int32_t* ptr = static_cast<int32_t*>(base);

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/ARMv7Assembler.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/ARMv7Assembler.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/ARMv7Assembler.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -2055,8 +2055,7 @@
         return OP_NOP_T2a | (OP_NOP_T2b << 16);
     }
 
-    template <typename CopyFunction>
-    static void fillNops(void* base, size_t size, CopyFunction copy)
+    static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
     {
         RELEASE_ASSERT(!(size % sizeof(int16_t)));
 
@@ -2064,7 +2063,10 @@
         const size_t num32s = size / sizeof(int32_t);
         for (size_t i = 0; i < num32s; i++) {
             const int32_t insn = nopPseudo32();
-            copy(ptr, &insn, sizeof(int32_t));
+            if (isCopyingToExecutableMemory)
+                performJITMemcpy(ptr, &insn, sizeof(int32_t));
+            else
+                memcpy(ptr, &insn, sizeof(int32_t));
             ptr += sizeof(int32_t);
         }
 
@@ -2073,7 +2075,10 @@
         ASSERT(num16s * sizeof(int16_t) + num32s * sizeof(int32_t) == size);
         if (num16s) {
             const int16_t insn = nopPseudo16();
-            copy(ptr, &insn, sizeof(int16_t));
+            if (isCopyingToExecutableMemory)
+                performJITMemcpy(ptr, &insn, sizeof(int16_t));
+            else
+                memcpy(ptr, &insn, sizeof(int16_t));
         }
     }
 
@@ -2240,6 +2245,7 @@
         }
     }
 
+    void* unlinkedCode() { return m_formatter.data(); }
     size_t codeSize() const { return m_formatter.codeSize(); }
 
     static unsigned getCallReturnOffset(AssemblerLabel call)

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/AbstractMacroAssembler.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -862,6 +862,8 @@
         AssemblerType::cacheFlush(code, size);
     }
 
+    AssemblerType m_assembler;
+    
     template<PtrTag tag>
     static void linkJump(void* code, Jump jump, CodeLocationLabel<tag> target)
     {
@@ -960,18 +962,13 @@
 
     void emitNops(size_t memoryToFillWithNopsInBytes)
     {
-#if CPU(ARM64)
-        RELEASE_ASSERT(memoryToFillWithNopsInBytes % 4 == 0);
-        for (unsigned i = 0; i < memoryToFillWithNopsInBytes / 4; ++i)
-            m_assembler.nop();
-#else
         AssemblerBuffer& buffer = m_assembler.buffer();
         size_t startCodeSize = buffer.codeSize();
         size_t targetCodeSize = startCodeSize + memoryToFillWithNopsInBytes;
         buffer.ensureSpace(memoryToFillWithNopsInBytes);
-        AssemblerType::fillNops(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes, memcpy);
+        bool isCopyingToExecutableMemory = false;
+        AssemblerType::fillNops(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes, isCopyingToExecutableMemory);
         buffer.setCodeSize(targetCodeSize);
-#endif
     }
 
     ALWAYS_INLINE void tagReturnAddress() { }
@@ -986,11 +983,6 @@
 protected:
     AbstractMacroAssembler()
         : m_randomSource(0)
-#if CPU(ARM64E)
-        , m_assembler(random())
-#else
-        , m_assembler()
-#endif
     {
         invalidateAllTempRegisters();
     }
@@ -1006,9 +998,6 @@
 
     bool m_randomSourceIsInitialized { false };
     WeakRandom m_randomSource;
-public:
-    AssemblerType m_assembler;
-protected:
 
 #if ENABLE(DFG_REGISTER_ALLOCATION_VALIDATION)
     Vector<RegisterAllocationOffset, 10> m_registerAllocationForOffsets;

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/AssemblerBuffer.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/AssemblerBuffer.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/AssemblerBuffer.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -33,15 +33,10 @@
 #include <string.h>
 #include <wtf/Assertions.h>
 #include <wtf/FastMalloc.h>
-#if CPU(ARM64E)
-#include <wtf/PtrTag.h>
-#endif
 #include <wtf/StdLibExtras.h>
 
 namespace JSC {
 
-    class LinkBuffer;
-
     struct AssemblerLabel {
         AssemblerLabel()
             : m_offset(std::numeric_limits<uint32_t>::max())
@@ -145,37 +140,11 @@
         unsigned m_capacity;
     };
 
-#if CPU(ARM64E)
-    class ARM64EHash {
-    public:
-        ARM64EHash(unsigned randomNumber)
-            : m_hash(randomNumber)
-            , m_randomSeed(randomNumber)
-        { }
-        ALWAYS_INLINE void update(unsigned value, uintptr_t index)
-        {
-            m_hash = tagInt((static_cast<uintptr_t>(value) + m_hash) ^ (m_hash >> 32), static_cast<PtrTag>(index));
-        }
-        uintptr_t hash() const { return m_hash; }
-        unsigned randomSeed() const { return m_randomSeed; }
-    private:
-        uintptr_t m_hash;
-        unsigned m_randomSeed;
-    };
-#endif
-
     class AssemblerBuffer {
     public:
-        AssemblerBuffer(
-#if CPU(ARM64E)
-            unsigned randomNumber
-#endif
-        )
+        AssemblerBuffer()
             : m_storage()
             , m_index(0)
-#if CPU(ARM64E)
-            , m_hash(randomNumber)
-#endif
         {
         }
 
@@ -195,23 +164,25 @@
             return !(m_index & (alignment - 1));
         }
 
-#if !CPU(ARM64)
         void putByteUnchecked(int8_t value) { putIntegralUnchecked(value); }
         void putByte(int8_t value) { putIntegral(value); }
         void putShortUnchecked(int16_t value) { putIntegralUnchecked(value); }
         void putShort(int16_t value) { putIntegral(value); }
+        void putIntUnchecked(int32_t value) { putIntegralUnchecked(value); }
+        void putInt(int32_t value) { putIntegral(value); }
         void putInt64Unchecked(int64_t value) { putIntegralUnchecked(value); }
         void putInt64(int64_t value) { putIntegral(value); }
-#endif
-        void putIntUnchecked(int32_t value) { putIntegralUnchecked(value); }
-        void putInt(int32_t value) { putIntegral(value); }
 
+        void* data() const
+        {
+            return m_storage.buffer();
+        }
+
         size_t codeSize() const
         {
             return m_index;
         }
 
-#if !CPU(ARM64)
         void setCodeSize(size_t index)
         {
             // Warning: Only use this if you know exactly what you are doing.
@@ -220,7 +191,6 @@
             m_index = index;
             ASSERT(m_index <= m_storage.capacity());
         }
-#endif
 
         AssemblerLabel label() const
         {
@@ -238,7 +208,6 @@
         //
         // LocalWriter *CANNOT* be mixed with other types of access to AssemblerBuffer.
         // AssemblerBuffer cannot be used until its LocalWriter goes out of scope.
-#if !CPU(ARM64) // If we ever need to use this on arm64e, we would need to make the checksum aware of this.
         class LocalWriter {
         public:
             LocalWriter(AssemblerBuffer& buffer, unsigned requiredSpace)
@@ -281,17 +250,7 @@
             unsigned m_requiredSpace;
 #endif
         };
-#endif // !CPU(ARM64)
 
-#if CPU(ARM64E)
-        ARM64EHash hash() const { return m_hash; }
-#endif
-
-#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.
-        void* data() const { return m_storage.buffer(); }
-#endif
-
-
     protected:
         template<typename IntegralType>
         void putIntegral(IntegralType value)
@@ -307,38 +266,35 @@
         template<typename IntegralType>
         void putIntegralUnchecked(IntegralType value)
         {
-#if CPU(ARM64)
-            static_assert(sizeof(value) == 4, "");
-#if CPU(ARM64E)
-            m_hash.update(value, m_index);
-#endif
-#endif
             ASSERT(isAvailable(sizeof(IntegralType)));
             *reinterpret_cast_ptr<IntegralType*>(m_storage.buffer() + m_index) = value;
             m_index += sizeof(IntegralType);
         }
 
-    private:
+        void append(const char* data, int size)
+        {
+            if (!isAvailable(size))
+                grow(size);
+
+            memcpy(m_storage.buffer() + m_index, data, size);
+            m_index += size;
+        }
+
         void grow(int extraCapacity = 0)
         {
             m_storage.grow(extraCapacity);
         }
 
+    private:
         NEVER_INLINE void outOfLineGrow()
         {
             m_storage.grow();
         }
 
-#if !CPU(ARM64)
         friend LocalWriter;
-#endif
-        friend LinkBuffer;
 
         AssemblerData m_storage;
         unsigned m_index;
-#if CPU(ARM64E)
-        ARM64EHash m_hash;
-#endif
     };
 
 } // namespace JSC

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/LinkBuffer.cpp (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/LinkBuffer.cpp	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/LinkBuffer.cpp	2018-10-26 00:11:33 UTC (rev 237439)
@@ -109,24 +109,14 @@
     m_assemblerStorage = macroAssembler.m_assembler.buffer().releaseAssemblerData();
     uint8_t* inData = reinterpret_cast<uint8_t*>(m_assemblerStorage.buffer());
 
-    uint8_t* codeOutData = m_code.dataLocation<uint8_t*>();
-#if CPU(ARM64E)
-    const ARM64EHash assemblerBufferHash = macroAssembler.m_assembler.buffer().hash();
-    ARM64EHash verifyUncompactedHash(assemblerBufferHash.randomSeed());
-    uint8_t* outData = codeOutData;
-#else
     AssemblerData outBuffer(m_size);
+
     uint8_t* outData = reinterpret_cast<uint8_t*>(outBuffer.buffer());
-#endif
+    uint8_t* codeOutData = m_code.dataLocation<uint8_t*>();
 
     int readPtr = 0;
     int writePtr = 0;
     unsigned jumpCount = jumpsToLink.size();
-
-#if CPU(ARM64E)
-    os_thread_self_restrict_rwx_to_rw();
-#endif
-
     if (m_shouldPerformBranchCompaction) {
         for (unsigned i = 0; i < jumpCount; ++i) {
             int offset = readPtr - writePtr;
@@ -140,18 +130,8 @@
             ASSERT(!(regionSize % 2));
             ASSERT(!(readPtr % 2));
             ASSERT(!(writePtr % 2));
-#if CPU(ARM64E)
-            unsigned index = readPtr;
-#endif
-            while (copySource != copyEnd) {
-                InstructionType insn = *copySource++;
-#if CPU(ARM64E)
-                static_assert(sizeof(InstructionType) == 4, "");
-                verifyUncompactedHash.update(insn, index);
-                index += sizeof(InstructionType);
-#endif
-                *copyDst++ = insn;
-            }
+            while (copySource != copyEnd)
+                *copyDst++ = *copySource++;
             recordLinkOffsets(m_assemblerStorage, readPtr, jumpsToLink[i].from(), offset);
             readPtr += regionSize;
             writePtr += regionSize;
@@ -182,77 +162,30 @@
                 ASSERT(!MacroAssembler::canCompact(jumpsToLink[i].type()));
         }
     }
-
     // Copy everything after the last jump
-    {
-        InstructionType* dst = bitwise_cast<InstructionType*>(outData + writePtr);
-        InstructionType* src = "" + readPtr);
-        size_t bytes = initialSize - readPtr;
-
-        RELEASE_ASSERT(bitwise_cast<uintptr_t>(dst) % sizeof(InstructionType) == 0);
-        RELEASE_ASSERT(bitwise_cast<uintptr_t>(src) % sizeof(InstructionType) == 0);
-        RELEASE_ASSERT(bytes % sizeof(InstructionType) == 0);
-
-#if CPU(ARM64E)
-        unsigned index = readPtr;
-#endif
-
-        for (size_t i = 0; i < bytes; i += sizeof(InstructionType)) {
-            InstructionType insn = *src++;
-#if CPU(ARM64E)
-            verifyUncompactedHash.update(insn, index);
-            index += sizeof(InstructionType);
-#endif
-            *dst++ = insn;
-        }
-    }
-
-#if CPU(ARM64E)
-    if (verifyUncompactedHash.hash() != assemblerBufferHash.hash()) {
-        dataLogLn("Hashes don't match: ", RawPointer(bitwise_cast<void*>(verifyUncompactedHash.hash())), " ", RawPointer(bitwise_cast<void*>(assemblerBufferHash.hash())));
-        dataLogLn("Crashing!");
-        CRASH();
-    }
-#endif
-
+    memcpy(outData + writePtr, inData + readPtr, initialSize - readPtr);
     recordLinkOffsets(m_assemblerStorage, readPtr, initialSize, readPtr - writePtr);
         
     for (unsigned i = 0; i < jumpCount; ++i) {
-#if CPU(ARM64E)
-        auto memcpyFunction = memcpy;
-#else
-        auto memcpyFunction = performJITMemcpy;
-#endif
-
         uint8_t* location = codeOutData + jumpsToLink[i].from();
         uint8_t* target = codeOutData + jumpsToLink[i].to() - executableOffsetFor(jumpsToLink[i].to());
-        MacroAssembler::link(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target, memcpyFunction);
+        MacroAssembler::link(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target);
     }
 
+    jumpsToLink.clear();
+
     size_t compactSize = writePtr + initialSize - readPtr;
-    if (!m_executableMemory) {
-        size_t nopSizeInBytes = initialSize - compactSize;
-        MacroAssembler::AssemblerType_T::fillNops(outData + compactSize, nopSizeInBytes, memcpy);
-    }
-
-#if CPU(ARM64E)
-    os_thread_self_restrict_rwx_to_rx();
-#endif
-
     if (m_executableMemory) {
         m_size = compactSize;
         m_executableMemory->shrink(m_size);
+    } else {
+        size_t nopSizeInBytes = initialSize - compactSize;
+        bool isCopyingToExecutableMemory = false;
+        MacroAssembler::AssemblerType_T::fillNops(outData + compactSize, nopSizeInBytes, isCopyingToExecutableMemory);
     }
 
-#if !CPU(ARM64E)
-    ASSERT(codeOutData != outData);
     performJITMemcpy(codeOutData, outData, m_size);
-#else
-    ASSERT(codeOutData == outData);
-#endif
 
-    jumpsToLink.clear();
-
 #if DUMP_LINK_STATISTICS
     dumpLinkStatistics(codeOutData, initialSize, m_size);
 #endif

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/MIPSAssembler.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/MIPSAssembler.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/MIPSAssembler.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -264,10 +264,9 @@
         emitInst(0x00000000);
     }
     
-    template <typename CopyFunction>
-    static void fillNops(void* base, size_t size, CopyFunction copy)
+    static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
     {
-        UNUSED_PARAM(copy);
+        UNUSED_PARAM(isCopyingToExecutableMemory);
         RELEASE_ASSERT(!(size % sizeof(int32_t)));
 
         int32_t* ptr = static_cast<int32_t*>(base);

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/MacroAssemblerARM64.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/MacroAssemblerARM64.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/MacroAssemblerARM64.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -79,12 +79,12 @@
     static const Assembler::JumpType DefaultJump = Assembler::JumpNoConditionFixedSize;
 
     Vector<LinkRecord, 0, UnsafeVectorOverflow>& jumpsToLink() { return m_assembler.jumpsToLink(); }
+    void* unlinkedCode() { return m_assembler.unlinkedCode(); }
     static bool canCompact(JumpType jumpType) { return Assembler::canCompact(jumpType); }
     static JumpLinkType computeJumpType(JumpType jumpType, const uint8_t* from, const uint8_t* to) { return Assembler::computeJumpType(jumpType, from, to); }
     static JumpLinkType computeJumpType(LinkRecord& record, const uint8_t* from, const uint8_t* to) { return Assembler::computeJumpType(record, from, to); }
     static int jumpSizeDelta(JumpType jumpType, JumpLinkType jumpLinkType) { return Assembler::jumpSizeDelta(jumpType, jumpLinkType); }
-    template <typename CopyFunction>
-    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); }
+    static void link(LinkRecord& record, uint8_t* from, const uint8_t* fromInstruction, uint8_t* to) { return Assembler::link(record, from, fromInstruction, to); }
 
     static const Scale ScalePtr = TimesEight;
 

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -65,6 +65,7 @@
     }
 
     Vector<LinkRecord, 0, UnsafeVectorOverflow>& jumpsToLink() { return m_assembler.jumpsToLink(); }
+    void* unlinkedCode() { return m_assembler.unlinkedCode(); }
     static bool canCompact(JumpType jumpType) { return ARMv7Assembler::canCompact(jumpType); }
     static JumpLinkType computeJumpType(JumpType jumpType, const uint8_t* from, const uint8_t* to) { return ARMv7Assembler::computeJumpType(jumpType, from, to); }
     static JumpLinkType computeJumpType(LinkRecord& record, const uint8_t* from, const uint8_t* to) { return ARMv7Assembler::computeJumpType(record, from, to); }

Modified: branches/safari-606-branch/Source/_javascript_Core/assembler/X86Assembler.h (237438 => 237439)


--- branches/safari-606-branch/Source/_javascript_Core/assembler/X86Assembler.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/_javascript_Core/assembler/X86Assembler.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -3902,10 +3902,9 @@
         m_formatter.oneByteOp(OP_NOP);
     }
 
-    template <typename CopyFunction>
-    static void fillNops(void* base, size_t size, CopyFunction copy)
+    static void fillNops(void* base, size_t size, bool isCopyingToExecutableMemory)
     {
-        UNUSED_PARAM(copy);
+        UNUSED_PARAM(isCopyingToExecutableMemory);
 #if CPU(X86_64)
         static const uint8_t nops[10][10] = {
             // nop

Modified: branches/safari-606-branch/Source/WTF/ChangeLog (237438 => 237439)


--- branches/safari-606-branch/Source/WTF/ChangeLog	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/WTF/ChangeLog	2018-10-26 00:11:33 UTC (rev 237439)
@@ -1,3 +1,7 @@
+2018-10-25  Kocsen Chung  <[email protected]>
+
+        Revert r237373. rdar://problem/45285669
+
 2018-10-23  Kocsen Chung  <[email protected]>
 
         Cherry-pick r236589. rdar://problem/45285669

Modified: branches/safari-606-branch/Source/WTF/wtf/PtrTag.h (237438 => 237439)


--- branches/safari-606-branch/Source/WTF/wtf/PtrTag.h	2018-10-26 00:11:28 UTC (rev 237438)
+++ branches/safari-606-branch/Source/WTF/wtf/PtrTag.h	2018-10-26 00:11:33 UTC (rev 237439)
@@ -147,13 +147,6 @@
 template<PtrTag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
 inline PtrType untagCFunctionPtr(PtrType ptr) { return ptr; }
 
-template <typename IntType>
-inline IntType tagInt(IntType ptrInt, PtrTag)
-{
-    static_assert(sizeof(IntType) == sizeof(uintptr_t), "");
-    return ptrInt;
-}
-
 template<typename PtrType> void assertIsCFunctionPtr(PtrType) { }
 template<typename PtrType> void assertIsNullOrCFunctionPtr(PtrType) { }
 
@@ -191,7 +184,6 @@
 using WTF::removeCodePtrTag;
 using WTF::tagCFunctionPtr;
 using WTF::untagCFunctionPtr;
-using WTF::tagInt;
 
 using WTF::assertIsCFunctionPtr;
 using WTF::assertIsNullOrCFunctionPtr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to