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

Changeset 280984 in webkit


Ignore:
Timestamp:
Aug 12, 2021, 1:45:02 PM (5 years ago)
Author:
sbarati@apple.com
Message:

Update ARM64EHash
https://bugs.webkit.org/show_bug.cgi?id=228962
<rdar://79883337>

Reviewed by Mark Lam.

  • assembler/AssemblerBuffer.h:

(JSC::ARM64EHash::makeDiversifier):
(JSC::ARM64EHash::nextValue):
(JSC::ARM64EHash::bitsForDiversifier):
(JSC::ARM64EHash::currentHash):
(JSC::ARM64EHash::setUpdatedHash):
(JSC::ARM64EHash::ARM64EHash):
(JSC::ARM64EHash::update):
(JSC::ARM64EHash::finalize):
(JSC::AssemblerBuffer::AssemblerBuffer):
(JSC::AssemblerBuffer::putIntegralUnchecked):
(JSC::AssemblerBuffer::hash const):

  • assembler/LinkBuffer.cpp:

(JSC::LinkBuffer::copyCompactAndLinkCode):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r280886 r280984  
     12021-08-12  Saam Barati  <sbarati@apple.com>
     2
     3        Update ARM64EHash
     4        https://bugs.webkit.org/show_bug.cgi?id=228962
     5        <rdar://79883337>
     6
     7        Reviewed by Mark Lam.
     8
     9        * assembler/AssemblerBuffer.h:
     10        (JSC::ARM64EHash::makeDiversifier):
     11        (JSC::ARM64EHash::nextValue):
     12        (JSC::ARM64EHash::bitsForDiversifier):
     13        (JSC::ARM64EHash::currentHash):
     14        (JSC::ARM64EHash::setUpdatedHash):
     15        (JSC::ARM64EHash::ARM64EHash):
     16        (JSC::ARM64EHash::update):
     17        (JSC::ARM64EHash::finalize):
     18        (JSC::AssemblerBuffer::AssemblerBuffer):
     19        (JSC::AssemblerBuffer::putIntegralUnchecked):
     20        (JSC::AssemblerBuffer::hash const):
     21        * assembler/LinkBuffer.cpp:
     22        (JSC::LinkBuffer::copyCompactAndLinkCode):
     23
    1242021-08-11  Yusuke Suzuki  <ysuzuki@apple.com>
    225
  • trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h

    r272191 r280984  
    206206    class ARM64EHash {
    207207    public:
    208         ARM64EHash(uint32_t initialHash)
    209             : m_hash(initialHash)
    210         {
    211         }
    212 
    213         ALWAYS_INLINE uint32_t update(uint32_t value)
    214         {
    215             uint64_t input = value ^ m_hash;
    216             uint64_t a = static_cast<uint32_t>(tagInt(input, static_cast<PtrTag>(0)) >> 39);
    217             uint64_t b = tagInt(input, static_cast<PtrTag>(0xb7e151628aed2a6a)) >> 23;
    218             m_hash = a ^ b;
    219             return m_hash;
     208        static constexpr uint8_t initializationNamespace = 0x11;
     209
     210        static ALWAYS_INLINE PtrTag makeDiversifier(uint8_t namespaceTag, uint64_t index, uint32_t value)
     211        {
     212            // <namespaceTag:8><index:24><value:32>
     213            return static_cast<PtrTag>((static_cast<uint64_t>(namespaceTag) << 56) + ((index & 0xFFFFFF) << 32) + static_cast<uint64_t>(value));
     214        }
     215
     216        static ALWAYS_INLINE uint32_t nextValue(uint64_t instruction, uint64_t index, uint32_t currentValue)
     217        {
     218            uint64_t a = tagInt(instruction, makeDiversifier(0x12, index, currentValue));
     219            uint64_t b = tagInt(instruction, makeDiversifier(0x13, index, currentValue));
     220            return static_cast<uint32_t>((a >> 39) ^ (b >> 23));
     221        }
     222
     223        static ALWAYS_INLINE uint32_t bitsForDiversifier(void* diversifier)
     224        {
     225            return static_cast<uint32_t>(bitwise_cast<uintptr_t>(diversifier));
     226        }
     227
     228        ALWAYS_INLINE uint32_t currentHash(uint32_t index, void* diversifier)
     229        {
     230            uint64_t result;
     231            bool hashFieldIsTagged = index == 0;
     232            if (hashFieldIsTagged)
     233                result = untagInt(m_hash, makeDiversifier(initializationNamespace, index, bitsForDiversifier(diversifier)));
     234            else
     235                result = m_hash;
     236            return static_cast<uint32_t>(result);
     237        }
     238
     239        ALWAYS_INLINE void setUpdatedHash(uint32_t value, uint32_t index, void* diversifier)
     240        {
     241            bool shouldTagHashField = index == 0;
     242            if (shouldTagHashField)
     243                m_hash = tagInt(static_cast<uint64_t>(value), makeDiversifier(initializationNamespace, index, bitsForDiversifier(diversifier)));
     244            else
     245                m_hash = value;
     246        }
     247
     248        ARM64EHash(void* diversifier)
     249        {
     250            setUpdatedHash(0, 0, diversifier);
     251        }
     252 
     253        ALWAYS_INLINE uint32_t update(uint32_t instruction, uint32_t index, void* diversifier)
     254        {
     255            uint32_t currentHash = this->currentHash(index, diversifier);
     256            uint64_t nextIndex = index + 1;
     257            uint32_t output = nextValue(instruction, nextIndex, currentHash);
     258            setUpdatedHash(output, nextIndex, diversifier);
     259            return output;
    220260        }
    221261
    222262    private:
    223         uint32_t m_hash;
     263        uint64_t m_hash;
    224264    };
    225265#endif
     
    231271            , m_index(0)
    232272#if CPU(ARM64E)
    233             , m_hash(static_cast<uint32_t>(bitwise_cast<uint64_t>(this)))
     273            , m_hash(this)
    234274            , m_hashes()
    235275#endif
     
    389429            static_assert(sizeof(value) == 4, "");
    390430#if CPU(ARM64E)
    391             uint32_t hash = m_hash.update(value);
     431            uint32_t hash = m_hash.update(value, m_index / sizeof(IntegralType), this);
    392432            WTF::unalignedStore<uint32_t>(m_hashes.buffer() + m_index, hash);
    393433#endif
  • trunk/Source/JavaScriptCore/assembler/LinkBuffer.cpp

    r278253 r280984  
    246246    uint8_t* inData = bitwise_cast<uint8_t*>(m_assemblerStorage.buffer());
    247247#if CPU(ARM64E)
    248     ARM64EHash verifyUncompactedHash { static_cast<uint32_t>(bitwise_cast<uint64_t>(&macroAssembler.m_assembler.buffer())) };
     248    void* bufferPtr = &macroAssembler.m_assembler.buffer();
     249    ARM64EHash verifyUncompactedHash { bufferPtr };
    249250    m_assemblerHashesStorage = macroAssembler.m_assembler.buffer().releaseAssemblerHashes();
    250251    uint32_t* inHashes = bitwise_cast<uint32_t*>(m_assemblerHashesStorage.buffer());
     
    268269        InstructionType value = *ptr;
    269270#if CPU(ARM64E)
    270         uint32_t hash = verifyUncompactedHash.update(value);
    271271        unsigned index = (bitwise_cast<uint8_t*>(ptr) - inData) / 4;
     272        uint32_t hash = verifyUncompactedHash.update(value, index, bufferPtr);
    272273        RELEASE_ASSERT(inHashes[index] == hash);
    273274#endif
Note: See TracChangeset for help on using the changeset viewer.