Changeset 242103 in webkit


Ignore:
Timestamp:
Feb 26, 2019 1:40:48 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

Misc cleanup in StructureIDTable after r242096.
https://bugs.webkit.org/show_bug.cgi?id=195063

Reviewed by Saam Barati.

  • runtime/StructureIDTable.cpp:

(JSC::StructureIDTable::allocateID):

  • RELEASE_ASSERT that the StructureID allocation will succeed.
  • runtime/StructureIDTable.h:

(JSC::StructureIDTable::decode):
(JSC::StructureIDTable::encode):

  • Add back a comment that Yusuke requested but was lost when the patch was rolled out and relanded.
  • Applied bitwise_casts that Saam requested.
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r242101 r242103  
     12019-02-26  Mark Lam  <mark.lam@apple.com>
     2
     3        Misc cleanup in StructureIDTable after r242096.
     4        https://bugs.webkit.org/show_bug.cgi?id=195063
     5
     6        Reviewed by Saam Barati.
     7
     8        * runtime/StructureIDTable.cpp:
     9        (JSC::StructureIDTable::allocateID):
     10        - RELEASE_ASSERT that the StructureID allocation will succeed.
     11
     12        * runtime/StructureIDTable.h:
     13        (JSC::StructureIDTable::decode):
     14        (JSC::StructureIDTable::encode):
     15        - Add back a comment that Yusuke requested but was lost when the patch was rolled
     16          out and relanded.
     17        - Applied bitwise_casts that Saam requested.
     18
    1192019-02-26  Mark Lam  <mark.lam@apple.com>
    220
  • trunk/Source/JavaScriptCore/runtime/StructureIDTable.cpp

    r242096 r242103  
    136136        resize(m_capacity * 2);
    137137        ASSERT(m_size < m_capacity);
    138         ASSERT(m_firstFreeOffset);
     138        RELEASE_ASSERT(m_firstFreeOffset);
    139139    }
    140 
    141     ASSERT(m_firstFreeOffset != s_unusedID);
    142140
    143141    // entropyBits must not be zero. This ensures that if a corrupted
  • trunk/Source/JavaScriptCore/runtime/StructureIDTable.h

    r242096 r242103  
    132132
    133133public:
     134    // 1. StructureID is encoded as:
     135    //
     136    //    ----------------------------------------------------------------
     137    //    | 1 Nuke Bit | 24 StructureIDTable index bits | 7 entropy bits |
     138    //    ----------------------------------------------------------------
     139    //
     140    //    The entropy bits are chosen at random and assigned when a StructureID
     141    //    is allocated.
     142    //
     143    // 2. For each StructureID, the StructureIDTable stores encodedStructureBits
     144    //    which are encoded from the structure pointer as such:
     145    //
     146    //    ----------------------------------------------------------------
     147    //    | 7 entropy bits |                   57 structure pointer bits |
     148    //    ----------------------------------------------------------------
     149    //
     150    //    The entropy bits here are the same 7 bits used in the encoding of the
     151    //    StructureID for this structure entry in the StructureIDTable.
     152
    134153    static constexpr uint32_t s_numberOfNukeBits = 1;
    135154    static constexpr uint32_t s_numberOfEntropyBits = 7;
     
    141160ALWAYS_INLINE Structure* StructureIDTable::decode(EncodedStructureBits bits, StructureID structureID)
    142161{
    143     return reinterpret_cast<Structure*>(bits ^ (static_cast<uintptr_t>(structureID) << s_entropyBitsShiftForStructurePointer));
     162    return bitwise_cast<Structure*>(bits ^ (static_cast<uintptr_t>(structureID) << s_entropyBitsShiftForStructurePointer));
    144163}
    145164
    146165ALWAYS_INLINE EncodedStructureBits StructureIDTable::encode(Structure* structure, StructureID structureID)
    147166{
    148     return reinterpret_cast<EncodedStructureBits>(structure) ^ (static_cast<EncodedStructureBits>(structureID) << s_entropyBitsShiftForStructurePointer);
     167    return bitwise_cast<EncodedStructureBits>(structure) ^ (static_cast<EncodedStructureBits>(structureID) << s_entropyBitsShiftForStructurePointer);
    149168}
    150169
Note: See TracChangeset for help on using the changeset viewer.