Title: [216512] trunk/Source/WTF
Revision
216512
Author
mark....@apple.com
Date
2017-05-09 10:11:27 -0700 (Tue, 09 May 2017)

Log Message

Force StaticStringImpl constructor to use the constexpr versions of StringImplShape constructors.
https://bugs.webkit.org/show_bug.cgi?id=171861

Reviewed by Yusuke Suzuki.

This is strictly necessary for correctness of the StaticStringImpl implementation.
We force the constructor selection by adding an extra dummy argument to the
constexpr versions of the StringImplShape constructors to disambiguate them from
the non-constexpr versions.

* wtf/text/StringImpl.h:
(WTF::StringImplShape::StringImplShape):
(WTF::StringImpl::StaticStringImpl::StaticStringImpl):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (216511 => 216512)


--- trunk/Source/WTF/ChangeLog	2017-05-09 17:10:58 UTC (rev 216511)
+++ trunk/Source/WTF/ChangeLog	2017-05-09 17:11:27 UTC (rev 216512)
@@ -1,3 +1,19 @@
+2017-05-09  Mark Lam  <mark....@apple.com>
+
+        Force StaticStringImpl constructor to use the constexpr versions of StringImplShape constructors.
+        https://bugs.webkit.org/show_bug.cgi?id=171861
+
+        Reviewed by Yusuke Suzuki.
+
+        This is strictly necessary for correctness of the StaticStringImpl implementation.
+        We force the constructor selection by adding an extra dummy argument to the
+        constexpr versions of the StringImplShape constructors to disambiguate them from
+        the non-constexpr versions.
+
+        * wtf/text/StringImpl.h:
+        (WTF::StringImplShape::StringImplShape):
+        (WTF::StringImpl::StaticStringImpl::StaticStringImpl):
+
 2017-05-09  Zan Dobersek  <zdober...@igalia.com>
 
         Upstream the WPE port

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (216511 => 216512)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2017-05-09 17:10:58 UTC (rev 216511)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2017-05-09 17:11:27 UTC (rev 216512)
@@ -146,8 +146,10 @@
         , m_hashAndFlags(hashAndFlags)
     { }
 
+    enum ConstructWithConstExprTag { ConstructWithConstExpr };
+    
     template<unsigned charactersCount>
-    constexpr StringImplShape(unsigned refCount, unsigned length, const char (&characters)[charactersCount], unsigned hashAndFlags)
+    constexpr StringImplShape(unsigned refCount, unsigned length, const char (&characters)[charactersCount], unsigned hashAndFlags, ConstructWithConstExprTag)
         : m_refCount(refCount)
         , m_length(length)
         , m_data8(reinterpret_cast<const LChar*>(characters))
@@ -155,7 +157,7 @@
     { }
     
     template<unsigned charactersCount>
-    constexpr StringImplShape(unsigned refCount, unsigned length, const char16_t (&characters)[charactersCount], unsigned hashAndFlags)
+    constexpr StringImplShape(unsigned refCount, unsigned length, const char16_t (&characters)[charactersCount], unsigned hashAndFlags, ConstructWithConstExprTag)
         : m_refCount(refCount)
         , m_length(length)
         , m_data16(reinterpret_cast<const UChar*>(characters))
@@ -593,7 +595,7 @@
         template<unsigned charactersCount>
         constexpr StaticStringImpl(const char (&characters)[charactersCount], StringKind stringKind = StringNormal)
             : StringImplShape(s_refCountFlagIsStaticString, charactersCount - 1, characters,
-                s_hashFlag8BitBuffer | s_hashFlagDidReportCost | stringKind | BufferInternal | (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount))
+                s_hashFlag8BitBuffer | s_hashFlagDidReportCost | stringKind | BufferInternal | (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount), ConstructWithConstExpr)
         {
         }
 
@@ -600,7 +602,7 @@
         template<unsigned charactersCount>
         constexpr StaticStringImpl(const char16_t (&characters)[charactersCount], StringKind stringKind = StringNormal)
             : StringImplShape(s_refCountFlagIsStaticString, charactersCount - 1, characters,
-                s_hashFlagDidReportCost | stringKind | BufferInternal | (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount))
+                s_hashFlagDidReportCost | stringKind | BufferInternal | (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount), ConstructWithConstExpr)
         {
         }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to