Changeset 83664 in webkit
- Timestamp:
- Apr 12, 2011 4:48:11 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r83661 r83664 15 15 (JSC::::init): 16 16 * heap/Handle.h: 17 18 2011-04-12 Geoffrey Garen <ggaren@apple.com> 19 20 Reviewed by Geoffrey Garen. 21 22 Cleaned up hash traits, and added hash traits for handles 23 https://bugs.webkit.org/show_bug.cgi?id=58381 24 25 * heap/Handle.h: 26 (JSC::HandleBase::swap): 27 (JSC::Handle::Handle): 28 (JSC::Handle::swap): Implemented swap, so we can rehash efficiently, and 29 without creating new handles (which is not allowed during handle finalization). 30 31 * heap/Strong.h: 32 (JSC::Strong::swap): Use new SimpleClassHashTraits to avoid duplication. 33 34 * heap/Weak.h: 35 (JSC::Weak::isHashTableDeletedValue): 36 (JSC::Weak::Weak): 37 (JSC::Weak::swap): 38 (JSC::Weak::hashTableDeletedValue): Ditto. 39 40 * wtf/HashTraits.h: 41 (WTF::SimpleClassHashTraits::constructDeletedValue): 42 (WTF::SimpleClassHashTraits::isDeletedValue): Added SimpleClassHashTraits, 43 which are analogous to SimpleClassVectorTraits, since they are used in a 44 bunch of places. 45 46 * wtf/RetainPtr.h: Use new SimpleClassHashTraits to avoid duplication. 47 48 * wtf/text/StringHash.h: Use new SimpleClassHashTraits to avoid duplication. 17 49 18 50 2011-04-12 Geoffrey Garen <ggaren@apple.com> -
trunk/Source/JavaScriptCore/heap/Handle.h
r83661 r83664 61 61 { 62 62 } 63 64 void swap(HandleBase& other) { std::swap(m_slot, other.m_slot); } 63 65 64 66 HandleSlot slot() const { return m_slot; } … … 142 144 { 143 145 typename HandleTypes<T>::template validateUpcast<U>(); 144 m_slot = o.slot(); 145 } 146 setSlot(o.slot()); 147 } 148 149 void swap(Handle& other) { HandleBase::swap(other); } 146 150 147 151 ExternalType get() const { return HandleTypes<T>::getFromSlot(this->slot()); } -
trunk/Source/JavaScriptCore/heap/Strong.h
r83637 r83664 89 89 } 90 90 91 void swap(Strong& other) 92 { 93 Handle<T>::swap(other); 94 } 95 91 96 void set(JSGlobalData& globalData, ExternalType value) 92 97 { … … 146 151 }; 147 152 148 template<typename P> struct HashTraits<JSC::Strong<P> > : GenericHashTraits<JSC::Strong<P> > { 149 static const bool emptyValueIsZero = true; 150 static JSC::Strong<P> emptyValue() { return JSC::Strong<P>(); } 151 static void constructDeletedValue(JSC::Strong<P>& slot) { new (&slot) JSC::Strong<P>(JSC::Strong<P>::HashTableDeletedValue); } 152 static bool isDeletedValue(const JSC::Strong<P>& value) { return value.isHashTableDeletedValue(); } 153 }; 153 template<typename P> struct HashTraits<JSC::Strong<P> > : SimpleClassHashTraits<JSC::Strong<P> > { }; 154 154 155 155 } -
trunk/Source/JavaScriptCore/heap/Weak.h
r83637 r83664 72 72 } 73 73 74 enum HashTableDeletedValueTag { HashTableDeletedValue }; 75 bool isHashTableDeletedValue() const { return slot() == hashTableDeletedValue(); } 76 Weak(HashTableDeletedValueTag) 77 : Handle<T>(hashTableDeletedValue()) 78 { 79 } 80 74 81 ~Weak() 75 82 { 76 83 clear(); 84 } 85 86 void swap(Weak& other) 87 { 88 Handle<T>::swap(other); 77 89 } 78 90 … … 98 110 99 111 private: 112 static HandleSlot hashTableDeletedValue() { return reinterpret_cast<HandleSlot>(-1); } 113 100 114 void set(ExternalType externalType) 101 115 { … … 115 129 }; 116 130 131 template<typename P> struct HashTraits<JSC::Weak<P> > : SimpleClassHashTraits<JSC::Weak<P> > { }; 132 117 133 } 118 134 -
trunk/Source/JavaScriptCore/wtf/HashTraits.h
r54618 r83664 82 82 }; 83 83 84 template<typename P> struct HashTraits<RefPtr<P> > : GenericHashTraits<RefPtr<P>> {84 template<typename T> struct SimpleClassHashTraits : GenericHashTraits<T> { 85 85 static const bool emptyValueIsZero = true; 86 static void constructDeletedValue( RefPtr<P>& slot) { new (&slot) RefPtr<P>(HashTableDeletedValue); }87 static bool isDeletedValue(const RefPtr<P>& value) { return value.isHashTableDeletedValue(); }86 static void constructDeletedValue(T& slot) { new (&slot) T(HashTableDeletedValue); } 87 static bool isDeletedValue(const T& value) { return value.isHashTableDeletedValue(); } 88 88 }; 89 90 template<typename P> struct HashTraits<RefPtr<P> > : SimpleClassHashTraits<RefPtr<P> > { }; 89 91 90 92 // special traits for pairs, helpful for their use in HashMap implementation -
trunk/Source/JavaScriptCore/wtf/RetainPtr.h
r79434 r83664 235 235 } 236 236 237 template<typename P> struct HashTraits<RetainPtr<P> > : GenericHashTraits<RetainPtr<P> > { 238 static const bool emptyValueIsZero = true; 239 static void constructDeletedValue(RetainPtr<P>& slot) { new (&slot) RetainPtr<P>(HashTableDeletedValue); } 240 static bool isDeletedValue(const RetainPtr<P>& value) { return value == reinterpret_cast<P*>(-1); } 241 }; 237 template<typename P> struct HashTraits<RetainPtr<P> > : SimpleClassHashTraits<RetainPtr<P> > { }; 242 238 243 239 template<typename P> struct PtrHash<RetainPtr<P> > : PtrHash<P*> { -
trunk/Source/JavaScriptCore/wtf/text/StringHash.h
r81548 r83664 180 180 }; 181 181 182 template<> struct HashTraits<String> : GenericHashTraits<String> { 183 static const bool emptyValueIsZero = true; 184 static void constructDeletedValue(String& slot) { new (&slot) String(HashTableDeletedValue); } 185 static bool isDeletedValue(const String& slot) { return slot.isHashTableDeletedValue(); } 186 }; 182 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { }; 187 183 188 184 } -
trunk/Source/WebCore/ChangeLog
r83659 r83664 1 2011-04-12 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Cleaned up hash traits, and added hash traits for handles 6 https://bugs.webkit.org/show_bug.cgi?id=58381 7 8 * dom/QualifiedName.h: Use new SimpleClassHashTraits to avoid duplication. 9 10 * platform/KURL.h: 11 (WebCore::KURL::KURL): 12 (WebCore::KURL::isHashTableDeletedValue): Added explicit hash table 13 deleted value constructor, to be more explicit and enable use of 14 SimpleClassHashTraits. 15 16 * platform/KURLHash.h: Use new SimpleClassHashTraits to avoid duplication. 17 18 * platform/graphics/FontCache.cpp: Ditto. 19 * platform/network/ProtectionSpaceHash.h: Ditto. 20 * svg/properties/SVGAnimatedPropertyDescription.h: Ditto. 21 1 22 2011-04-12 Luiz Agostini <luiz.agostini@openbossa.org> 2 23 -
trunk/Source/WebCore/dom/QualifiedName.h
r81548 r83664 142 142 }; 143 143 144 template<> struct HashTraits<WebCore::QualifiedName> : GenericHashTraits<WebCore::QualifiedName> {144 template<> struct HashTraits<WebCore::QualifiedName> : SimpleClassHashTraits<WebCore::QualifiedName> { 145 145 static const bool emptyValueIsZero = false; 146 146 static WebCore::QualifiedName emptyValue() { return WebCore::QualifiedName(nullAtom, nullAtom, nullAtom); } 147 static void constructDeletedValue(WebCore::QualifiedName& slot) { new (&slot) WebCore::QualifiedName(WTF::HashTableDeletedValue); }148 static bool isDeletedValue(const WebCore::QualifiedName& slot) { return slot.isHashTableDeletedValue(); }149 147 }; 150 148 } -
trunk/Source/WebCore/platform/KURL.h
r80566 r83664 77 77 KURL(ParsedURLStringTag, const String&); 78 78 KURL(ParsedURLStringTag, const URLString&); 79 KURL(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDeletedValue) { } 80 bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedValue(); } 79 81 80 82 // Resolves the relative URL with the given base URL. If provided, the -
trunk/Source/WebCore/platform/KURLHash.h
r65077 r83664 51 51 namespace WTF { 52 52 53 template<> struct HashTraits<WebCore::KURL> : GenericHashTraits<WebCore::KURL> { 54 static const bool emptyValueIsZero = true; 55 static void constructDeletedValue(WebCore::KURL& slot) { new (&slot) WebCore::KURL(WebCore::ParsedURLString, WTF::String(HashTableDeletedValue)); } 56 static bool isDeletedValue(const WebCore::KURL& slot) { return slot.string().isHashTableDeletedValue(); } 57 }; 53 template<> struct HashTraits<WebCore::KURL> : SimpleClassHashTraits<WebCore::KURL> { }; 58 54 59 55 } // namespace WTF -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r81548 r83664 122 122 }; 123 123 124 struct FontPlatformDataCacheKeyTraits : WTF::GenericHashTraits<FontPlatformDataCacheKey> { 125 static const bool emptyValueIsZero = true; 126 static const FontPlatformDataCacheKey& emptyValue() 127 { 128 DEFINE_STATIC_LOCAL(FontPlatformDataCacheKey, key, (nullAtom)); 129 return key; 130 } 131 static void constructDeletedValue(FontPlatformDataCacheKey& slot) 132 { 133 new (&slot) FontPlatformDataCacheKey(HashTableDeletedValue); 134 } 135 static bool isDeletedValue(const FontPlatformDataCacheKey& value) 136 { 137 return value.isHashTableDeletedValue(); 138 } 139 }; 124 struct FontPlatformDataCacheKeyTraits : WTF::SimpleClassHashTraits<FontPlatformDataCacheKey> { }; 140 125 141 126 typedef HashMap<FontPlatformDataCacheKey, FontPlatformData*, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache; -
trunk/Source/WebCore/platform/network/ProtectionSpaceHash.h
r81548 r83664 58 58 namespace WTF { 59 59 60 // WebCore::ProtectionSpaceHash is the default hash for ProtectionSpace 61 template<> struct HashTraits<WebCore::ProtectionSpace> : GenericHashTraits<WebCore::ProtectionSpace> { 62 static const bool emptyValueIsZero = true; 63 static void constructDeletedValue(WebCore::ProtectionSpace& slot) { new (&slot) WebCore::ProtectionSpace(HashTableDeletedValue); } 64 static bool isDeletedValue(const WebCore::ProtectionSpace& slot) { return slot.isHashTableDeletedValue(); } 65 }; 60 template<> struct HashTraits<WebCore::ProtectionSpace> : SimpleClassHashTraits<WebCore::ProtectionSpace> { }; 66 61 67 62 template<typename T> struct DefaultHash; -
trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h
r81548 r83664 81 81 }; 82 82 83 struct SVGAnimatedPropertyDescriptionHashTraits : WTF::GenericHashTraits<SVGAnimatedPropertyDescription> { 84 static const bool emptyValueIsZero = true; 85 86 static void constructDeletedValue(SVGAnimatedPropertyDescription& slot) 87 { 88 new (&slot) SVGAnimatedPropertyDescription(WTF::HashTableDeletedValue); 89 } 90 91 static bool isDeletedValue(const SVGAnimatedPropertyDescription& value) 92 { 93 return value.isHashTableDeletedValue(); 94 } 95 }; 83 struct SVGAnimatedPropertyDescriptionHashTraits : WTF::SimpleClassHashTraits<SVGAnimatedPropertyDescription> { }; 96 84 97 85 }
Note: See TracChangeset
for help on using the changeset viewer.