Title: [226299] trunk/Source
Revision
226299
Author
clo...@igalia.com
Date
2017-12-27 08:46:02 -0800 (Wed, 27 Dec 2017)

Log Message

REGRESSION(r225769): Build error with constexpr std::max // std::min in libdstdc++4
https://bugs.webkit.org/show_bug.cgi?id=181160

Reviewed by Myles C. Maxfield.

Source/_javascript_Core:

Disambiguate usage of min and max (Use the version from stdlib).

* runtime/JSArray.cpp:
(JSC::JSArray::unshiftCountSlowCase):
(JSC::JSArray::setLengthWithArrayStorage):
(JSC::JSArray::shiftCountWithArrayStorage):
(JSC::JSArray::fillArgList):
(JSC::JSArray::copyToArguments):

Source/WebCore:

No new tests, its a build fix.

* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::MediaPlayerPrivateAVFoundationCF::currentMediaTime const): Disambiguate usage of max (Use the version from stdlib).
* platform/graphics/FontSelectionAlgorithm.h:
(WebCore::FontSelectionValue::clampFloat): Use WTF::min and WTF::max for constexpr result.
* platform/graphics/win/UniscribeController.cpp:
(WebCore::UniscribeController::shapeAndPlaceItem): Disambiguate usage of min and max (Use the version from stdlib).

Source/WebKitLegacy/win:

* Plugins/PluginView.cpp:
(WebCore::PluginView::handlePost): Disambiguate usage of min (Use the version from stdlib).

Source/WTF:

In libstdc++-4 std::max and std::min are not annotated with constexpr.
This patch adds a WTF::min and WTF::max for using where a constexpr result is expected.
Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60271

* wtf/StdLibExtras.h:
(WTF::min):
(WTF::max):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (226298 => 226299)


--- trunk/Source/_javascript_Core/ChangeLog	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-12-27 16:46:02 UTC (rev 226299)
@@ -1,3 +1,19 @@
+2017-12-26  Carlos Alberto Lopez Perez  <clo...@igalia.com>
+
+        REGRESSION(r225769): Build error with constexpr std::max // std::min in libdstdc++4
+        https://bugs.webkit.org/show_bug.cgi?id=181160
+
+        Reviewed by Myles C. Maxfield.
+
+        Disambiguate usage of min and max (Use the version from stdlib).
+
+        * runtime/JSArray.cpp:
+        (JSC::JSArray::unshiftCountSlowCase):
+        (JSC::JSArray::setLengthWithArrayStorage):
+        (JSC::JSArray::shiftCountWithArrayStorage):
+        (JSC::JSArray::fillArgList):
+        (JSC::JSArray::copyToArguments):
+
 2017-12-27  Zan Dobersek  <zdober...@igalia.com>
 
         REGRESSION(r225913): about 30 JSC test failures on ARMv7

Modified: trunk/Source/_javascript_Core/runtime/JSArray.cpp (226298 => 226299)


--- trunk/Source/_javascript_Core/runtime/JSArray.cpp	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/_javascript_Core/runtime/JSArray.cpp	2017-12-27 16:46:02 UTC (rev 226299)
@@ -339,7 +339,7 @@
 
     unsigned length = storage->length();
     unsigned oldVectorLength = storage->vectorLength();
-    unsigned usedVectorLength = min(oldVectorLength, length);
+    unsigned usedVectorLength = std::min(oldVectorLength, length);
     ASSERT(usedVectorLength <= MAX_STORAGE_VECTOR_LENGTH);
     // Check that required vector length is possible, in an overflow-safe fashion.
     if (count > MAX_STORAGE_VECTOR_LENGTH - usedVectorLength)
@@ -353,7 +353,7 @@
     // FIXME: This code should be fixed to avoid internal fragmentation. It's not super high
     // priority since increaseVectorLength() will "fix" any mistakes we make, but it would be cool
     // to get this right eventually.
-    unsigned desiredCapacity = min(MAX_STORAGE_VECTOR_LENGTH, max(BASE_ARRAY_STORAGE_VECTOR_LEN, requiredVectorLength) << 1);
+    unsigned desiredCapacity = std::min(MAX_STORAGE_VECTOR_LENGTH, std::max(BASE_ARRAY_STORAGE_VECTOR_LEN, requiredVectorLength) << 1);
 
     // Step 2:
     // We're either going to choose to allocate a new ArrayStorage, or we're going to reuse the existing one.
@@ -388,7 +388,7 @@
         postCapacity = newStorageCapacity - requiredVectorLength;
     else if (length < storage->vectorLength()) {
         // Atomic decay, + the post-capacity cannot be greater than what is available.
-        postCapacity = min((storage->vectorLength() - length) >> 1, newStorageCapacity - requiredVectorLength);
+        postCapacity = std::min((storage->vectorLength() - length) >> 1, newStorageCapacity - requiredVectorLength);
         // If we're moving contents within the same allocation, the post-capacity is being reduced.
         ASSERT(newAllocBase != butterfly->base(structure) || postCapacity < storage->vectorLength() - length);
     }
@@ -444,7 +444,7 @@
         if (newLength < length) {
             // Copy any keys we might be interested in into a vector.
             Vector<unsigned, 0, UnsafeVectorOverflow> keys;
-            keys.reserveInitialCapacity(min(map->size(), static_cast<size_t>(length - newLength)));
+            keys.reserveInitialCapacity(std::min(map->size(), static_cast<size_t>(length - newLength)));
             SparseArrayValueMap::const_iterator end = map->end();
             for (SparseArrayValueMap::const_iterator it = map->begin(); it != end; ++it) {
                 unsigned index = static_cast<unsigned>(it->key);
@@ -479,7 +479,7 @@
 
     if (newLength < length) {
         // Delete properties from the vector.
-        unsigned usedVectorLength = min(length, storage->vectorLength());
+        unsigned usedVectorLength = std::min(length, storage->vectorLength());
         for (unsigned i = newLength; i < usedVectorLength; ++i) {
             WriteBarrier<Unknown>& valueSlot = storage->m_vector[i];
             bool hadValue = !!valueSlot;
@@ -800,7 +800,7 @@
     if (startIndex + count > vectorLength)
         count = vectorLength - startIndex;
     
-    unsigned usedVectorLength = min(vectorLength, oldLength);
+    unsigned usedVectorLength = std::min(vectorLength, oldLength);
     
     unsigned numElementsBeforeShiftRegion = startIndex;
     unsigned firstIndexAfterShiftRegion = startIndex + count;
@@ -1180,7 +1180,7 @@
         ArrayStorage* storage = butterfly->arrayStorage();
         
         vector = storage->m_vector;
-        vectorEnd = min(storage->length(), storage->vectorLength());
+        vectorEnd = std::min(storage->length(), storage->vectorLength());
         break;
     }
         
@@ -1252,7 +1252,7 @@
     case ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES: {
         ArrayStorage* storage = butterfly->arrayStorage();
         vector = storage->m_vector;
-        vectorEnd = min(length, storage->vectorLength());
+        vectorEnd = std::min(length, storage->vectorLength());
         break;
     }
         

Modified: trunk/Source/WTF/ChangeLog (226298 => 226299)


--- trunk/Source/WTF/ChangeLog	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/WTF/ChangeLog	2017-12-27 16:46:02 UTC (rev 226299)
@@ -1,3 +1,18 @@
+2017-12-26  Carlos Alberto Lopez Perez  <clo...@igalia.com>
+
+        REGRESSION(r225769): Build error with constexpr std::max // std::min in libdstdc++4
+        https://bugs.webkit.org/show_bug.cgi?id=181160
+
+        Reviewed by Myles C. Maxfield.
+
+        In libstdc++-4 std::max and std::min are not annotated with constexpr.
+        This patch adds a WTF::min and WTF::max for using where a constexpr result is expected.
+        Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60271
+
+        * wtf/StdLibExtras.h:
+        (WTF::min):
+        (WTF::max):
+
 2017-12-26  Yusuke Suzuki  <utatane....@gmail.com>
 
         [JSC] Remove std::chrono completely

Modified: trunk/Source/WTF/wtf/StdLibExtras.h (226298 => 226299)


--- trunk/Source/WTF/wtf/StdLibExtras.h	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/WTF/wtf/StdLibExtras.h	2017-12-27 16:46:02 UTC (rev 226299)
@@ -27,6 +27,7 @@
 #ifndef WTF_StdLibExtras_h
 #define WTF_StdLibExtras_h
 
+#include <algorithm>
 #include <cstring>
 #include <memory>
 #include <type_traits>
@@ -446,7 +447,8 @@
 }
 
 // libstdc++5 does not have constexpr std::tie. Since we cannot redefine std::tie with constexpr, we define WTF::tie instead.
-// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65978
+// This workaround can be removed after 2019-04 and all users of WTF::tie can be converted to std::tie
+// For more info see: https://bugs.webkit.org/show_bug.cgi?id=180692 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65978
 template <class ...Args>
 inline constexpr std::tuple<Args&...> tie(Args&... values) noexcept
 {
@@ -453,6 +455,22 @@
     return std::tuple<Args&...>(values...);
 }
 
+// libstdc++4 does not have constexpr std::min or std::max.
+// As a workaround this defines WTF::min and WTF::max with constexpr, to be used when a constexpr result is expected.
+// This workaround can be removed after 2018-06 and all users of WTF::min and WTF::max can be converted to std::min and std::max.
+// For more info see: https://bugs.webkit.org/show_bug.cgi?id=181160
+template <class T>
+inline constexpr const T& min(const T& a, const T& b)
+{
+    return std::min(a, b);
+}
+
+template <class T>
+inline constexpr const T& max(const T& a, const T& b)
+{
+    return std::max(a, b);
+}
+
 } // namespace WTF
 
 // This version of placement new omits a 0 check.

Modified: trunk/Source/WebCore/ChangeLog (226298 => 226299)


--- trunk/Source/WebCore/ChangeLog	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/WebCore/ChangeLog	2017-12-27 16:46:02 UTC (rev 226299)
@@ -1,3 +1,19 @@
+2017-12-26  Carlos Alberto Lopez Perez  <clo...@igalia.com>
+
+        REGRESSION(r225769): Build error with constexpr std::max // std::min in libdstdc++4
+        https://bugs.webkit.org/show_bug.cgi?id=181160
+
+        Reviewed by Myles C. Maxfield.
+
+        No new tests, its a build fix.
+
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundationCF::currentMediaTime const): Disambiguate usage of max (Use the version from stdlib).
+        * platform/graphics/FontSelectionAlgorithm.h:
+        (WebCore::FontSelectionValue::clampFloat): Use WTF::min and WTF::max for constexpr result.
+        * platform/graphics/win/UniscribeController.cpp:
+        (WebCore::UniscribeController::shapeAndPlaceItem): Disambiguate usage of min and max (Use the version from stdlib).
+
 2017-12-25  Dan Bernstein  <m...@apple.com>
 
         [macOS] On Retina displays, icon used as drag image for large image is scaled down

Modified: trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h (226298 => 226299)


--- trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h	2017-12-27 16:46:02 UTC (rev 226299)
@@ -102,7 +102,7 @@
 
 constexpr FontSelectionValue FontSelectionValue::clampFloat(float value)
 {
-    return FontSelectionValue { std::max<float>(minimumValue(), std::min<float>(value, maximumValue())) };
+    return FontSelectionValue { WTF::max<float>(minimumValue(), WTF::min<float>(value, maximumValue())) };
 }
 
 constexpr FontSelectionValue::FontSelectionValue(int rawValue, RawTag)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (226298 => 226299)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2017-12-27 16:46:02 UTC (rev 226299)
@@ -609,7 +609,7 @@
 
     CMTime itemTime = AVCFPlayerItemGetCurrentTime(avPlayerItem(m_avfWrapper));
     if (CMTIME_IS_NUMERIC(itemTime))
-        return max(PAL::toMediaTime(itemTime), MediaTime::zeroTime());
+        return std::max(PAL::toMediaTime(itemTime), MediaTime::zeroTime());
 
     return MediaTime::zeroTime();
 }

Modified: trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp (226298 => 226299)


--- trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp	2017-12-27 16:46:02 UTC (rev 226299)
@@ -370,10 +370,10 @@
 
         FloatRect glyphBounds = fontData->boundsForGlyph(glyph);
         glyphBounds.move(m_glyphOrigin.x(), m_glyphOrigin.y());
-        m_minGlyphBoundingBoxX = min(m_minGlyphBoundingBoxX, glyphBounds.x());
-        m_maxGlyphBoundingBoxX = max(m_maxGlyphBoundingBoxX, glyphBounds.maxX());
-        m_minGlyphBoundingBoxY = min(m_minGlyphBoundingBoxY, glyphBounds.y());
-        m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, glyphBounds.maxY());
+        m_minGlyphBoundingBoxX = std::min(m_minGlyphBoundingBoxX, glyphBounds.x());
+        m_maxGlyphBoundingBoxX = std::max(m_maxGlyphBoundingBoxX, glyphBounds.maxX());
+        m_minGlyphBoundingBoxY = std::min(m_minGlyphBoundingBoxY, glyphBounds.y());
+        m_maxGlyphBoundingBoxY = std::max(m_maxGlyphBoundingBoxY, glyphBounds.maxY());
         m_glyphOrigin.move(advance + offsetX, -offsetY);
 
         // Mutate the glyph array to contain our altered advances.

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (226298 => 226299)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2017-12-27 16:46:02 UTC (rev 226299)
@@ -1,3 +1,13 @@
+2017-12-26  Carlos Alberto Lopez Perez  <clo...@igalia.com>
+
+        REGRESSION(r225769): Build error with constexpr std::max // std::min in libdstdc++4
+        https://bugs.webkit.org/show_bug.cgi?id=181160
+
+        Reviewed by Myles C. Maxfield.
+
+        * Plugins/PluginView.cpp:
+        (WebCore::PluginView::handlePost): Disambiguate usage of min (Use the version from stdlib).
+
 2017-12-21  Jeremy Jones  <jere...@apple.com>
 
         Enable picture-in-picture from inline element on suspend.

Modified: trunk/Source/WebKitLegacy/win/Plugins/PluginView.cpp (226298 => 226299)


--- trunk/Source/WebKitLegacy/win/Plugins/PluginView.cpp	2017-12-27 10:52:39 UTC (rev 226298)
+++ trunk/Source/WebKitLegacy/win/Plugins/PluginView.cpp	2017-12-27 16:46:02 UTC (rev 226299)
@@ -90,8 +90,6 @@
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
-using std::min;
-
 using namespace WTF;
 
 namespace WebCore {
@@ -1078,7 +1076,7 @@
                 String contentLength = headerFields.get(HTTPHeaderName::ContentLength);
 
                 if (!contentLength.isNull())
-                    dataLength = min(contentLength.toInt(), (int)dataLength);
+                    dataLength = std::min(contentLength.toInt(), (int)dataLength);
                 headerFields.remove(HTTPHeaderName::ContentLength);
 
                 postData += location;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to