Remove remaining poisoning code.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2019 07:50:04 +0000 (07:50 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2019 07:50:04 +0000 (07:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194138

Reviewed by Saam Barati.

Source/WTF:

This patch removes the instantiation of Poisoned variants of the various containers
but retains the ability of those containers to work with pointer traits.  This
allows us to use them with smart pointers in the future (just like we used to with
Poisoned values).  At minimum, this ability will be useful when we want to insert
an observer into the container storage type for debugging purposes, or to collect
statistics for profiling.

* WTF.xcodeproj/project.pbxproj:
* wtf/Bag.h:
* wtf/CMakeLists.txt:
* wtf/Platform.h:
* wtf/Poisoned.cpp: Removed.
* wtf/Poisoned.h: Removed.
* wtf/PoisonedUniquePtr.h: Removed.
* wtf/Ref.h:
* wtf/RefCountedArray.h:
* wtf/RefPtr.h:
* wtf/WTFAssertions.cpp:

Tools:

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/Poisoned.cpp: Removed.
* TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: Removed.
* TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: Removed.
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp: Removed.
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp: Removed.
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp: Removed.

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

21 files changed:
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/Bag.h
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/Platform.h
Source/WTF/wtf/Poisoned.cpp [deleted file]
Source/WTF/wtf/Poisoned.h [deleted file]
Source/WTF/wtf/PoisonedUniquePtr.h [deleted file]
Source/WTF/wtf/Ref.h
Source/WTF/wtf/RefCountedArray.h
Source/WTF/wtf/RefPtr.h
Source/WTF/wtf/WTFAssertions.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/Poisoned.cpp [deleted file]
Tools/TestWebKitAPI/Tests/WTF/PoisonedRef.cpp [deleted file]
Tools/TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp [deleted file]
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp [deleted file]
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp [deleted file]
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp [deleted file]

index 236058c..118c592 100644 (file)
@@ -1,3 +1,29 @@
+2019-02-26  Mark Lam  <mark.lam@apple.com>
+
+        Remove remaining poisoning code.
+        https://bugs.webkit.org/show_bug.cgi?id=194138
+
+        Reviewed by Saam Barati.
+
+        This patch removes the instantiation of Poisoned variants of the various containers
+        but retains the ability of those containers to work with pointer traits.  This
+        allows us to use them with smart pointers in the future (just like we used to with
+        Poisoned values).  At minimum, this ability will be useful when we want to insert
+        an observer into the container storage type for debugging purposes, or to collect
+        statistics for profiling.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/Bag.h:
+        * wtf/CMakeLists.txt:
+        * wtf/Platform.h:
+        * wtf/Poisoned.cpp: Removed.
+        * wtf/Poisoned.h: Removed.
+        * wtf/PoisonedUniquePtr.h: Removed.
+        * wtf/Ref.h:
+        * wtf/RefCountedArray.h:
+        * wtf/RefPtr.h:
+        * wtf/WTFAssertions.cpp:
+
 2019-02-26  Keith Miller  <keith_miller@apple.com>
 
         Code quality cleanup in NeverDestroyed
index 318c145..178ea89 100644 (file)
                E4A0AD391A96245500536DF6 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD371A96245500536DF6 /* WorkQueue.cpp */; };
                E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
                FE05FAFF1FE5007500093230 /* WTFAssertions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE05FAFE1FE5007500093230 /* WTFAssertions.cpp */; };
-               FE85416E1FBE285D008DA5DA /* Poisoned.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE85416C1FBE285B008DA5DA /* Poisoned.cpp */; };
                FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; };
                FEEA4DF9216D7BE400AC0602 /* StackPointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEEA4DF8216D7BE400AC0602 /* StackPointer.cpp */; };
 /* End PBXBuildFile section */
                F72BBDB107FA424886178B9E /* SymbolImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolImpl.cpp; sourceTree = "<group>"; };
                FE05FAE61FDB214300093230 /* DumbPtrTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumbPtrTraits.h; sourceTree = "<group>"; };
                FE05FAFE1FE5007500093230 /* WTFAssertions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WTFAssertions.cpp; sourceTree = "<group>"; };
-               FE05FB041FE8453200093230 /* PoisonedUniquePtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PoisonedUniquePtr.h; sourceTree = "<group>"; };
                FE7497E4208FFCAA0003565B /* PtrTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PtrTag.h; sourceTree = "<group>"; };
                FE7497ED209163060003565B /* MetaAllocatorPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaAllocatorPtr.h; sourceTree = "<group>"; };
                FE8225301B2A1E5B00BA68FD /* NakedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NakedPtr.h; sourceTree = "<group>"; };
-               FE85416C1FBE285B008DA5DA /* Poisoned.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Poisoned.cpp; sourceTree = "<group>"; };
-               FE85416D1FBE285C008DA5DA /* Poisoned.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Poisoned.h; sourceTree = "<group>"; };
                FE86A8741E59440200111BBF /* ForbidHeapAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForbidHeapAllocation.h; sourceTree = "<group>"; };
                FE8925AF1D00DAEC0046907E /* Indenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Indenter.h; sourceTree = "<group>"; };
                FEB6B035201BE0B600B958C1 /* PointerPreparations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointerPreparations.h; sourceTree = "<group>"; };
                                E3200AB41E9A536D003B59D2 /* PlatformRegisters.h */,
                                0FF860941BCCBD740045127F /* PointerComparison.h */,
                                FEB6B035201BE0B600B958C1 /* PointerPreparations.h */,
-                               FE85416C1FBE285B008DA5DA /* Poisoned.cpp */,
-                               FE85416D1FBE285C008DA5DA /* Poisoned.h */,
-                               FE05FB041FE8453200093230 /* PoisonedUniquePtr.h */,
                                0F9D335D165DBA73005AD387 /* PrintStream.cpp */,
                                0F9D335E165DBA73005AD387 /* PrintStream.h */,
                                53EC253C1E95AD30000831B9 /* PriorityQueue.h */,
                                51F1752B1F3D486000C74950 /* PersistentCoders.cpp in Sources */,
                                51F1752C1F3D486000C74950 /* PersistentDecoder.cpp in Sources */,
                                51F1752D1F3D486000C74950 /* PersistentEncoder.cpp in Sources */,
-                               FE85416E1FBE285D008DA5DA /* Poisoned.cpp in Sources */,
                                0F9D3362165DBA73005AD387 /* PrintStream.cpp in Sources */,
                                7AF023B52061E17000A8EFD6 /* ProcessPrivilege.cpp in Sources */,
                                143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */,
index 182d32d..1f85720 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -156,12 +156,6 @@ private:
     typename PtrTraits::StorageType m_head { nullptr };
 };
 
-template<typename Poison, typename T> struct PoisonedPtrTraits;
-
-template<typename Poison, typename T>
-using PoisonedBag = Bag<T, PoisonedPtrTraits<Poison, Private::BagNode<T>>>;
-
 } // namespace WTF
 
 using WTF::Bag;
-using WTF::PoisonedBag;
index ae88b68..20f00f9 100644 (file)
@@ -165,8 +165,6 @@ set(WTF_PUBLIC_HEADERS
     PlatformRegisters.h
     PointerComparison.h
     PointerPreparations.h
-    Poisoned.h
-    PoisonedUniquePtr.h
     PrintStream.h
     PriorityQueue.h
     ProcessID.h
@@ -383,7 +381,6 @@ set(WTF_SOURCES
     ParallelHelperPool.cpp
     ParallelJobsGeneric.cpp
     ParkingLot.cpp
-    Poisoned.cpp
     PrintStream.cpp
     ProcessPrivilege.cpp
     RAMSize.cpp
index 9bfac42..94037ce 100644 (file)
 #define ENABLE_SIGNAL_BASED_VM_TRAPS 1
 #endif
 
-#define ENABLE_POISON 0
-
 #if !defined(USE_POINTER_PROFILING) || USE(JSVALUE32_64) || !ENABLE(JIT)
 #undef USE_POINTER_PROFILING
 #define USE_POINTER_PROFILING 0
diff --git a/Source/WTF/wtf/Poisoned.cpp b/Source/WTF/wtf/Poisoned.cpp
deleted file mode 100644 (file)
index c850b80..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include <wtf/Poisoned.h>
-
-#include <wtf/CryptographicallyRandomNumber.h>
-
-namespace WTF {
-
-uintptr_t makePoison()
-{
-    uintptr_t poison = 0;
-#if ENABLE(POISON)
-    do {
-        poison = cryptographicallyRandomNumber();
-        poison = (poison << 16) ^ (static_cast<uintptr_t>(cryptographicallyRandomNumber()) << 3);
-    } while (!(poison >> 32)); // Ensure that bits 32-47 are not completely 0.
-
-    // Ensure that the poisoned bits (pointer ^ poison) looks like a valid pointer.
-    RELEASE_ASSERT(poison && !(poison >> 48));
-
-    // Ensure that the poisoned bits (pointer ^ poison) cannot be 0. This is so that the poisoned
-    // bits can also be used for a normal zero check without needing to be decoded first.
-    poison |= (1 << 2);
-
-    // Ensure that the bottom 2 alignment bits are still 0 so that the poisoned bits will
-    // still preserve the properties of a pointer where these bits are expected to be 0.
-    // This allows the poisoned bits to be used in place of the pointer by clients that
-    // rely on this property of pointers and sets flags in the low bits.
-    // Note: a regular pointer has 3 alignment bits, but the poisoned bits need to use one
-    // (see above). Hence, clients can only use 2 bits for flags.
-    RELEASE_ASSERT(!(poison & 0x3));
-#endif
-    return poison;
-}
-
-} // namespace WTF
diff --git a/Source/WTF/wtf/Poisoned.h b/Source/WTF/wtf/Poisoned.h
deleted file mode 100644 (file)
index 87a8e58..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <cstddef>
-#include <utility>
-#include <wtf/Assertions.h>
-
-#define ENABLE_POISON_ASSERTS 0
-
-#if !ENABLE(POISON)
-#undef ENABLE_POISON_ASSERTS
-#define ENABLE_POISON_ASSERTS 0
-#endif
-
-namespace WTF {
-
-using PoisonedBits = uintptr_t;
-
-namespace PoisonedImplHelper {
-
-template<typename T>
-struct isFunctionPointer : std::integral_constant<bool, std::is_function<typename std::remove_pointer<T>::type>::value> { };
-
-template<typename T>
-struct isVoidPointer : std::integral_constant<bool, std::is_void<typename std::remove_pointer<T>::type>::value> { };
-
-template<typename T>
-struct isConvertibleToReference : std::integral_constant<bool, !isFunctionPointer<T>::value && !isVoidPointer<T>::value> { };
-
-template<typename T>
-typename std::enable_if_t<!isConvertibleToReference<T>::value, int>&
-asReference(T) { RELEASE_ASSERT_NOT_REACHED(); }
-
-template<typename T>
-typename std::enable_if_t<isConvertibleToReference<T>::value, typename std::remove_pointer<T>::type>&
-asReference(T ptr) { return *ptr; }
-
-} // namespace PoisonedImplHelper
-
-enum AlreadyPoisonedTag { AlreadyPoisoned };
-
-template<uintptr_t& poisonKey>
-class Poison {
-public:
-    template<typename PoisonedType = void>
-    static uintptr_t key(const PoisonedType* = nullptr) { return poisonKey; }
-};
-
-template<typename Poison, typename T, typename = std::enable_if_t<sizeof(T) == sizeof(void*)>>
-class Poisoned {
-public:
-    static constexpr bool isPoisonedType = true;
-
-    Poisoned() { }
-
-    Poisoned(std::nullptr_t) { }
-
-    Poisoned(T ptr)
-        : m_poisonedBits(poison(ptr))
-    { }
-
-    Poisoned(const Poisoned&) = default;
-
-    template<typename Other, typename = std::enable_if_t<Other::isPoisonedType>>
-    Poisoned(const Other& other)
-        : m_poisonedBits(poison<T>(other.unpoisoned()))
-    { }
-
-    Poisoned(Poisoned&&) = default;
-
-    explicit Poisoned(AlreadyPoisonedTag, PoisonedBits poisonedBits)
-        : m_poisonedBits(poisonedBits)
-    { }
-
-#if ENABLE(POISON_ASSERTS)
-    template<typename U = void*>
-    static bool isPoisoned(U value) { return !value || (reinterpret_cast<uintptr_t>(value) & 0xffff000000000000); }
-    template<typename U = void*>
-    static void assertIsPoisoned(U value) { RELEASE_ASSERT(isPoisoned(value)); }
-    template<typename U = void*>
-    static void assertIsNotPoisoned(U value) { RELEASE_ASSERT(!isPoisoned(value)); }
-#else
-    template<typename U = void*> static void assertIsPoisoned(U) { }
-    template<typename U = void*> static void assertIsNotPoisoned(U) { }
-#endif
-    void assertIsPoisoned() const { assertIsPoisoned(m_poisonedBits); }
-    void assertIsNotPoisoned() const { assertIsNotPoisoned(m_poisonedBits); }
-
-    template<typename U = T>
-    U unpoisoned() const { return unpoison<U>(m_poisonedBits); }
-
-    void clear() { m_poisonedBits = 0; }
-
-    auto& operator*() const { ASSERT(m_poisonedBits); return PoisonedImplHelper::asReference(unpoison(m_poisonedBits)); }
-    ALWAYS_INLINE T operator->() const { return unpoison(m_poisonedBits); }
-
-    template<typename U = PoisonedBits>
-    U bits() const { return bitwise_cast<U>(m_poisonedBits); }
-
-    bool operator!() const { return !m_poisonedBits; }
-    explicit operator bool() const { return !!m_poisonedBits; }
-
-    bool operator==(const Poisoned& b) const { return m_poisonedBits == b.m_poisonedBits; }
-    bool operator!=(const Poisoned& b) const { return m_poisonedBits != b.m_poisonedBits; }
-
-    bool operator==(T b) const { return unpoisoned() == b; }
-    bool operator!=(T b) const { return unpoisoned() != b; }
-    bool operator<(T b) const { return unpoisoned() < b; }
-    bool operator<=(T b) const { return unpoisoned() <= b; }
-    bool operator>(T b) const { return unpoisoned() > b; }
-    bool operator>=(T b) const { return unpoisoned() >= b; }
-
-    Poisoned& operator=(T ptr)
-    {
-        m_poisonedBits = poison(ptr);
-        return *this;
-    }
-    Poisoned& operator=(const Poisoned&) = default;
-
-    Poisoned& operator=(std::nullptr_t)
-    {
-        clear();
-        return *this;
-    }
-
-    template<typename Other, typename = std::enable_if_t<Other::isPoisonedType>>
-    Poisoned& operator=(const Other& other)
-    {
-        m_poisonedBits = poison<T>(other.unpoisoned());
-        return *this;
-    }
-
-    void swap(Poisoned& other)
-    {
-        std::swap(m_poisonedBits, other.m_poisonedBits);
-    }
-
-    void swap(std::nullptr_t) { clear(); }
-
-    template<typename Other, typename = std::enable_if_t<Other::isPoisonedType>>
-    void swap(Other& other)
-    {
-        T t1 = this->unpoisoned();
-        T t2 = other.unpoisoned();
-        std::swap(t1, t2);
-        m_poisonedBits = poison(t1);
-        other.m_poisonedBits = other.poison(t2);
-    }
-
-    void swap(T& t2)
-    {
-        T t1 = this->unpoisoned();
-        std::swap(t1, t2);
-        m_poisonedBits = poison(t1);
-    }
-
-    template<class U>
-    T exchange(U&& newValue)
-    {
-        T oldValue = unpoisoned();
-        m_poisonedBits = poison(std::forward<U>(newValue));
-        return oldValue;
-    }
-
-private:
-    template<typename U>
-    ALWAYS_INLINE PoisonedBits poison(U ptr) const { return poison<PoisonedBits>(this, bitwise_cast<uintptr_t>(ptr)); }
-    template<typename U = T>
-    ALWAYS_INLINE U unpoison(PoisonedBits poisonedBits) const { return unpoison<U>(this, poisonedBits); }
-
-    constexpr static PoisonedBits poison(const Poisoned*, std::nullptr_t) { return 0; }
-#if ENABLE(POISON)
-    template<typename U>
-    ALWAYS_INLINE static PoisonedBits poison(const Poisoned* thisPoisoned, U ptr) { return ptr ? bitwise_cast<PoisonedBits>(ptr) ^ Poison::key(thisPoisoned) : 0; }
-    template<typename U = T>
-    ALWAYS_INLINE static U unpoison(const Poisoned* thisPoisoned, PoisonedBits poisonedBits) { return poisonedBits ? bitwise_cast<U>(poisonedBits ^ Poison::key(thisPoisoned)) : bitwise_cast<U>(0ll); }
-#else
-    template<typename U>
-    ALWAYS_INLINE static PoisonedBits poison(const Poisoned*, U ptr) { return bitwise_cast<PoisonedBits>(ptr); }
-    template<typename U = T>
-    ALWAYS_INLINE static U unpoison(const Poisoned*, PoisonedBits poisonedBits) { return bitwise_cast<U>(poisonedBits); }
-#endif
-
-    PoisonedBits m_poisonedBits { 0 };
-
-    template<typename, typename, typename> friend class Poisoned;
-};
-
-template<typename T, typename U, typename = std::enable_if_t<T::isPoisonedType && U::isPoisonedType && !std::is_same<T, U>::value>>
-inline bool operator==(const T& a, const U& b) { return a.unpoisoned() == b.unpoisoned(); }
-
-template<typename T, typename U, typename = std::enable_if_t<T::isPoisonedType && U::isPoisonedType && !std::is_same<T, U>::value>>
-inline bool operator!=(const T& a, const U& b) { return a.unpoisoned() != b.unpoisoned(); }
-
-template<typename T, typename U, typename = std::enable_if_t<T::isPoisonedType && U::isPoisonedType>>
-inline bool operator<(const T& a, const U& b) { return a.unpoisoned() < b.unpoisoned(); }
-
-template<typename T, typename U, typename = std::enable_if_t<T::isPoisonedType && U::isPoisonedType>>
-inline bool operator<=(const T& a, const U& b) { return a.unpoisoned() <= b.unpoisoned(); }
-
-template<typename T, typename U, typename = std::enable_if_t<T::isPoisonedType && U::isPoisonedType>>
-inline bool operator>(const T& a, const U& b) { return a.unpoisoned() > b.unpoisoned(); }
-
-template<typename T, typename U, typename = std::enable_if_t<T::isPoisonedType && U::isPoisonedType>>
-inline bool operator>=(const T& a, const U& b) { return a.unpoisoned() >= b.unpoisoned(); }
-
-template<typename T, typename U, typename = std::enable_if_t<T::isPoisonedType>>
-inline void swap(T& a, U& b)
-{
-    a.swap(b);
-}
-
-WTF_EXPORT_PRIVATE uintptr_t makePoison();
-
-template<typename Poison, typename T>
-struct PoisonedPtrTraits {
-    using StorageType = Poisoned<Poison, T*>;
-
-    template<class U> static ALWAYS_INLINE T* exchange(StorageType& ptr, U&& newValue) { return ptr.exchange(newValue); }
-
-    template<typename Other>
-    static ALWAYS_INLINE void swap(Poisoned<Poison, T*>& a, Other& b) { a.swap(b); }
-
-    static ALWAYS_INLINE T* unwrap(const StorageType& ptr) { return ptr.unpoisoned(); }
-};
-
-template<typename Poison, typename T>
-struct PoisonedValueTraits {
-    using StorageType = Poisoned<Poison, T>;
-
-    template<class U> static ALWAYS_INLINE T exchange(StorageType& val, U&& newValue) { return val.exchange(newValue); }
-
-    template<typename Other>
-    static ALWAYS_INLINE void swap(Poisoned<Poison, T>& a, Other& b) { a.swap(b); }
-
-    static ALWAYS_INLINE T unwrap(const StorageType& val) { return val.unpoisoned(); }
-};
-
-} // namespace WTF
-
-using WTF::AlreadyPoisoned;
-using WTF::Poison;
-using WTF::Poisoned;
-using WTF::PoisonedBits;
-using WTF::PoisonedPtrTraits;
-using WTF::PoisonedValueTraits;
-using WTF::makePoison;
diff --git a/Source/WTF/wtf/PoisonedUniquePtr.h b/Source/WTF/wtf/PoisonedUniquePtr.h
deleted file mode 100644 (file)
index e06a299..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <cstddef>
-#include <memory>
-#include <wtf/FastMalloc.h>
-#include <wtf/Poisoned.h>
-
-namespace WTF {
-
-template<typename Poison, typename T, typename Enable = void>
-class PoisonedUniquePtr : public Poisoned<Poison, T*> {
-    WTF_MAKE_FAST_ALLOCATED;
-    using Base = Poisoned<Poison, T*>;
-public:
-    static constexpr bool isPoisonedUniquePtrType = true;
-    using ValueType = T;
-
-    PoisonedUniquePtr() = default;
-    PoisonedUniquePtr(std::nullptr_t) : Base() { }
-    PoisonedUniquePtr(T* ptr) : Base(ptr) { }
-    PoisonedUniquePtr(PoisonedUniquePtr&& ptr) : Base(WTFMove(ptr)) { ptr.clearWithoutDestroy(); }
-    PoisonedUniquePtr(std::unique_ptr<T>&& unique) : PoisonedUniquePtr(unique.release()) { }
-
-    template<typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
-    PoisonedUniquePtr(std::unique_ptr<U>&& unique)
-        : Base(unique.release())
-    { }
-
-    template<typename Other, typename = std::enable_if_t<Other::isPoisonedUniquePtrType && std::is_base_of<T, typename Other::ValueType>::value>>
-    PoisonedUniquePtr(Other&& ptr)
-        : Base(ptr.unpoisoned())
-    {
-        ptr.clearWithoutDestroy();
-    }
-
-    PoisonedUniquePtr(const PoisonedUniquePtr&) = delete;
-
-    ~PoisonedUniquePtr() { destroy(); }
-
-    template<typename... Arguments>
-    static PoisonedUniquePtr create(Arguments&&... arguments)
-    {
-        return new T(std::forward<Arguments>(arguments)...);
-    }
-
-    PoisonedUniquePtr& operator=(T* ptr)
-    {
-        if (LIKELY(this->unpoisoned() != ptr)) {
-            this->clear();
-            this->Base::operator=(ptr);
-        }
-        return *this;
-    }
-
-    PoisonedUniquePtr& operator=(std::unique_ptr<T>&& unique)
-    {
-        this->clear();
-        this->Base::operator=(unique.release());
-        return *this;
-    }
-
-    template<typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
-    PoisonedUniquePtr& operator=(std::unique_ptr<U>&& unique)
-    {
-        this->clear();
-        this->Base::operator=(unique.release());
-        return *this;
-    }
-
-    template<typename Other, typename = std::enable_if_t<Other::isPoisonedUniquePtrType && std::is_base_of<T, typename Other::ValueType>::value>>
-    PoisonedUniquePtr& operator=(Other&& ptr)
-    {
-        ASSERT(this == static_cast<void*>(&ptr) || this->unpoisoned() != ptr.unpoisoned());
-        if (LIKELY(this != static_cast<void*>(&ptr))) {
-            this->clear();
-            this->Base::operator=(WTFMove(ptr));
-            ptr.clearWithoutDestroy();
-        }
-        return *this;
-    }
-
-    PoisonedUniquePtr& operator=(const PoisonedUniquePtr&) = delete;
-
-    T* get() const { return this->unpoisoned(); }
-    T& operator[](size_t index) const { return this->unpoisoned()[index]; }
-
-    void clear()
-    {
-        destroy();
-        clearWithoutDestroy();
-    }
-
-private:
-    void destroy()
-    {
-        if (!this->bits())
-            return;
-        delete this->unpoisoned();
-    }
-
-    void clearWithoutDestroy() { Base::clear(); }
-
-    template<typename, typename, typename> friend class PoisonedUniquePtr;
-};
-
-template<typename Poison, typename T>
-class PoisonedUniquePtr<Poison, T[]> : public Poisoned<Poison, T*> {
-    WTF_MAKE_FAST_ALLOCATED;
-    using Base = Poisoned<Poison, T*>;
-public:
-    static constexpr bool isPoisonedUniquePtrType = true;
-    using ValueType = T[];
-
-    PoisonedUniquePtr() = default;
-    PoisonedUniquePtr(std::nullptr_t) : Base() { }
-    PoisonedUniquePtr(T* ptr) : Base(ptr) { }
-    PoisonedUniquePtr(PoisonedUniquePtr&& ptr) : Base(WTFMove(ptr)) { ptr.clearWithoutDestroy(); }
-    PoisonedUniquePtr(std::unique_ptr<T[]>&& unique) : PoisonedUniquePtr(unique.release()) { }
-
-    template<typename Other, typename = std::enable_if_t<Other::isPoisonedUniquePtrType && std::is_same<T[], typename Other::ValueType>::value>>
-    PoisonedUniquePtr(Other&& ptr)
-        : Base(ptr.unpoisoned())
-    {
-        ptr.clearWithoutDestroy();
-    }
-
-    PoisonedUniquePtr(const PoisonedUniquePtr&) = delete;
-
-    ~PoisonedUniquePtr() { destroy(); }
-
-    template<typename... Arguments>
-    static PoisonedUniquePtr create(size_t count, Arguments&&... arguments)
-    {
-        T* result = new T[count];
-        while (count--)
-            new (result + count) T(std::forward<Arguments>(arguments)...);
-        return result;
-    }
-
-    PoisonedUniquePtr& operator=(T* ptr)
-    {
-        if (LIKELY(this->unpoisoned() != ptr)) {
-            this->clear();
-            this->Base::operator=(ptr);
-        }
-        return *this;
-    }
-    
-    PoisonedUniquePtr& operator=(std::unique_ptr<T[]>&& unique)
-    {
-        this->clear();
-        this->Base::operator=(unique.release());
-        return *this;
-    }
-
-    template<typename Other, typename = std::enable_if_t<Other::isPoisonedUniquePtrType && std::is_same<T[], typename Other::ValueType>::value>>
-    PoisonedUniquePtr& operator=(Other&& ptr)
-    {
-        ASSERT(this == static_cast<void*>(&ptr) || this->unpoisoned() != ptr.unpoisoned());
-        if (LIKELY(this != static_cast<void*>(&ptr))) {
-            this->clear();
-            this->Base::operator=(WTFMove(ptr));
-            ptr.clearWithoutDestroy();
-        }
-        return *this;
-    }
-
-    PoisonedUniquePtr& operator=(const PoisonedUniquePtr&) = delete;
-
-    T* get() const { return this->unpoisoned(); }
-    T& operator[](size_t index) const { return this->unpoisoned()[index]; }
-
-    void clear()
-    {
-        destroy();
-        clearWithoutDestroy();
-    }
-
-private:
-    void destroy()
-    {
-        if (!this->bits())
-            return;
-        delete[] this->unpoisoned();
-    }
-
-    void clearWithoutDestroy() { Base::clear(); }
-
-    template<typename, typename, typename> friend class PoisonedUniquePtr;
-};
-
-} // namespace WTF
-
-using WTF::PoisonedUniquePtr;
-
index 6dc684e..c077c7e 100644 (file)
@@ -267,14 +267,8 @@ inline bool is(const Ref<ArgType, PtrTraits>& source)
     return is<ExpectedType>(source.get());
 }
 
-template<typename Poison, typename T> struct PoisonedPtrTraits;
-
-template<typename Poison, typename T>
-using PoisonedRef = Ref<T, PoisonedPtrTraits<Poison, T>>;
-
 } // namespace WTF
 
-using WTF::PoisonedRef;
 using WTF::Ref;
 using WTF::adoptRef;
 using WTF::makeRef;
index ff9bf50..63cd1ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -248,12 +248,6 @@ private:
     typename PtrTraits::StorageType m_data { nullptr };
 };
 
-template<typename Poison, typename T> struct PoisonedPtrTraits;
-
-template<typename Poison, typename T>
-using PoisonedRefCountedArray = RefCountedArray<T, PoisonedPtrTraits<Poison, T>>;
-
 } // namespace WTF
 
-using WTF::PoisonedRefCountedArray;
 using WTF::RefCountedArray;
index 2a35572..6eb9d21 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2005-2018 Apple Inc. All rights reserved.
+ *  Copyright (C) 2005-2019 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Library General Public
@@ -271,14 +271,8 @@ inline bool is(const RefPtr<ArgType, PtrTraits>& source)
     return is<ExpectedType>(source.get());
 }
 
-template<typename Poison, typename T> struct PoisonedPtrTraits;
-
-template<typename Poison, typename T>
-using PoisonedRefPtr = RefPtr<T, PoisonedPtrTraits<Poison, T>>;
-
 } // namespace WTF
 
-using WTF::PoisonedRefPtr;
 using WTF::RefPtr;
 using WTF::adoptRef;
 using WTF::makeRefPtr;
index 9870764..3ca40dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,8 +26,6 @@
 #include "config.h"
 
 #include <wtf/Bag.h>
-#include <wtf/Poisoned.h>
-#include <wtf/PoisonedUniquePtr.h>
 #include <wtf/RefCountedArray.h>
 #include <wtf/RefPtr.h>
 
@@ -35,24 +33,15 @@ namespace WTF {
 
 namespace {
 struct DummyStruct { };
-uintptr_t dummyPoison = 0;
 }
 
 static_assert(sizeof(Bag<DummyStruct>) == sizeof(void*), "");
-static_assert(sizeof(PoisonedBag<Poison<dummyPoison>, DummyStruct>) == sizeof(void*), "");
 
 static_assert(sizeof(Ref<DummyStruct>) == sizeof(DummyStruct*), "");
-static_assert(sizeof(PoisonedRef<Poison<dummyPoison>, DummyStruct>) == sizeof(DummyStruct*), "");
 
 static_assert(sizeof(RefPtr<DummyStruct>) == sizeof(DummyStruct*), "");
-static_assert(sizeof(PoisonedRefPtr<Poison<dummyPoison>, DummyStruct>) == sizeof(DummyStruct*), "");
-
-static_assert(sizeof(PoisonedUniquePtr<Poison<dummyPoison>, DummyStruct>) == sizeof(DummyStruct*), "");
-static_assert(sizeof(PoisonedUniquePtr<Poison<dummyPoison>, int[]>) == sizeof(int*), "");
-static_assert(sizeof(PoisonedUniquePtr<Poison<dummyPoison>, DummyStruct[]>) == sizeof(DummyStruct*), "");
 
 static_assert(sizeof(RefCountedArray<DummyStruct>) == sizeof(void*), "");
-static_assert(sizeof(PoisonedRefCountedArray<Poison<dummyPoison>, DummyStruct>) == sizeof(void*), "");
     
 } // namespace WTF
 
index 05251bc..aed1ddf 100644 (file)
@@ -1,3 +1,19 @@
+2019-02-26  Mark Lam  <mark.lam@apple.com>
+
+        Remove remaining poisoning code.
+        https://bugs.webkit.org/show_bug.cgi?id=194138
+
+        Reviewed by Saam Barati.
+
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/Poisoned.cpp: Removed.
+        * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: Removed.
+        * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: Removed.
+        * TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp: Removed.
+        * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp: Removed.
+        * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp: Removed.
+
 2019-02-26  Alex Christensen  <achristensen@webkit.org>
 
         Move ephemeral local storage from WebProcess to UIProcess
index d9cea8f..ca9acc8 100644 (file)
@@ -147,12 +147,6 @@ set(TestWTF_SOURCES
     ${TESTWEBKITAPI_DIR}/Tests/WTF/Optional.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/OptionSet.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/ParkingLot.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WTF/Poisoned.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedRef.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedRefPtr.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedUniquePtr.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp
-    ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/PriorityQueue.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/Ref.cpp
index 4e56bc5..f0e732e 100644 (file)
                F6B7BE9717469B96008A3445 /* associate-form-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6B7BE9617469B7E008A3445 /* associate-form-controls.html */; };
                F6F49C6B15545CA70007F39D /* DOMWindowExtensionNoCache_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */; };
                F6FDDDD614241C6F004F1729 /* push-state.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6FDDDD514241C48004F1729 /* push-state.html */; };
-               FE05FAEC1FDB510A00093230 /* PoisonedRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE05FAEB1FDB510200093230 /* PoisonedRef.cpp */; };
-               FE05FAED1FDB510E00093230 /* PoisonedRefPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE05FAEA1FDB510100093230 /* PoisonedRefPtr.cpp */; };
-               FE05FAEF1FE0645B00093230 /* Poisoned.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE05FAEE1FE0643D00093230 /* Poisoned.cpp */; };
-               FE05FB061FE84FB700093230 /* PoisonedUniquePtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE05FB051FE84FAE00093230 /* PoisonedUniquePtr.cpp */; };
-               FEC8F4E71FE9C9050056FD8A /* PoisonedUniquePtrForTriviallyDestructibleArrays.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEC8F4E61FE9C8DE0056FD8A /* PoisonedUniquePtrForTriviallyDestructibleArrays.cpp */; };
-               FEC8F4EB1FE9F5AF0056FD8A /* PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEC8F4EA1FE9F5A70056FD8A /* PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
                F6F49C6715545C8D0007F39D /* DOMWindowExtensionNoCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionNoCache.cpp; sourceTree = "<group>"; };
                F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
                F6FDDDD514241C48004F1729 /* push-state.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "push-state.html"; sourceTree = "<group>"; };
-               FE05FAEA1FDB510100093230 /* PoisonedRefPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PoisonedRefPtr.cpp; sourceTree = "<group>"; };
-               FE05FAEB1FDB510200093230 /* PoisonedRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PoisonedRef.cpp; sourceTree = "<group>"; };
-               FE05FAEE1FE0643D00093230 /* Poisoned.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Poisoned.cpp; sourceTree = "<group>"; };
-               FE05FB051FE84FAE00093230 /* PoisonedUniquePtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PoisonedUniquePtr.cpp; sourceTree = "<group>"; };
                FEB6F74E1B2BA44E009E4922 /* NakedPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NakedPtr.cpp; sourceTree = "<group>"; };
-               FEC8F4E61FE9C8DE0056FD8A /* PoisonedUniquePtrForTriviallyDestructibleArrays.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PoisonedUniquePtrForTriviallyDestructibleArrays.cpp; sourceTree = "<group>"; };
-               FEC8F4EA1FE9F5A70056FD8A /* PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                                1AFDE6541953B2C000C48FFA /* Optional.cpp */,
                                CE50D8C81C8665CE0072EA5A /* OptionSet.cpp */,
                                0FE447971B76F1E3009498EB /* ParkingLot.cpp */,
-                               FE05FAEE1FE0643D00093230 /* Poisoned.cpp */,
-                               FE05FAEB1FDB510200093230 /* PoisonedRef.cpp */,
-                               FE05FAEA1FDB510100093230 /* PoisonedRefPtr.cpp */,
-                               FE05FB051FE84FAE00093230 /* PoisonedUniquePtr.cpp */,
-                               FEC8F4EA1FE9F5A70056FD8A /* PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp */,
-                               FEC8F4E61FE9C8DE0056FD8A /* PoisonedUniquePtrForTriviallyDestructibleArrays.cpp */,
                                53EC253F1E96BC80000831B9 /* PriorityQueue.cpp */,
                                0FC6C4CB141027E0005B7F0C /* RedBlackTree.cpp */,
                                93A427AA180DA26400CD24D7 /* Ref.cpp */,
                                1A77BAA31D9AFFFC005FC568 /* OptionSet.cpp in Sources */,
                                7C83DF021D0A590C00FEBCF3 /* OSObjectPtr.cpp in Sources */,
                                7C83DF591D0A590C00FEBCF3 /* ParkingLot.cpp in Sources */,
-                               FE05FAEF1FE0645B00093230 /* Poisoned.cpp in Sources */,
-                               FE05FAEC1FDB510A00093230 /* PoisonedRef.cpp in Sources */,
-                               FE05FAED1FDB510E00093230 /* PoisonedRefPtr.cpp in Sources */,
-                               FE05FB061FE84FB700093230 /* PoisonedUniquePtr.cpp in Sources */,
-                               FEC8F4EB1FE9F5AF0056FD8A /* PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp in Sources */,
-                               FEC8F4E71FE9C9050056FD8A /* PoisonedUniquePtrForTriviallyDestructibleArrays.cpp in Sources */,
                                53EC25411E96FD87000831B9 /* PriorityQueue.cpp in Sources */,
                                7C83DF131D0A590C00FEBCF3 /* RedBlackTree.cpp in Sources */,
                                7C83DF141D0A590C00FEBCF3 /* Ref.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WTF/Poisoned.cpp b/Tools/TestWebKitAPI/Tests/WTF/Poisoned.cpp
deleted file mode 100644 (file)
index e0d9910..0000000
+++ /dev/null
@@ -1,609 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "RefLogger.h"
-#include <mutex>
-#include <wtf/Poisoned.h>
-
-namespace TestWebKitAPI {
-
-namespace {
-
-uintptr_t g_testPoisonA;
-uintptr_t g_testPoisonB;
-
-using TestPoisonA = Poison<g_testPoisonA>;
-using TestPoisonB = Poison<g_testPoisonB>;
-
-static void initializeTestPoison()
-{
-    static std::once_flag initializeOnceFlag;
-    std::call_once(initializeOnceFlag, [] {
-        // Make sure we get 2 different poison values.
-        g_testPoisonA = makePoison();
-        while (!g_testPoisonB || g_testPoisonB == g_testPoisonA)
-            g_testPoisonB = makePoison();
-    });
-}
-
-} // namespace anonymous
-
-// For these tests, we need a base class and a derived class. For this purpose,
-// we reuse the RefLogger and DerivedRefLogger classes.
-
-TEST(WTF_Poisoned, DISABLED_Basic)
-{
-    initializeTestPoison();
-    DerivedRefLogger a("a");
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> empty;
-        ASSERT_EQ(nullptr, empty.unpoisoned());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> empty(nullptr);
-        ASSERT_EQ(nullptr, empty.unpoisoned());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
-        ASSERT_EQ(&a, ptr.unpoisoned());
-        ASSERT_EQ(&a, &*ptr);
-        ASSERT_EQ(&a.name, &ptr->name);
-
-#if ENABLE(POISON)
-        uintptr_t ptrBits;
-        std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
-        ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(&a));
-#if ENABLE(POISON_ASSERTS)
-        ASSERT_TRUE((Poisoned<TestPoisonA, RefLogger*>::isPoisoned(ptrBits)));
-#endif
-#endif // ENABLE(POISON)
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> ptr = &a;
-        ASSERT_EQ(&a, ptr.unpoisoned());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1 = &a;
-        Poisoned<TestPoisonA, RefLogger*> p2(p1);
-
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&a, p2.unpoisoned());
-        ASSERT_TRUE(p1 == p2);
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonB, RefLogger*> p3(p1);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_TRUE(p1 == p3);
-        ASSERT_TRUE(p1.bits() != p3.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1 = &a;
-        Poisoned<TestPoisonA, RefLogger*> p2 = p1;
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&a, p2.unpoisoned());
-        ASSERT_TRUE(p1 == p2);
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonB, RefLogger*> p3 = p1;
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_TRUE(p1 == p3);
-        ASSERT_TRUE(p1.bits() != p3.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1 = &a;
-        Poisoned<TestPoisonA, RefLogger*> p2 = WTFMove(p1);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&a, p2.unpoisoned());
-        ASSERT_TRUE(p1 == p2);
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonA, RefLogger*> p3 = &a;
-        Poisoned<TestPoisonB, RefLogger*> p4 = WTFMove(p3);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&a, p4.unpoisoned());
-        ASSERT_TRUE(p3 == p4);
-        ASSERT_TRUE(p3.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1 = &a;
-        Poisoned<TestPoisonA, RefLogger*> p2(WTFMove(p1));
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&a, p2.unpoisoned());
-        ASSERT_TRUE(p1 == p2);
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonA, RefLogger*> p3 = &a;
-        Poisoned<TestPoisonB, RefLogger*> p4(WTFMove(p3));
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&a, p4.unpoisoned());
-        ASSERT_TRUE(p3 == p4);
-        ASSERT_TRUE(p3.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, DerivedRefLogger*> p1 = &a;
-        Poisoned<TestPoisonA, RefLogger*> p2 = p1;
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&a, p2.unpoisoned());
-        ASSERT_TRUE(p1 == p2);
-        ASSERT_TRUE(p2 == p1);
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonB, RefLogger*> p3 = p1;
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_TRUE(p1 == p3);
-        ASSERT_TRUE(p3 == p1);
-        ASSERT_TRUE(p1.bits() != p3.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, DerivedRefLogger*> p1 = &a;
-        Poisoned<TestPoisonA, RefLogger*> p2 = WTFMove(p1);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&a, p2.unpoisoned());
-        ASSERT_TRUE(p1 == p2);
-        ASSERT_TRUE(p2 == p1);
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonA, DerivedRefLogger*> p3 = &a;
-        Poisoned<TestPoisonB, RefLogger*> p4 = WTFMove(p3);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&a, p4.unpoisoned());
-        ASSERT_TRUE(p3 == p4);
-        ASSERT_TRUE(p4 == p3);
-        ASSERT_TRUE(p3.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
-        ASSERT_EQ(&a, ptr.unpoisoned());
-        ptr.clear();
-        ASSERT_EQ(nullptr, ptr.unpoisoned());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> pA1000a = reinterpret_cast<RefLogger*>(0x1000);
-        Poisoned<TestPoisonB, RefLogger*> pB2000a = reinterpret_cast<RefLogger*>(0x2000);
-
-        Poisoned<TestPoisonA, RefLogger*> pA1000b = reinterpret_cast<RefLogger*>(0x1000);
-        Poisoned<TestPoisonA, RefLogger*> pA2000b = reinterpret_cast<RefLogger*>(0x2000);
-
-        Poisoned<TestPoisonB, RefLogger*> pB1000c = reinterpret_cast<RefLogger*>(0x1000);
-        Poisoned<TestPoisonB, RefLogger*> pB2000c = reinterpret_cast<RefLogger*>(0x2000);
-
-
-        ASSERT_EQ(pA1000a == pA1000a, true);
-        ASSERT_EQ(pA1000a == pA1000b, true);
-        ASSERT_EQ(pA1000a == pA2000b, false);
-        ASSERT_EQ(pA1000a == pB1000c, true);
-        ASSERT_EQ(pA1000a == pB2000c, false);
-
-        ASSERT_EQ(pA1000a != pA1000a, false);
-        ASSERT_EQ(pA1000a != pA1000b, false);
-        ASSERT_EQ(pA1000a != pA2000b, true);
-        ASSERT_EQ(pA1000a != pB1000c, false);
-        ASSERT_EQ(pA1000a != pB2000c, true);
-
-        ASSERT_EQ(pA1000a < pA1000a, false);
-        ASSERT_EQ(pA1000a < pA1000b, false);
-        ASSERT_EQ(pA1000a < pA2000b, true);
-        ASSERT_EQ(pA1000a < pB1000c, false);
-        ASSERT_EQ(pA1000a < pB2000c, true);
-
-        ASSERT_EQ(pB2000a < pB2000a, false);
-        ASSERT_EQ(pB2000a < pA1000b, false);
-        ASSERT_EQ(pB2000a < pA2000b, false);
-        ASSERT_EQ(pB2000a < pB1000c, false);
-        ASSERT_EQ(pB2000a < pB2000c, false);
-
-        ASSERT_EQ(pA1000a <= pA1000a, true);
-        ASSERT_EQ(pA1000a <= pA1000b, true);
-        ASSERT_EQ(pA1000a <= pA2000b, true);
-        ASSERT_EQ(pA1000a <= pB1000c, true);
-        ASSERT_EQ(pA1000a <= pB2000c, true);
-
-        ASSERT_EQ(pB2000a <= pB2000a, true);
-        ASSERT_EQ(pB2000a <= pA1000b, false);
-        ASSERT_EQ(pB2000a <= pA2000b, true);
-        ASSERT_EQ(pB2000a <= pB1000c, false);
-        ASSERT_EQ(pB2000a <= pB2000c, true);
-
-        ASSERT_EQ(pA1000a > pA1000a, false);
-        ASSERT_EQ(pA1000a > pA1000b, false);
-        ASSERT_EQ(pA1000a > pA2000b, false);
-        ASSERT_EQ(pA1000a > pB1000c, false);
-        ASSERT_EQ(pA1000a > pB2000c, false);
-
-        ASSERT_EQ(pB2000a > pB2000a, false);
-        ASSERT_EQ(pB2000a > pA1000b, true);
-        ASSERT_EQ(pB2000a > pA2000b, false);
-        ASSERT_EQ(pB2000a > pB1000c, true);
-        ASSERT_EQ(pB2000a > pB2000c, false);
-
-        ASSERT_EQ(pA1000a >= pA1000a, true);
-        ASSERT_EQ(pA1000a >= pA1000b, true);
-        ASSERT_EQ(pA1000a >= pA2000b, false);
-        ASSERT_EQ(pA1000a >= pB1000c, true);
-        ASSERT_EQ(pA1000a >= pB2000c, false);
-
-        ASSERT_EQ(pB2000a >= pB2000a, true);
-        ASSERT_EQ(pB2000a >= pA1000b, true);
-        ASSERT_EQ(pB2000a >= pA2000b, true);
-        ASSERT_EQ(pB2000a >= pB1000c, true);
-        ASSERT_EQ(pB2000a >= pB2000c, true);
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> prA1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
-        Poisoned<TestPoisonA, DerivedRefLogger*> pdA1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
-        Poisoned<TestPoisonB, RefLogger*> prB1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
-        Poisoned<TestPoisonB, DerivedRefLogger*> pdB1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
-
-        Poisoned<TestPoisonA, RefLogger*> prA2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
-        Poisoned<TestPoisonA, DerivedRefLogger*> pdA2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
-        Poisoned<TestPoisonB, RefLogger*> prB2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
-        Poisoned<TestPoisonB, DerivedRefLogger*> pdB2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
-
-        ASSERT_EQ(prA1000 == pdA1000, true);
-        ASSERT_EQ(prA1000 == pdB1000, true);
-        ASSERT_EQ(prA1000 == pdA2000, false);
-        ASSERT_EQ(prA1000 == pdB2000, false);
-        ASSERT_EQ(pdA1000 == prA1000, true);
-        ASSERT_EQ(pdA1000 == prB1000, true);
-        ASSERT_EQ(pdA1000 == prA2000, false);
-        ASSERT_EQ(pdA1000 == prB2000, false);
-
-        ASSERT_EQ(prA1000 != pdA1000, false);
-        ASSERT_EQ(prA1000 != pdB1000, false);
-        ASSERT_EQ(prA1000 != pdA2000, true);
-        ASSERT_EQ(prA1000 != pdB2000, true);
-        ASSERT_EQ(pdA1000 != prA1000, false);
-        ASSERT_EQ(pdA1000 != prB1000, false);
-        ASSERT_EQ(pdA1000 != prA2000, true);
-        ASSERT_EQ(pdA1000 != prB2000, true);
-
-        ASSERT_EQ(prA1000 < pdA1000, false);
-        ASSERT_EQ(prA1000 < pdB1000, false);
-        ASSERT_EQ(prA1000 < pdA2000, true);
-        ASSERT_EQ(prA1000 < pdB2000, true);
-        ASSERT_EQ(pdA1000 < prA1000, false);
-        ASSERT_EQ(pdA1000 < prB1000, false);
-        ASSERT_EQ(pdA1000 < prA2000, true);
-        ASSERT_EQ(pdA1000 < prB2000, true);
-
-        ASSERT_EQ(prA2000 < pdA1000, false);
-        ASSERT_EQ(prA2000 < pdB1000, false);
-        ASSERT_EQ(prA2000 < pdA2000, false);
-        ASSERT_EQ(prA2000 < pdB2000, false);
-        ASSERT_EQ(pdA2000 < prA1000, false);
-        ASSERT_EQ(pdA2000 < prB1000, false);
-        ASSERT_EQ(pdA2000 < prA2000, false);
-        ASSERT_EQ(pdA2000 < prB2000, false);
-
-        ASSERT_EQ(prA1000 <= pdA1000, true);
-        ASSERT_EQ(prA1000 <= pdB1000, true);
-        ASSERT_EQ(prA1000 <= pdA2000, true);
-        ASSERT_EQ(prA1000 <= pdB2000, true);
-        ASSERT_EQ(pdA1000 <= prA1000, true);
-        ASSERT_EQ(pdA1000 <= prB1000, true);
-        ASSERT_EQ(pdA1000 <= prA2000, true);
-        ASSERT_EQ(pdA1000 <= prB2000, true);
-
-        ASSERT_EQ(prA2000 <= pdA1000, false);
-        ASSERT_EQ(prA2000 <= pdB1000, false);
-        ASSERT_EQ(prA2000 <= pdA2000, true);
-        ASSERT_EQ(prA2000 <= pdB2000, true);
-        ASSERT_EQ(pdA2000 <= prA1000, false);
-        ASSERT_EQ(pdA2000 <= prB1000, false);
-        ASSERT_EQ(pdA2000 <= prA2000, true);
-        ASSERT_EQ(pdA2000 <= prB2000, true);
-
-        ASSERT_EQ(prA1000 > pdA1000, false);
-        ASSERT_EQ(prA1000 > pdB1000, false);
-        ASSERT_EQ(prA1000 > pdA2000, false);
-        ASSERT_EQ(prA1000 > pdB2000, false);
-        ASSERT_EQ(pdA1000 > prA1000, false);
-        ASSERT_EQ(pdA1000 > prB1000, false);
-        ASSERT_EQ(pdA1000 > prA2000, false);
-        ASSERT_EQ(pdA1000 > prB2000, false);
-
-        ASSERT_EQ(prA2000 > pdA1000, true);
-        ASSERT_EQ(prA2000 > pdB1000, true);
-        ASSERT_EQ(prA2000 > pdA2000, false);
-        ASSERT_EQ(prA2000 > pdB2000, false);
-        ASSERT_EQ(pdA2000 > prA1000, true);
-        ASSERT_EQ(pdA2000 > prB1000, true);
-        ASSERT_EQ(pdA2000 > prA2000, false);
-        ASSERT_EQ(pdA2000 > prB2000, false);
-
-        ASSERT_EQ(prA1000 >= pdA1000, true);
-        ASSERT_EQ(prA1000 >= pdB1000, true);
-        ASSERT_EQ(prA1000 >= pdA2000, false);
-        ASSERT_EQ(prA1000 >= pdB2000, false);
-        ASSERT_EQ(pdA1000 >= prA1000, true);
-        ASSERT_EQ(pdA1000 >= prB1000, true);
-        ASSERT_EQ(pdA1000 >= prA2000, false);
-        ASSERT_EQ(pdA1000 >= prB2000, false);
-
-        ASSERT_EQ(prA2000 >= pdA1000, true);
-        ASSERT_EQ(prA2000 >= pdB1000, true);
-        ASSERT_EQ(prA2000 >= pdA2000, true);
-        ASSERT_EQ(prA2000 >= pdB2000, true);
-        ASSERT_EQ(pdA2000 >= prA1000, true);
-        ASSERT_EQ(pdA2000 >= prB1000, true);
-        ASSERT_EQ(pdA2000 >= prA2000, true);
-        ASSERT_EQ(pdA2000 >= prB2000, true);
-    }
-}
-
-TEST(WTF_Poisoned, DISABLED_Assignment)
-{
-    initializeTestPoison();
-    DerivedRefLogger a("a");
-    RefLogger b("b");
-    DerivedRefLogger c("c");
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1(&a);
-        Poisoned<TestPoisonA, RefLogger*> p2(&b);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&b, p2.unpoisoned());
-        p1 = p2;
-        ASSERT_EQ(&b, p1.unpoisoned());
-        ASSERT_EQ(&b, p2.unpoisoned());
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonA, RefLogger*> p3(&a);
-        Poisoned<TestPoisonB, RefLogger*> p4(&b);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&b, p4.unpoisoned());
-        p3 = p4;
-        ASSERT_EQ(&b, p3.unpoisoned());
-        ASSERT_EQ(&b, p4.unpoisoned());
-        ASSERT_TRUE(p3.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
-        ASSERT_EQ(&a, ptr.unpoisoned());
-        ptr = &b;
-        ASSERT_EQ(&b, ptr.unpoisoned());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
-        ASSERT_EQ(&a, ptr.unpoisoned());
-        ptr = nullptr;
-        ASSERT_EQ(nullptr, ptr.unpoisoned());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1(&a);
-        Poisoned<TestPoisonA, RefLogger*> p2(&b);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&b, p2.unpoisoned());
-        p1 = WTFMove(p2);
-        ASSERT_EQ(&b, p1.unpoisoned());
-        ASSERT_EQ(&b, p2.unpoisoned());
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonA, RefLogger*> p3(&a);
-        Poisoned<TestPoisonB, RefLogger*> p4(&b);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&b, p4.unpoisoned());
-        p3 = WTFMove(p4);
-        ASSERT_EQ(&b, p3.unpoisoned());
-        ASSERT_EQ(&b, p4.unpoisoned());
-        ASSERT_TRUE(p3.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1(&a);
-        Poisoned<TestPoisonA, DerivedRefLogger*> p2(&c);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&c, p2.unpoisoned());
-        p1 = p2;
-        ASSERT_EQ(&c, p1.unpoisoned());
-        ASSERT_EQ(&c, p2.unpoisoned());
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonA, RefLogger*> p3(&a);
-        Poisoned<TestPoisonB, DerivedRefLogger*> p4(&c);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&c, p4.unpoisoned());
-        p3 = p4;
-        ASSERT_EQ(&c, p3.unpoisoned());
-        ASSERT_EQ(&c, p4.unpoisoned());
-        ASSERT_TRUE(p3.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
-        ASSERT_EQ(&a, ptr.unpoisoned());
-        ptr = &c;
-        ASSERT_EQ(&c, ptr.unpoisoned());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1(&a);
-        Poisoned<TestPoisonA, DerivedRefLogger*> p2(&c);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&c, p2.unpoisoned());
-        p1 = WTFMove(p2);
-        ASSERT_EQ(&c, p1.unpoisoned());
-        ASSERT_EQ(&c, p2.unpoisoned());
-        ASSERT_TRUE(p1.bits() == p2.bits());
-
-        Poisoned<TestPoisonA, RefLogger*> p3(&a);
-        Poisoned<TestPoisonB, DerivedRefLogger*> p4(&c);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&c, p4.unpoisoned());
-        p3 = WTFMove(p4);
-        ASSERT_EQ(&c, p3.unpoisoned());
-        ASSERT_EQ(&c, p4.unpoisoned());
-        ASSERT_TRUE(p3.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
-        ASSERT_EQ(&a, ptr.unpoisoned());
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wunknown-warning-option"
-#pragma clang diagnostic ignored "-Wself-assign-overloaded"
-#endif
-        ptr = ptr;
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-        ASSERT_EQ(&a, ptr.unpoisoned());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
-        ASSERT_EQ(&a, ptr.unpoisoned());
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wself-move"
-#endif
-        ptr = WTFMove(ptr);
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-        ASSERT_EQ(&a, ptr.unpoisoned());
-    }
-}
-
-TEST(WTF_Poisoned, DISABLED_Swap)
-{
-    initializeTestPoison();
-    RefLogger a("a");
-    RefLogger b("b");
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1(&a);
-        Poisoned<TestPoisonA, RefLogger*> p2(&b);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&b, p2.unpoisoned());
-        p1.swap(p2);
-        ASSERT_EQ(&b, p1.unpoisoned());
-        ASSERT_EQ(&a, p2.unpoisoned());
-
-        ASSERT_TRUE(p1.bits() != p2.bits());
-
-        Poisoned<TestPoisonA, RefLogger*> p3(&a);
-        Poisoned<TestPoisonB, RefLogger*> p4(&b);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&b, p4.unpoisoned());
-        p3.swap(p4);
-        ASSERT_EQ(&b, p3.unpoisoned());
-        ASSERT_EQ(&a, p4.unpoisoned());
-
-        ASSERT_TRUE(p3.bits() != p4.bits());
-        ASSERT_TRUE(p1.bits() == p3.bits());
-        ASSERT_TRUE(p2.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1(&a);
-        Poisoned<TestPoisonA, RefLogger*> p2(&b);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&b, p2.unpoisoned());
-        swap(p1, p2);
-        ASSERT_EQ(&b, p1.unpoisoned());
-        ASSERT_EQ(&a, p2.unpoisoned());
-
-        ASSERT_TRUE(p1.bits() != p2.bits());
-
-        Poisoned<TestPoisonA, RefLogger*> p3(&a);
-        Poisoned<TestPoisonB, RefLogger*> p4(&b);
-        ASSERT_EQ(&a, p3.unpoisoned());
-        ASSERT_EQ(&b, p4.unpoisoned());
-        swap(p3, p4);
-        ASSERT_EQ(&b, p3.unpoisoned());
-        ASSERT_EQ(&a, p4.unpoisoned());
-
-        ASSERT_TRUE(p3.bits() != p4.bits());
-        ASSERT_TRUE(p1.bits() == p3.bits());
-        ASSERT_TRUE(p2.bits() != p4.bits());
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1(&a);
-        RefLogger* p2(&b);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&b, p2);
-        swap(p1, p2);
-        ASSERT_EQ(&b, p1.unpoisoned());
-        ASSERT_EQ(&a, p2);
-
-        ASSERT_TRUE(p1.bits() != bitwise_cast<uintptr_t>(p2));
-    }
-
-    {
-        Poisoned<TestPoisonA, RefLogger*> p1(&a);
-        RefLogger* p2(&b);
-        ASSERT_EQ(&a, p1.unpoisoned());
-        ASSERT_EQ(&b, p2);
-        p1.swap(p2);
-        ASSERT_EQ(&b, p1.unpoisoned());
-        ASSERT_EQ(&a, p2);
-
-        ASSERT_TRUE(p1.bits() != bitwise_cast<uintptr_t>(p2));
-    }
-}
-
-static Poisoned<TestPoisonA, RefLogger*> poisonedPtrFoo(RefLogger& logger)
-{
-    return Poisoned<TestPoisonA, RefLogger*>(&logger);
-}
-
-TEST(WTF_Poisoned, DISABLED_ReturnValue)
-{
-    initializeTestPoison();
-    DerivedRefLogger a("a");
-
-    {
-        auto ptr = poisonedPtrFoo(a);
-        ASSERT_EQ(&a, ptr.unpoisoned());
-        ASSERT_EQ(&a, &*ptr);
-        ASSERT_EQ(&a.name, &ptr->name);
-    }
-}
-
-} // namespace TestWebKitAPI
-
diff --git a/Tools/TestWebKitAPI/Tests/WTF/PoisonedRef.cpp b/Tools/TestWebKitAPI/Tests/WTF/PoisonedRef.cpp
deleted file mode 100644 (file)
index 3be228f..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "RefLogger.h"
-#include <mutex>
-#include <wtf/Poisoned.h>
-#include <wtf/RefPtr.h>
-
-namespace TestWebKitAPI {
-
-namespace {
-
-uintptr_t g_poisonA;
-uintptr_t g_poisonB;
-uintptr_t g_poisonC;
-uintptr_t g_poisonD;
-uintptr_t g_poisonE;
-uintptr_t g_poisonF;
-
-using PoisonA = Poison<g_poisonA>;
-using PoisonB = Poison<g_poisonB>;
-using PoisonC = Poison<g_poisonC>;
-using PoisonD = Poison<g_poisonD>;
-using PoisonE = Poison<g_poisonE>;
-using PoisonF = Poison<g_poisonF>;
-
-static void initializePoisons()
-{
-    static std::once_flag initializeOnceFlag;
-    std::call_once(initializeOnceFlag, [] {
-        g_poisonA = makePoison();
-        g_poisonB = makePoison();
-        g_poisonC = makePoison();
-        g_poisonD = makePoison();
-        g_poisonF = makePoison();
-        g_poisonF = makePoison();
-    });
-}
-
-} // namespace anonymous
-
-TEST(WTF_PoisonedRef, Basic)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-
-    {
-        PoisonedRef<PoisonA, RefLogger> ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        EXPECT_EQ(&a.name, &ref->name);
-
-#if ENABLE(POISON)
-        uintptr_t ptrBits;
-        std::memcpy(&ptrBits, &ref, sizeof(ptrBits));
-        ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(&a));
-        ASSERT_EQ(ptrBits, (Poisoned<PoisonA, RefLogger*>(&a).bits()));
-#if ENABLE(POISON_ASSERTS)
-        ASSERT_TRUE((Poisoned<PoisonA, RefLogger*>::isPoisoned(ptrBits)));
-#endif
-#endif // ENABLE(POISON)
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonB, RefLogger> ref(adoptRef(a));
-        EXPECT_EQ(&a, ref.ptr());
-        EXPECT_EQ(&a.name, &ref->name);
-    }
-    EXPECT_STREQ("deref(a) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRef, Assignment)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-    RefLogger b("b");
-    DerivedRefLogger c("c");
-
-    {
-        PoisonedRef<PoisonC, RefLogger> ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        ref = b;
-        EXPECT_EQ(&b, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | ref(b) deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonD, RefLogger> ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        ref = c;
-        EXPECT_EQ(&c, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | ref(c) deref(a) | deref(c) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonE, RefLogger> ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        ref = adoptRef(b);
-        EXPECT_EQ(&b, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonF, RefLogger> ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        ref = adoptRef(c);
-        EXPECT_EQ(&c, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | deref(a) | deref(c) ", takeLogStr().c_str());
-}
-
-static PoisonedRef<PoisonB, RefLogger> passWithRef(PoisonedRef<PoisonC, RefLogger>&& reference)
-{
-    return WTFMove(reference);
-}
-
-TEST(WTF_PoisonedRef, ReturnValue)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-    RefLogger b("b");
-    DerivedRefLogger c("c");
-
-    {
-        PoisonedRef<PoisonB, RefLogger> ref(passWithRef(PoisonedRef<PoisonC, RefLogger>(a)));
-        EXPECT_EQ(&a, ref.ptr());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonD, RefLogger> ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        ref = passWithRef(b);
-        EXPECT_EQ(&b, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | ref(b) deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonE, RefLogger> ptr(passWithRef(a));
-        EXPECT_EQ(&a, ptr.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonF, DerivedRefLogger> ptr(&a);
-        PoisonedRefPtr<PoisonA, RefLogger> ptr2(WTFMove(ptr));
-        EXPECT_EQ(nullptr, ptr.get());
-        EXPECT_EQ(&a, ptr2.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonB, DerivedRefLogger> derivedReference(a);
-        PoisonedRef<PoisonC, RefLogger> baseReference(passWithRef(derivedReference.copyRef()));
-        EXPECT_EQ(&a, derivedReference.ptr());
-        EXPECT_EQ(&a, baseReference.ptr());
-    }
-    EXPECT_STREQ("ref(a) ref(a) deref(a) deref(a) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRef, Swap)
-{
-    initializePoisons();
-
-    RefLogger a("a");
-    RefLogger b("b");
-
-    {
-        PoisonedRef<PoisonD, RefLogger> p1(a);
-        PoisonedRef<PoisonE, RefLogger> p2(b);
-        log() << "| ";
-        EXPECT_EQ(&a, p1.ptr());
-        EXPECT_EQ(&b, p2.ptr());
-        p1.swap(p2);
-        EXPECT_EQ(&b, p1.ptr());
-        EXPECT_EQ(&a, p2.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonF, RefLogger> p1(a);
-        PoisonedRef<PoisonA, RefLogger> p2(b);
-        log() << "| ";
-        EXPECT_EQ(&a, p1.ptr());
-        EXPECT_EQ(&b, p2.ptr());
-        swap(p1, p2);
-        EXPECT_EQ(&b, p1.ptr());
-        EXPECT_EQ(&a, p2.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonF, RefLogger> p1(a);
-        Ref<RefLogger> p2(b);
-        log() << "| ";
-        EXPECT_EQ(&a, p1.ptr());
-        EXPECT_EQ(&b, p2.ptr());
-        swap(p1, p2);
-        EXPECT_EQ(&b, p1.ptr());
-        EXPECT_EQ(&a, p2.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRef<PoisonF, RefLogger> p1(a);
-        Ref<RefLogger> p2(b);
-        log() << "| ";
-        EXPECT_EQ(&a, p1.ptr());
-        EXPECT_EQ(&b, p2.ptr());
-        p1.swap(p2);
-        EXPECT_EQ(&b, p1.ptr());
-        EXPECT_EQ(&a, p2.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
-}
-
-struct PoisonedRefCheckingRefLogger : RefLogger {
-    using Ref = PoisonedRef<PoisonB, PoisonedRefCheckingRefLogger>;
-
-    PoisonedRefCheckingRefLogger(const char* name);
-    void ref();
-    void deref();
-    const Ref* slotToCheck { nullptr };
-};
-
-struct DerivedPoisonedRefCheckingRefLogger : PoisonedRefCheckingRefLogger {
-    DerivedPoisonedRefCheckingRefLogger(const char* name);
-};
-
-PoisonedRefCheckingRefLogger::PoisonedRefCheckingRefLogger(const char* name)
-    : RefLogger { name }
-{
-}
-
-void PoisonedRefCheckingRefLogger::ref()
-{
-    if (slotToCheck)
-        log() << "slot=" << slotToCheck->get().name << " ";
-    RefLogger::ref();
-}
-
-void PoisonedRefCheckingRefLogger::deref()
-{
-    if (slotToCheck)
-        log() << "slot=" << slotToCheck->get().name << " ";
-    RefLogger::deref();
-}
-
-DerivedPoisonedRefCheckingRefLogger::DerivedPoisonedRefCheckingRefLogger(const char* name)
-    : PoisonedRefCheckingRefLogger { name }
-{
-}
-
-TEST(WTF_PoisonedRef, AssignBeforeDeref)
-{
-    initializePoisons();
-
-    DerivedPoisonedRefCheckingRefLogger a("a");
-    PoisonedRefCheckingRefLogger b("b");
-    DerivedPoisonedRefCheckingRefLogger c("c");
-
-    {
-        PoisonedRefCheckingRefLogger::Ref ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        a.slotToCheck = &ref;
-        b.slotToCheck = &ref;
-        ref = b;
-        a.slotToCheck = nullptr;
-        b.slotToCheck = nullptr;
-        EXPECT_EQ(&b, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | slot=a ref(b) slot=b deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefCheckingRefLogger::Ref ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        a.slotToCheck = &ref;
-        c.slotToCheck = &ref;
-        ref = c;
-        a.slotToCheck = nullptr;
-        c.slotToCheck = nullptr;
-        EXPECT_EQ(&c, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | slot=a ref(c) slot=c deref(a) | deref(c) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefCheckingRefLogger::Ref ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        a.slotToCheck = &ref;
-        ref = adoptRef(b);
-        a.slotToCheck = nullptr;
-        EXPECT_EQ(&b, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | slot=b deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefCheckingRefLogger::Ref ref(a);
-        EXPECT_EQ(&a, ref.ptr());
-        log() << "| ";
-        a.slotToCheck = &ref;
-        ref = adoptRef(c);
-        a.slotToCheck = nullptr;
-        EXPECT_EQ(&c, ref.ptr());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | slot=c deref(a) | deref(c) ", takeLogStr().c_str());
-}
-
-} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp b/Tools/TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp
deleted file mode 100644 (file)
index fb40cf6..0000000
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "RefLogger.h"
-#include <mutex>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/Poisoned.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-namespace TestWebKitAPI {
-
-namespace {
-
-uintptr_t g_poisonA;
-uintptr_t g_poisonB;
-uintptr_t g_poisonC;
-uintptr_t g_poisonD;
-uintptr_t g_poisonE;
-uintptr_t g_poisonF;
-
-using PoisonA = Poison<g_poisonA>;
-using PoisonB = Poison<g_poisonB>;
-using PoisonC = Poison<g_poisonC>;
-using PoisonD = Poison<g_poisonD>;
-using PoisonE = Poison<g_poisonE>;
-using PoisonF = Poison<g_poisonF>;
-
-static void initializePoisons()
-{
-    static std::once_flag initializeOnceFlag;
-    std::call_once(initializeOnceFlag, [] {
-        g_poisonA = makePoison();
-        g_poisonB = makePoison();
-        g_poisonC = makePoison();
-        g_poisonD = makePoison();
-        g_poisonF = makePoison();
-        g_poisonF = makePoison();
-    });
-}
-
-} // namespace anonymous
-
-TEST(WTF_PoisonedRefPtr, Basic)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-
-    PoisonedRefPtr<PoisonA, RefLogger> empty;
-    EXPECT_EQ(nullptr, empty.get());
-
-    {
-        PoisonedRefPtr<PoisonB, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        EXPECT_EQ(&a, &*ptr);
-        EXPECT_EQ(&a.name, &ptr->name);
-
-#if ENABLE(POISON)
-        uintptr_t ptrBits;
-        std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
-        ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(&a));
-        ASSERT_EQ(ptrBits, (Poisoned<PoisonB, RefLogger*>(&a).bits()));
-#if ENABLE(POISON_ASSERTS)
-        ASSERT_TRUE((Poisoned<PoisonB, RefLogger*>::isPoisoned(ptrBits)));
-#endif
-#endif // ENABLE(POISON)
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonC, RefLogger> ptr = &a;
-        EXPECT_EQ(&a, ptr.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonD, RefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonE, RefLogger> p2(p1);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) ref(a) deref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonF, RefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonB, RefLogger> p2 = p1;
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) ref(a) deref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonC, RefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonD, RefLogger> p2 = WTFMove(p1);
-        EXPECT_EQ(nullptr, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonE, RefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonF, RefLogger> p2(WTFMove(p1));
-        EXPECT_EQ(nullptr, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonB, DerivedRefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonC, RefLogger> p2 = p1;
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) ref(a) deref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonD, DerivedRefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonE, RefLogger> p2 = WTFMove(p1);
-        EXPECT_EQ(nullptr, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonF, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        ptr = nullptr;
-        EXPECT_EQ(nullptr, ptr.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRefPtr, AssignPassRefToPoisonedRefPtr)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-    {
-        Ref<RefLogger> passRef(a);
-        PoisonedRefPtr<PoisonB, RefLogger> ptr = WTFMove(passRef);
-        EXPECT_EQ(&a, ptr.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRefPtr, Adopt)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-
-    PoisonedRefPtr<PoisonC, RefLogger> empty;
-    EXPECT_EQ(nullptr, empty.get());
-
-    {
-        PoisonedRefPtr<PoisonD, RefLogger> ptr(adoptRef(&a));
-        EXPECT_EQ(&a, ptr.get());
-        EXPECT_EQ(&a, &*ptr);
-        EXPECT_EQ(&a.name, &ptr->name);
-    }
-    EXPECT_STREQ("deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonE, RefLogger> ptr = adoptRef(&a);
-        EXPECT_EQ(&a, ptr.get());
-    }
-    EXPECT_STREQ("deref(a) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRefPtr, Assignment)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-    RefLogger b("b");
-    DerivedRefLogger c("c");
-
-    {
-        PoisonedRefPtr<PoisonF, RefLogger> p1(&a);
-        PoisonedRefPtr<PoisonB, RefLogger> p2(&b);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        log() << "| ";
-        p1 = p2;
-        EXPECT_EQ(&b, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | ref(b) deref(a) | deref(b) deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonC, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        log() << "| ";
-        ptr = &b;
-        EXPECT_EQ(&b, ptr.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | ref(b) deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonD, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        log() << "| ";
-        ptr = adoptRef(&b);
-        EXPECT_EQ(&b, ptr.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonE, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        ptr = nullptr;
-        EXPECT_EQ(nullptr, ptr.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonB, RefLogger> p1(&a);
-        PoisonedRefPtr<PoisonC, RefLogger> p2(&b);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        log() << "| ";
-        p1 = WTFMove(p2);
-        EXPECT_EQ(&b, p1.get());
-        EXPECT_EQ(nullptr, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonD, RefLogger> p1(&a);
-        PoisonedRefPtr<PoisonE, DerivedRefLogger> p2(&c);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&c, p2.get());
-        log() << "| ";
-        p1 = p2;
-        EXPECT_EQ(&c, p1.get());
-        EXPECT_EQ(&c, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(c) | ref(c) deref(a) | deref(c) deref(c) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonF, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        log() << "| ";
-        ptr = &c;
-        EXPECT_EQ(&c, ptr.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | ref(c) deref(a) | deref(c) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonB, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        log() << "| ";
-        ptr = adoptRef(&c);
-        EXPECT_EQ(&c, ptr.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | deref(a) | deref(c) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonC, RefLogger> p1(&a);
-        PoisonedRefPtr<PoisonD, DerivedRefLogger> p2(&c);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&c, p2.get());
-        log() << "| ";
-        p1 = WTFMove(p2);
-        EXPECT_EQ(&c, p1.get());
-        EXPECT_EQ(nullptr, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(c) | deref(a) | deref(c) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonE, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        log() << "| ";
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wunknown-warning-option"
-#pragma clang diagnostic ignored "-Wself-assign-overloaded"
-#endif
-        ptr = ptr;
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-        EXPECT_EQ(&a, ptr.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | ref(a) deref(a) | deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonF, RefLogger> ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wself-move"
-#endif
-        ptr = WTFMove(ptr);
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-        EXPECT_EQ(&a, ptr.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRefPtr, Swap)
-{
-    initializePoisons();
-
-    RefLogger a("a");
-    RefLogger b("b");
-
-    {
-        PoisonedRefPtr<PoisonB, RefLogger> p1(&a);
-        PoisonedRefPtr<PoisonC, RefLogger> p2(&b);
-        log() << "| ";
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        p1.swap(p2);
-        EXPECT_EQ(&b, p1.get());
-        EXPECT_EQ(&a, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonD, RefLogger> p1(&a);
-        PoisonedRefPtr<PoisonE, RefLogger> p2(&b);
-        log() << "| ";
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        swap(p1, p2);
-        EXPECT_EQ(&b, p1.get());
-        EXPECT_EQ(&a, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRefPtr, ReleaseNonNull)
-{
-    initializePoisons();
-
-    RefLogger a("a");
-
-    {
-        PoisonedRefPtr<PoisonF, RefLogger> refPtr = &a;
-        PoisonedRefPtr<PoisonB, RefLogger> ref = refPtr.releaseNonNull();
-    }
-
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRefPtr, Release)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-    RefLogger b("b");
-    DerivedRefLogger c("c");
-
-    {
-        PoisonedRefPtr<PoisonC, RefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonD, RefLogger> p2 = WTFMove(p1);
-        EXPECT_EQ(nullptr, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonE, RefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonF, RefLogger> p2(WTFMove(p1));
-        EXPECT_EQ(nullptr, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonB, DerivedRefLogger> p1 = &a;
-        PoisonedRefPtr<PoisonC, RefLogger> p2 = WTFMove(p1);
-        EXPECT_EQ(nullptr, p1.get());
-        EXPECT_EQ(&a, p2.get());
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonD, RefLogger> p1(&a);
-        PoisonedRefPtr<PoisonE, RefLogger> p2(&b);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        log() << "| ";
-        p1 = WTFMove(p2);
-        EXPECT_EQ(&b, p1.get());
-        EXPECT_EQ(nullptr, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtr<PoisonF, RefLogger> p1(&a);
-        PoisonedRefPtr<PoisonB, DerivedRefLogger> p2(&c);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&c, p2.get());
-        log() << "| ";
-        p1 = WTFMove(p2);
-        EXPECT_EQ(&c, p1.get());
-        EXPECT_EQ(nullptr, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(c) | deref(a) | deref(c) ", takeLogStr().c_str());
-}
-
-static PoisonedRefPtr<PoisonC, RefLogger> f1(RefLogger& logger)
-{
-    return PoisonedRefPtr<PoisonC, RefLogger>(&logger);
-}
-
-TEST(WTF_PoisonedRefPtr, ReturnValue)
-{
-    initializePoisons();
-
-    DerivedRefLogger a("a");
-
-    {
-        f1(a);
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-
-    {
-        auto ptr = f1(a);
-    }
-    EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
-}
-
-struct ConstRefCounted : RefCounted<ConstRefCounted> {
-    static Ref<ConstRefCounted> create() { return adoptRef(*new ConstRefCounted); }
-};
-
-static const ConstRefCounted& returnConstRefCountedRef()
-{
-    static NeverDestroyed<ConstRefCounted> instance;
-    return instance.get();
-}
-static ConstRefCounted& returnRefCountedRef()
-{
-    static NeverDestroyed<ConstRefCounted> instance;
-    return instance.get();
-}
-
-TEST(WTF_PoisonedRefPtr, Const)
-{
-    initializePoisons();
-
-    // This test passes if it compiles without an error.
-    auto a = ConstRefCounted::create();
-    Ref<const ConstRefCounted> b = WTFMove(a);
-    PoisonedRefPtr<PoisonD, const ConstRefCounted> c = b.ptr();
-    Ref<const ConstRefCounted> d = returnConstRefCountedRef();
-    PoisonedRefPtr<PoisonE, const ConstRefCounted> e = &returnConstRefCountedRef();
-    PoisonedRefPtr<PoisonF, ConstRefCounted> f = ConstRefCounted::create();
-    PoisonedRefPtr<PoisonB, const ConstRefCounted> g = f;
-    PoisonedRefPtr<PoisonC, const ConstRefCounted> h(f);
-    Ref<const ConstRefCounted> i(returnRefCountedRef());
-}
-
-struct PoisonedRefPtrCheckingRefLogger : RefLogger {
-    using Ref = PoisonedRefPtr<PoisonD, PoisonedRefPtrCheckingRefLogger>;
-
-    PoisonedRefPtrCheckingRefLogger(const char* name);
-    void ref();
-    void deref();
-    const Ref* slotToCheck { nullptr };
-};
-
-PoisonedRefPtrCheckingRefLogger::PoisonedRefPtrCheckingRefLogger(const char* name)
-    : RefLogger { name }
-{
-}
-
-static const char* loggerName(const PoisonedRefPtrCheckingRefLogger::Ref& pointer)
-{
-    return pointer ? &pointer->name : "null";
-}
-
-void PoisonedRefPtrCheckingRefLogger::ref()
-{
-    if (slotToCheck)
-        log() << "slot=" << loggerName(*slotToCheck) << " ";
-    RefLogger::ref();
-}
-
-void PoisonedRefPtrCheckingRefLogger::deref()
-{
-    if (slotToCheck)
-        log() << "slot=" << loggerName(*slotToCheck) << " ";
-    RefLogger::deref();
-}
-
-TEST(WTF_PoisonedRefPtr, AssignBeforeDeref)
-{
-    initializePoisons();
-
-    PoisonedRefPtrCheckingRefLogger a("a");
-    PoisonedRefPtrCheckingRefLogger b("b");
-
-    {
-        PoisonedRefPtrCheckingRefLogger::Ref p1(&a);
-        PoisonedRefPtrCheckingRefLogger::Ref p2(&b);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        log() << "| ";
-        a.slotToCheck = &p1;
-        b.slotToCheck = &p1;
-        p1 = p2;
-        a.slotToCheck = nullptr;
-        b.slotToCheck = nullptr;
-        EXPECT_EQ(&b, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | slot=a ref(b) slot=b deref(a) | deref(b) deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtrCheckingRefLogger::Ref ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        log() << "| ";
-        a.slotToCheck = &ptr;
-        b.slotToCheck = &ptr;
-        ptr = &b;
-        a.slotToCheck = nullptr;
-        b.slotToCheck = nullptr;
-        EXPECT_EQ(&b, ptr.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) | slot=a ref(b) slot=b deref(a) | deref(b) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtrCheckingRefLogger::Ref ptr(&a);
-        EXPECT_EQ(&a, ptr.get());
-        a.slotToCheck = &ptr;
-        ptr = nullptr;
-        a.slotToCheck = nullptr;
-        EXPECT_EQ(nullptr, ptr.get());
-    }
-    EXPECT_STREQ("ref(a) slot=null deref(a) ", takeLogStr().c_str());
-
-    {
-        PoisonedRefPtrCheckingRefLogger::Ref p1(&a);
-        PoisonedRefPtrCheckingRefLogger::Ref p2(&b);
-        EXPECT_EQ(&a, p1.get());
-        EXPECT_EQ(&b, p2.get());
-        log() << "| ";
-        a.slotToCheck = &p1;
-        b.slotToCheck = &p1;
-        p1 = WTFMove(p2);
-        a.slotToCheck = nullptr;
-        b.slotToCheck = nullptr;
-        EXPECT_EQ(&b, p1.get());
-        EXPECT_EQ(nullptr, p2.get());
-        log() << "| ";
-    }
-    EXPECT_STREQ("ref(a) ref(b) | slot=b deref(a) | deref(b) ", takeLogStr().c_str());
-}
-
-TEST(WTF_PoisonedRefPtr, ReleaseNonNullBeforeDeref)
-{
-    initializePoisons();
-
-    PoisonedRefPtrCheckingRefLogger a("a");
-
-    {
-        PoisonedRefPtrCheckingRefLogger::Ref refPtr = &a;
-        a.slotToCheck = &refPtr;
-        refPtr.releaseNonNull();
-        a.slotToCheck = nullptr;
-    }
-
-    EXPECT_STREQ("ref(a) slot=null deref(a) ", takeLogStr().c_str());
-}
-
-} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp b/Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp
deleted file mode 100644 (file)
index a8af391..0000000
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <mutex>
-#include <wtf/PoisonedUniquePtr.h>
-
-namespace TestWebKitAPI {
-
-namespace {
-
-uintptr_t g_poisonA;
-uintptr_t g_poisonB;
-
-using PoisonA = Poison<g_poisonA>;
-using PoisonB = Poison<g_poisonB>;
-
-static void initializePoisons()
-{
-    static std::once_flag initializeOnceFlag;
-    std::call_once(initializeOnceFlag, [] {
-        // Make sure we get 2 different poison values.
-        g_poisonA = makePoison();
-        while (!g_poisonB || g_poisonB == g_poisonA)
-            g_poisonB = makePoison();
-    });
-}
-
-struct Logger {
-    Logger(const char* name, int& destructCount)
-        : name(*name)
-        , destructCount(destructCount)
-    { }
-
-    ~Logger() { ++destructCount; }
-
-    const char& name;
-    int& destructCount;
-};
-    
-struct DerivedLogger : Logger {
-    DerivedLogger(const char* name, int& destructCount)
-        : Logger(name, destructCount)
-    { }
-};
-
-struct Other {
-    Other(const char*, int&)
-    { }
-};
-
-} // anonymous namespace
-
-TEST(WTF_PoisonedUniquePtr, DISABLED_Basic)
-{
-    initializePoisons();
-
-    {
-        PoisonedUniquePtr<PoisonA, Logger> empty;
-        ASSERT_EQ(nullptr, empty.unpoisoned());
-        ASSERT_EQ(0u, empty.bits());
-    }
-    {
-        PoisonedUniquePtr<PoisonA, Logger> empty(nullptr);
-        ASSERT_EQ(nullptr, empty.unpoisoned());
-        ASSERT_EQ(0u, empty.bits());
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ASSERT_EQ(a, &*ptr);
-            ASSERT_EQ(&a->name, &ptr->name);
-
-#if ENABLE(POISON)
-            uintptr_t ptrBits;
-            std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
-            ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(a));
-#if ENABLE(POISON_ASSERTS)
-            ASSERT_TRUE((PoisonedUniquePtr<PoisonA, Logger>::isPoisoned(ptrBits)));
-#endif
-#endif // ENABLE(POISON)
-        }
-        ASSERT_EQ(1, aDestructCount);
-
-        int bDestructCount = 0;
-        DerivedLogger* b = new DerivedLogger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr(b);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(b, ptr.unpoisoned());
-            ASSERT_EQ(b, &*ptr);
-            ASSERT_EQ(&b->name, &ptr->name);
-        }
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr = a;
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-
-        int bDestructCount = 0;
-        DerivedLogger* b = new DerivedLogger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr = b;
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(b, ptr.unpoisoned());
-        }
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        const char* aName = "a";
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr = PoisonedUniquePtr<PoisonA, Logger>::create(aName, aDestructCount);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_TRUE(nullptr != ptr.unpoisoned());
-            ASSERT_EQ(aName, &ptr->name);
-        }
-        ASSERT_EQ(1, aDestructCount);
-
-        int bDestructCount = 0;
-        const char* bName = "b";
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr = PoisonedUniquePtr<PoisonA, DerivedLogger>::create(bName, bDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_TRUE(nullptr != ptr.unpoisoned());
-            ASSERT_EQ(bName, &ptr->name);
-        }
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        const char* aName = "a";
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr = std::make_unique<Logger>(aName, aDestructCount);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_TRUE(nullptr != ptr.unpoisoned());
-            ASSERT_EQ(aName, &ptr->name);
-        }
-        ASSERT_EQ(1, aDestructCount);
-
-        int bDestructCount = 0;
-        const char* bName = "b";
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr = std::make_unique<DerivedLogger>(bName, bDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_TRUE(nullptr != ptr.unpoisoned());
-            ASSERT_EQ(bName, &ptr->name);
-        }
-        ASSERT_EQ(1, bDestructCount);
-
-        int uniqueDestructCount = 0;
-        const char* uniqueName = "unique";
-        {
-            PoisonedUniquePtr<PoisonA, DerivedLogger> ptr = std::make_unique<DerivedLogger>(uniqueName, uniqueDestructCount);
-            ASSERT_EQ(0, uniqueDestructCount);
-            ASSERT_TRUE(nullptr != ptr.unpoisoned());
-            ASSERT_EQ(uniqueName, &ptr->name);
-        }
-        ASSERT_EQ(1, uniqueDestructCount);
-
-        int uniqueDerivedDestructCount = 0;
-        const char* uniqueDerivedName = "unique derived";
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr = std::make_unique<DerivedLogger>(uniqueDerivedName, uniqueDerivedDestructCount);
-            ASSERT_EQ(0, uniqueDerivedDestructCount);
-            ASSERT_TRUE(nullptr != ptr.unpoisoned());
-            ASSERT_EQ(uniqueDerivedName, &ptr->name);
-        }
-        ASSERT_EQ(1, uniqueDerivedDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        Logger* b = new Logger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger> p2 = WTFMove(p1);
-            ASSERT_EQ(aDestructCount, 0);
-            ASSERT_EQ(nullptr, p1.unpoisoned());
-            ASSERT_EQ(0u, p1.bits());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger> p4 = WTFMove(p3);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(nullptr, p3.unpoisoned());
-            ASSERT_EQ(0u, p3.bits());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        Logger* b = new Logger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger> p2(WTFMove(p1));
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(nullptr, p1.unpoisoned());
-            ASSERT_EQ(0u, p1.bits());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger> p4(WTFMove(p3));
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(nullptr, p3.unpoisoned());
-            ASSERT_EQ(0u, p3.bits());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        DerivedLogger* a = new DerivedLogger("a", aDestructCount);
-        DerivedLogger* b = new DerivedLogger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger> p2 = WTFMove(p1);
-            ASSERT_EQ(aDestructCount, 0);
-            ASSERT_TRUE(!p1.unpoisoned());
-            ASSERT_TRUE(!p1.bits());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger> p4 = WTFMove(p3);
-            ASSERT_EQ(bDestructCount, 0);
-            ASSERT_TRUE(!p3.unpoisoned());
-            ASSERT_TRUE(!p3.bits());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        DerivedLogger* a = new DerivedLogger("a", aDestructCount);
-        DerivedLogger* b = new DerivedLogger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger> p2(WTFMove(p1));
-            ASSERT_EQ(aDestructCount, 0);
-            ASSERT_TRUE(!p1.unpoisoned());
-            ASSERT_TRUE(!p1.bits());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger> p4(WTFMove(p3));
-            ASSERT_EQ(bDestructCount, 0);
-            ASSERT_TRUE(!p3.unpoisoned());
-            ASSERT_TRUE(!p3.bits());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr.clear();
-            ASSERT_TRUE(!ptr.unpoisoned());
-            ASSERT_TRUE(!ptr.bits());
-            ASSERT_EQ(1, aDestructCount);
-        }
-        ASSERT_EQ(1, aDestructCount);
-    }
-}
-
-TEST(WTF_PoisonedUniquePtr, DISABLED_Assignment)
-{
-    initializePoisons();
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        Logger* b = new Logger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr = b;
-            ASSERT_EQ(1, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(b, ptr.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr = nullptr;
-            ASSERT_EQ(1, aDestructCount);
-            ASSERT_EQ(nullptr, ptr.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        int cDestructCount = 0;
-        int dDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        Logger* b = new Logger("b", bDestructCount);
-        Logger* c = new Logger("c", cDestructCount);
-        Logger* d = new Logger("d", dDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> p1(a);
-            PoisonedUniquePtr<PoisonA, Logger> p2(b);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(a, p1.unpoisoned());
-            ASSERT_EQ(b, p2.unpoisoned());
-            p1 = WTFMove(p2);
-            ASSERT_EQ(1, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(b, p1.unpoisoned());
-            ASSERT_EQ(nullptr, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger> p3(c);
-            PoisonedUniquePtr<PoisonB, Logger> p4(d);
-            ASSERT_EQ(0, cDestructCount);
-            ASSERT_EQ(0, dDestructCount);
-            ASSERT_EQ(c, p3.unpoisoned());
-            ASSERT_EQ(d, p4.unpoisoned());
-            p3 = WTFMove(p4);
-            ASSERT_EQ(1, cDestructCount);
-            ASSERT_EQ(0, dDestructCount);
-            ASSERT_EQ(d, p3.unpoisoned());
-            ASSERT_EQ(nullptr, p4.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-        ASSERT_EQ(1, cDestructCount);
-        ASSERT_EQ(1, dDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        DerivedLogger* a = new DerivedLogger("a", aDestructCount);
-        DerivedLogger* b = new DerivedLogger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr = b;
-            ASSERT_EQ(1, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(b, ptr.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        int cDestructCount = 0;
-        int dDestructCount = 0;
-        DerivedLogger* a = new DerivedLogger("a", aDestructCount);
-        DerivedLogger* b = new DerivedLogger("b", bDestructCount);
-        DerivedLogger* c = new DerivedLogger("c", cDestructCount);
-        DerivedLogger* d = new DerivedLogger("d", dDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> p1(a);
-            PoisonedUniquePtr<PoisonA, DerivedLogger> p2(b);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(a, p1.unpoisoned());
-            ASSERT_EQ(b, p2.unpoisoned());
-            p1 = WTFMove(p2);
-            ASSERT_EQ(1, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(b, p1.unpoisoned());
-            ASSERT_EQ(nullptr, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger> p3(c);
-            PoisonedUniquePtr<PoisonB, DerivedLogger> p4(d);
-            ASSERT_EQ(0, cDestructCount);
-            ASSERT_EQ(0, dDestructCount);
-            ASSERT_EQ(c, p3.unpoisoned());
-            ASSERT_EQ(d, p4.unpoisoned());
-            p3 = WTFMove(p4);
-            ASSERT_EQ(1, cDestructCount);
-            ASSERT_EQ(0, dDestructCount);
-            ASSERT_EQ(d, p3.unpoisoned());
-            ASSERT_EQ(nullptr, p4.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-        ASSERT_EQ(1, cDestructCount);
-        ASSERT_EQ(1, dDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr = a;
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wself-move"
-#endif
-            ptr = WTFMove(ptr);
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-    }
-}
-
-TEST(WTF_PoisonedUniquePtr, DISABLED_Swap)
-{
-    initializePoisons();
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        Logger* b = new Logger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger> p2;
-            ASSERT_EQ(a, p1.unpoisoned());
-            ASSERT_TRUE(!p2.bits());
-            ASSERT_TRUE(!p2.unpoisoned());
-            p2.swap(p1);
-            ASSERT_EQ(aDestructCount, 0);
-            ASSERT_TRUE(!p1.bits());
-            ASSERT_TRUE(!p1.unpoisoned());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger> p4;
-            ASSERT_EQ(b, p3.unpoisoned());
-            ASSERT_TRUE(!p4.bits());
-            ASSERT_TRUE(!p4.unpoisoned());
-            p4.swap(p3);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_TRUE(!p3.bits());
-            ASSERT_TRUE(!p3.unpoisoned());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        Logger* b = new Logger("b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger> p2;
-            ASSERT_EQ(a, p1.unpoisoned());
-            ASSERT_TRUE(!p2.bits());
-            ASSERT_TRUE(!p2.unpoisoned());
-            swap(p1, p2);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_TRUE(!p1.bits());
-            ASSERT_TRUE(!p1.unpoisoned());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger> p4;
-            ASSERT_EQ(b, p3.unpoisoned());
-            ASSERT_TRUE(!p4.bits());
-            ASSERT_TRUE(!p4.unpoisoned());
-            swap(p3, p4);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_TRUE(!p3.bits());
-            ASSERT_TRUE(!p3.unpoisoned());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(1, aDestructCount);
-        ASSERT_EQ(1, bDestructCount);
-    }
-}
-
-static PoisonedUniquePtr<PoisonA, Logger> poisonedPtrFoo(Logger* logger)
-{
-    return PoisonedUniquePtr<PoisonA, Logger>(logger);
-}
-
-TEST(WTF_PoisonedUniquePtr, DISABLED_ReturnValue)
-{
-    initializePoisons();
-
-    {
-        int aDestructCount = 0;
-        Logger* a = new Logger("a", aDestructCount);
-        {
-            auto ptr = poisonedPtrFoo(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ASSERT_EQ(a, &*ptr);
-            ASSERT_EQ(&a->name, &ptr->name);
-        }
-        ASSERT_EQ(1, aDestructCount);
-    }
-}
-
-} // namespace TestWebKitAPI
-
diff --git a/Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp b/Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp
deleted file mode 100644 (file)
index 501aa12..0000000
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <mutex>
-#include <wtf/PoisonedUniquePtr.h>
-
-namespace TestWebKitAPI {
-
-namespace {
-
-uintptr_t g_poisonA;
-uintptr_t g_poisonB;
-
-using PoisonA = Poison<g_poisonA>;
-using PoisonB = Poison<g_poisonB>;
-
-static void initializePoisons()
-{
-    static std::once_flag initializeOnceFlag;
-    std::call_once(initializeOnceFlag, [] {
-        // Make sure we get 2 different poison values.
-        g_poisonA = makePoison();
-        while (!g_poisonB || g_poisonB == g_poisonA)
-            g_poisonB = makePoison();
-    });
-}
-
-struct Logger {
-    Logger() { }
-    Logger(const char* name, int& destructCount)
-        : name(name)
-        , destructCount(&destructCount)
-    { }
-
-    ~Logger() { ++(*destructCount); }
-
-    const char* name;
-    int* destructCount;
-};
-    
-template<typename T, typename... Arguments>
-T* makeArray(size_t count, Arguments&&... arguments)
-{
-    T* result = new T[count];
-    while (count--)
-        new (result + count) T(std::forward<Arguments>(arguments)...);
-    return result;
-}
-
-const int arraySize = 5;
-
-} // anonymous namespace
-
-TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, DISABLED_Basic)
-{
-    initializePoisons();
-
-    {
-        PoisonedUniquePtr<PoisonA, Logger[]> empty;
-        ASSERT_EQ(nullptr, empty.unpoisoned());
-        ASSERT_EQ(0u, empty.bits());
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ASSERT_EQ(a, &*ptr);
-            for (auto i = 0; i < arraySize; ++i)
-                ASSERT_EQ(a[i].name, ptr[i].name);
-
-#if ENABLE(POISON)
-            uintptr_t ptrBits;
-            std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
-            ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(a));
-#if ENABLE(POISON_ASSERTS)
-            ASSERT_TRUE((PoisonedUniquePtr<PoisonA, Logger[]>::isPoisoned(ptrBits)));
-#endif
-#endif // ENABLE(POISON)
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> ptr = a;
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            for (auto i = 0; i < arraySize; ++i)
-                ASSERT_EQ(a[i].name, ptr[i].name);
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        const char* aName = "a";
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> ptr = PoisonedUniquePtr<PoisonA, Logger[]>::create(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);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger[]> p2 = WTFMove(p1);
-            ASSERT_EQ(aDestructCount, 0);
-            ASSERT_EQ(nullptr, p1.unpoisoned());
-            ASSERT_EQ(0u, p1.bits());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger[]> p4 = WTFMove(p3);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(nullptr, p3.unpoisoned());
-            ASSERT_EQ(0u, p3.bits());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-        ASSERT_EQ(arraySize, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger[]> p2(WTFMove(p1));
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(nullptr, p1.unpoisoned());
-            ASSERT_EQ(0u, p1.bits());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger[]> p4(WTFMove(p3));
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(nullptr, p3.unpoisoned());
-            ASSERT_EQ(0u, p3.bits());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-        ASSERT_EQ(arraySize, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger[]> p2 = WTFMove(p1);
-            ASSERT_EQ(aDestructCount, 0);
-            ASSERT_TRUE(!p1.unpoisoned());
-            ASSERT_TRUE(!p1.bits());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger[]> p4 = WTFMove(p3);
-            ASSERT_EQ(bDestructCount, 0);
-            ASSERT_TRUE(!p3.unpoisoned());
-            ASSERT_TRUE(!p3.bits());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-        ASSERT_EQ(arraySize, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger[]> p2(WTFMove(p1));
-            ASSERT_EQ(aDestructCount, 0);
-            ASSERT_TRUE(!p1.unpoisoned());
-            ASSERT_TRUE(!p1.bits());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger[]> p4(WTFMove(p3));
-            ASSERT_EQ(bDestructCount, 0);
-            ASSERT_TRUE(!p3.unpoisoned());
-            ASSERT_TRUE(!p3.bits());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-        ASSERT_EQ(arraySize, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr.clear();
-            ASSERT_TRUE(!ptr.unpoisoned());
-            ASSERT_TRUE(!ptr.bits());
-            ASSERT_EQ(arraySize, aDestructCount);
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-}
-
-TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, DISABLED_Assignment)
-{
-    initializePoisons();
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr = b;
-            ASSERT_EQ(arraySize, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(b, ptr.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-        ASSERT_EQ(arraySize, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr = nullptr;
-            ASSERT_EQ(arraySize, aDestructCount);
-            ASSERT_EQ(nullptr, ptr.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        int cDestructCount = 0;
-        int dDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
-        Logger* c = makeArray<Logger>(arraySize, "c", cDestructCount);
-        Logger* d = makeArray<Logger>(arraySize, "d", dDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> p1(a);
-            PoisonedUniquePtr<PoisonA, Logger[]> p2(b);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(a, p1.unpoisoned());
-            ASSERT_EQ(b, p2.unpoisoned());
-            p1 = WTFMove(p2);
-            ASSERT_EQ(arraySize, aDestructCount);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_EQ(b, p1.unpoisoned());
-            ASSERT_EQ(nullptr, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger[]> p3(c);
-            PoisonedUniquePtr<PoisonB, Logger[]> p4(d);
-            ASSERT_EQ(0, cDestructCount);
-            ASSERT_EQ(0, dDestructCount);
-            ASSERT_EQ(c, p3.unpoisoned());
-            ASSERT_EQ(d, p4.unpoisoned());
-            p3 = WTFMove(p4);
-            ASSERT_EQ(arraySize, cDestructCount);
-            ASSERT_EQ(0, dDestructCount);
-            ASSERT_EQ(d, p3.unpoisoned());
-            ASSERT_EQ(nullptr, p4.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-        ASSERT_EQ(arraySize, bDestructCount);
-        ASSERT_EQ(arraySize, cDestructCount);
-        ASSERT_EQ(arraySize, dDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ptr = a;
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wself-move"
-#endif
-            ptr = WTFMove(ptr);
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-}
-
-TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, DISABLED_Swap)
-{
-    initializePoisons();
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger[]> p2;
-            ASSERT_EQ(a, p1.unpoisoned());
-            ASSERT_TRUE(!p2.bits());
-            ASSERT_TRUE(!p2.unpoisoned());
-            p2.swap(p1);
-            ASSERT_EQ(aDestructCount, 0);
-            ASSERT_TRUE(!p1.bits());
-            ASSERT_TRUE(!p1.unpoisoned());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger[]> p4;
-            ASSERT_EQ(b, p3.unpoisoned());
-            ASSERT_TRUE(!p4.bits());
-            ASSERT_TRUE(!p4.unpoisoned());
-            p4.swap(p3);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_TRUE(!p3.bits());
-            ASSERT_TRUE(!p3.unpoisoned());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-        ASSERT_EQ(arraySize, bDestructCount);
-    }
-
-    {
-        int aDestructCount = 0;
-        int bDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
-        {
-            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<PoisonA, Logger[]> p2;
-            ASSERT_EQ(a, p1.unpoisoned());
-            ASSERT_TRUE(!p2.bits());
-            ASSERT_TRUE(!p2.unpoisoned());
-            swap(p1, p2);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_TRUE(!p1.bits());
-            ASSERT_TRUE(!p1.unpoisoned());
-            ASSERT_EQ(a, p2.unpoisoned());
-
-            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<PoisonB, Logger[]> p4;
-            ASSERT_EQ(b, p3.unpoisoned());
-            ASSERT_TRUE(!p4.bits());
-            ASSERT_TRUE(!p4.unpoisoned());
-            swap(p3, p4);
-            ASSERT_EQ(0, bDestructCount);
-            ASSERT_TRUE(!p3.bits());
-            ASSERT_TRUE(!p3.unpoisoned());
-            ASSERT_EQ(b, p4.unpoisoned());
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-        ASSERT_EQ(arraySize, bDestructCount);
-    }
-}
-
-static PoisonedUniquePtr<PoisonA, Logger[]> poisonedPtrFoo(Logger* array)
-{
-    return PoisonedUniquePtr<PoisonA, Logger[]>(array);
-}
-
-TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, DISABLED_ReturnValue)
-{
-    initializePoisons();
-
-    {
-        int aDestructCount = 0;
-        Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
-        {
-            auto ptr = poisonedPtrFoo(a);
-            ASSERT_EQ(0, aDestructCount);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ASSERT_EQ(a, &*ptr);
-            for (auto i = 0; i < arraySize; ++i)
-                ASSERT_EQ(a[i].name, ptr[i].name);
-        }
-        ASSERT_EQ(arraySize, aDestructCount);
-    }
-}
-
-} // namespace TestWebKitAPI
-
diff --git a/Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp b/Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp
deleted file mode 100644 (file)
index 864af6a..0000000
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <mutex>
-#include <wtf/FastMalloc.h>
-#include <wtf/PoisonedUniquePtr.h>
-
-namespace TestWebKitAPI {
-
-namespace {
-
-uintptr_t g_poisonA;
-uintptr_t g_poisonB;
-
-using PoisonA = Poison<g_poisonA>;
-using PoisonB = Poison<g_poisonB>;
-
-static void initializePoisons()
-{
-    static std::once_flag initializeOnceFlag;
-    std::call_once(initializeOnceFlag, [] {
-        // Make sure we get 2 different poison values.
-        g_poisonA = makePoison();
-        while (!g_poisonB || g_poisonB == g_poisonA)
-            g_poisonB = makePoison();
-    });
-}
-
-template<typename T>
-static void fillArray(T& array, int size)
-{
-    for (int i = 0; i < size; ++i)
-        array[i] = i + 100;
-}
-
-static const int arraySize = 5;
-
-} // anonymous namespace
-
-TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, DISABLED_Basic)
-{
-    initializePoisons();
-
-    {
-        PoisonedUniquePtr<PoisonA, int[]> empty;
-        ASSERT_EQ(nullptr, empty.unpoisoned());
-        ASSERT_EQ(0u, empty.bits());
-    }
-    {
-        PoisonedUniquePtr<PoisonA, int[]> empty(nullptr);
-        ASSERT_EQ(nullptr, empty.unpoisoned());
-        ASSERT_EQ(0u, empty.bits());
-    }
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-        {
-            PoisonedUniquePtr<PoisonA, int[]> ptr(a);
-            ASSERT_EQ(a, ptr.unpoisoned());
-            ASSERT_EQ(a, &*ptr);
-            for (auto i = 0; i < arraySize; ++i)
-                ASSERT_EQ(a[i], ptr[i]);
-
-#if ENABLE(POISON)
-            uintptr_t ptrBits;
-            std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
-            ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(a));
-#if ENABLE(POISON_ASSERTS)
-            ASSERT_TRUE((PoisonedUniquePtr<PoisonA, int[]>::isPoisoned(ptrBits)));
-#endif
-#endif // ENABLE(POISON)
-        }
-    }
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> ptr = a;
-        ASSERT_EQ(a, ptr.unpoisoned());
-        ASSERT_EQ(a, &*ptr);
-        for (auto i = 0; i < arraySize; ++i)
-            ASSERT_EQ(a[i], ptr[i]);
-    }
-
-    {
-        PoisonedUniquePtr<PoisonA, int[]> ptr = PoisonedUniquePtr<PoisonA, int[]>::create(arraySize);
-        ASSERT_TRUE(nullptr != ptr.unpoisoned());
-        fillArray(ptr, arraySize);
-        for (auto i = 0; i < arraySize; ++i)
-            ASSERT_EQ((100 + i), ptr[i]);
-    }
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-        auto* b = new int[arraySize];
-        fillArray(b, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> p1 = a;
-        PoisonedUniquePtr<PoisonA, int[]> p2 = WTFMove(p1);
-        ASSERT_EQ(nullptr, p1.unpoisoned());
-        ASSERT_EQ(0u, p1.bits());
-        ASSERT_EQ(a, p2.unpoisoned());
-        for (auto i = 0; i < arraySize; ++i)
-            ASSERT_EQ(a[i], p2[i]);
-
-        PoisonedUniquePtr<PoisonA, int[]> p3 = b;
-        PoisonedUniquePtr<PoisonB, int[]> p4 = WTFMove(p3);
-        ASSERT_EQ(nullptr, p3.unpoisoned());
-        ASSERT_EQ(0u, p3.bits());
-        ASSERT_EQ(b, p4.unpoisoned());
-        for (auto i = 0; i < arraySize; ++i)
-            ASSERT_EQ(b[i], p4[i]);
-    }
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-        auto* b = new int[arraySize];
-        fillArray(b, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> p1 = a;
-        PoisonedUniquePtr<PoisonA, int[]> p2(WTFMove(p1));
-        ASSERT_EQ(nullptr, p1.unpoisoned());
-        ASSERT_EQ(0u, p1.bits());
-        ASSERT_EQ(a, p2.unpoisoned());
-        for (auto i = 0; i < arraySize; ++i)
-            ASSERT_EQ(a[i], p2[i]);
-
-        PoisonedUniquePtr<PoisonA, int[]> p3 = b;
-        PoisonedUniquePtr<PoisonB, int[]> p4(WTFMove(p3));
-        ASSERT_EQ(nullptr, p3.unpoisoned());
-        ASSERT_EQ(0u, p3.bits());
-        ASSERT_EQ(b, p4.unpoisoned());
-        for (auto i = 0; i < arraySize; ++i)
-            ASSERT_EQ(b[i], p4[i]);
-    }
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
-        ASSERT_EQ(a, ptr.unpoisoned());
-        ptr.clear();
-        ASSERT_TRUE(!ptr.unpoisoned());
-        ASSERT_TRUE(!ptr.bits());
-    }
-}
-
-TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, DISABLED_Assignment)
-{
-    initializePoisons();
-
-    {
-        auto* a = new int[arraySize];
-        auto* b = new int[arraySize];
-        fillArray(a, arraySize);
-        fillArray(b, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
-        ASSERT_EQ(a, ptr.unpoisoned());
-        ptr = b;
-        ASSERT_EQ(b, ptr.unpoisoned());
-    }
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
-        ASSERT_EQ(a, ptr.unpoisoned());
-        ptr = nullptr;
-        ASSERT_EQ(nullptr, ptr.unpoisoned());
-    }
-
-    {
-        auto* a = new int[arraySize];
-        auto* b = new int[arraySize];
-        auto* c = new int[arraySize];
-        auto* d = new int[arraySize];
-        fillArray(a, arraySize);
-        fillArray(b, arraySize);
-        fillArray(c, arraySize);
-        fillArray(d, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> p1(a);
-        PoisonedUniquePtr<PoisonA, int[]> p2(b);
-        ASSERT_EQ(a, p1.unpoisoned());
-        ASSERT_EQ(b, p2.unpoisoned());
-        p1 = WTFMove(p2);
-        ASSERT_EQ(b, p1.unpoisoned());
-        ASSERT_EQ(nullptr, p2.unpoisoned());
-
-        PoisonedUniquePtr<PoisonA, int[]> p3(c);
-        PoisonedUniquePtr<PoisonB, int[]> p4(d);
-        ASSERT_EQ(c, p3.unpoisoned());
-        ASSERT_EQ(d, p4.unpoisoned());
-        p3 = WTFMove(p4);
-        ASSERT_EQ(d, p3.unpoisoned());
-        ASSERT_EQ(nullptr, p4.unpoisoned());
-    }
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
-        ASSERT_EQ(a, ptr.unpoisoned());
-        ptr = a;
-        ASSERT_EQ(a, ptr.unpoisoned());
-    }
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
-        ASSERT_EQ(a, ptr.unpoisoned());
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wself-move"
-#endif
-        ptr = WTFMove(ptr);
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-        ASSERT_EQ(a, ptr.unpoisoned());
-    }
-}
-
-TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, DISABLED_Swap)
-{
-    initializePoisons();
-
-    {
-        auto* a = new int[arraySize];
-        auto* b = new int[arraySize];
-        fillArray(a, arraySize);
-        fillArray(b, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> p1 = a;
-        PoisonedUniquePtr<PoisonA, int[]> p2;
-        ASSERT_EQ(p1.unpoisoned(), a);
-        ASSERT_TRUE(!p2.bits());
-        ASSERT_TRUE(!p2.unpoisoned());
-        p2.swap(p1);
-        ASSERT_TRUE(!p1.bits());
-        ASSERT_TRUE(!p1.unpoisoned());
-        ASSERT_EQ(p2.unpoisoned(), a);
-
-        PoisonedUniquePtr<PoisonA, int[]> p3 = b;
-        PoisonedUniquePtr<PoisonB, int[]> p4;
-        ASSERT_EQ(p3.unpoisoned(), b);
-        ASSERT_TRUE(!p4.bits());
-        ASSERT_TRUE(!p4.unpoisoned());
-        p4.swap(p3);
-        ASSERT_TRUE(!p3.bits());
-        ASSERT_TRUE(!p3.unpoisoned());
-        ASSERT_EQ(p4.unpoisoned(), b);
-    }
-
-    {
-        auto* a = new int[arraySize];
-        auto* b = new int[arraySize];
-        fillArray(a, arraySize);
-        fillArray(b, arraySize);
-
-        PoisonedUniquePtr<PoisonA, int[]> p1 = a;
-        PoisonedUniquePtr<PoisonA, int[]> p2;
-        ASSERT_EQ(p1.unpoisoned(), a);
-        ASSERT_TRUE(!p2.bits());
-        ASSERT_TRUE(!p2.unpoisoned());
-        swap(p1, p2);
-        ASSERT_TRUE(!p1.bits());
-        ASSERT_TRUE(!p1.unpoisoned());
-        ASSERT_EQ(p2.unpoisoned(), a);
-
-        PoisonedUniquePtr<PoisonA, int[]> p3 = b;
-        PoisonedUniquePtr<PoisonB, int[]> p4;
-        ASSERT_EQ(p3.unpoisoned(), b);
-        ASSERT_TRUE(!p4.bits());
-        ASSERT_TRUE(!p4.unpoisoned());
-        swap(p3, p4);
-        ASSERT_TRUE(!p3.bits());
-        ASSERT_TRUE(!p3.unpoisoned());
-        ASSERT_EQ(p4.unpoisoned(), b);
-    }
-}
-
-static PoisonedUniquePtr<PoisonA, int[]> poisonedPtrFoo(int* ptr)
-{
-    return PoisonedUniquePtr<PoisonA, int[]>(ptr);
-}
-
-TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, DISABLED_ReturnValue)
-{
-    initializePoisons();
-
-    {
-        auto* a = new int[arraySize];
-        fillArray(a, arraySize);
-
-        auto ptr = poisonedPtrFoo(a);
-        ASSERT_EQ(a, ptr.unpoisoned());
-        ASSERT_EQ(a, &*ptr);
-        for (auto i = 0; i < arraySize; ++i)
-            ASSERT_EQ(a[i], ptr[i]);
-    }
-}
-
-} // namespace TestWebKitAPI
-