Changeset 280996 in webkit


Ignore:
Timestamp:
Aug 12, 2021, 4:49:42 PM (4 years ago)
Author:
mark.lam@apple.com
Message:

Refactor some ARM64EHash code.
https://bugs.webkit.org/show_bug.cgi?id=229054

Reviewed by Keith Miller and Robin Morisset.

This patch only refactors ARM64EHash code by moving some methods into the private
section, and removing some unneeded static_casts.

Verified with a diff of otool -tv dumps of the built JavaScriptCore binaries,
that there are no diffs in the generated code from this change.

  • assembler/AssemblerBuffer.h:

(JSC::ARM64EHash::ARM64EHash):
(JSC::ARM64EHash::update):
(JSC::ARM64EHash::makeDiversifier):
(JSC::ARM64EHash::nextValue):
(JSC::ARM64EHash::bitsForDiversifier):
(JSC::ARM64EHash::currentHash):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r280984 r280996  
     12021-08-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Refactor some ARM64EHash code.
     4        https://bugs.webkit.org/show_bug.cgi?id=229054
     5
     6        Reviewed by Keith Miller and Robin Morisset.
     7
     8        This patch only refactors ARM64EHash code by moving some methods into the private
     9        section, and removing some unneeded static_casts.
     10
     11        Verified with a diff of `otool -tv` dumps of the built JavaScriptCore binaries,
     12        that there are no diffs in the generated code from this change.
     13
     14        * assembler/AssemblerBuffer.h:
     15        (JSC::ARM64EHash::ARM64EHash):
     16        (JSC::ARM64EHash::update):
     17        (JSC::ARM64EHash::makeDiversifier):
     18        (JSC::ARM64EHash::nextValue):
     19        (JSC::ARM64EHash::bitsForDiversifier):
     20        (JSC::ARM64EHash::currentHash):
     21
    1222021-08-12  Saam Barati  <sbarati@apple.com>
    223
  • trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h

    r280984 r280996  
    11/*
    2  * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    206206    class ARM64EHash {
    207207    public:
     208        ARM64EHash(void* diversifier)
     209        {
     210            setUpdatedHash(0, 0, diversifier);
     211        }
     212
     213        ALWAYS_INLINE uint32_t update(uint32_t instruction, uint32_t index, void* diversifier)
     214        {
     215            uint32_t currentHash = this->currentHash(index, diversifier);
     216            uint64_t nextIndex = index + 1;
     217            uint32_t output = nextValue(instruction, nextIndex, currentHash);
     218            setUpdatedHash(output, nextIndex, diversifier);
     219            return output;
     220        }
     221
     222    private:
    208223        static constexpr uint8_t initializationNamespace = 0x11;
    209224
     
    211226        {
    212227            // <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));
     228            return static_cast<PtrTag>((static_cast<uint64_t>(namespaceTag) << 56) + ((index & 0xFFFFFF) << 32) + value);
    214229        }
    215230
     
    218233            uint64_t a = tagInt(instruction, makeDiversifier(0x12, index, currentValue));
    219234            uint64_t b = tagInt(instruction, makeDiversifier(0x13, index, currentValue));
    220             return static_cast<uint32_t>((a >> 39) ^ (b >> 23));
     235            return (a >> 39) ^ (b >> 23);
    221236        }
    222237
    223238        static ALWAYS_INLINE uint32_t bitsForDiversifier(void* diversifier)
    224239        {
    225             return static_cast<uint32_t>(bitwise_cast<uintptr_t>(diversifier));
     240            return bitwise_cast<uintptr_t>(diversifier);
    226241        }
    227242
    228243        ALWAYS_INLINE uint32_t currentHash(uint32_t index, void* diversifier)
    229244        {
    230             uint64_t result;
    231245            bool hashFieldIsTagged = index == 0;
    232246            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);
     247                return untagInt(m_hash, makeDiversifier(initializationNamespace, index, bitsForDiversifier(diversifier)));
     248            return m_hash;
    237249        }
    238250
     
    246258        }
    247259
    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;
    260         }
    261 
    262     private:
    263260        uint64_t m_hash;
    264261    };
Note: See TracChangeset for help on using the changeset viewer.