Title: [156492] trunk/Source
Revision
156492
Author
[email protected]
Date
2013-09-26 13:44:02 -0700 (Thu, 26 Sep 2013)

Log Message

Change a couple of HashMap value types from OwnPtr to std::unique_ptr
https://bugs.webkit.org/show_bug.cgi?id=121973

Reviewed by Andreas Kling.

Source/_javascript_Core:

* API/JSClassRef.cpp:
(OpaqueJSClassContextData::OpaqueJSClassContextData):
(OpaqueJSClass::contextData):
* API/JSClassRef.h:
* bytecode/SamplingTool.h:
* ftl/FTLAbstractHeap.h:
* parser/Parser.cpp:
(JSC::::parseFunctionInfo):
* parser/SourceProviderCache.cpp:
(JSC::SourceProviderCache::add):
* parser/SourceProviderCache.h:
* parser/SourceProviderCacheItem.h:
(JSC::SourceProviderCacheItem::create):
* profiler/ProfilerCompilation.cpp:
(JSC::Profiler::Compilation::executionCounterFor):
(JSC::Profiler::Compilation::toJS):
* profiler/ProfilerCompilation.h:
* runtime/JSGlobalObject.h:

Source/WTF:

* wtf/RefPtrHashMap.h:
Add a missing std::forward.

* wtf/StdLibExtras.h:
(std::make_unique):
Add more overloads.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSClassRef.cpp (156491 => 156492)


--- trunk/Source/_javascript_Core/API/JSClassRef.cpp	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/API/JSClassRef.cpp	2013-09-26 20:44:02 UTC (rev 156492)
@@ -66,7 +66,7 @@
         while (staticValue->name) {
             String valueName = String::fromUTF8(staticValue->name);
             if (!valueName.isNull())
-                m_staticValues->set(valueName.impl(), adoptPtr(new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes, valueName)));
+                m_staticValues->set(valueName.impl(), std::make_unique<StaticValueEntry>(staticValue->getProperty, staticValue->setProperty, staticValue->attributes, valueName));
             ++staticValue;
         }
     }
@@ -76,7 +76,7 @@
         while (staticFunction->name) {
             String functionName = String::fromUTF8(staticFunction->name);
             if (!functionName.isNull())
-                m_staticFunctions->set(functionName.impl(), adoptPtr(new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes)));
+                m_staticFunctions->set(functionName.impl(), std::make_unique<StaticFunctionEntry>(staticFunction->callAsFunction, staticFunction->attributes));
             ++staticFunction;
         }
     }
@@ -131,30 +131,30 @@
     : m_class(jsClass)
 {
     if (jsClass->m_staticValues) {
-        staticValues = adoptPtr(new OpaqueJSClassStaticValuesTable);
+        staticValues = std::make_unique<OpaqueJSClassStaticValuesTable>();
         OpaqueJSClassStaticValuesTable::const_iterator end = jsClass->m_staticValues->end();
         for (OpaqueJSClassStaticValuesTable::const_iterator it = jsClass->m_staticValues->begin(); it != end; ++it) {
             ASSERT(!it->key->isIdentifier());
             String valueName = it->key->isolatedCopy();
-            staticValues->add(valueName.impl(), adoptPtr(new StaticValueEntry(it->value->getProperty, it->value->setProperty, it->value->attributes, valueName)));
+            staticValues->add(valueName.impl(), std::make_unique<StaticValueEntry>(it->value->getProperty, it->value->setProperty, it->value->attributes, valueName));
         }
     }
 
     if (jsClass->m_staticFunctions) {
-        staticFunctions = adoptPtr(new OpaqueJSClassStaticFunctionsTable);
+        staticFunctions = std::make_unique<OpaqueJSClassStaticFunctionsTable>();
         OpaqueJSClassStaticFunctionsTable::const_iterator end = jsClass->m_staticFunctions->end();
         for (OpaqueJSClassStaticFunctionsTable::const_iterator it = jsClass->m_staticFunctions->begin(); it != end; ++it) {
             ASSERT(!it->key->isIdentifier());
-            staticFunctions->add(it->key->isolatedCopy(), adoptPtr(new StaticFunctionEntry(it->value->callAsFunction, it->value->attributes)));
+            staticFunctions->add(it->key->isolatedCopy(), std::make_unique<StaticFunctionEntry>(it->value->callAsFunction, it->value->attributes));
         }
     }
 }
 
 OpaqueJSClassContextData& OpaqueJSClass::contextData(ExecState* exec)
 {
-    OwnPtr<OpaqueJSClassContextData>& contextData = exec->lexicalGlobalObject()->opaqueJSClassData().add(this, nullptr).iterator->value;
+    std::unique_ptr<OpaqueJSClassContextData>& contextData = exec->lexicalGlobalObject()->opaqueJSClassData().add(this, nullptr).iterator->value;
     if (!contextData)
-        contextData = adoptPtr(new OpaqueJSClassContextData(exec->vm(), this));
+        contextData = std::make_unique<OpaqueJSClassContextData>(exec->vm(), this);
     return *contextData;
 }
 

Modified: trunk/Source/_javascript_Core/API/JSClassRef.h (156491 => 156492)


--- trunk/Source/_javascript_Core/API/JSClassRef.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/API/JSClassRef.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -59,8 +59,8 @@
     JSPropertyAttributes attributes;
 };
 
-typedef HashMap<RefPtr<StringImpl>, OwnPtr<StaticValueEntry> > OpaqueJSClassStaticValuesTable;
-typedef HashMap<RefPtr<StringImpl>, OwnPtr<StaticFunctionEntry> > OpaqueJSClassStaticFunctionsTable;
+typedef HashMap<RefPtr<StringImpl>, std::unique_ptr<StaticValueEntry>> OpaqueJSClassStaticValuesTable;
+typedef HashMap<RefPtr<StringImpl>, std::unique_ptr<StaticFunctionEntry>> OpaqueJSClassStaticFunctionsTable;
 
 struct OpaqueJSClass;
 
@@ -79,8 +79,8 @@
     // 4. When it is used, the old context data is found in VM and used.
     RefPtr<OpaqueJSClass> m_class;
 
-    OwnPtr<OpaqueJSClassStaticValuesTable> staticValues;
-    OwnPtr<OpaqueJSClassStaticFunctionsTable> staticFunctions;
+    std::unique_ptr<OpaqueJSClassStaticValuesTable> staticValues;
+    std::unique_ptr<OpaqueJSClassStaticFunctionsTable> staticFunctions;
     JSC::Weak<JSC::JSObject> cachedPrototype;
 };
 

Modified: trunk/Source/_javascript_Core/ChangeLog (156491 => 156492)


--- trunk/Source/_javascript_Core/ChangeLog	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-09-26 20:44:02 UTC (rev 156492)
@@ -1,3 +1,29 @@
+2013-09-26  Anders Carlsson  <[email protected]>
+
+        Change a couple of HashMap value types from OwnPtr to std::unique_ptr
+        https://bugs.webkit.org/show_bug.cgi?id=121973
+
+        Reviewed by Andreas Kling.
+
+        * API/JSClassRef.cpp:
+        (OpaqueJSClassContextData::OpaqueJSClassContextData):
+        (OpaqueJSClass::contextData):
+        * API/JSClassRef.h:
+        * bytecode/SamplingTool.h:
+        * ftl/FTLAbstractHeap.h:
+        * parser/Parser.cpp:
+        (JSC::::parseFunctionInfo):
+        * parser/SourceProviderCache.cpp:
+        (JSC::SourceProviderCache::add):
+        * parser/SourceProviderCache.h:
+        * parser/SourceProviderCacheItem.h:
+        (JSC::SourceProviderCacheItem::create):
+        * profiler/ProfilerCompilation.cpp:
+        (JSC::Profiler::Compilation::executionCounterFor):
+        (JSC::Profiler::Compilation::toJS):
+        * profiler/ProfilerCompilation.h:
+        * runtime/JSGlobalObject.h:
+
 2013-09-26  Mark Lam  <[email protected]>
 
         Move DFG inline caching logic into jit/.

Modified: trunk/Source/_javascript_Core/bytecode/SamplingTool.h (156491 => 156492)


--- trunk/Source/_javascript_Core/bytecode/SamplingTool.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/bytecode/SamplingTool.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -211,7 +211,7 @@
         unsigned m_size;
     };
 
-    typedef HashMap<ScriptExecutable*, OwnPtr<ScriptSampleRecord> > ScriptSampleRecordMap;
+    typedef HashMap<ScriptExecutable*, std::unique_ptr<ScriptSampleRecord>> ScriptSampleRecordMap;
 
     class SamplingThread {
     public:

Modified: trunk/Source/_javascript_Core/ftl/FTLAbstractHeap.h (156491 => 156492)


--- trunk/Source/_javascript_Core/ftl/FTLAbstractHeap.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/ftl/FTLAbstractHeap.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -177,7 +177,7 @@
         static void constructDeletedValue(ptrdiff_t& slot) { slot = 1; }
         static bool isDeletedValue(ptrdiff_t value) { return value == 1; }
     };
-    typedef HashMap<ptrdiff_t, OwnPtr<AbstractField>, WTF::IntHash<ptrdiff_t>, WithoutZeroOrOneHashTraits> MapType;
+    typedef HashMap<ptrdiff_t, std::unique_ptr<AbstractField>, WTF::IntHash<ptrdiff_t>, WithoutZeroOrOneHashTraits> MapType;
     
     OwnPtr<MapType> m_largeIndices;
     Vector<CString, 16> m_largeIndexNames;

Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (156491 => 156492)


--- trunk/Source/_javascript_Core/parser/Parser.cpp	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp	2013-09-26 20:44:02 UTC (rev 156492)
@@ -995,7 +995,7 @@
     // Cache the tokenizer state and the function scope the first time the function is parsed.
     // Any future reparsing can then skip the function.
     static const int minimumFunctionLengthToCache = 16;
-    OwnPtr<SourceProviderCacheItem> newInfo;
+    std::unique_ptr<SourceProviderCacheItem> newInfo;
     int functionLength = closeBraceOffset - openBraceOffset;
     if (TreeBuilder::CanUseFunctionCache && m_functionCache && functionLength > minimumFunctionLengthToCache) {
         SourceProviderCacheItemCreationParameters parameters;
@@ -1013,7 +1013,7 @@
     matchOrFail(CLOSEBRACE);
     
     if (newInfo)
-        m_functionCache->add(openBraceOffset, newInfo.release());
+        m_functionCache->add(openBraceOffset, std::move(newInfo));
     
     next();
     return true;

Modified: trunk/Source/_javascript_Core/parser/SourceProviderCache.cpp (156491 => 156492)


--- trunk/Source/_javascript_Core/parser/SourceProviderCache.cpp	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/parser/SourceProviderCache.cpp	2013-09-26 20:44:02 UTC (rev 156492)
@@ -38,9 +38,9 @@
     m_map.clear();
 }
 
-void SourceProviderCache::add(int sourcePosition, PassOwnPtr<SourceProviderCacheItem> item)
+void SourceProviderCache::add(int sourcePosition, std::unique_ptr<SourceProviderCacheItem> item)
 {
-    m_map.add(sourcePosition, item);
+    m_map.add(sourcePosition, std::move(item));
 }
 
 }

Modified: trunk/Source/_javascript_Core/parser/SourceProviderCache.h (156491 => 156492)


--- trunk/Source/_javascript_Core/parser/SourceProviderCache.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/parser/SourceProviderCache.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -41,11 +41,11 @@
     JS_EXPORT_PRIVATE ~SourceProviderCache();
 
     JS_EXPORT_PRIVATE void clear();
-    void add(int sourcePosition, PassOwnPtr<SourceProviderCacheItem>);
+    void add(int sourcePosition, std::unique_ptr<SourceProviderCacheItem>);
     const SourceProviderCacheItem* get(int sourcePosition) const { return m_map.get(sourcePosition); }
 
 private:
-    HashMap<int, OwnPtr<SourceProviderCacheItem> > m_map;
+    HashMap<int, std::unique_ptr<SourceProviderCacheItem>> m_map;
 };
 
 }

Modified: trunk/Source/_javascript_Core/parser/SourceProviderCacheItem.h (156491 => 156492)


--- trunk/Source/_javascript_Core/parser/SourceProviderCacheItem.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/parser/SourceProviderCacheItem.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -53,7 +53,7 @@
 class SourceProviderCacheItem {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassOwnPtr<SourceProviderCacheItem> create(const SourceProviderCacheItemCreationParameters&);
+    static std::unique_ptr<SourceProviderCacheItem> create(const SourceProviderCacheItemCreationParameters&);
     ~SourceProviderCacheItem();
 
     JSToken closeBraceToken() const 
@@ -98,12 +98,12 @@
         m_variables[i]->deref();
 }
 
-inline PassOwnPtr<SourceProviderCacheItem> SourceProviderCacheItem::create(const SourceProviderCacheItemCreationParameters& parameters)
+inline std::unique_ptr<SourceProviderCacheItem> SourceProviderCacheItem::create(const SourceProviderCacheItemCreationParameters& parameters)
 {
     size_t variableCount = parameters.writtenVariables.size() + parameters.usedVariables.size();
     size_t objectSize = sizeof(SourceProviderCacheItem) + sizeof(StringImpl*) * variableCount;
     void* slot = fastMalloc(objectSize);
-    return adoptPtr(new (slot) SourceProviderCacheItem(parameters));
+    return std::unique_ptr<SourceProviderCacheItem>(new (slot) SourceProviderCacheItem(parameters));
 }
 
 inline SourceProviderCacheItem::SourceProviderCacheItem(const SourceProviderCacheItemCreationParameters& parameters)

Modified: trunk/Source/_javascript_Core/profiler/ProfilerCompilation.cpp (156491 => 156492)


--- trunk/Source/_javascript_Core/profiler/ProfilerCompilation.cpp	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/profiler/ProfilerCompilation.cpp	2013-09-26 20:44:02 UTC (rev 156492)
@@ -69,14 +69,11 @@
 
 ExecutionCounter* Compilation::executionCounterFor(const OriginStack& origin)
 {
-    HashMap<OriginStack, OwnPtr<ExecutionCounter> >::iterator iter = m_counters.find(origin);
-    if (iter != m_counters.end())
-        return iter->value.get();
-    
-    OwnPtr<ExecutionCounter> counter = adoptPtr(new ExecutionCounter());
-    ExecutionCounter* result = counter.get();
-    m_counters.add(origin, counter.release());
-    return result;
+    std::unique_ptr<ExecutionCounter>& counter = m_counters.add(origin, nullptr).iterator->value;
+    if (!counter)
+        counter = std::make_unique<ExecutionCounter>();
+
+    return counter.get();
 }
 
 void Compilation::addOSRExitSite(const Vector<const void*>& codeAddresses)
@@ -108,11 +105,10 @@
     result->putDirect(exec->vm(), exec->propertyNames().descriptions, descriptions);
     
     JSArray* counters = constructEmptyArray(exec, 0);
-    HashMap<OriginStack, OwnPtr<ExecutionCounter> >::const_iterator end = m_counters.end();
-    for (HashMap<OriginStack, OwnPtr<ExecutionCounter> >::const_iterator iter = m_counters.begin(); iter != end; ++iter) {
+    for (auto it = m_counters.begin(), end = m_counters.end(); it != end; ++it) {
         JSObject* counterEntry = constructEmptyObject(exec);
-        counterEntry->putDirect(exec->vm(), exec->propertyNames().origin, iter->key.toJS(exec));
-        counterEntry->putDirect(exec->vm(), exec->propertyNames().executionCount, jsNumber(iter->value->count()));
+        counterEntry->putDirect(exec->vm(), exec->propertyNames().origin, it->key.toJS(exec));
+        counterEntry->putDirect(exec->vm(), exec->propertyNames().executionCount, jsNumber(it->value->count()));
         counters->push(exec, counterEntry);
     }
     result->putDirect(exec->vm(), exec->propertyNames().counters, counters);

Modified: trunk/Source/_javascript_Core/profiler/ProfilerCompilation.h (156491 => 156492)


--- trunk/Source/_javascript_Core/profiler/ProfilerCompilation.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/profiler/ProfilerCompilation.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -74,7 +74,7 @@
     CompilationKind m_kind;
     Vector<ProfiledBytecodes> m_profiledBytecodes;
     Vector<CompiledBytecode> m_descriptions;
-    HashMap<OriginStack, OwnPtr<ExecutionCounter> > m_counters;
+    HashMap<OriginStack, std::unique_ptr<ExecutionCounter>> m_counters;
     Vector<OSRExitSite> m_osrExitSites;
     SegmentedVector<OSRExit> m_osrExits;
     unsigned m_numInlinedGetByIds;

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (156491 => 156492)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -123,8 +123,8 @@
 
 class JSGlobalObject : public JSSegmentedVariableObject {
 private:
-    typedef HashSet<RefPtr<OpaqueJSWeakObjectMap> > WeakMapSet;
-    typedef HashMap<OpaqueJSClass*, OwnPtr<OpaqueJSClassContextData> > OpaqueJSClassDataMap;
+    typedef HashSet<RefPtr<OpaqueJSWeakObjectMap>> WeakMapSet;
+    typedef HashMap<OpaqueJSClass*, std::unique_ptr<OpaqueJSClassContextData>> OpaqueJSClassDataMap;
 
     struct JSGlobalObjectRareData {
         JSGlobalObjectRareData()

Modified: trunk/Source/WTF/ChangeLog (156491 => 156492)


--- trunk/Source/WTF/ChangeLog	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/WTF/ChangeLog	2013-09-26 20:44:02 UTC (rev 156492)
@@ -1,3 +1,17 @@
+2013-09-26  Anders Carlsson  <[email protected]>
+
+        Change a couple of HashMap value types from OwnPtr to std::unique_ptr
+        https://bugs.webkit.org/show_bug.cgi?id=121973
+
+        Reviewed by Andreas Kling.
+
+        * wtf/RefPtrHashMap.h:
+        Add a missing std::forward.
+
+        * wtf/StdLibExtras.h:
+        (std::make_unique):
+        Add more overloads.
+
 2013-09-26  Julien Brianceau  <[email protected]>
 
         [Qt] Remove PassTraits.h from WTF.pro.

Modified: trunk/Source/WTF/wtf/RefPtrHashMap.h (156491 => 156492)


--- trunk/Source/WTF/wtf/RefPtrHashMap.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/WTF/wtf/RefPtrHashMap.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -228,7 +228,7 @@
     template<typename V>
     auto HashMap<RefPtr<KeyArg>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>::set(RawKeyType key, V&& value) -> AddResult
     {
-        AddResult result = inlineAdd(key, value);
+        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.
             result.iterator->value = std::forward<V>(value);

Modified: trunk/Source/WTF/wtf/StdLibExtras.h (156491 => 156492)


--- trunk/Source/WTF/wtf/StdLibExtras.h	2013-09-26 20:32:15 UTC (rev 156491)
+++ trunk/Source/WTF/wtf/StdLibExtras.h	2013-09-26 20:44:02 UTC (rev 156492)
@@ -344,6 +344,31 @@
     {
         return unique_ptr<T>(new T(std::forward<A1>(a1), std::forward<A2>(a2)));
     }
+
+    template<class T, class A1, class A2, class A3> typename _Unique_if<T>::_Single_object
+    make_unique(A1&& a1, A1&& a2, A3&& a3)
+    {
+        return unique_ptr<T>(new T(std::forward<A1>(a1), std::forward<A2>(a2), std::forward<A3>(a3)));
+    }
+
+    template<class T, class A1, class A2, class A3, class A4> typename _Unique_if<T>::_Single_object
+    make_unique(A1&& a1, A1&& a2, A3&& a3, A4&& a4)
+    {
+        return unique_ptr<T>(new T(std::forward<A1>(a1), std::forward<A2>(a2), std::forward<A3>(a3), std::forward<A4>(a4)));
+    }
+
+    template<class T, class A1, class A2, class A3, class A4, class A5> typename _Unique_if<T>::_Single_object
+    make_unique(A1&& a1, A1&& a2, A3&& a3, A4&& a4, A5&& a5)
+    {
+        return unique_ptr<T>(new T(std::forward<A1>(a1), std::forward<A2>(a2), std::forward<A3>(a3), std::forward<A4>(a4), std::forward<A5>(a5)));
+    }
+
+    template<class T, class A1, class A2, class A3, class A4, class A5, class A6> typename _Unique_if<T>::_Single_object
+    make_unique(A1&& a1, A1&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6)
+    {
+        return unique_ptr<T>(new T(std::forward<A1>(a1), std::forward<A2>(a2), std::forward<A3>(a3), std::forward<A4>(a4), std::forward<A5>(a5), std::forward<A6>(a6)));
+    }
+
 #endif
 
     template<class T> typename _Unique_if<T>::_Unknown_bound
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to