Title: [210227] trunk/Source
Revision
210227
Author
[email protected]
Date
2017-01-02 13:22:19 -0800 (Mon, 02 Jan 2017)

Log Message

Use StaticStringImpl instead of StaticASCIILiteral
https://bugs.webkit.org/show_bug.cgi?id=166586

Reviewed by Darin Adler.

Source/WebCore:

* bindings/scripts/StaticString.pm:
(GenerateStrings):

Source/WTF:

It is more handy way to define static StringImpl. It calculates the length
and hash value by using the constexpr constructor and function. So we do
not need to calculate these things in Perl script.
And it allows us to use StaticStringImpl in the hand written C++ code.
Previously, we need to calculate the length and hash value by hand if we
would like to use StaticASCIILiteral in the hand written C++ code, and it
meant that we cannot use it at all in the hand written C++ code.

* wtf/text/AtomicStringImpl.cpp:
(WTF::AtomicStringImpl::addSlowCase):
(WTF::AtomicStringImpl::lookUpSlowCase):
* wtf/text/AtomicStringImpl.h:
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (210226 => 210227)


--- trunk/Source/WTF/ChangeLog	2017-01-02 21:16:09 UTC (rev 210226)
+++ trunk/Source/WTF/ChangeLog	2017-01-02 21:22:19 UTC (rev 210227)
@@ -1,3 +1,26 @@
+2017-01-02  Yusuke Suzuki  <[email protected]>
+
+        Use StaticStringImpl instead of StaticASCIILiteral
+        https://bugs.webkit.org/show_bug.cgi?id=166586
+
+        Reviewed by Darin Adler.
+
+        It is more handy way to define static StringImpl. It calculates the length
+        and hash value by using the constexpr constructor and function. So we do
+        not need to calculate these things in Perl script.
+        And it allows us to use StaticStringImpl in the hand written C++ code.
+        Previously, we need to calculate the length and hash value by hand if we
+        would like to use StaticASCIILiteral in the hand written C++ code, and it
+        meant that we cannot use it at all in the hand written C++ code.
+
+        * wtf/text/AtomicStringImpl.cpp:
+        (WTF::AtomicStringImpl::addSlowCase):
+        (WTF::AtomicStringImpl::lookUpSlowCase):
+        * wtf/text/AtomicStringImpl.h:
+        * wtf/text/StringImpl.h:
+        * wtf/text/SymbolImpl.h:
+        * wtf/text/UniquedStringImpl.h:
+
 2017-01-02  Andreas Kling  <[email protected]>
 
         Discard media controls JS/CSS caches under memory pressure.

Modified: trunk/Source/WTF/wtf/text/AtomicStringImpl.cpp (210226 => 210227)


--- trunk/Source/WTF/wtf/text/AtomicStringImpl.cpp	2017-01-02 21:16:09 UTC (rev 210226)
+++ trunk/Source/WTF/wtf/text/AtomicStringImpl.cpp	2017-01-02 21:22:19 UTC (rev 210227)
@@ -405,7 +405,7 @@
     if (!string.length())
         return *static_cast<AtomicStringImpl*>(StringImpl::empty());
 
-    if (string.isSymbol()) {
+    if (string.isSymbol() || string.isStatic()) {
         if (string.is8Bit())
             return *add(string.characters8(), string.length());
         return *add(string.characters16(), string.length());
@@ -429,7 +429,7 @@
     if (!string.length())
         return *static_cast<AtomicStringImpl*>(StringImpl::empty());
 
-    if (string.isSymbol()) {
+    if (string.isSymbol() || string.isStatic()) {
         if (string.is8Bit())
             return *add(string.characters8(), string.length());
         return *add(string.characters16(), string.length());
@@ -466,7 +466,7 @@
     if (!string.length())
         return static_cast<AtomicStringImpl*>(StringImpl::empty());
 
-    if (string.isSymbol()) {
+    if (string.isSymbol() || string.isStatic()) {
         if (string.is8Bit())
             return lookUpInternal(string.characters8(), string.length());
         return lookUpInternal(string.characters16(), string.length());

Modified: trunk/Source/WTF/wtf/text/AtomicStringImpl.h (210226 => 210227)


--- trunk/Source/WTF/wtf/text/AtomicStringImpl.h	2017-01-02 21:16:09 UTC (rev 210226)
+++ trunk/Source/WTF/wtf/text/AtomicStringImpl.h	2017-01-02 21:22:19 UTC (rev 210227)
@@ -111,7 +111,7 @@
 };
 
 #if !ASSERT_DISABLED
-// AtomicStringImpls created from StaticASCIILiteral will ASSERT
+// AtomicStringImpls created from StaticStringImpl will ASSERT
 // in the generic ValueCheck<T>::checkConsistency
 // as they are not allocated by fastMalloc.
 // We don't currently have any way to detect that case

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (210226 => 210227)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2017-01-02 21:16:09 UTC (rev 210226)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2017-01-02 21:22:19 UTC (rev 210227)
@@ -845,21 +845,6 @@
 #endif
 
 public:
-    // FIXME: It should be replaced with StaticStringImpl.
-    // https://bugs.webkit.org/show_bug.cgi?id=165134
-    struct StaticASCIILiteral {
-        // These member variables must match the layout of StringImpl.
-        unsigned m_refCount;
-        unsigned m_length;
-        const LChar* m_data8;
-        unsigned m_hashAndFlags;
-
-        // These values mimic ConstructFromLiteral.
-        static const unsigned s_initialRefCount = s_refCountIncrement;
-        static const unsigned s_initialFlags = s_hashFlag8BitBuffer | StringNormal | BufferInternal;
-        static const unsigned s_hashShift = s_flagCount;
-    };
-
 #ifndef NDEBUG
     void assertHashIsCorrect()
     {
@@ -869,7 +854,7 @@
 #endif
 
 private:
-    // These member variables must match the layout of StaticASCIILiteral and StaticStringImpl.
+    // These member variables must match the layout of StaticStringImpl.
     unsigned m_refCount;
     unsigned m_length;
     union {
@@ -879,11 +864,10 @@
     mutable unsigned m_hashAndFlags;
 };
 
-static_assert(sizeof(StringImpl) == sizeof(StringImpl::StaticASCIILiteral), "");
 static_assert(sizeof(StringImpl) == sizeof(StringImpl::StaticStringImpl), "");
 
 #if !ASSERT_DISABLED
-// StringImpls created from StaticASCIILiteral will ASSERT
+// StringImpls created from StaticStringImpl will ASSERT
 // in the generic ValueCheck<T>::checkConsistency
 // as they are not allocated by fastMalloc.
 // We don't currently have any way to detect that case

Modified: trunk/Source/WTF/wtf/text/SymbolImpl.h (210226 => 210227)


--- trunk/Source/WTF/wtf/text/SymbolImpl.h	2017-01-02 21:16:09 UTC (rev 210226)
+++ trunk/Source/WTF/wtf/text/SymbolImpl.h	2017-01-02 21:22:19 UTC (rev 210227)
@@ -105,7 +105,7 @@
 }
 
 #if !ASSERT_DISABLED
-// SymbolImpls created from StaticASCIILiteral will ASSERT
+// SymbolImpls created from StaticStringImpl will ASSERT
 // in the generic ValueCheck<T>::checkConsistency
 // as they are not allocated by fastMalloc.
 // We don't currently have any way to detect that case

Modified: trunk/Source/WTF/wtf/text/UniquedStringImpl.h (210226 => 210227)


--- trunk/Source/WTF/wtf/text/UniquedStringImpl.h	2017-01-02 21:16:09 UTC (rev 210226)
+++ trunk/Source/WTF/wtf/text/UniquedStringImpl.h	2017-01-02 21:22:19 UTC (rev 210227)
@@ -42,7 +42,7 @@
 };
 
 #if !ASSERT_DISABLED
-// UniquedStringImpls created from StaticASCIILiteral will ASSERT
+// UniquedStringImpls created from StaticStringImpl will ASSERT
 // in the generic ValueCheck<T>::checkConsistency
 // as they are not allocated by fastMalloc.
 // We don't currently have any way to detect that case

Modified: trunk/Source/WebCore/ChangeLog (210226 => 210227)


--- trunk/Source/WebCore/ChangeLog	2017-01-02 21:16:09 UTC (rev 210226)
+++ trunk/Source/WebCore/ChangeLog	2017-01-02 21:22:19 UTC (rev 210227)
@@ -1,3 +1,13 @@
+2017-01-02  Yusuke Suzuki  <[email protected]>
+
+        Use StaticStringImpl instead of StaticASCIILiteral
+        https://bugs.webkit.org/show_bug.cgi?id=166586
+
+        Reviewed by Darin Adler.
+
+        * bindings/scripts/StaticString.pm:
+        (GenerateStrings):
+
 2017-01-02  Andreas Kling  <[email protected]>
 
         Drop the render tree for documents in the page cache.

Modified: trunk/Source/WebCore/bindings/scripts/StaticString.pm (210226 => 210227)


--- trunk/Source/WebCore/bindings/scripts/StaticString.pm	2017-01-02 21:16:09 UTC (rev 210226)
+++ trunk/Source/WebCore/bindings/scripts/StaticString.pm	2017-01-02 21:22:19 UTC (rev 210227)
@@ -33,28 +33,28 @@
 
     my @result = ();
 
-    for my $name (sort keys %strings) {
-        push(@result, "static const LChar ${name}String8[] = \"$strings{$name}\";\n");
-    }
+    push(@result, <<END);
+#if COMPILER(MSVC)
+#pragma warning(push)
+#pragma warning(disable: 4307)
+#endif
+END
 
     push(@result, "\n");
 
     for my $name (sort keys %strings) {
         my $value = $strings{$name};
-        my $length = length($value);
-        my $hash = Hasher::GenerateHashValue($value);
-        push(@result, <<END);
-static StringImpl::StaticASCIILiteral ${name}Data = {
-    StringImpl::StaticASCIILiteral::s_initialRefCount,
-    $length,
-    ${name}String8,
-    StringImpl::StaticASCIILiteral::s_initialFlags | (${hash} << StringImpl::StaticASCIILiteral::s_hashShift)
-};
-END
+        push(@result, "static StringImpl::StaticStringImpl ${name}Data(\"${value}\");\n");
     }
 
     push(@result, "\n");
 
+    push(@result, <<END);
+#if COMPILER(MSVC)
+#pragma warning(pop)
+#endif
+END
+
     return join "", @result;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to