Title: [276699] releases/WebKitGTK/webkit-2.32/Source/_javascript_Core
Revision
276699
Author
[email protected]
Date
2021-04-28 02:32:22 -0700 (Wed, 28 Apr 2021)

Log Message

Merge r275856 - ICU 69 deprecates ubrk_safeClone in favor of ubrk_clone
https://bugs.webkit.org/show_bug.cgi?id=224093

Reviewed by Yusuke Suzuki.

In a shining example of "disappointing library practices", ICU 69 deprecates ubrk_safeClone in favor of
a new *draft* API ubrk_clone, meaning that no function with this functionality is exposed by default.

This patch introduces a function cloneUBreakIterator to abstract over this change; however, since we need to:

  1. confine the effects of disabling U_HIDE_DRAFT_API to a non-unified implementation file
  2. still be able to include ubrk.h from IntlSegmenter.h to instantiate ICUDeleter<ubrk_close> (*not* `clone`!)

...the new helper function is introduced in a *headerless* implementation file, IntlWorkaround.cpp.

* _javascript_Core.xcodeproj/project.pbxproj:
* Sources.txt:
* runtime/IntlSegmenter.cpp:
(JSC::IntlSegmenter::segment const):
* runtime/IntlSegmenter.h:
* runtime/IntlSegments.cpp:
(JSC::IntlSegments::createSegmentIterator):
* runtime/IntlWorkaround.cpp: Added.
(JSC::cloneUBreakIterator):

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ChangeLog (276698 => 276699)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ChangeLog	2021-04-28 08:51:37 UTC (rev 276698)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ChangeLog	2021-04-28 09:32:22 UTC (rev 276699)
@@ -1,3 +1,30 @@
+2021-04-12  Ross Kirsling  <[email protected]>
+
+        ICU 69 deprecates ubrk_safeClone in favor of ubrk_clone
+        https://bugs.webkit.org/show_bug.cgi?id=224093
+
+        Reviewed by Yusuke Suzuki.
+
+        In a shining example of "disappointing library practices", ICU 69 deprecates ubrk_safeClone in favor of
+        a new *draft* API ubrk_clone, meaning that no function with this functionality is exposed by default.
+
+        This patch introduces a function cloneUBreakIterator to abstract over this change; however, since we need to:
+
+          1. confine the effects of disabling U_HIDE_DRAFT_API to a non-unified implementation file
+          2. still be able to include ubrk.h from IntlSegmenter.h to instantiate ICUDeleter<ubrk_close> (*not* `clone`!)
+
+        ...the new helper function is introduced in a *headerless* implementation file, IntlWorkaround.cpp.
+
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * Sources.txt:
+        * runtime/IntlSegmenter.cpp:
+        (JSC::IntlSegmenter::segment const):
+        * runtime/IntlSegmenter.h:
+        * runtime/IntlSegments.cpp:
+        (JSC::IntlSegments::createSegmentIterator):
+        * runtime/IntlWorkaround.cpp: Added.
+        (JSC::cloneUBreakIterator):
+
 2021-03-25  Carlos Garcia Campos  <[email protected]>
 
         [GTK][WPE] JSC crashes if a function expects a parameter but doesn't receive any

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (276698 => 276699)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2021-04-28 08:51:37 UTC (rev 276698)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2021-04-28 09:32:22 UTC (rev 276699)
@@ -1402,6 +1402,7 @@
 		A1D792FF1B43864B004516F5 /* IntlNumberFormatConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = A1D792F91B43864B004516F5 /* IntlNumberFormatConstructor.h */; };
 		A1D793011B43864B004516F5 /* IntlNumberFormatPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = A1D792FB1B43864B004516F5 /* IntlNumberFormatPrototype.h */; };
 		A38D250E25800D440042BFDD /* JSArrayBufferPrototypeInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = A38D250D25800D430042BFDD /* JSArrayBufferPrototypeInlines.h */; };
+		A3EE8543262514B000FC9B8D /* IntlWorkaround.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A37619402625127C00CBCBA9 /* IntlWorkaround.cpp */; };
 		A3FF9BC72234749100B1A9AB /* YarrFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = A3FF9BC52234746600B1A9AB /* YarrFlags.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A503FA1A188E0FB000110F14 /* _javascript_CallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = A503FA14188E0FAF00110F14 /* _javascript_CallFrame.h */; };
 		A503FA1E188E0FB000110F14 /* JSJavaScriptCallFramePrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = A503FA18188E0FB000110F14 /* JSJavaScriptCallFramePrototype.h */; };
@@ -4414,6 +4415,7 @@
 		A1E0451B1C25B4B100BB663C /* StringPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = StringPrototype.js; sourceTree = "<group>"; };
 		A1FE1EB01C2C537E00A289FF /* DatePrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = DatePrototype.js; sourceTree = "<group>"; };
 		A27958D7FA1142B0AC9E364D /* WasmContextInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmContextInlines.h; sourceTree = "<group>"; };
+		A37619402625127C00CBCBA9 /* IntlWorkaround.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntlWorkaround.cpp; sourceTree = "<group>"; };
 		A38D250D25800D430042BFDD /* JSArrayBufferPrototypeInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferPrototypeInlines.h; sourceTree = "<group>"; };
 		A3AFF92B245A3CF900C9BA3B /* IntlLocale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlLocale.h; sourceTree = "<group>"; };
 		A3AFF92C245A3CFA00C9BA3B /* IntlLocaleConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlLocaleConstructor.h; sourceTree = "<group>"; };
@@ -7277,6 +7279,7 @@
 				BCD203480E17135E002C7E82 /* DatePrototype.h */,
 				534638761E71E06E00F12AC1 /* DeferredWorkTimer.cpp */,
 				534638741E70DDEC00F12AC1 /* DeferredWorkTimer.h */,
+				FE9F3FC626163CA90069E89F /* DeferTermination.h */,
 				169948EDE68D4054B01EF797 /* DefinePropertyAttributes.h */,
 				734B655423F4A33100A069D1 /* DeletePropertySlot.h */,
 				0FE0500F1AA9091100D33B33 /* DirectArguments.cpp */,
@@ -7462,6 +7465,7 @@
 				E3F2193324C7882A003AE453 /* IntlSegments.h */,
 				E3F2193224C7882A003AE453 /* IntlSegmentsPrototype.cpp */,
 				E3F2193624C7882B003AE453 /* IntlSegmentsPrototype.h */,
+				A37619402625127C00CBCBA9 /* IntlWorkaround.cpp */,
 				0F275F2C1ECE079600620D47 /* Intrinsic.cpp */,
 				86BF642A148DB2B5004DE36A /* Intrinsic.h */,
 				8B9F6D551D5912FA001C739F /* IterationKind.h */,
@@ -9478,6 +9482,7 @@
 				0FC712DF17CD877C008CC93C /* DeferredCompilationCallback.h in Headers */,
 				FE5068651AE246390009DAB7 /* DeferredSourceDump.h in Headers */,
 				534638751E70DDEC00F12AC1 /* DeferredWorkTimer.h in Headers */,
+				FE9F3FC826163CA90069E89F /* DeferTermination.h in Headers */,
 				473DA4A4764C45FE871B0485 /* DefinePropertyAttributes.h in Headers */,
 				0FBB73BB1DEF8645002C009E /* DeleteAllCodeEffort.h in Headers */,
 				7311FA32240DB1D3003D48DB /* DeleteByIdVariant.h in Headers */,
@@ -10437,6 +10442,7 @@
 				A5BA15EA182340B400A82E69 /* RemoteInspectorConstants.h in Headers */,
 				992F56B71E4E84B20035953B /* RemoteInspectorXPCConnection.h in Headers */,
 				0F24E55117EE274900ABB217 /* Repatch.h in Headers */,
+				FE9F3FB92613C7890069E89F /* ResourceExhaustion.h in Headers */,
 				869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */,
 				FE3B642F25D6FB4D001ADDB4 /* RootMarkReason.h in Headers */,
 				0F2C63AA1E4FA42E00C13839 /* RunningScope.h in Headers */,
@@ -10663,8 +10669,11 @@
 				0F919D2615853CE3004A4E7D /* Watchpoint.h in Headers */,
 				142E313C134FF0A600AFADB5 /* Weak.h in Headers */,
 				14E84F9F14EE1ACC00D6D5D4 /* WeakBlock.h in Headers */,
+				BCE2FAFF26091782000A510F /* WeakGCHashTable.h in Headers */,
 				14BFCE6910CDB1FC00364CCE /* WeakGCMap.h in Headers */,
 				AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */,
+				BCE2FAFB260916EF000A510F /* WeakGCSet.h in Headers */,
+				BCE2FAFD260916FF000A510F /* WeakGCSetInlines.h in Headers */,
 				14F7256614EE265E00B1652B /* WeakHandleOwner.h in Headers */,
 				14E84FA214EE1ACC00D6D5D4 /* WeakImpl.h in Headers */,
 				14BE7D3317135CF400D1807A /* WeakInlines.h in Headers */,
@@ -11539,6 +11548,7 @@
 				5C4196622270E0000047B7CD /* InspectorBackendDispatcherCompatibility.cpp in Sources */,
 				E399AEC32559457F00B78485 /* IntlDateTimeFormat.cpp in Sources */,
 				E366441E254409B30001876F /* IntlListFormat.cpp in Sources */,
+				A3EE8543262514B000FC9B8D /* IntlWorkaround.cpp in Sources */,
 				E38E8790254B978400F6F9E4 /* JSDateMath.cpp in Sources */,
 				536B319E1F735F160037FC33 /* LowLevelInterpreter.cpp in Sources */,
 				DFBC2CA625E6D5B90081BDD1 /* SymbolStubsForSafariCompatibility.mm in Sources */,

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/Sources.txt (276698 => 276699)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/Sources.txt	2021-04-28 08:51:37 UTC (rev 276698)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/Sources.txt	2021-04-28 09:32:22 UTC (rev 276699)
@@ -848,6 +848,7 @@
 runtime/IntlSegmenterPrototype.cpp
 runtime/IntlSegments.cpp
 runtime/IntlSegmentsPrototype.cpp
+runtime/IntlWorkaround.cpp @no-unify // Confine U_HIDE_DRAFT_API's effect to this file.
 runtime/IteratorOperations.cpp
 runtime/IteratorPrototype.cpp
 runtime/JSArray.cpp

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegmenter.cpp (276698 => 276699)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegmenter.cpp	2021-04-28 08:51:37 UTC (rev 276698)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegmenter.cpp	2021-04-28 09:32:22 UTC (rev 276699)
@@ -125,7 +125,7 @@
     auto upconvertedCharacters = Box<Vector<UChar>>::create(string.charactersWithoutNullTermination());
 
     UErrorCode status = U_ZERO_ERROR;
-    auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(ubrk_safeClone(m_segmenter.get(), nullptr, nullptr, &status));
+    auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(cloneUBreakIterator(m_segmenter.get(), &status));
     if (U_FAILURE(status)) {
         throwTypeError(globalObject, scope, "failed to initialize Segments"_s);
         return { };

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegmenter.h (276698 => 276699)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegmenter.h	2021-04-28 08:51:37 UTC (rev 276698)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegmenter.h	2021-04-28 09:32:22 UTC (rev 276699)
@@ -75,4 +75,8 @@
     Granularity m_granularity { Granularity::Grapheme };
 };
 
+// Abstraction to call ubrk_safeClone or ubrk_clone depending on ICU version.
+// This is implemented in IntlWorkaround.cpp in order to confine draft API visibility.
+UBreakIterator* cloneUBreakIterator(const UBreakIterator*, UErrorCode*);
+
 } // namespace JSC

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegments.cpp (276698 => 276699)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegments.cpp	2021-04-28 08:51:37 UTC (rev 276698)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlSegments.cpp	2021-04-28 09:32:22 UTC (rev 276699)
@@ -100,7 +100,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     UErrorCode status = U_ZERO_ERROR;
-    auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(ubrk_safeClone(m_segmenter.get(), nullptr, nullptr, &status));
+    auto segmenter = std::unique_ptr<UBreakIterator, UBreakIteratorDeleter>(cloneUBreakIterator(m_segmenter.get(), &status));
     if (U_FAILURE(status)) {
         throwTypeError(globalObject, scope, "failed to initialize SegmentIterator"_s);
         return nullptr;

Added: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlWorkaround.cpp (0 => 276699)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlWorkaround.cpp	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/IntlWorkaround.cpp	2021-04-28 09:32:22 UTC (rev 276699)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2021 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 <unicode/uvernum.h>
+
+// ICU 69 introduces draft API ubrk_clone and deprecates ubrk_safeClone.
+#if U_ICU_VERSION_MAJOR_NUM >= 69
+#define HAVE_ICU_UBRK_CLONE 1
+#endif
+
+#if defined(U_HIDE_DRAFT_API)
+#undef U_HIDE_DRAFT_API
+#endif
+#include <unicode/ubrk.h>
+
+namespace JSC {
+
+UBreakIterator* cloneUBreakIterator(const UBreakIterator*, UErrorCode*);
+
+UBreakIterator* cloneUBreakIterator(const UBreakIterator* iterator, UErrorCode* status)
+{
+#if HAVE(ICU_UBRK_CLONE)
+    return ubrk_clone(iterator, status);
+#else
+    return ubrk_safeClone(iterator, nullptr, nullptr, status);
+#endif
+}
+
+} // namespace JSC
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to