Ignore:
Timestamp:
Apr 30, 2015, 1:37:51 AM (10 years ago)
Author:
Yusuke Suzuki
Message:

Use the default hash value for Symbolized StringImpl
https://bugs.webkit.org/show_bug.cgi?id=144347

Reviewed by Darin Adler.

Source/JavaScriptCore:

Before this patch, symbolized StringImpl* has a special hash value
to avoid the hash collision with the other normal StringImpl*.
I guess that it is introduced when private symbols are introduced.
However, it prevents using symbolized StringImpl* in the other place
For example, using it as WTFString cause a problem because of its special hash value.

When only using private symbols, they are not exposed to the outside of JSC,
so we can handle it carefully. But now, it's extended to symbols.
So I think storing a special hash value in StringImpl* causes an error.

To avoid this, I propose using the usual hash value in symbolized StringImpl*.
And to provide significantly different hash value when using it as symbol,
store the additional hash value in symbolized StringImpl*. It is used when
the hash value is required by IdentifierRepHash.

  • runtime/Identifier.h:

(JSC::IdentifierRepHash::hash):

  • runtime/Lookup.h:

(JSC::HashTable::entry):

  • runtime/PropertyMapHashTable.h:

(JSC::PropertyTable::find):
(JSC::PropertyTable::get):

  • runtime/Structure.cpp:

(JSC::PropertyTable::checkConsistency):

Source/WTF:

Use a default hash value calculation for symbolized StringImpl.

  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::createSymbol):

  • wtf/text/StringImpl.h:

(WTF::StringImpl::StringImpl):
(WTF::StringImpl::symbolAwareHash):
(WTF::StringImpl::existingSymbolAwareHash):
(WTF::StringImpl::hashForSymbol):

  • wtf/text/StringStatics.cpp:

(WTF::StringImpl::nextHashForSymbol):
(WTF::StringImpl::hashAndFlagsForSymbol): Deleted.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r182747 r183624  
    11631163            continue;
    11641164        ++nonEmptyEntryCount;
    1165         unsigned i = rep->existingHash();
     1165        unsigned i = IdentifierRepHash::hash(rep);
    11661166        unsigned k = 0;
    11671167        unsigned entryIndex;
     
    11721172                break;
    11731173            if (k == 0)
    1174                 k = 1 | doubleHash(rep->existingHash());
     1174                k = 1 | doubleHash(IdentifierRepHash::hash(rep));
    11751175            i += k;
    11761176        }
Note: See TracChangeset for help on using the changeset viewer.