Title: [156056] trunk/Source
Revision
156056
Author
ander...@apple.com
Date
2013-09-18 12:51:28 -0700 (Wed, 18 Sep 2013)

Log Message

RefPtrHashMap should work with move only types
https://bugs.webkit.org/show_bug.cgi?id=121564

Reviewed by Andreas Kling.

Source/_javascript_Core:

* runtime/VM.cpp:
(JSC::VM::addSourceProviderCache):

Source/WebCore:

* bridge/IdentifierRep.cpp:
(WebCore::IdentifierRep::get):
* page/PageGroup.cpp:
(WebCore::PageGroup::transientLocalStorage):

Source/WebKit/mac:

* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::methodNamed):
(WebKit::ProxyInstance::fieldNamed):

Source/WebKit2:

* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::LocalStorageNamespace::getOrCreateStorageArea):
(WebKit::StorageManager::SessionStorageNamespace::getOrCreateStorageArea):
* WebProcess/Storage/StorageNamespaceImpl.cpp:
(WebKit::StorageNamespaceImpl::storageArea):

Source/WTF:

Add the same rvalue references and std::forward calls that already exist in HashMap.

* wtf/RefPtrHashMap.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (156055 => 156056)


--- trunk/Source/_javascript_Core/ChangeLog	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-09-18 19:51:28 UTC (rev 156056)
@@ -1,3 +1,13 @@
+2013-09-18  Anders Carlsson  <ander...@apple.com>
+
+        RefPtrHashMap should work with move only types
+        https://bugs.webkit.org/show_bug.cgi?id=121564
+
+        Reviewed by Andreas Kling.
+
+        * runtime/VM.cpp:
+        (JSC::VM::addSourceProviderCache):
+
 2013-09-17  Mark Hahnenberg  <mhahnenb...@apple.com>
 
         Rename OperationInProgress to HeapOperation and move it out of Heap.h into its own header

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (156055 => 156056)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2013-09-18 19:51:28 UTC (rev 156056)
@@ -492,7 +492,7 @@
 
 SourceProviderCache* VM::addSourceProviderCache(SourceProvider* sourceProvider)
 {
-    SourceProviderCacheMap::AddResult addResult = sourceProviderCacheMap.add(sourceProvider, 0);
+    auto addResult = sourceProviderCacheMap.add(sourceProvider, nullptr);
     if (addResult.isNewEntry)
         addResult.iterator->value = adoptRef(new SourceProviderCache);
     return addResult.iterator->value.get();

Modified: trunk/Source/WTF/ChangeLog (156055 => 156056)


--- trunk/Source/WTF/ChangeLog	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WTF/ChangeLog	2013-09-18 19:51:28 UTC (rev 156056)
@@ -1,3 +1,14 @@
+2013-09-18  Anders Carlsson  <ander...@apple.com>
+
+        RefPtrHashMap should work with move only types
+        https://bugs.webkit.org/show_bug.cgi?id=121564
+
+        Reviewed by Andreas Kling.
+
+        Add the same rvalue references and std::forward calls that already exist in HashMap.
+
+        * wtf/RefPtrHashMap.h:
+
 2013-09-18  Filip Pizlo  <fpi...@apple.com>
 
         DFG should support Int52 for local variables

Modified: trunk/Source/WTF/wtf/RefPtrHashMap.h (156055 => 156056)


--- trunk/Source/WTF/wtf/RefPtrHashMap.h	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WTF/wtf/RefPtrHashMap.h	2013-09-18 19:51:28 UTC (rev 156056)
@@ -87,14 +87,14 @@
         // replaces value but not key if key is already present
         // return value is a pair of the iterator to the key location, 
         // and a boolean that's true if a new value was actually added
-        AddResult set(const KeyType&, MappedPassInType);
-        AddResult set(RawKeyType, MappedPassInType);
+        template<typename V> AddResult set(const KeyType&, V&&);
+        template<typename V> AddResult set(RawKeyType, V&&);
 
         // does nothing if key is already present
         // return value is a pair of the iterator to the key location, 
         // and a boolean that's true if a new value was actually added
-        AddResult add(const KeyType&, MappedPassInType);
-        AddResult add(RawKeyType, MappedPassInType);
+        template<typename V> AddResult add(const KeyType&, V&&);
+        template<typename V> AddResult add(RawKeyType, V&&);
 
         bool remove(const KeyType&);
         bool remove(RawKeyType);
@@ -105,9 +105,12 @@
         MappedPassOutType take(RawKeyType); // efficient combination of get with remove
 
     private:
-        AddResult inlineAdd(const KeyType&, MappedPassInReferenceType);
-        AddResult inlineAdd(RawKeyType, MappedPassInReferenceType);
+        template<typename V>
+        AddResult inlineAdd(const KeyType&, V&&);
 
+        template<typename V>
+        AddResult inlineAdd(RawKeyType, V&&);
+
         HashTableType m_impl;
     };
     
@@ -195,56 +198,56 @@
         return m_impl.template contains<Translator>(key);
     }
 
-    template<typename T, typename U, typename V, typename W, typename X>
-    inline typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
-    HashMap<RefPtr<T>, U, V, W, X>::inlineAdd(const KeyType& key, MappedPassInReferenceType mapped) 
+    template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg>
+    template<typename V>
+    auto HashMap<RefPtr<KeyArg>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>::inlineAdd(const KeyType& key, V&& mapped) -> AddResult
     {
-        return m_impl.template add<Translator>(key, mapped);
+        return m_impl.template add<Translator>(key, std::forward<V>(mapped));
     }
 
-    template<typename T, typename U, typename V, typename W, typename X>
-    inline typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
-    HashMap<RefPtr<T>, U, V, W, X>::inlineAdd(RawKeyType key, MappedPassInReferenceType mapped) 
+    template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg>
+    template<typename V>
+    auto HashMap<RefPtr<KeyArg>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>::inlineAdd(RawKeyType key, V&& mapped) -> AddResult
     {
-        return m_impl.template add<Translator>(key, mapped);
+        return m_impl.template add<Translator>(key, std::forward<V>(mapped));
     }
 
-    template<typename T, typename U, typename V, typename W, typename X>
-    typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
-    HashMap<RefPtr<T>, U, V, W, X>::set(const KeyType& key, MappedPassInType mapped) 
+    template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg>
+    template<typename V>
+    auto HashMap<RefPtr<KeyArg>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>::set(const KeyType& key, V&& value) -> AddResult
     {
-        AddResult result = inlineAdd(key, mapped);
+        AddResult result = inlineAdd(key, std::forward<V>(value));
         if (!result.isNewEntry) {
             // The inlineAdd call above found an existing hash table entry; we need to set the mapped value.
-            MappedTraits::store(mapped, result.iterator->value);
+            result.iterator->value = std::forward<V>(value);
         }
         return result;
     }
 
-    template<typename T, typename U, typename V, typename W, typename X>
-    typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
-    HashMap<RefPtr<T>, U, V, W, X>::set(RawKeyType key, MappedPassInType mapped) 
+    template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg>
+    template<typename V>
+    auto HashMap<RefPtr<KeyArg>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>::set(RawKeyType key, V&& value) -> AddResult
     {
-        AddResult result = inlineAdd(key, mapped);
+        AddResult result = inlineAdd(key, value);
         if (!result.isNewEntry) {
             // The inlineAdd call above found an existing hash table entry; we need to set the mapped value.
-            MappedTraits::store(mapped, result.iterator->value);
+            result.iterator->value = std::forward<V>(value);
         }
         return result;
     }
 
-    template<typename T, typename U, typename V, typename W, typename X>
-    typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
-    HashMap<RefPtr<T>, U, V, W, X>::add(const KeyType& key, MappedPassInType mapped)
+    template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg>
+    template<typename V>
+    auto HashMap<RefPtr<KeyArg>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>::add(const KeyType& key, V&& value) -> AddResult
     {
-        return inlineAdd(key, mapped);
+        return inlineAdd(key, std::forward<V>(value));
     }
 
-    template<typename T, typename U, typename V, typename W, typename X>
-    typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
-    HashMap<RefPtr<T>, U, V, W, X>::add(RawKeyType key, MappedPassInType mapped)
+    template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg>
+    template<typename V>
+    auto HashMap<RefPtr<KeyArg>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>::add(RawKeyType key, V&& value) -> AddResult
     {
-        return inlineAdd(key, mapped);
+        return inlineAdd(key, std::forward<V>(value));
     }
 
     template<typename T, typename U, typename V, typename W, typename MappedTraits>

Modified: trunk/Source/WebCore/ChangeLog (156055 => 156056)


--- trunk/Source/WebCore/ChangeLog	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WebCore/ChangeLog	2013-09-18 19:51:28 UTC (rev 156056)
@@ -1,3 +1,15 @@
+2013-09-18  Anders Carlsson  <ander...@apple.com>
+
+        RefPtrHashMap should work with move only types
+        https://bugs.webkit.org/show_bug.cgi?id=121564
+
+        Reviewed by Andreas Kling.
+
+        * bridge/IdentifierRep.cpp:
+        (WebCore::IdentifierRep::get):
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::transientLocalStorage):
+
 2013-09-18  Enrica Casucci  <enr...@apple.com>
 
         Upstream changes to WebHTMLConverter to support HTML

Modified: trunk/Source/WebCore/bridge/IdentifierRep.cpp (156055 => 156056)


--- trunk/Source/WebCore/bridge/IdentifierRep.cpp	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WebCore/bridge/IdentifierRep.cpp	2013-09-18 19:51:28 UTC (rev 156056)
@@ -92,7 +92,7 @@
         return 0;
   
     String string = String::fromUTF8WithLatin1Fallback(name, strlen(name));
-    StringIdentifierMap::AddResult result = stringIdentifierMap().add(string.impl(), 0);
+    StringIdentifierMap::AddResult result = stringIdentifierMap().add(string.impl(), nullptr);
     if (result.isNewEntry) {
         ASSERT(!result.iterator->value);
         result.iterator->value = new IdentifierRep(name);

Modified: trunk/Source/WebCore/page/PageGroup.cpp (156055 => 156056)


--- trunk/Source/WebCore/page/PageGroup.cpp	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WebCore/page/PageGroup.cpp	2013-09-18 19:51:28 UTC (rev 156056)
@@ -265,7 +265,7 @@
 
 StorageNamespace* PageGroup::transientLocalStorage(SecurityOrigin* topOrigin)
 {
-    HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageNamespace> >::AddResult result = m_transientLocalStorageMap.add(topOrigin, 0);
+    auto result = m_transientLocalStorageMap.add(topOrigin, nullptr);
 
     if (result.isNewEntry)
         result.iterator->value = StorageNamespace::transientLocalStorageNamespace(this, topOrigin);

Modified: trunk/Source/WebKit/mac/ChangeLog (156055 => 156056)


--- trunk/Source/WebKit/mac/ChangeLog	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-09-18 19:51:28 UTC (rev 156056)
@@ -1,3 +1,14 @@
+2013-09-18  Anders Carlsson  <ander...@apple.com>
+
+        RefPtrHashMap should work with move only types
+        https://bugs.webkit.org/show_bug.cgi?id=121564
+
+        Reviewed by Andreas Kling.
+
+        * Plugins/Hosted/ProxyInstance.mm:
+        (WebKit::ProxyInstance::methodNamed):
+        (WebKit::ProxyInstance::fieldNamed):
+
 2013-09-16  Enrica Casucci  <enr...@apple.com>
 
         Remove unused function didSetSelectionTypesForPasteboard from EditorClient.

Modified: trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm (156055 => 156056)


--- trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm	2013-09-18 19:51:28 UTC (rev 156056)
@@ -374,7 +374,7 @@
         return 0;
 
     // Add a new entry to the map unless an entry was added while we were in waitForReply.
-    auto mapAddResult = m_methods.add(name.impl(), 0);
+    auto mapAddResult = m_methods.add(name.impl(), nullptr);
     if (mapAddResult.isNewEntry && reply->m_result)
         mapAddResult.iterator->value = new ProxyMethod(methodName);
 
@@ -411,7 +411,7 @@
         return 0;
     
     // Add a new entry to the map unless an entry was added while we were in waitForReply.
-    auto mapAddResult = m_fields.add(name.impl(), 0);
+    auto mapAddResult = m_fields.add(name.impl(), nullptr);
     if (mapAddResult.isNewEntry && reply->m_result)
         mapAddResult.iterator->value = new ProxyField(identifier);
     return mapAddResult.iterator->value;

Modified: trunk/Source/WebKit2/ChangeLog (156055 => 156056)


--- trunk/Source/WebKit2/ChangeLog	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WebKit2/ChangeLog	2013-09-18 19:51:28 UTC (rev 156056)
@@ -1,3 +1,16 @@
+2013-09-18  Anders Carlsson  <ander...@apple.com>
+
+        RefPtrHashMap should work with move only types
+        https://bugs.webkit.org/show_bug.cgi?id=121564
+
+        Reviewed by Andreas Kling.
+
+        * UIProcess/Storage/StorageManager.cpp:
+        (WebKit::StorageManager::LocalStorageNamespace::getOrCreateStorageArea):
+        (WebKit::StorageManager::SessionStorageNamespace::getOrCreateStorageArea):
+        * WebProcess/Storage/StorageNamespaceImpl.cpp:
+        (WebKit::StorageNamespaceImpl::storageArea):
+
 2013-09-18  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] WebKitScriptWorld not in API documentation

Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (156055 => 156056)


--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp	2013-09-18 19:51:28 UTC (rev 156056)
@@ -268,7 +268,7 @@
 
 PassRefPtr<StorageManager::StorageArea> StorageManager::LocalStorageNamespace::getOrCreateStorageArea(PassRefPtr<SecurityOrigin> securityOrigin)
 {
-    HashMap<RefPtr<SecurityOrigin>, StorageArea*>::AddResult result = m_storageAreaMap.add(securityOrigin, 0);
+    auto result = m_storageAreaMap.add(securityOrigin, nullptr);
     if (!result.isNewEntry)
         return result.iterator->value;
 
@@ -351,7 +351,7 @@
 
 PassRefPtr<StorageManager::StorageArea> StorageManager::SessionStorageNamespace::getOrCreateStorageArea(PassRefPtr<SecurityOrigin> securityOrigin)
 {
-    HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageArea>>::AddResult result = m_storageAreaMap.add(securityOrigin, 0);
+    auto result = m_storageAreaMap.add(securityOrigin, nullptr);
     if (result.isNewEntry)
         result.iterator->value = StorageArea::create(0, result.iterator->key, m_quotaInBytes);
 

Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp (156055 => 156056)


--- trunk/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp	2013-09-18 19:13:18 UTC (rev 156055)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp	2013-09-18 19:51:28 UTC (rev 156056)
@@ -85,7 +85,7 @@
 
 PassRefPtr<StorageArea> StorageNamespaceImpl::storageArea(PassRefPtr<SecurityOrigin> securityOrigin)
 {
-    HashMap<RefPtr<WebCore::SecurityOrigin>, RefPtr<StorageAreaMap>>::AddResult result = m_storageAreaMaps.add(securityOrigin.get(), 0);
+    auto result = m_storageAreaMaps.add(securityOrigin.get(), nullptr);
     if (result.isNewEntry)
         result.iterator->value = StorageAreaMap::create(this, securityOrigin);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to