JavaScriptCore:
Reviewed by Maciej.
- JavaScriptCore part of fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8049
StringImpl hash traits deleted value creates an init routine for WebCore
<rdar://problem/
4442248> REGRESSION: WebCore has init routines (8049)
Change HashMap and HashSet implementation so they fold various types together.
This allows us to implement maps and sets that use RefPtr<WebCore::StringImpl>
and WebCore::String in terms of the underlying raw pointer type, and hence use
-1 for the deleted value.
* kxmlcore/HashTraits.h: Added a new type to HashTraits, StorageTraits, which is a
type to be used when storing a value that has the same layout as the type itself.
This is used only for non-key cases. In the case of keys, the hash function must also
be considered. Moved emptyValue out of GenericHashTraitsBase into GenericHashTraits.
Added a new bool to HashTraits, needsRef, which indicates whether the type needs
explicit reference counting. If the type itself has needsRef true, but the storage
type has needsRef false, then the HashSet or HashMap has to handle the reference
counting explicitly. Added hash trait specializations for all signed integer values
that give -1 as the deleted value. Gave all integers StorageTraits of the canonical
integer type of the same size so int and long will share code. Gave all pointers and
RefPtrs StorageTraits of the appropriately sized integer type. Removed redundant
TraitType and emptyValue definitions in the pointer specialization for HashTraits.
Added PairBaseHashTraits, which doesn't try to set up needsDestruction and deletedValue.
Useful for types where we don't want to force the existence of deletedValue, such as
the type of a pair in a HashMap which is not the actual storage type. Removed an
unneeded parameter from the DeletedValueAssigner template. Added HashKeyStorageTraits
template, which determines what type can be used to store a given hash key type with
a given hash function, and specialized it for pointers and RefPtr so that pointer
hash tables share an underlying HashTable that uses IntHash.
* kxmlcore/HashTable.h: Added HashTableConstIteratorAdapter, HashTableIteratorAdapter,
NeedsRef, RefCountManagerBase, RefCountManager, HashTableRefCountManagerBase, and
HashTableRefCountManager. All are used by both HashSet and HashMap to handle hash
tables where the type stored is not the same as the real value type.
* kxmlcore/HashFunctions.h: Added a new struct named IntTypes that finds an
integer type given a sizeof value. Renamed pointerHash to intHash and made it
use overloading and take integer parameters. Added an IntHash struct which is
a hash function that works for integers. Changed PtrHash to call IntHash with
an appropriately sized integer. Made IntHash the default hash function for
many integer types. Made PtrHash the default hash function for RefPtr as well
as for raw pointers.
* kxmlcore/HashSet.h: Changed implementation to use a separate "storage type"
derived from the new traits. The HashTable will use the storage type and all
necessary translation and ref/deref is done at the HashSet level. Also reorganized
the file so that the HashSet is at the top and has no inline implementation inside
it so it's easy to read the interface to HashSet.
* kxmlcore/HashMap.h: Changed implementation to use a separate "storage type"
derived from the new traits. The HashTable will use the storage type and all
necessary translation and ref/deref is done at the HashMap level. Also reorganized
the file so that the HashMap is at the top and has no inline implementation inside
it so it's easy to read the interface to HashMap.
* kxmlcore/HashMapPtrSpec.h: Removed. Superceded by optimizations in HashMap itself.
* JavaScriptCore.xcodeproj/project.pbxproj: Remove HashMapPtrSpec.h, resort files,
and also remove some unnecessary build settings from the aggregate target that
generates derived sources.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto.
WebCore:
Reviewed by Maciej.
- fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8049
StringImpl hash traits deleted value creates an init routine for WebCore
<rdar://problem/
4442248> REGRESSION: WebCore has init routines (8049)
* platform/StringHash.h: Added. Moved hash functions and such for
WebCore::String and friends into this file so we don't have to include
the hash traits header everywhere. Changed hashing for WebCore::StringImpl
and WebCore::String so that they use a raw pointer for the underlying
storage type, taking advantage of the new feature added in JavaScriptCore.
* platform/AtomicString.h: Moved StrHash specialization to StringHash.h.
* platform/PlatformString.h: Moved StrHash specialization to StringHash.h.
* platform/StringImpl.h: Moved StrHash, CaseInsensitiveHash, and HashTraits
to StringHash.h. Left DefaultHash behind so that you can't get the wrong
hash function by accident if you forget to include "StringHash.h".
* platform/StringImpl.cpp: Added include of StringHash.h and removed
RefPtr<StringImpl> HashTraits<RefPtr<StringImpl> >::_deleted, which is
the object with a global initializer causing all the trouble!
* kwq/AccessibilityObjectCache.h: Changed hash function to be IntHash
instead of PtrHash.
* dom/StyledElement.cpp: Changed MappedAttributeKeyTraits to inherit from
the generic traits in KXMLCore so we get a StorageType. Also cleaned up a
tiny bit by adding default values to the MappedAttributeKey constructor.
* platform/CharsetNames.cpp: Changed hash traits here to be a new
TextEncodingIDHashTraits struct rather than defining new default traits
for the integer type since more integer types have default traits in
HashTraits.h now. Also added a specialization so this class will share
the underlying implementation (since InvalidEncoding happens to be -1).
* bridge/mac/FrameMac.h:
* dom/Document.h:
* dom/xml_tokenizer.h:
* khtml/xsl/XSLTProcessor.h:
* kwq/JavaAppletWidget.h:
* page/FramePrivate.h:
* page/Page.cpp:
* platform/AtomicString.cpp:
* platform/TransferJob.h:
* rendering/render_applet.h:
Added include of StringHash.h.
* WebCore.xcodeproj/project.pbxproj: Added StringHash.h. Remove unneeded
CREATE_HASH_TABLE variable in build settings. Re-sorted some file lists.
Added quotes to the CREATE_HASH_TABLE initialization in the rule that
builds generated files. Removed various unneeded build settings for that
target as well.
* ForwardingHeaders/kxmlcore/HashTraits.h: Added.
- other minor cleanup
* bridge/mac/FrameMac.mm: Sorted includes.
* dom/Node.cpp: Removed bogus symbol after #endif.
* khtml/xsl/XSLTProcessor.cpp: Sorted includes. Removed redundant using
namespace WebCore.
* loader/Cache.cpp: Ditto.
WebKitTools:
Reviewed by Maciej.
* Scripts/check-for-global-initializers: Remove StringImpl from the list of files that
are allowed to have global initializers.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13703
268f45cc-cd09-0410-ab3c-
d52691b4dbfc