Commit 1895f48b authored by andersca@apple.com's avatar andersca@apple.com

RefPtrHashMap should work with move only types

https://bugs.webkit.org/show_bug.cgi?id=121564

Reviewed by Andreas Kling.

Source/JavaScriptCore:

* 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:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156056 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c249e787
2013-09-18 Anders Carlsson <andersca@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 <mhahnenberg@apple.com>
Rename OperationInProgress to HeapOperation and move it out of Heap.h into its own header
......
......@@ -492,7 +492,7 @@ void VM::dumpSampleData(ExecState* exec)
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();
......
2013-09-18 Anders Carlsson <andersca@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 <fpizlo@apple.com>
DFG should support Int52 for local variables
......
......@@ -87,14 +87,14 @@ namespace WTF {
// 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,8 +105,11 @@ namespace WTF {
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 @@ namespace WTF {
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>
......
2013-09-18 Anders Carlsson <andersca@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 <enrica@apple.com>
Upstream changes to WebHTMLConverter to support HTML
......@@ -92,7 +92,7 @@ IdentifierRep* IdentifierRep::get(const char* name)
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);
......
......@@ -265,7 +265,7 @@ StorageNamespace* PageGroup::localStorage()
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);
......
2013-09-18 Anders Carlsson <andersca@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 <enrica@apple.com>
Remove unused function didSetSelectionTypesForPasteboard from EditorClient.
......
......@@ -374,7 +374,7 @@ Method* ProxyInstance::methodNamed(PropertyName propertyName)
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 @@ Field* ProxyInstance::fieldNamed(PropertyName propertyName)
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;
......
2013-09-18 Anders Carlsson <andersca@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 <cgarcia@igalia.com>
[GTK] WebKitScriptWorld not in API documentation
......
......@@ -268,7 +268,7 @@ StorageManager::LocalStorageNamespace::~LocalStorageNamespace()
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 @@ void StorageManager::SessionStorageNamespace::setAllowedConnection(CoreIPC::Conn
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);
......
......@@ -85,7 +85,7 @@ StorageNamespaceImpl::~StorageNamespaceImpl()
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment