Use LazyNeverDestroyed instead of DEFINE_GLOBAL for QualifiedName
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Aug 2017 16:46:59 +0000 (16:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Aug 2017 16:46:59 +0000 (16:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175010
<rdar://problem/33647818>

Patch by Fujii Hironori <Hironori.Fujii@sony.com> on 2017-08-02
Reviewed by Alex Christensen.

Source/WebCore:

No new tests because no behavior change.

Stop using DEFINE_GLOBAL hack in favor of LazyNeverDestroyed.

* contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::isValidCSSSelector):
Call QualifiedName::init().
* dom/DOMAllInOne.cpp: Remove the warning. Include QualifiedName.cpp.
* dom/QualifiedName.cpp:
(WebCore::QualifiedName::init): Call LazyNeverDestroyed::construct
instead of placement new.
* dom/QualifiedName.h: Use LazyNeverDestroyed.

Source/WebKit:

* UIProcess/API/APIContentRuleListStore.cpp:
(API::ContentRuleListStore::compileContentRuleList):
Call QualifiedName::init().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220131 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/contentextensions/ContentExtensionParser.cpp
Source/WebCore/dom/DOMAllInOne.cpp
Source/WebCore/dom/QualifiedName.cpp
Source/WebCore/dom/QualifiedName.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp

index 3a90565161ee27c300336d768ed95d4716ee4302..026a2f976eb7e934f1b4f700c7cc1a66e5e56870 100644 (file)
@@ -1,3 +1,24 @@
+2017-08-02  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        Use LazyNeverDestroyed instead of DEFINE_GLOBAL for QualifiedName
+        https://bugs.webkit.org/show_bug.cgi?id=175010
+        <rdar://problem/33647818>
+
+        Reviewed by Alex Christensen.
+
+        No new tests because no behavior change.
+
+        Stop using DEFINE_GLOBAL hack in favor of LazyNeverDestroyed.
+
+        * contentextensions/ContentExtensionParser.cpp:
+        (WebCore::ContentExtensions::isValidCSSSelector):
+        Call QualifiedName::init().
+        * dom/DOMAllInOne.cpp: Remove the warning. Include QualifiedName.cpp.
+        * dom/QualifiedName.cpp:
+        (WebCore::QualifiedName::init): Call LazyNeverDestroyed::construct
+        instead of placement new.
+        * dom/QualifiedName.h: Use LazyNeverDestroyed.
+
 2017-08-01  Joseph Pecoraro  <pecoraro@apple.com>
 
         CFString leak dragging an image - allocation under PlatformPasteboard::writeObjectRepresentations
index c2d2c58d09fd18de514f0ae229e499ed02181802..7dde5a08742e569b2ba17984f82846abbb2e57d6 100644 (file)
@@ -234,6 +234,7 @@ static Expected<Trigger, std::error_code> loadTrigger(ExecState& exec, const JSO
 bool isValidCSSSelector(const String& selector)
 {
     AtomicString::init();
+    QualifiedName::init();
     CSSParserContext context(HTMLQuirksMode);
     CSSParser parser(context);
     CSSSelectorList selectorList;
index 8d13fedfbd9dd60321af694cc85526ef897dfaf6..01f3c2b5b1cdd956f85a145a7f597de1ba6f0e2f 100644 (file)
 #include "ProcessingInstruction.cpp"
 #include "ProgressEvent.cpp"
 #include "PseudoElement.cpp"
-// Build error if adding QualifiedName.cpp to DOMAllInOne.cpp
-// https://bugs.webkit.org/show_bug.cgi?id=146586
-// #include "QualifiedName.cpp"
+#include "QualifiedName.cpp"
 #include "RadioButtonGroups.cpp"
 #include "Range.cpp"
 #include "RejectedPromiseTracker.cpp"
index 946763414c2c2c331c5eaaf67511f98b822e67e0..2c463036269cbd8335756cadd8807da1f6b9cf5d 100644 (file)
  */
 
 #include "config.h"
-
-#ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC
-#define WEBCORE_QUALIFIEDNAME_HIDE_GLOBALS 1
-#else
-#define QNAME_DEFAULT_CONSTRUCTOR
-#endif
-
 #include "QualifiedName.h"
+
 #include "QualifiedNameCache.h"
 #include "ThreadGlobalData.h"
 #include <wtf/Assertions.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/StaticConstructors.h>
 
 namespace WebCore {
 
@@ -45,7 +37,7 @@ QualifiedName::QualifiedNameImpl::~QualifiedNameImpl()
 }
 
 // Global init routines
-DEFINE_GLOBAL(QualifiedName, anyName, nullAtom(), starAtom(), starAtom())
+LazyNeverDestroyed<const QualifiedName> anyName;
 
 void QualifiedName::init()
 {
@@ -53,9 +45,8 @@ void QualifiedName::init()
     if (initialized)
         return;
 
-    // Use placement new to initialize the globals.
     AtomicString::init();
-    new (NotNull, (void*)&anyName) QualifiedName(nullAtom(), starAtom(), starAtom());
+    anyName.construct(nullAtom(), starAtom(), starAtom());
     initialized = true;
 }
 
index 2f38c19845180ca16e4d17f484ed44433b9992ed..48c12fbfe3e2343e4a013ae74c5f0afe01145351 100644 (file)
@@ -21,6 +21,7 @@
 #pragma once
 
 #include <wtf/HashTraits.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/text/AtomicString.h>
 
 namespace WebCore {
@@ -96,7 +97,7 @@ public:
 #endif
     
     // Init routine for globals
-    static void init();
+    WEBCORE_EXPORT static void init();
 
 private:
     static QualifiedNameImpl* hashTableDeletedValue() { return RefPtr<QualifiedNameImpl>::hashTableDeletedValue(); }
@@ -104,10 +105,8 @@ private:
     RefPtr<QualifiedNameImpl> m_impl;
 };
 
-#ifndef WEBCORE_QUALIFIEDNAME_HIDE_GLOBALS
-extern const QualifiedName anyName;
+extern LazyNeverDestroyed<const QualifiedName> anyName;
 inline const QualifiedName& anyQName() { return anyName; }
-#endif
 
 const QualifiedName& nullQName();
 
index 48276978b1f67a9edc0d7e1b52b0e8207b409f5c..bc81815902bfafec835c8ae3e3fe110fc6a325b0 100644 (file)
@@ -1,3 +1,15 @@
+2017-08-02  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        Use LazyNeverDestroyed instead of DEFINE_GLOBAL for QualifiedName
+        https://bugs.webkit.org/show_bug.cgi?id=175010
+        <rdar://problem/33647818>
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/APIContentRuleListStore.cpp:
+        (API::ContentRuleListStore::compileContentRuleList):
+        Call QualifiedName::init().
+
 2017-08-01  Chris Dumez  <cdumez@apple.com>
 
         Add initial support for navigator.sendBeacon
index a67aa2335ae1bdca7062a15e5dedba3a025d6798..69cca9e45bee4f4ac5f58f98d933acb8c4ba20c4 100644 (file)
@@ -35,6 +35,7 @@
 #include "WebCompiledContentRuleList.h"
 #include <WebCore/ContentExtensionCompiler.h>
 #include <WebCore/ContentExtensionError.h>
+#include <WebCore/QualifiedName.h>
 #include <string>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RunLoop.h>
@@ -427,6 +428,7 @@ void ContentRuleListStore::getAvailableContentRuleListIdentifiers(Function<void(
 void ContentRuleListStore::compileContentRuleList(const WTF::String& identifier, WTF::String&& json, Function<void(RefPtr<API::ContentRuleList>, std::error_code)> completionHandler)
 {
     AtomicString::init();
+    WebCore::QualifiedName::init();
     m_compileQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), legacyFilename = m_legacyFilename, json = json.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable {
         auto path = constructedPath(storePath, identifier, legacyFilename);