Title: [287308] trunk/Source
Revision
287308
Author
[email protected]
Date
2021-12-21 02:33:01 -0800 (Tue, 21 Dec 2021)

Log Message

[WTF] Remove RefCountedArray and use RefCountedFixedVector
https://bugs.webkit.org/show_bug.cgi?id=234484

Reviewed by Dean Jackson.

Source/WebCore:

Use RefCountedFixedVector intead. No semantic change.

* layout/integration/InlineIteratorBoxLegacyPath.h:
* platform/graphics/FontCascadeDescription.cpp:
(WebCore::FontCascadeDescription::FontCascadeDescription):
* platform/graphics/FontCascadeDescription.h:
(WebCore::FontCascadeDescription::familyCount const):
(WebCore::FontCascadeDescription::familyAt const):
(WebCore::FontCascadeDescription::families const):
(WebCore::FontCascadeDescription::setOneFamily):
(WebCore::FontCascadeDescription::setFamilies):
(WebCore::FontCascadeDescription::operator== const):

Source/WTF:

Use RefCountedFixedVector<T> instead of RefCountedArray<T> and remove RefCountedArray<T>.
RefCountedFixedVector<T> is much simpler interface: it is just using Ref<> / RefPtr<>
instead of integrating ref-counting holder semantics into the class itself.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/FixedVector.h:
* wtf/RefCountedArray.cpp: Removed.
* wtf/RefCountedArray.h: Removed.
* wtf/WTFAssertions.cpp:

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (287307 => 287308)


--- trunk/Source/WTF/ChangeLog	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WTF/ChangeLog	2021-12-21 10:33:01 UTC (rev 287308)
@@ -1,3 +1,21 @@
+2021-12-21  Yusuke Suzuki  <[email protected]>
+
+        [WTF] Remove RefCountedArray and use RefCountedFixedVector
+        https://bugs.webkit.org/show_bug.cgi?id=234484
+
+        Reviewed by Dean Jackson.
+
+        Use RefCountedFixedVector<T> instead of RefCountedArray<T> and remove RefCountedArray<T>.
+        RefCountedFixedVector<T> is much simpler interface: it is just using Ref<> / RefPtr<>
+        instead of integrating ref-counting holder semantics into the class itself.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/FixedVector.h:
+        * wtf/RefCountedArray.cpp: Removed.
+        * wtf/RefCountedArray.h: Removed.
+        * wtf/WTFAssertions.cpp:
+
 2021-12-20  Alexey Shvayka  <[email protected]>
 
         [WebIDL] convertVariadicArguments() should return a FixedVector

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (287307 => 287308)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2021-12-21 10:33:01 UTC (rev 287308)
@@ -176,7 +176,6 @@
 		E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; };
 		E311FB171F0A568B003C08DE /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E311FB151F0A568B003C08DE /* ThreadGroup.cpp */; };
 		E3149A37228BB42200BFA6C7 /* Bag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FEBA64120CF37100074941C /* Bag.cpp */; };
-		E3149A38228BB42C00BFA6C7 /* RefCountedArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FA6F39020CC61EB00A03DCD /* RefCountedArray.cpp */; };
 		E3149A39228BB43500BFA6C7 /* Vector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F95B63420CB53C100479635 /* Vector.cpp */; };
 		E3149A3B228BDCAC00BFA6C7 /* ConcurrentBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3149A3A228BDCAB00BFA6C7 /* ConcurrentBuffer.cpp */; };
 		E336674A2722551100259122 /* Int128.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E33667492722550900259122 /* Int128.cpp */; };
@@ -280,7 +279,6 @@
 		0F9DAA041FD1C37B0079C5B2 /* StackShot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackShot.h; sourceTree = "<group>"; };
 		0F9DAA051FD1C37B0079C5B2 /* StackShotProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackShotProfiler.h; sourceTree = "<group>"; };
 		0FA6F38E20CC580E00A03DCD /* SegmentedVector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SegmentedVector.cpp; sourceTree = "<group>"; };
-		0FA6F39020CC61EB00A03DCD /* RefCountedArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCountedArray.cpp; sourceTree = "<group>"; };
 		0FA6F39220CC73A200A03DCD /* SmallSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmallSet.cpp; sourceTree = "<group>"; };
 		0FA6F39420CCACE900A03DCD /* UniqueArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueArray.cpp; sourceTree = "<group>"; };
 		0FB14E18180FA218009B6B4D /* Bag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bag.h; sourceTree = "<group>"; };
@@ -649,7 +647,6 @@
 		A8A472FD151A825B004123FF /* RandomNumberSeed.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomNumberSeed.h; sourceTree = "<group>"; };
 		A8A472FE151A825B004123FF /* RedBlackTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RedBlackTree.h; sourceTree = "<group>"; };
 		A8A472FF151A825B004123FF /* RefCounted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCounted.h; sourceTree = "<group>"; };
-		A8A47300151A825B004123FF /* RefCountedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCountedArray.h; sourceTree = "<group>"; };
 		A8A47301151A825B004123FF /* RefCountedLeakCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCountedLeakCounter.cpp; sourceTree = "<group>"; };
 		A8A47302151A825B004123FF /* RefCountedLeakCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCountedLeakCounter.h; sourceTree = "<group>"; };
 		A8A47303151A825B004123FF /* RefPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefPtr.h; sourceTree = "<group>"; };
@@ -1269,8 +1266,6 @@
 				26299B6D17A9E5B800ADEBE5 /* Ref.h */,
 				46BEB6E922FFDDD500269867 /* RefCounted.cpp */,
 				A8A472FF151A825B004123FF /* RefCounted.h */,
-				0FA6F39020CC61EB00A03DCD /* RefCountedArray.cpp */,
-				A8A47300151A825B004123FF /* RefCountedArray.h */,
 				E3E8162F2764799300BAA45B /* RefCountedFixedVector.h */,
 				A8A47301151A825B004123FF /* RefCountedLeakCounter.cpp */,
 				A8A47302151A825B004123FF /* RefCountedLeakCounter.h */,
@@ -1824,7 +1819,6 @@
 				A8A47414151A825B004123FF /* RandomNumber.cpp in Sources */,
 				0FEC3C5E1F368A9700F59B6C /* ReadWriteLock.cpp in Sources */,
 				46BEB6EB22FFE24900269867 /* RefCounted.cpp in Sources */,
-				E3149A38228BB42C00BFA6C7 /* RefCountedArray.cpp in Sources */,
 				A8A4741A151A825B004123FF /* RefCountedLeakCounter.cpp in Sources */,
 				E392FA2722E92BFF00ECDC73 /* ResourceUsageCocoa.cpp in Sources */,
 				2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */,

Modified: trunk/Source/WTF/wtf/CMakeLists.txt (287307 => 287308)


--- trunk/Source/WTF/wtf/CMakeLists.txt	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WTF/wtf/CMakeLists.txt	2021-12-21 10:33:01 UTC (rev 287308)
@@ -219,7 +219,6 @@
     RedBlackTree.h
     Ref.h
     RefCounted.h
-    RefCountedArray.h
     RefCountedFixedVector.h
     RefCountedLeakCounter.h
     RefCounter.h
@@ -458,7 +457,6 @@
     RandomNumber.cpp
     ReadWriteLock.cpp
     RefCounted.cpp
-    RefCountedArray.cpp
     RefCountedLeakCounter.cpp
     RunLoop.cpp
     SHA1.cpp

Modified: trunk/Source/WTF/wtf/FixedVector.h (287307 => 287308)


--- trunk/Source/WTF/wtf/FixedVector.h	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WTF/wtf/FixedVector.h	2021-12-21 10:33:01 UTC (rev 287308)
@@ -26,12 +26,9 @@
 #pragma once
 
 #include <wtf/EmbeddedFixedVector.h>
-#include <wtf/RefCountedArray.h>
 
 namespace WTF {
 
-// Wrapper around RefCountedArray, fixed-sized, memory compact Vector.
-// Copy constructor / assignment operator work differently from RefCountedArray: works as like a Vector.
 template<typename T>
 class FixedVector {
 public:

Deleted: trunk/Source/WTF/wtf/RefCountedArray.cpp (287307 => 287308)


--- trunk/Source/WTF/wtf/RefCountedArray.cpp	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WTF/wtf/RefCountedArray.cpp	2021-12-21 10:33:01 UTC (rev 287308)
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2020 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/RefCountedArray.h>
-
-#include <wtf/NeverDestroyed.h>
-
-namespace WTF {
-
-DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(RefCountedArray);
-
-} // namespace WTF

Deleted: trunk/Source/WTF/wtf/RefCountedArray.h (287307 => 287308)


--- trunk/Source/WTF/wtf/RefCountedArray.h	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WTF/wtf/RefCountedArray.h	2021-12-21 10:33:01 UTC (rev 287308)
@@ -1,362 +0,0 @@
-/*
- * 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
- * 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 <wtf/FastMalloc.h>
-#include <wtf/RawPtrTraits.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/Vector.h>
-
-// This implements a reference counted array for POD** values, which is optimized for:
-// - An empty array only uses one word.
-// - A copy of the array only uses one word (i.e. assignment means aliasing).
-// - The vector can't grow beyond 2^32-1 elements.
-// - In all other regards this has similar space usage to a Vector.
-//
-// ** This could be modified to support non-POD values quite easily. It just
-//    hasn't been, so far, because there has been no need. Moreover, even now,
-//    it's used for things that aren't quite POD according to the official
-//    defintion, such as JSC::Instruction.
-
-namespace WTF {
-
-DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(RefCountedArray);
-
-template<typename T, typename PtrTraits = RawPtrTraits<T>>
-class RefCountedArray {
-    enum CommonCopyConstructorTag { CommonCopyConstructor };
-
-public:
-    using iterator = T*;
-    using const_iterator = const T*;
-    using reverse_iterator = std::reverse_iterator<iterator>;
-    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
-
-    RefCountedArray() = default;
-    
-    RefCountedArray(const RefCountedArray& other)
-        : RefCountedArray(CommonCopyConstructor, other)
-    { }
-
-    template<typename OtherTraits>
-    RefCountedArray(const RefCountedArray<T, OtherTraits>& other)
-        : RefCountedArray(CommonCopyConstructor, other)
-    { }
-
-    RefCountedArray(RefCountedArray&& other)
-        : m_data(PtrTraits::exchange(other.m_data, nullptr))
-    { }
-
-    explicit RefCountedArray(size_t size)
-    {
-        if (!size) {
-            // NOTE: JSC's LowLevelInterpreter relies on this being nullptr when the size is zero.
-            PtrTraits::exchange(m_data, nullptr);
-            return;
-        }
-
-        m_data = allocateUninitializedData(size);
-        VectorTypeOperations<T>::initializeIfNonPOD(begin(), end());
-    }
-
-    template<typename OtherTraits = PtrTraits>
-    RefCountedArray<T, OtherTraits> clone() const
-    {
-        RefCountedArray<T, OtherTraits> result(size());
-        const T* data = ""
-        T* resultData = result.data();
-        for (unsigned i = size(); i--;)
-            resultData[i] = data[i];
-        return result;
-    }
-
-    template<size_t inlineCapacity, typename OverflowHandler>
-    explicit RefCountedArray(const Vector<T, inlineCapacity, OverflowHandler>& other)
-    {
-        if (other.isEmpty()) {
-            PtrTraits::exchange(m_data, nullptr);
-            return;
-        }
-
-        T* data = ""
-        m_data = data;
-        VectorTypeOperations<T>::uninitializedCopy(other.begin(), other.end(), data);
-    }
-
-    template<size_t inlineCapacity, typename OverflowHandler>
-    explicit RefCountedArray(Vector<T, inlineCapacity, OverflowHandler>&& other)
-    {
-        Vector<T, inlineCapacity, OverflowHandler> vector(WTFMove(other));
-        if (vector.isEmpty()) {
-            PtrTraits::exchange(m_data, nullptr);
-            return;
-        }
-
-        T* data = ""
-        m_data = data;
-        for (unsigned index = 0; index < vector.size(); ++index)
-            new (data + index) T(WTFMove(vector[index]));
-    }
-    
-    template<typename OtherTraits = PtrTraits>
-    RefCountedArray& operator=(const RefCountedArray<T, OtherTraits>& other)
-    {
-        return assign<OtherTraits>(other);
-    }
-
-    RefCountedArray& operator=(const RefCountedArray& other)
-    {
-        return assign<PtrTraits>(other);
-    }
-
-    template<size_t inlineCapacity, typename OverflowHandler>
-    RefCountedArray& operator=(const Vector<T, inlineCapacity, OverflowHandler>& other)
-    {
-        T* oldData = data();
-        if (other.isEmpty())
-            PtrTraits::exchange(m_data, nullptr);
-        else {
-            T* data = ""
-            m_data = data;
-            VectorTypeOperations<T>::uninitializedCopy(other.begin(), other.end(), data);
-        }
-        if (!oldData)
-            return *this;
-        unsigned refCount = Header::fromPayload(oldData)->refCount - 1;
-        if (refCount) {
-            Header::fromPayload(oldData)->refCount = refCount;
-            return *this;
-        }
-        VectorTypeOperations<T>::destruct(oldData, oldData + Header::fromPayload(oldData)->length);
-
-        RefCountedArrayMalloc::free(Header::fromPayload(oldData));
-        return *this;
-    }
-
-    template<size_t inlineCapacity, typename OverflowHandler>
-    RefCountedArray& operator=(Vector<T, inlineCapacity, OverflowHandler>&& other)
-    {
-        Vector<T, inlineCapacity, OverflowHandler> vector(WTFMove(other));
-        T* oldData = data();
-        if (vector.isEmpty())
-            PtrTraits::exchange(m_data, nullptr);
-        else {
-            T* data = ""
-            m_data = data;
-            for (unsigned index = 0; index < vector.size(); ++index)
-                new (data + index) T(WTFMove(vector[index]));
-        }
-        if (!oldData)
-            return *this;
-        unsigned refCount = Header::fromPayload(oldData)->refCount - 1;
-        if (refCount) {
-            Header::fromPayload(oldData)->refCount = refCount;
-            return *this;
-        }
-        VectorTypeOperations<T>::destruct(oldData, oldData + Header::fromPayload(oldData)->length);
-
-        RefCountedArrayMalloc::free(Header::fromPayload(oldData));
-        return *this;
-    }
-
-    ~RefCountedArray()
-    {
-        if (!m_data)
-            return;
-        T* data = ""
-        unsigned refCount = Header::fromPayload(data)->refCount - 1;
-        if (refCount) {
-            Header::fromPayload(data)->refCount = refCount;
-            return;
-        }
-        VectorTypeOperations<T>::destruct(begin(), end());
-        RefCountedArrayMalloc::free(Header::fromPayload(data));
-    }
-    
-    unsigned refCount() const
-    {
-        if (!m_data)
-            return 0;
-        return Header::fromPayload(data())->refCount;
-    }
-    
-    size_t size() const
-    {
-        if (!m_data)
-            return 0;
-        return Header::fromPayload(data())->length;
-    }
-
-    bool isEmpty() const { return size() == 0; }
-    
-    size_t byteSize() const { return size() * sizeof(T); }
-    
-    T* data() { return PtrTraits::unwrap(m_data); }
-    iterator begin() { return data(); }
-    iterator end()
-    {
-        if (!m_data)
-            return 0;
-        T* data = ""
-        return data + Header::fromPayload(data)->length;
-    }
-    
-    const T* data() const { return const_cast<RefCountedArray*>(this)->data(); }
-    const_iterator begin() const { return const_cast<RefCountedArray*>(this)->begin(); }
-    const_iterator end() const { return const_cast<RefCountedArray*>(this)->end(); }
-
-    reverse_iterator rbegin() { return reverse_iterator(end()); }
-    reverse_iterator rend() { return reverse_iterator(begin()); }
-    const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
-    const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
-    
-    T& at(size_t i)
-    {
-        ASSERT_WITH_SECURITY_IMPLICATION(i < size());
-        return begin()[i];
-    }
-    
-    const T& at(size_t i) const
-    {
-        ASSERT_WITH_SECURITY_IMPLICATION(i < size());
-        return begin()[i];
-    }
-    
-    T& operator[](size_t i) { return at(i); }
-    const T& operator[](size_t i) const { return at(i); }
-
-    T& first() { return (*this)[0]; }
-    const T& first() const { return (*this)[0]; }
-    T& last() { return (*this)[size() - 1]; }
-    const T& last() const { return (*this)[size() - 1]; }
-
-    void fill(const T& val)
-    {
-        std::fill(begin(), end(), val);
-    }
-
-    void swap(RefCountedArray& other)
-    {
-        PtrTraits::swap(m_data, other.m_data);
-    }
-
-    template<typename OtherTraits = PtrTraits>
-    bool operator==(const RefCountedArray<T, OtherTraits>& other) const
-    {
-        T* data = ""
-        T* otherData = const_cast<T*>(other.data());
-        if (data == otherData)
-            return true;
-        if (!data || !otherData)
-            return false;
-        unsigned length = Header::fromPayload(data)->length;
-        if (length != Header::fromPayload(otherData)->length)
-            return false;
-        for (unsigned i = 0; i < length; ++i) {
-            if (data[i] != otherData[i])
-                return false;
-        }
-        return true;
-    }
-
-    bool operator==(const RefCountedArray& other) const { return this->operator==<PtrTraits>(other); }
-    
-private:
-    static T* allocateUninitializedData(unsigned length)
-    {
-        T* data = "" + sizeof(T) * length)))->payload();
-        Header::fromPayload(data)->refCount = 1;
-        Header::fromPayload(data)->length = length;
-        ASSERT(Header::fromPayload(data)->length == length);
-        return data;
-    }
-
-    template<typename OtherTraits = PtrTraits>
-    RefCountedArray& assign(const RefCountedArray<T, OtherTraits>& other)
-    {
-        T* oldData = data();
-        T* otherData = const_cast<T*>(other.data());
-        if (otherData)
-            Header::fromPayload(otherData)->refCount++;
-        m_data = otherData;
-
-        if (!oldData)
-            return *this;
-        unsigned refCount = Header::fromPayload(oldData)->refCount - 1;
-        if (refCount) {
-            Header::fromPayload(oldData)->refCount = refCount;
-            return *this;
-        }
-        VectorTypeOperations<T>::destruct(oldData, oldData + Header::fromPayload(oldData)->length);
-
-        RefCountedArrayMalloc::free(Header::fromPayload(oldData));
-        return *this;
-    }
-
-    struct Header {
-        unsigned refCount;
-        unsigned length;
-        
-        static constexpr size_t size()
-        {
-            return (sizeof(Header) + 7) & ~7;
-        }
-
-        static ptrdiff_t offsetOfLength() { return OBJECT_OFFSETOF(Header, length); }
-        
-        T* payload()
-        {
-            char* result = reinterpret_cast<char*>(this) + size();
-            ASSERT(!(bitwise_cast<uintptr_t>(result) & 7));
-            return reinterpret_cast_ptr<T*>(result);
-        }
-        
-        static Header* fromPayload(T* payload)
-        {
-            return reinterpret_cast_ptr<Header*>(reinterpret_cast<char*>(payload) - size());
-        }
-
-        static const Header* fromPayload(const T* payload)
-        {
-            return fromPayload(const_cast<T*>(payload));
-        }
-    };
-
-    template<typename OtherTraits>
-    RefCountedArray(CommonCopyConstructorTag, const RefCountedArray<T, OtherTraits>& other)
-        : m_data(const_cast<T*>(other.data()))
-    {
-        if (m_data)
-            Header::fromPayload(data())->refCount++;
-    }
-
-    friend class JSC::LLIntOffsetsExtractor;
-    typename PtrTraits::StorageType m_data { nullptr };
-};
-
-} // namespace WTF
-
-using WTF::RefCountedArray;

Modified: trunk/Source/WTF/wtf/WTFAssertions.cpp (287307 => 287308)


--- trunk/Source/WTF/wtf/WTFAssertions.cpp	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WTF/wtf/WTFAssertions.cpp	2021-12-21 10:33:01 UTC (rev 287308)
@@ -27,7 +27,6 @@
 
 #include <wtf/Bag.h>
 #include <wtf/Platform.h>
-#include <wtf/RefCountedArray.h>
 #include <wtf/RefPtr.h>
 
 #if OS(DARWIN)
@@ -47,8 +46,6 @@
 
 static_assert(sizeof(RefPtr<DummyStruct>) == sizeof(DummyStruct*), "");
 
-static_assert(sizeof(RefCountedArray<DummyStruct>) == sizeof(void*), "");
-
 #if OS(DARWIN) && CPU(ADDRESS64)
 // NaN boxing encoding relies on this.
 static_assert(MACH_VM_MAX_ADDRESS <= (1ull << 48));

Modified: trunk/Source/WebCore/ChangeLog (287307 => 287308)


--- trunk/Source/WebCore/ChangeLog	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WebCore/ChangeLog	2021-12-21 10:33:01 UTC (rev 287308)
@@ -1,3 +1,23 @@
+2021-12-21  Yusuke Suzuki  <[email protected]>
+
+        [WTF] Remove RefCountedArray and use RefCountedFixedVector
+        https://bugs.webkit.org/show_bug.cgi?id=234484
+
+        Reviewed by Dean Jackson.
+
+        Use RefCountedFixedVector intead. No semantic change.
+
+        * layout/integration/InlineIteratorBoxLegacyPath.h:
+        * platform/graphics/FontCascadeDescription.cpp:
+        (WebCore::FontCascadeDescription::FontCascadeDescription):
+        * platform/graphics/FontCascadeDescription.h:
+        (WebCore::FontCascadeDescription::familyCount const):
+        (WebCore::FontCascadeDescription::familyAt const):
+        (WebCore::FontCascadeDescription::families const):
+        (WebCore::FontCascadeDescription::setOneFamily):
+        (WebCore::FontCascadeDescription::setFamilies):
+        (WebCore::FontCascadeDescription::operator== const):
+
 2021-12-21  Youenn Fablet  <[email protected]>
 
         REGRESSION (r287258): Flaky crash in WebCore::RTCRtpScriptTransformer::enqueueFrame

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorBoxLegacyPath.h (287307 => 287308)


--- trunk/Source/WebCore/layout/integration/InlineIteratorBoxLegacyPath.h	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorBoxLegacyPath.h	2021-12-21 10:33:01 UTC (rev 287308)
@@ -29,7 +29,6 @@
 #include "LegacyRootInlineBox.h"
 #include "RenderText.h"
 #include "TextBoxSelectableRange.h"
-#include <wtf/RefCountedArray.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {

Modified: trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp (287307 => 287308)


--- trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp	2021-12-21 10:33:01 UTC (rev 287308)
@@ -52,7 +52,8 @@
 COMPILE_ASSERT(sizeof(FontCascadeDescription) == sizeof(SameSizeAsFontCascadeDescription), FontCascadeDescription_should_stay_small);
 
 FontCascadeDescription::FontCascadeDescription()
-    : m_isAbsoluteSize(false)
+    : m_families(RefCountedFixedVector<AtomString>::create(1))
+    , m_isAbsoluteSize(false)
     , m_kerning(static_cast<unsigned>(Kerning::Auto))
     , m_keywordSize(0)
     , m_fontSmoothing(static_cast<unsigned>(FontSmoothingMode::AutoSmoothing))

Modified: trunk/Source/WebCore/platform/graphics/FontCascadeDescription.h (287307 => 287308)


--- trunk/Source/WebCore/platform/graphics/FontCascadeDescription.h	2021-12-21 10:16:21 UTC (rev 287307)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeDescription.h	2021-12-21 10:33:01 UTC (rev 287308)
@@ -27,7 +27,7 @@
 #include "CSSValueKeywords.h"
 #include "FontDescription.h"
 #include <variant>
-#include <wtf/RefCountedArray.h>
+#include <wtf/RefCountedFixedVector.h>
 
 #if PLATFORM(COCOA)
 #include "FontFamilySpecificationCoreText.h"
@@ -52,10 +52,10 @@
     bool operator==(const FontCascadeDescription&) const;
     bool operator!=(const FontCascadeDescription& other) const { return !(*this == other); }
 
-    unsigned familyCount() const { return m_families.size(); }
+    unsigned familyCount() const { return m_families->size(); }
     const AtomString& firstFamily() const { return familyAt(0); }
-    const AtomString& familyAt(unsigned i) const { return m_families[i]; }
-    const RefCountedArray<AtomString>& families() const { return m_families; }
+    const AtomString& familyAt(unsigned i) const { return m_families.get()[i]; }
+    RefCountedFixedVector<AtomString>& families() const { return m_families.get(); }
 
     static bool familyNamesAreEqual(const AtomString&, const AtomString&);
     static unsigned familyNameHash(const AtomString&);
@@ -85,9 +85,9 @@
     FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMode>(m_fontSmoothing); }
     bool isSpecifiedFont() const { return m_isSpecifiedFont; }
 
-    void setOneFamily(const AtomString& family) { ASSERT(m_families.size() == 1); m_families[0] = family; }
-    void setFamilies(const Vector<AtomString>& families) { m_families = RefCountedArray<AtomString>(families); }
-    void setFamilies(const RefCountedArray<AtomString>& families) { m_families = families; }
+    void setOneFamily(const AtomString& family) { ASSERT(m_families->size() == 1); m_families.get()[0] = family; }
+    void setFamilies(const Vector<AtomString>& families) { m_families = RefCountedFixedVector<AtomString>::createFromVector(families); }
+    void setFamilies(RefCountedFixedVector<AtomString>& families) { m_families = families; }
     void setSpecifiedSize(float s) { m_specifiedSize = clampToFloat(s); }
     void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
     void setKerning(Kerning kerning) { m_kerning = static_cast<unsigned>(kerning); }
@@ -136,7 +136,7 @@
     static FontPalette initialFontPalette() { return { FontPalette::Type::Normal, nullAtom() }; }
 
 private:
-    RefCountedArray<AtomString> m_families { 1 };
+    Ref<RefCountedFixedVector<AtomString>> m_families;
 
     // Specified CSS value. Independent of rendering issues such as integer rounding, minimum font sizes, and zooming.
     float m_specifiedSize { 0 };
@@ -155,7 +155,7 @@
 inline bool FontCascadeDescription::operator==(const FontCascadeDescription& other) const
 {
     return FontDescription::operator==(other)
-        && m_families == other.m_families
+        && m_families.get() == other.m_families.get()
         && m_specifiedSize == other.m_specifiedSize
         && m_isAbsoluteSize == other.m_isAbsoluteSize
         && m_kerning == other.m_kerning
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to