WebKit Bugzilla
Attachment 372332 Details for
Bug 198957
: Add WTF::crossThreadCopy(T&&) to utilize String::isolatedCopy() &&
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198957-20190618182806.patch (text/plain), 8.87 KB, created by
Fujii Hironori
on 2019-06-18 02:28:08 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2019-06-18 02:28:08 PDT
Size:
8.87 KB
patch
obsolete
>Subversion Revision: 246534 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 26049362030fffd6844826caf0a515196859132b..1cec3af1253795e30c81a955e1628a6029264bd1 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,21 @@ >+2019-06-18 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ Add WTF::crossThreadCopy(T&&) to utilize String::isolatedCopy() && >+ https://bugs.webkit.org/show_bug.cgi?id=198957 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ &&-qualified String::isolatedCopy() has a optimization path which >+ does just WTFMove if it isSafeToSendToAnotherThread which means >+ the object hasOneRef. >+ >+ However, WTF::crossThreadCopy was using only &-qualified >+ isolatedCopy. To use the optimization, added >+ WTF::crossThreadCopy(T&&) overloading. >+ >+ * wtf/CrossThreadCopier.h: >+ (WTF::crossThreadCopy): Added a overload of (T&&). >+ > 2019-06-17 Jiewen Tan <jiewen_tan@apple.com> > > Move SOAuthorization from WebKitAdditions to WebKit >diff --git a/Source/WTF/wtf/CrossThreadCopier.h b/Source/WTF/wtf/CrossThreadCopier.h >index 633878ae938869db3b315471020897bca079f0c6..c53373a86073530757551c9f3e1751ed0f6cb214 100644 >--- a/Source/WTF/wtf/CrossThreadCopier.h >+++ b/Source/WTF/wtf/CrossThreadCopier.h >@@ -31,6 +31,7 @@ > > #pragma once > >+#include <type_traits> > #include <wtf/Assertions.h> > #include <wtf/Forward.h> > #include <wtf/HashSet.h> >@@ -77,9 +78,9 @@ template<typename T> struct CrossThreadCopierBase<true, false, T> : public Cross > > // Classes that have an isolatedCopy() method get a default specialization. > template<class T> struct CrossThreadCopierBase<false, false, T> { >- static T copy(const T& value) >+ template<typename U> static auto copy(U&& value) > { >- return value.isolatedCopy(); >+ return std::forward<U>(value).isolatedCopy(); > } > }; > >@@ -153,12 +154,24 @@ template<typename T> struct CrossThreadCopierBase<false, false, Optional<T>> { > return WTF::nullopt; > return CrossThreadCopier<T>::copy(*source); > } >+ >+ static Type copy(Type&& source) >+ { >+ if (!source) >+ return WTF::nullopt; >+ return CrossThreadCopier<T>::copy(WTFMove(*source)); >+ } > }; > > template<typename T> T crossThreadCopy(const T& source) > { > return CrossThreadCopier<T>::copy(source); > } >+ >+template<typename T> auto crossThreadCopy(T&& source) >+{ >+ return CrossThreadCopier<std::remove_reference_t<T>>::copy(std::forward<T>(source)); >+} > > } // namespace WTF > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 09cccc2467edeb892ac4b5b13a63f3638741f7f5..7902f7656b41de6f2be6759a5c8c2d1d0a94df27 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2019-06-18 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ Add WTF::crossThreadCopy(T&&) to utilize String::isolatedCopy() && >+ https://bugs.webkit.org/show_bug.cgi?id=198957 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/CMakeLists.txt: >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WTF/CrossThreadCopier.cpp: Added. >+ > 2019-06-18 Dan Bernstein <mitz@apple.com> > > Revert workaround for bug 198904 from run-webkit-archive >diff --git a/Tools/TestWebKitAPI/CMakeLists.txt b/Tools/TestWebKitAPI/CMakeLists.txt >index 7adb608eeaa611b66b1ed5074a5917d0a0df8548..619e78d39fddd10cde5b9778220a247e20ef6a0c 100644 >--- a/Tools/TestWebKitAPI/CMakeLists.txt >+++ b/Tools/TestWebKitAPI/CMakeLists.txt >@@ -30,6 +30,7 @@ set(TestWTF_SOURCES > Tests/WTF/CheckedArithmeticOperations.cpp > Tests/WTF/ConcurrentPtrHashSet.cpp > Tests/WTF/Condition.cpp >+ Tests/WTF/CrossThreadCopier.cpp > Tests/WTF/CrossThreadTask.cpp > Tests/WTF/DateMath.cpp > Tests/WTF/Deque.cpp >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 864729a99db43355650ba417c99f468d32149750..5100f443b5ac8757ac809ceba31a4ccc75e19283 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -1469,6 +1469,7 @@ > 26F52EB018288F0F0023D412 /* geolocationWatchPosition.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = geolocationWatchPosition.html; sourceTree = "<group>"; }; > 26F52EB118288F0F0023D412 /* geolocationWatchPositionWithHighAccuracy.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = geolocationWatchPositionWithHighAccuracy.html; sourceTree = "<group>"; }; > 26F6E1EF1ADC749B00DE696B /* DFAMinimizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFAMinimizer.cpp; sourceTree = "<group>"; }; >+ 278DE64B22B8D611004E0E7A /* CrossThreadCopier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossThreadCopier.cpp; sourceTree = "<group>"; }; > 290A9BB51735DE8A00D71BBC /* CloseNewWindowInNavigationPolicyDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CloseNewWindowInNavigationPolicyDelegate.mm; sourceTree = "<group>"; }; > 290A9BB81735F42300D71BBC /* OpenNewWindow.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = OpenNewWindow.html; sourceTree = "<group>"; }; > 290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "custom-protocol-sync-xhr.html"; sourceTree = "<group>"; }; >@@ -3397,6 +3398,7 @@ > A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */, > 0F30CB5B1FCE1792004B5323 /* ConcurrentPtrHashSet.cpp */, > 0FEAE3671B7D19CB00CE17F2 /* Condition.cpp */, >+ 278DE64B22B8D611004E0E7A /* CrossThreadCopier.cpp */, > 51714EB91D087416004723C4 /* CrossThreadTask.cpp */, > 26A2C72E15E2E73C005B1A14 /* CString.cpp */, > 7AA021BA1AB09EA70052953F /* DateMath.cpp */, >diff --git a/Tools/TestWebKitAPI/Tests/WTF/CrossThreadCopier.cpp b/Tools/TestWebKitAPI/Tests/WTF/CrossThreadCopier.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..5a287b8d217fe883f7a2f484f52fe36b757dc5c0 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WTF/CrossThreadCopier.cpp >@@ -0,0 +1,72 @@ >+/* >+ * Copyright (C) 2019 Sony Interactive Entertainment Inc. >+ * >+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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/CrossThreadCopier.h> >+ >+#include <wtf/Optional.h> >+#include <wtf/text/WTFString.h> >+ >+namespace TestWebKitAPI { >+ >+TEST(WTF_CrossThreadCopier, CopyString) >+{ >+ String original { "1234" }; >+ auto copy = crossThreadCopy(original); >+ EXPECT_TRUE(original.impl()->hasOneRef()); >+ EXPECT_TRUE(copy.impl()->hasOneRef()); >+ EXPECT_FALSE(original.impl() == copy.impl()); >+} >+ >+TEST(WTF_CrossThreadCopier, NotCopyString) >+{ >+ String original { "1234" }; >+ auto copy = crossThreadCopy(WTFMove(original)); >+ EXPECT_TRUE(copy.impl()->hasOneRef()); >+ // moved-out RefPtr becomes nullptr >+ EXPECT_EQ(nullptr, original.impl()); >+} >+ >+TEST(WTF_CrossThreadCopier, CopyOptionalString) >+{ >+ Optional<String> original { "1234" }; >+ auto copy = crossThreadCopy(original); >+ EXPECT_TRUE(original->impl()->hasOneRef()); >+ EXPECT_TRUE(copy->impl()->hasOneRef()); >+ EXPECT_FALSE(original->impl() == copy->impl()); >+} >+ >+TEST(WTF_CrossThreadCopier, NotCopyOptionalString) >+{ >+ Optional<String> original { "1234" }; >+ auto copy = crossThreadCopy(WTFMove(original)); >+ EXPECT_TRUE(copy->impl()->hasOneRef()); >+ // moved-out RefPtr becomes nullptr >+ EXPECT_EQ(nullptr, original->impl()); >+} >+ >+ >+ >+} // namespace TestWebKitAPI
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198957
:
372330
|
372332
|
372422