Title: [107421] trunk/Source/_javascript_Core
Revision
107421
Author
e...@google.com
Date
2012-02-10 11:36:38 -0800 (Fri, 10 Feb 2012)

Log Message

Remove implicit copy constructor usage in HashMaps with OwnPtr
https://bugs.webkit.org/show_bug.cgi?id=78071

Reviewed by Darin Adler.

Change the return type of emptyValue() in PairHashTraits to be the
actual type returned rather than the trait type to avoid an implicit
generation of the OwnPtr copy constructor. This happens for hash
traits involving OwnPtr where the empty value is not zero and each
hash bucket needs to be initialized with emptyValue().

Also, update StructureTransitionTable to use default hash traits
rather than rolling its own, in order to update it to handle
EmptyValueType.

Test: patch from bug 74154 compiles on Clang with this patch

* runtime/StructureTransitionTable.h:
(StructureTransitionTable):
* wtf/HashTraits.h:
(GenericHashTraits):
(PairHashTraits):
(WTF::PairHashTraits::emptyValue):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (107420 => 107421)


--- trunk/Source/_javascript_Core/ChangeLog	2012-02-10 19:33:59 UTC (rev 107420)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-02-10 19:36:38 UTC (rev 107421)
@@ -1,3 +1,29 @@
+2012-02-10  Adrienne Walker  <e...@google.com>
+
+        Remove implicit copy constructor usage in HashMaps with OwnPtr
+        https://bugs.webkit.org/show_bug.cgi?id=78071
+
+        Reviewed by Darin Adler.
+
+        Change the return type of emptyValue() in PairHashTraits to be the
+        actual type returned rather than the trait type to avoid an implicit
+        generation of the OwnPtr copy constructor. This happens for hash
+        traits involving OwnPtr where the empty value is not zero and each
+        hash bucket needs to be initialized with emptyValue().
+
+        Also, update StructureTransitionTable to use default hash traits
+        rather than rolling its own, in order to update it to handle
+        EmptyValueType.
+
+        Test: patch from bug 74154 compiles on Clang with this patch
+
+        * runtime/StructureTransitionTable.h:
+        (StructureTransitionTable):
+        * wtf/HashTraits.h:
+        (GenericHashTraits):
+        (PairHashTraits):
+        (WTF::PairHashTraits::emptyValue):
+
 2012-02-10  Aron Rosenberg  <arosenb...@logitech.com>
 
         [Qt] Fix compiler warning in Visual Studio 2010 about TR1

Modified: trunk/Source/_javascript_Core/runtime/StructureTransitionTable.h (107420 => 107421)


--- trunk/Source/_javascript_Core/runtime/StructureTransitionTable.h	2012-02-10 19:33:59 UTC (rev 107420)
+++ trunk/Source/_javascript_Core/runtime/StructureTransitionTable.h	2012-02-10 19:36:38 UTC (rev 107421)
@@ -29,7 +29,6 @@
 #include "UString.h"
 #include "WeakGCMap.h"
 #include <wtf/HashFunctions.h>
-#include <wtf/HashTraits.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
 
@@ -55,22 +54,6 @@
         static const bool safeToCompareToEmptyOrDeleted = true;
     };
 
-    struct HashTraits {
-        typedef WTF::HashTraits<RefPtr<StringImpl> > FirstTraits;
-        typedef WTF::GenericHashTraits<unsigned> SecondTraits;
-        typedef std::pair<FirstTraits::TraitType, SecondTraits::TraitType > TraitType;
-
-        static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero;
-        static TraitType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); }
-
-        static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction;
-
-        static const int minimumTableSize = FirstTraits::minimumTableSize;
-
-        static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); }
-        static bool isDeletedValue(const TraitType& value) { return FirstTraits::isDeletedValue(value.first); }
-    };
-
     struct WeakGCMapFinalizerCallback {
         static void* finalizerContextFor(Hash::Key)
         {
@@ -83,7 +66,7 @@
         }
     };
 
-    typedef WeakGCMap<Hash::Key, Structure, WeakGCMapFinalizerCallback, Hash, HashTraits> TransitionMap;
+    typedef WeakGCMap<Hash::Key, Structure, WeakGCMapFinalizerCallback, Hash> TransitionMap;
 
     static Hash::Key keyForWeakGCMapFinalizer(void* context, Structure*);
 

Modified: trunk/Source/_javascript_Core/wtf/HashTraits.h (107420 => 107421)


--- trunk/Source/_javascript_Core/wtf/HashTraits.h	2012-02-10 19:33:59 UTC (rev 107420)
+++ trunk/Source/_javascript_Core/wtf/HashTraits.h	2012-02-10 19:36:38 UTC (rev 107421)
@@ -57,6 +57,7 @@
 
     template<typename T> struct GenericHashTraits : GenericHashTraitsBase<IsInteger<T>::value, T> {
         typedef T TraitType;
+        typedef T EmptyValueType;
 
         static T emptyValue() { return T(); }
 
@@ -112,8 +113,10 @@
     };
 
     template<typename P> struct HashTraits<OwnPtr<P> > : SimpleClassHashTraits<OwnPtr<P> > {
-        static std::nullptr_t emptyValue() { return nullptr; }
+        typedef std::nullptr_t EmptyValueType;
 
+        static EmptyValueType emptyValue() { return nullptr; }
+
         typedef PassOwnPtr<P> PassInType;
         static void store(PassOwnPtr<P> value, OwnPtr<P>& storage) { storage = value; }
 
@@ -144,9 +147,10 @@
         typedef FirstTraitsArg FirstTraits;
         typedef SecondTraitsArg SecondTraits;
         typedef pair<typename FirstTraits::TraitType, typename SecondTraits::TraitType> TraitType;
+        typedef pair<typename FirstTraits::EmptyValueType, typename SecondTraits::EmptyValueType> EmptyValueType;
 
         static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero;
-        static TraitType emptyValue() { return make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); }
+        static EmptyValueType emptyValue() { return make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); }
 
         static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to