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

Changeset 98495 in webkit


Ignore:
Timestamp:
Oct 26, 2011, 10:12:13 AM (15 years ago)
Author:
msaboff@apple.com
Message:

Increase StringImpl Flag Bits for 8 bit Strings
https://bugs.webkit.org/show_bug.cgi?id=70937

Increased the number of bits used for flags in StringImpl
from 6 to 8 bits. This frees up 2 flag bits that will be
used for 8-bit string support. Updated hash methods accordingly.
Changed hash value masking from the low bits to the high
bits.

Reviewed by Darin Adler.

Source/JavaScriptCore:

  • create_hash_table:
  • wtf/StringHasher.h:

(WTF::StringHasher::hash):

  • wtf/text/StringImpl.h:

Source/WebCore:

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHashValue):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r98491 r98495  
     12011-10-26  Michael Saboff  <msaboff@apple.com>
     2
     3        Increase StringImpl Flag Bits for 8 bit Strings
     4        https://bugs.webkit.org/show_bug.cgi?id=70937
     5
     6        Increased the number of bits used for flags in StringImpl
     7        from 6 to 8 bits. This frees up 2 flag bits that will be
     8        used for 8-bit string support. Updated hash methods accordingly.
     9        Changed hash value masking from the low bits to the high
     10        bits.
     11
     12        Reviewed by Darin Adler.
     13
     14        * create_hash_table:
     15        * wtf/StringHasher.h:
     16        (WTF::StringHasher::hash):
     17        * wtf/text/StringImpl.h:
     18
    1192011-10-26  Dan Bernstein  <mitz@apple.com>
    220
  • trunk/Source/JavaScriptCore/create_hash_table

    r98491 r98495  
    222222  $hash ^= (leftShift($hash, 10)% $EXP2_32);
    223223
    224   # Save 6 bits for StringImpl to use as flags.
    225   $hash = ($hash >> 6);
     224  # Save 8 bits for StringImpl to use as flags.
     225  $hash &= 0xffffff;
    226226
    227227  # This avoids ever returning a hash code of 0, since that is used to
     
    229229  # reasonable fidelity to a hash code of 0 because it is likely to yield
    230230  # exactly 0 when hash lookup masks out the high bits.
    231   $hash = (0x80000000 >> 6) if ($hash == 0);
     231  $hash = (0x80000000 >> 8) if ($hash == 0);
    232232
    233233  return $hash;
  • trunk/Source/JavaScriptCore/wtf/StringHasher.h

    r98217 r98495  
    3737class StringHasher {
    3838public:
    39     static const unsigned flagCount = 6; // Save 6 bits for StringImpl to use as flags.
     39    static const unsigned flagCount = 8; // Save 8 bits for StringImpl to use as flags.
    4040
    4141    inline StringHasher()
     
    8282        result ^= result << 10;
    8383
    84         // Reserving the high bits for flags preserves most of the hash's value,
    85         // since hash lookup typically masks out the high bits anyway.
    86         result >>= flagCount;
     84        // Reserving space from the high bits for flags preserves most of the hash's
     85        // value, since hash lookup typically masks out the high bits anyway.
     86        result &= (1u << (sizeof(result) * 8 - flagCount)) - 1;
    8787
    8888        // This avoids ever returning a hash code of 0, since that is used to
  • trunk/Source/JavaScriptCore/wtf/text/StringImpl.h

    r98316 r98495  
    382382    static const unsigned s_refCountIncrement = 0x2; // This allows us to ref / deref without disturbing the static string flag.
    383383
    384     // The bottom 6 bits in the hash are flags.
    385     static const unsigned s_flagCount = 6;
     384    // The bottom 8 bits in the hash are flags.
     385    static const unsigned s_flagCount = 8;
    386386    static const unsigned s_flagMask = (1u << s_flagCount) - 1;
    387387    COMPILE_ASSERT(s_flagCount == StringHasher::flagCount, StringHasher_reserves_enough_bits_for_StringImpl_flags);
  • trunk/Source/WebCore/ChangeLog

    r98492 r98495  
     12011-10-26  Michael Saboff  <msaboff@apple.com>
     2
     3        Increase StringImpl Flag Bits for 8 bit Strings
     4        https://bugs.webkit.org/show_bug.cgi?id=70937
     5
     6        Increased the number of bits used for flags in StringImpl
     7        from 6 to 8 bits. This frees up 2 flag bits that will be
     8        used for 8-bit string support. Updated hash methods accordingly.
     9        Changed hash value masking from the low bits to the high
     10        bits.
     11
     12        Reviewed by Darin Adler.
     13
     14        * bindings/scripts/CodeGeneratorJS.pm:
     15        (GenerateHashValue):
     16
    1172011-10-26  Dimitri Glazkov  <dglazkov@chromium.org>
    218
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r98434 r98495  
    30693069    $hash ^= (leftShift($hash, 10)% $EXP2_32);
    30703070   
    3071     # Save 6 bits for StringImpl to use as flags.
    3072     $hash = ($hash >> 6);
     3071    # Save 8 bits for StringImpl to use as flags.
     3072    $hash &= 0xffffff;
    30733073   
    30743074    # This avoids ever returning a hash code of 0, since that is used to
     
    30763076    # reasonable fidelity to a hash code of 0 because it is likely to yield
    30773077    # exactly 0 when hash lookup masks out the high bits.
    3078     $hash = (0x80000000 >> 6) if ($hash == 0);
     3078    $hash = (0x80000000 >> 8) if ($hash == 0);
    30793079   
    30803080    return $hash;
Note: See TracChangeset for help on using the changeset viewer.