Remove makePoisonedUnique
authorjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Jan 2018 22:02:45 +0000 (22:02 +0000)
committerjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Jan 2018 22:02:45 +0000 (22:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181630
<rdar://problem/36498623>

Reviewed by Mark Lam.

Source/JavaScriptCore:

I added a conversion from std::unique_ptr, so we can just use
std::make_unique and it'll auto-poison when converted.

* bytecode/CodeBlock.h:
(JSC::CodeBlock::makePoisonedUnique): Deleted.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::makePoisonedUnique): Deleted.

Source/WTF:

I added a conversion from std::unique_ptr, so we can just use
std::make_unique and it'll auto-poison when converted.

* wtf/PoisonedUniquePtr.h:
(WTF::makePoisonedUnique): Deleted.

Tools:

Update tests.

* TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226956 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/CodeBlock.h
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/WTF/ChangeLog
Source/WTF/wtf/PoisonedUniquePtr.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp

index 98e28a5..82a1756 100644 (file)
@@ -1,3 +1,21 @@
+2018-01-15  JF Bastien  <jfbastien@apple.com>
+
+        Remove makePoisonedUnique
+        https://bugs.webkit.org/show_bug.cgi?id=181630
+        <rdar://problem/36498623>
+
+        Reviewed by Mark Lam.
+
+        I added a conversion from std::unique_ptr, so we can just use
+        std::make_unique and it'll auto-poison when converted.
+
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::makePoisonedUnique): Deleted.
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::makePoisonedUnique): Deleted.
+
 2018-01-15  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         REGRESSION(r226266): [GTK] RELEASE_ASSERT(reservedZoneSize >= minimumReservedZoneSize) in JSC::VM::updateStackLimits
index 5b12e86..a1ff6da 100644 (file)
@@ -946,12 +946,6 @@ private:
     void insertBasicBlockBoundariesForControlFlowProfiler(RefCountedArray<Instruction>&);
     void ensureCatchLivenessIsComputedForBytecodeOffsetSlow(unsigned);
 
-    template<typename T, typename... Arguments, typename Enable = void>
-    static PoisonedUniquePtr<POISON(CodeBlock), T> makePoisonedUnique(Arguments&&... arguments)
-    {
-        return WTF::makePoisonedUnique<POISON(CodeBlock), T>(std::forward<Arguments>(arguments)...);
-    }
-
     WriteBarrier<UnlinkedCodeBlock> m_unlinkedCode;
     int m_numParameters;
     int m_numberOfArgumentsToSkip { 0 };
index 9480613..84d0189 100644 (file)
@@ -401,8 +401,8 @@ void JSGlobalObject::init(VM& vm)
     m_debugger = 0;
 
 #if ENABLE(REMOTE_INSPECTOR)
-    m_inspectorController = makePoisonedUnique<Inspector::JSGlobalObjectInspectorController>(*this);
-    m_inspectorDebuggable = makePoisonedUnique<JSGlobalObjectDebuggable>(*this);
+    m_inspectorController = std::make_unique<Inspector::JSGlobalObjectInspectorController>(*this);
+    m_inspectorDebuggable = std::make_unique<JSGlobalObjectDebuggable>(*this);
     m_inspectorDebuggable->init();
     m_consoleClient = m_inspectorController->consoleClient();
 #endif
@@ -1011,63 +1011,63 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct
 
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(arrayIteratorPrototype, m_vm.propertyNames->next);
-            m_arrayIteratorPrototypeNext = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_arrayIteratorProtocolWatchpoint);
+            m_arrayIteratorPrototypeNext = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_arrayIteratorProtocolWatchpoint);
             m_arrayIteratorPrototypeNext->install();
         }
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this->arrayPrototype(), m_vm.propertyNames->iteratorSymbol);
-            m_arrayPrototypeSymbolIteratorWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_arrayIteratorProtocolWatchpoint);
+            m_arrayPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_arrayIteratorProtocolWatchpoint);
             m_arrayPrototypeSymbolIteratorWatchpoint->install();
         }
 
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(mapIteratorPrototype, m_vm.propertyNames->next);
-            m_mapIteratorPrototypeNextWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapIteratorProtocolWatchpoint);
+            m_mapIteratorPrototypeNextWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapIteratorProtocolWatchpoint);
             m_mapIteratorPrototypeNextWatchpoint->install();
         }
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapPrototype.get(), m_vm.propertyNames->iteratorSymbol);
-            m_mapPrototypeSymbolIteratorWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapIteratorProtocolWatchpoint);
+            m_mapPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapIteratorProtocolWatchpoint);
             m_mapPrototypeSymbolIteratorWatchpoint->install();
         }
 
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(setIteratorPrototype, m_vm.propertyNames->next);
-            m_setIteratorPrototypeNextWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setIteratorProtocolWatchpoint);
+            m_setIteratorPrototypeNextWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setIteratorProtocolWatchpoint);
             m_setIteratorPrototypeNextWatchpoint->install();
         }
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setPrototype.get(), m_vm.propertyNames->iteratorSymbol);
-            m_setPrototypeSymbolIteratorWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setIteratorProtocolWatchpoint);
+            m_setPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setIteratorProtocolWatchpoint);
             m_setPrototypeSymbolIteratorWatchpoint->install();
         }
 
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_stringIteratorPrototype.get(), m_vm.propertyNames->next);
-            m_stringIteratorPrototypeNextWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_stringIteratorProtocolWatchpoint);
+            m_stringIteratorPrototypeNextWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_stringIteratorProtocolWatchpoint);
             m_stringIteratorPrototypeNextWatchpoint->install();
         }
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_stringPrototype.get(), m_vm.propertyNames->iteratorSymbol);
-            m_stringPrototypeSymbolIteratorWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_stringIteratorProtocolWatchpoint);
+            m_stringPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_stringIteratorProtocolWatchpoint);
             m_stringPrototypeSymbolIteratorWatchpoint->install();
         }
 
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapPrototype.get(), m_vm.propertyNames->set);
-            m_mapPrototypeSetWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapSetWatchpoint);
+            m_mapPrototypeSetWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapSetWatchpoint);
             m_mapPrototypeSetWatchpoint->install();
         }
 
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setPrototype.get(), m_vm.propertyNames->add);
-            m_setPrototypeAddWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setAddWatchpoint);
+            m_setPrototypeAddWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setAddWatchpoint);
             m_setPrototypeAddWatchpoint->install();
         }
 
         {
             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(numberPrototype(), m_vm.propertyNames->toString);
-            m_numberPrototypeToStringWatchpoint = makePoisonedUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_numberToStringWatchpoint);
+            m_numberPrototypeToStringWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_numberToStringWatchpoint);
             m_numberPrototypeToStringWatchpoint->install();
             m_numberProtoToStringFunction.set(vm, this, jsCast<JSFunction*>(numberPrototype()->getDirect(vm, vm.propertyNames->toString)));
         }
index 8f94e74..8f2e4fd 100644 (file)
@@ -920,12 +920,6 @@ private:
 
     JS_EXPORT_PRIVATE static void clearRareData(JSCell*);
 
-    template<typename T, typename... Arguments, typename Enable = void>
-    static JSGlobalObject::PoisonedUniquePtr<T> makePoisonedUnique(Arguments&&... arguments)
-    {
-        return WTF::makePoisonedUnique<POISON(JSGlobalObject), T>(std::forward<Arguments>(arguments)...);
-    }
-
     bool m_needsSiteSpecificQuirks { false };
 #if JSC_OBJC_API_ENABLED
     RetainPtr<JSWrapperMap> m_wrapperMap;
index b078738..7af2d69 100644 (file)
@@ -1,3 +1,17 @@
+2018-01-15  JF Bastien  <jfbastien@apple.com>
+
+        Remove makePoisonedUnique
+        https://bugs.webkit.org/show_bug.cgi?id=181630
+        <rdar://problem/36498623>
+
+        Reviewed by Mark Lam.
+
+        I added a conversion from std::unique_ptr, so we can just use
+        std::make_unique and it'll auto-poison when converted.
+
+        * wtf/PoisonedUniquePtr.h:
+        (WTF::makePoisonedUnique): Deleted.
+
 2018-01-13  Mark Lam  <mark.lam@apple.com>
 
         Replace all use of ConstExprPoisoned with Poisoned.
index 87b2453..a891e22 100644 (file)
@@ -128,12 +128,6 @@ private:
     template<uintptr_t&, typename, typename> friend class PoisonedUniquePtr;
 };
 
-template<uintptr_t& key, typename T, typename... Arguments, typename Enable = void>
-PoisonedUniquePtr<key, T> makePoisonedUnique(Arguments&&... arguments)
-{
-    return PoisonedUniquePtr<key, T>::create(std::forward<Arguments>(arguments)...);
-}
-
 template<uintptr_t& key, typename T>
 class PoisonedUniquePtr<key, T[]> : public Poisoned<key, T*> {
     WTF_MAKE_FAST_ALLOCATED;
@@ -220,14 +214,7 @@ private:
     template<uintptr_t&, typename, typename> friend class PoisonedUniquePtr;
 };
 
-template<uintptr_t& key, typename T, typename... Arguments>
-PoisonedUniquePtr<key, T[]> makePoisonedUnique(size_t count, Arguments&&... arguments)
-{
-    return PoisonedUniquePtr<key, T[]>::create(count, std::forward<Arguments>(arguments)...);
-}
-
 } // namespace WTF
 
 using WTF::PoisonedUniquePtr;
-using WTF::makePoisonedUnique;
 
index a25e588..adbaa37 100644 (file)
@@ -1,3 +1,18 @@
+2018-01-15  JF Bastien  <jfbastien@apple.com>
+
+        Remove makePoisonedUnique
+        https://bugs.webkit.org/show_bug.cgi?id=181630
+        <rdar://problem/36498623>
+
+        Reviewed by Mark Lam.
+
+        Update tests.
+
+        * TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp:
+        (TestWebKitAPI::TEST):
+
 2018-01-15  Adrian Perez de Castro  <aperez@igalia.com>
 
         [GTK][JHBuild] Tools/gtk/install-dependencies: Package libxfont does not exist anymore in Arch Linux
index 6e36e37..fa81d91 100644 (file)
@@ -165,7 +165,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int aDestructCount = 0;
         const char* aName = "a";
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = makePoisonedUnique<g_poisonA, Logger>(aName, aDestructCount);
+            PoisonedUniquePtr<g_poisonA, Logger> ptr = std::make_unique<Logger>(aName, aDestructCount);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             ASSERT_EQ(aName, &ptr->name);
@@ -175,7 +175,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int bDestructCount = 0;
         const char* bName = "b";
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = makePoisonedUnique<g_poisonA, DerivedLogger>(bName, bDestructCount);
+            PoisonedUniquePtr<g_poisonA, Logger> ptr = std::make_unique<DerivedLogger>(bName, bDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             ASSERT_EQ(bName, &ptr->name);
index 199a6e0..0fbedc4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -133,32 +133,6 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
 
     {
         int aDestructCount = 0;
-        const char* aName = "a";
-        {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr = makePoisonedUnique<g_poisonA, Logger[]>(arraySize, aName, aDestructCount);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_TRUE(nullptr != ptr.unpoisoned());
-            for (auto i = 0; i < arraySize; ++i)
-                ASSERT_EQ(aName, ptr[i].name);
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        const char* aName = "a";
-        {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr = makePoisonedUnique<g_poisonA, Logger[]>(arraySize, aName, aDestructCount);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_TRUE(nullptr != ptr.unpoisoned());
-            for (auto i = 0; i < arraySize; ++i)
-                ASSERT_EQ(aName, ptr[i].name);
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
         int bDestructCount = 0;
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);