Title: [223314] trunk/Source
Revision
223314
Author
pvol...@apple.com
Date
2017-10-13 17:50:39 -0700 (Fri, 13 Oct 2017)

Log Message

[Win] When built with VS2017, MiniBrowser crashes on startup.
https://bugs.webkit.org/show_bug.cgi?id=175209

Reviewed by Daniel Bates.

Source/WebCore:

Generated StaticStringImpl objects are not initialized compile-time with VS2017.
When compiling with VS2017, the global, static, StaticStringImpl objects needs to
be defined with the constexpr specifier, in order for the objects to be initialized
at compile time. Since the StaticStringImpl objects will be const then, we need to
be able to create an AtomicString object from a const StaticStringImpl object.
This constructor has been added to the AtomicString class.

No new tests, covered by existing tests.

* bindings/scripts/StaticString.pm:
(GenerateStrings):
(GenerateStringAsserts):
* dom/QualifiedName.cpp:
(WebCore::createQualifiedName):
* dom/QualifiedName.h:
* dom/make_names.pl:
(printDefinitions):

Source/WTF:

Add AtomicString(const StaticStringImpl*) constructor. This is needed since
this patch adds constexpr to the static, global StaticStringImpl objects
generated in WebCore/bindings/scripts/StaticString.pm.

* wtf/text/AtomicString.h:
(WTF::AtomicString::AtomicString):
* wtf/text/AtomicStringImpl.cpp:
(WTF::addStatic):
(WTF::AtomicStringImpl::add):
* wtf/text/AtomicStringImpl.h:
* wtf/text/StringImpl.h:
(WTF::StringImpl::assertHashIsCorrect const):
(WTF::StringImpl::assertHashIsCorrect): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (223313 => 223314)


--- trunk/Source/WTF/ChangeLog	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WTF/ChangeLog	2017-10-14 00:50:39 UTC (rev 223314)
@@ -1,3 +1,24 @@
+2017-10-13  Per Arne Vollan  <pvol...@apple.com>
+
+        [Win] When built with VS2017, MiniBrowser crashes on startup.
+        https://bugs.webkit.org/show_bug.cgi?id=175209
+
+        Reviewed by Daniel Bates.
+
+        Add AtomicString(const StaticStringImpl*) constructor. This is needed since
+        this patch adds constexpr to the static, global StaticStringImpl objects
+        generated in WebCore/bindings/scripts/StaticString.pm.
+
+        * wtf/text/AtomicString.h:
+        (WTF::AtomicString::AtomicString):
+        * wtf/text/AtomicStringImpl.cpp:
+        (WTF::addStatic):
+        (WTF::AtomicStringImpl::add):
+        * wtf/text/AtomicStringImpl.h:
+        * wtf/text/StringImpl.h:
+        (WTF::StringImpl::assertHashIsCorrect const):
+        (WTF::StringImpl::assertHashIsCorrect): Deleted.
+
 2017-10-12  Alex Christensen  <achristen...@webkit.org>
 
         Add Expected, HashMap, HashSet, and SHA1 to wtf/Forward.h

Modified: trunk/Source/WTF/wtf/text/AtomicString.h (223313 => 223314)


--- trunk/Source/WTF/wtf/text/AtomicString.h	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WTF/wtf/text/AtomicString.h	2017-10-14 00:50:39 UTC (rev 223314)
@@ -58,6 +58,7 @@
 
     AtomicString(AtomicStringImpl*);
     AtomicString(RefPtr<AtomicStringImpl>&&);
+    AtomicString(const StaticStringImpl*);
     ATOMICSTRING_CONVERSION AtomicString(StringImpl*);
     ATOMICSTRING_CONVERSION AtomicString(const String&);
     AtomicString(StringImpl* baseString, unsigned start, unsigned length);
@@ -268,6 +269,11 @@
 {
 }
 
+inline AtomicString::AtomicString(const StaticStringImpl* imp)
+    : m_string(AtomicStringImpl::add(imp))
+{
+}
+
 inline AtomicString::AtomicString(const String& s)
     : m_string(AtomicStringImpl::add(s.impl()))
 {

Modified: trunk/Source/WTF/wtf/text/AtomicStringImpl.cpp (223313 => 223314)


--- trunk/Source/WTF/wtf/text/AtomicStringImpl.cpp	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WTF/wtf/text/AtomicStringImpl.cpp	2017-10-14 00:50:39 UTC (rev 223314)
@@ -398,7 +398,7 @@
     return addSymbol(locker, stringTable(), base);
 }
 
-static Ref<AtomicStringImpl> addStatic(AtomicStringTableLocker& locker, StringTableImpl& atomicStringTable, StringImpl& base)
+static Ref<AtomicStringImpl> addStatic(AtomicStringTableLocker& locker, StringTableImpl& atomicStringTable, const StringImpl& base)
 {
     ASSERT(base.length());
     ASSERT(base.isStatic());
@@ -411,12 +411,19 @@
     return addToStringTable<UCharBuffer, BufferFromStaticDataTranslator<UChar>>(locker, atomicStringTable, buffer);
 }
 
-static inline Ref<AtomicStringImpl> addStatic(StringImpl& base)
+static inline Ref<AtomicStringImpl> addStatic(const StringImpl& base)
 {
     AtomicStringTableLocker locker;
     return addStatic(locker, stringTable(), base);
 }
 
+RefPtr<AtomicStringImpl> AtomicStringImpl::add(const StaticStringImpl* string)
+{
+    auto s = reinterpret_cast<const StringImpl*>(string);
+    ASSERT(s->isStatic());
+    return addStatic(*s);
+}
+
 Ref<AtomicStringImpl> AtomicStringImpl::addSlowCase(StringImpl& string)
 {
     // This check is necessary for null symbols.

Modified: trunk/Source/WTF/wtf/text/AtomicStringImpl.h (223313 => 223314)


--- trunk/Source/WTF/wtf/text/AtomicStringImpl.h	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WTF/wtf/text/AtomicStringImpl.h	2017-10-14 00:50:39 UTC (rev 223314)
@@ -53,6 +53,7 @@
             return static_cast<AtomicStringImpl*>(string);
         return add(*string);
     }
+    WTF_EXPORT_STRING_API static RefPtr<AtomicStringImpl> add(const StaticStringImpl*);
     WTF_EXPORT_STRING_API static Ref<AtomicStringImpl> addLiteral(const char* characters, unsigned length);
 
     // Returns null if the input data contains an invalid UTF-8 sequence.

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (223313 => 223314)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2017-10-14 00:50:39 UTC (rev 223314)
@@ -876,7 +876,7 @@
 
 public:
 #ifndef NDEBUG
-    void assertHashIsCorrect()
+    void assertHashIsCorrect() const
     {
         ASSERT(hasHash());
         ASSERT(existingHash() == StringHasher::computeHashAndMaskTop8Bits(characters8(), length()));

Modified: trunk/Source/WebCore/ChangeLog (223313 => 223314)


--- trunk/Source/WebCore/ChangeLog	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WebCore/ChangeLog	2017-10-14 00:50:39 UTC (rev 223314)
@@ -1,3 +1,28 @@
+2017-10-13  Per Arne Vollan  <pvol...@apple.com>
+
+        [Win] When built with VS2017, MiniBrowser crashes on startup.
+        https://bugs.webkit.org/show_bug.cgi?id=175209
+
+        Reviewed by Daniel Bates.
+
+        Generated StaticStringImpl objects are not initialized compile-time with VS2017.
+        When compiling with VS2017, the global, static, StaticStringImpl objects needs to
+        be defined with the constexpr specifier, in order for the objects to be initialized
+        at compile time. Since the StaticStringImpl objects will be const then, we need to
+        be able to create an AtomicString object from a const StaticStringImpl object. 
+        This constructor has been added to the AtomicString class.
+
+        No new tests, covered by existing tests. 
+
+        * bindings/scripts/StaticString.pm:
+        (GenerateStrings):
+        (GenerateStringAsserts):
+        * dom/QualifiedName.cpp:
+        (WebCore::createQualifiedName):
+        * dom/QualifiedName.h:
+        * dom/make_names.pl:
+        (printDefinitions):
+
 2017-10-13  Brent Fulgham  <bfulg...@apple.com>
 
         Protect FrameView during style calculations

Modified: trunk/Source/WebCore/bindings/scripts/StaticString.pm (223313 => 223314)


--- trunk/Source/WebCore/bindings/scripts/StaticString.pm	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WebCore/bindings/scripts/StaticString.pm	2017-10-14 00:50:39 UTC (rev 223314)
@@ -43,7 +43,7 @@
 
     for my $name (sort keys %strings) {
         my $value = $strings{$name};
-        push(@result, "static StringImpl::StaticStringImpl ${name}Data(\"${value}\");\n");
+        push(@result, "static constexpr StringImpl::StaticStringImpl ${name}Data(\"${value}\");\n");
     }
 
     push(@result, <<END);
@@ -67,7 +67,7 @@
     push(@result, "#ifndef NDEBUG\n");
 
     for my $name (sort keys %strings) {
-        push(@result, "    reinterpret_cast<StringImpl*>(&${name}Data)->assertHashIsCorrect();\n");
+        push(@result, "    reinterpret_cast<const StringImpl*>(&${name}Data)->assertHashIsCorrect();\n");
     }
 
     push(@result, "#endif // NDEBUG\n");

Modified: trunk/Source/WebCore/dom/QualifiedName.cpp (223313 => 223314)


--- trunk/Source/WebCore/dom/QualifiedName.cpp	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WebCore/dom/QualifiedName.cpp	2017-10-14 00:50:39 UTC (rev 223314)
@@ -69,12 +69,12 @@
     return hashComponents(components);
 }
 
-void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace)
+void createQualifiedName(void* targetAddress, const StaticStringImpl* name, const AtomicString& nameNamespace)
 {
     new (NotNull, reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom(), AtomicString(name), nameNamespace);
 }
 
-void createQualifiedName(void* targetAddress, StringImpl* name)
+void createQualifiedName(void* targetAddress, const StaticStringImpl* name)
 {
     new (NotNull, reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom(), AtomicString(name), nullAtom());
 }

Modified: trunk/Source/WebCore/dom/QualifiedName.h (223313 => 223314)


--- trunk/Source/WebCore/dom/QualifiedName.h	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WebCore/dom/QualifiedName.h	2017-10-14 00:50:39 UTC (rev 223314)
@@ -136,8 +136,8 @@
     static const bool safeToCompareToEmptyOrDeleted = false;
 };
 
-void createQualifiedName(void* targetAddress, StringImpl* name);
-void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace);
+void createQualifiedName(void* targetAddress, const StaticStringImpl* name);
+void createQualifiedName(void* targetAddress, const StaticStringImpl* name, const AtomicString& nameNamespace);
 
 inline String QualifiedName::toString() const
 {

Modified: trunk/Source/WebCore/dom/make_names.pl (223313 => 223314)


--- trunk/Source/WebCore/dom/make_names.pl	2017-10-14 00:44:53 UTC (rev 223313)
+++ trunk/Source/WebCore/dom/make_names.pl	2017-10-14 00:50:39 UTC (rev 223314)
@@ -138,7 +138,7 @@
         # FIXME: Would like to use static_cast here, but there are differences in const
         # depending on whether SKIP_STATIC_CONSTRUCTORS_ON_GCC is used, so stick with a
         # C-style cast for now.
-        print F "    new (NotNull, (void*)&$name) AtomicString(reinterpret_cast<StringImpl*>(&${name}Data));\n";
+        print F "    new (NotNull, (void*)&$name) AtomicString(&${name}Data);\n";
     }
 
     print F "}\n}\n}\n";
@@ -902,7 +902,7 @@
 
     struct ${capitalizedType}TableEntry {
         void* targetAddress;
-        StringImpl& name;
+        const StaticStringImpl& name;
     };
 
     static const ${capitalizedType}TableEntry ${type}Table[] = {
@@ -909,7 +909,7 @@
 END
 ;
     for my $name (sort keys %$namesRef) {
-        print F "        { (void*)&$name$shortCamelType, *reinterpret_cast<StringImpl*>(&${name}Data) },\n";
+        print F "        { (void*)&$name$shortCamelType, *(&${name}Data) },\n";
     }
 
 print F <<END
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to