Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (288457 => 288458)
--- trunk/Source/_javascript_Core/ChangeLog 2022-01-24 19:19:05 UTC (rev 288457)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-01-24 20:01:13 UTC (rev 288458)
@@ -1,3 +1,15 @@
+2022-01-24 Mark Lam <[email protected]>
+
+ Add FixedVector::clear(), contains(), find(), and findMatching().
+ https://bugs.webkit.org/show_bug.cgi?id=234855
+
+ Reviewed by Yusuke Suzuki.
+
+ Use FixedVector instead of Vector in DeferredWorkTimer::TicketData now that
+ the needed APIs have been added.
+
+ * runtime/DeferredWorkTimer.h:
+
2022-01-24 Joseph Griego <[email protected]>
[Shadow Realms] Use WebCore module loaders for shadow realm importValue
Modified: trunk/Source/_javascript_Core/runtime/DeferredWorkTimer.h (288457 => 288458)
--- trunk/Source/_javascript_Core/runtime/DeferredWorkTimer.h 2022-01-24 19:19:05 UTC (rev 288457)
+++ trunk/Source/_javascript_Core/runtime/DeferredWorkTimer.h 2022-01-24 20:01:13 UTC (rev 288458)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -56,7 +56,7 @@
void cancel();
bool isCancelled() const { return !scriptExecutionOwner.get(); }
- Vector<Strong<JSCell>> dependencies;
+ FixedVector<Strong<JSCell>> dependencies;
Strong<JSObject> scriptExecutionOwner;
};
Modified: trunk/Source/WTF/ChangeLog (288457 => 288458)
--- trunk/Source/WTF/ChangeLog 2022-01-24 19:19:05 UTC (rev 288457)
+++ trunk/Source/WTF/ChangeLog 2022-01-24 20:01:13 UTC (rev 288458)
@@ -1,3 +1,16 @@
+2022-01-24 Mark Lam <[email protected]>
+
+ Add FixedVector::clear(), contains(), find(), and findMatching().
+ https://bugs.webkit.org/show_bug.cgi?id=234855
+
+ Reviewed by Yusuke Suzuki.
+
+ * wtf/FixedVector.h:
+ (WTF::FixedVector::clear):
+ (WTF::FixedVector<T>::contains const):
+ (WTF::FixedVector<T>::findMatching const):
+ (WTF::FixedVector<T>::find const):
+
2022-01-21 Yusuke Suzuki <[email protected]>
[JSC] Relax Date.parse requirement
Modified: trunk/Source/WTF/wtf/FixedVector.h (288457 => 288458)
--- trunk/Source/WTF/wtf/FixedVector.h 2022-01-24 19:19:05 UTC (rev 288457)
+++ trunk/Source/WTF/wtf/FixedVector.h 2022-01-24 20:01:13 UTC (rev 288458)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2021-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -127,6 +127,8 @@
T& last() { return (*this)[size() - 1]; }
const T& last() const { return (*this)[size() - 1]; }
+ void clear() { m_storage = nullptr; }
+
void fill(const T& val)
{
if (!m_storage)
@@ -151,6 +153,10 @@
return *m_storage == *other.m_storage;
}
+ template<typename U> bool contains(const U&) const;
+ template<typename U> size_t find(const U&) const;
+ template<typename MatchFunction> size_t findMatching(const MatchFunction&) const;
+
void swap(FixedVector<T>& other)
{
using std::swap;
@@ -169,6 +175,33 @@
static_assert(sizeof(FixedVector<int>) == sizeof(int*));
template<typename T>
+template<typename U>
+bool FixedVector<T>::contains(const U& value) const
+{
+ return find(value) != notFound;
+}
+
+template<typename T>
+template<typename MatchFunction>
+size_t FixedVector<T>::findMatching(const MatchFunction& matches) const
+{
+ for (size_t i = 0; i < size(); ++i) {
+ if (matches(at(i)))
+ return i;
+ }
+ return notFound;
+}
+
+template<typename T>
+template<typename U>
+size_t FixedVector<T>::find(const U& value) const
+{
+ return findMatching([&](auto& item) {
+ return item == value;
+ });
+}
+
+template<typename T>
inline void swap(FixedVector<T>& a, FixedVector<T>& b)
{
a.swap(b);
Modified: trunk/Tools/ChangeLog (288457 => 288458)
--- trunk/Tools/ChangeLog 2022-01-24 19:19:05 UTC (rev 288457)
+++ trunk/Tools/ChangeLog 2022-01-24 20:01:13 UTC (rev 288458)
@@ -1,3 +1,18 @@
+2022-01-24 Mark Lam <[email protected]>
+
+ Add FixedVector::clear(), contains(), find(), and findMatching().
+ https://bugs.webkit.org/show_bug.cgi?id=234855
+
+ Reviewed by Yusuke Suzuki.
+
+ Added new tests for FixedVector. Also added the ClearContainsAndFind test to
+ Vector since it is missing these tests.
+
+ * TestWebKitAPI/Tests/WTF/FixedVector.cpp:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WTF/Vector.cpp:
+ (TestWebKitAPI::TEST):
+
2022-01-24 Carlos Garcia Campos <[email protected]>
[GTK][a11y] Test accessibility/url-test.html fails with ATSPI
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp (288457 => 288458)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp 2022-01-24 19:19:05 UTC (rev 288457)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp 2022-01-24 20:01:13 UTC (rev 288458)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2021-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -78,6 +78,46 @@
vector[0] = Test();
}
+TEST(WTF_FixedVector, ClearContainsAndFind)
+{
+ FixedVector<int> v;
+ EXPECT_TRUE(v.isEmpty());
+ v.clear();
+ EXPECT_TRUE(v.isEmpty());
+
+ v = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ EXPECT_EQ(10U, v.size());
+ EXPECT_FALSE(v.contains(1));
+ EXPECT_EQ(notFound, v.find(1));
+ v.clear();
+ EXPECT_TRUE(v.isEmpty());
+ EXPECT_FALSE(v.contains(1));
+ EXPECT_EQ(notFound, v.find(1));
+
+ v = { 3, 1, 2, 1, 1, 4, 2, 2, 1, 1, 3, 5 };
+ EXPECT_EQ(12U, v.size());
+ EXPECT_TRUE(v.contains(3));
+ EXPECT_TRUE(v.contains(4));
+ EXPECT_TRUE(v.contains(5));
+ EXPECT_FALSE(v.contains(6));
+ EXPECT_EQ(0U, v.find(3));
+ EXPECT_EQ(5U, v.find(4));
+ EXPECT_EQ(11U, v.find(5));
+ EXPECT_EQ(notFound, v.find(6));
+ EXPECT_TRUE(v == FixedVector<int>({ 3, 1, 2, 1, 1, 4, 2, 2, 1, 1, 3, 5 }));
+ v.clear();
+ EXPECT_EQ(0U, v.size());
+ EXPECT_FALSE(v.contains(3));
+ EXPECT_FALSE(v.contains(4));
+ EXPECT_FALSE(v.contains(5));
+ EXPECT_FALSE(v.contains(6));
+ EXPECT_EQ(notFound, v.find(3));
+ EXPECT_EQ(notFound, v.find(4));
+ EXPECT_EQ(notFound, v.find(5));
+ EXPECT_EQ(notFound, v.find(6));
+ EXPECT_TRUE(v == FixedVector<int>({ }));
+}
+
TEST(WTF_FixedVector, Copy)
{
FixedVector<unsigned> vec1(3);
@@ -117,6 +157,21 @@
EXPECT_EQ(2U, vec2[2]);
}
+TEST(WTF_FixedVector, FindMatching)
+{
+ FixedVector<int> v;
+ EXPECT_TRUE(v.findMatching([](int) { return false; }) == notFound);
+ EXPECT_TRUE(v.findMatching([](int) { return true; }) == notFound);
+
+ v = { 3, 1, 2, 1, 2, 1, 2, 2, 1, 1, 1, 3 };
+ EXPECT_TRUE(v.findMatching([](int value) { return value > 3; }) == notFound);
+ EXPECT_TRUE(v.findMatching([](int) { return false; }) == notFound);
+ EXPECT_EQ(0U, v.findMatching([](int) { return true; }));
+ EXPECT_EQ(0U, v.findMatching([](int value) { return value <= 3; }));
+ EXPECT_EQ(1U, v.findMatching([](int value) { return value < 3; }));
+ EXPECT_EQ(2U, v.findMatching([](int value) { return value == 2; }));
+}
+
TEST(WTF_FixedVector, Move)
{
FixedVector<unsigned> vec1(3);
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp (288457 => 288458)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp 2022-01-24 19:19:05 UTC (rev 288457)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp 2022-01-24 20:01:13 UTC (rev 288458)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -685,6 +685,46 @@
EXPECT_TRUE(v2 == vExpected);
}
+TEST(WTF_Vector, ClearContainsAndFind)
+{
+ Vector<int> v;
+ EXPECT_TRUE(v.isEmpty());
+ v.clear();
+ EXPECT_TRUE(v.isEmpty());
+
+ v = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ EXPECT_EQ(10U, v.size());
+ EXPECT_FALSE(v.contains(1));
+ EXPECT_EQ(notFound, v.find(1));
+ v.clear();
+ EXPECT_TRUE(v.isEmpty());
+ EXPECT_FALSE(v.contains(1));
+ EXPECT_EQ(notFound, v.find(1));
+
+ v = { 3, 1, 2, 1, 1, 4, 2, 2, 1, 1, 3, 5 };
+ EXPECT_EQ(12U, v.size());
+ EXPECT_TRUE(v.contains(3));
+ EXPECT_TRUE(v.contains(4));
+ EXPECT_TRUE(v.contains(5));
+ EXPECT_FALSE(v.contains(6));
+ EXPECT_EQ(0U, v.find(3));
+ EXPECT_EQ(5U, v.find(4));
+ EXPECT_EQ(11U, v.find(5));
+ EXPECT_EQ(notFound, v.find(6));
+ EXPECT_TRUE(v == Vector<int>({ 3, 1, 2, 1, 1, 4, 2, 2, 1, 1, 3, 5 }));
+ v.clear();
+ EXPECT_EQ(0U, v.size());
+ EXPECT_FALSE(v.contains(3));
+ EXPECT_FALSE(v.contains(4));
+ EXPECT_FALSE(v.contains(5));
+ EXPECT_FALSE(v.contains(6));
+ EXPECT_EQ(notFound, v.find(3));
+ EXPECT_EQ(notFound, v.find(4));
+ EXPECT_EQ(notFound, v.find(5));
+ EXPECT_EQ(notFound, v.find(6));
+ EXPECT_TRUE(v == Vector<int>({ }));
+}
+
TEST(WTF_Vector, FindMatching)
{
Vector<int> v;