Use LazyNeverDestroyed instead of DEFINE_GLOBAL
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Nov 2017 13:31:36 +0000 (13:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Nov 2017 13:31:36 +0000 (13:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174979

Patch by Fujii Hironori <Hironori.Fujii@sony.com> on 2017-11-01
Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

* config.h: Removed definitions of SKIP_STATIC_CONSTRUCTORS_ON_MSVC and SKIP_STATIC_CONSTRUCTORS_ON_GCC.

Source/WebCore:

No new tests since there should be no behavioral change.

* DerivedSources.cpp: Remove the warning of StaticConstructors.h.
* WebCore.order: Removed
* config.h: Removed definitions of SKIP_STATIC_CONSTRUCTORS_ON_MSVC and SKIP_STATIC_CONSTRUCTORS_ON_GCC.
* dom/QualifiedName.cpp:
(WebCore::createQualifiedName): Deleted.
* dom/QualifiedName.h: Removed createQualifiedName.
* dom/make_names.pl:
(printCppHead): Do not include StaticConstructors.h.

Source/WTF:

DEFINE_GLOBAL is not used anymore. Remove it.

* WTF.xcodeproj/project.pbxproj: Removed StaticConstructors.h
* config.h: Removed definitions of SKIP_STATIC_CONSTRUCTORS_ON_MSVC and SKIP_STATIC_CONSTRUCTORS_ON_GCC.
* wtf/CMakeLists.txt: Removed StaticConstructors.h
* wtf/StaticConstructors.h: Removed.

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

14 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/config.h
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/config.h
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/StaticConstructors.h [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/WebCore.order
Source/WebCore/config.h
Source/WebCore/dom/QualifiedName.cpp
Source/WebCore/dom/QualifiedName.h
Source/WebCore/dom/make_names.pl

index 14ec6fb..e79e8a0 100644 (file)
@@ -1,3 +1,12 @@
+2017-11-01  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        Use LazyNeverDestroyed instead of DEFINE_GLOBAL
+        https://bugs.webkit.org/show_bug.cgi?id=174979
+
+        Reviewed by Yusuke Suzuki.
+
+        * config.h: Removed definitions of SKIP_STATIC_CONSTRUCTORS_ON_MSVC and SKIP_STATIC_CONSTRUCTORS_ON_GCC.
+
 2017-10-27  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [DFG][FTL] Introduce StringSlice
index 1bd9d09..1d1ed7b 100644 (file)
@@ -32,9 +32,3 @@
 #endif
 
 #include <wtf/DisallowCType.h>
-
-#if COMPILER(MSVC)
-#define SKIP_STATIC_CONSTRUCTORS_ON_MSVC 1
-#else
-#define SKIP_STATIC_CONSTRUCTORS_ON_GCC 1
-#endif
index f525f21..9cafad3 100644 (file)
@@ -1,3 +1,17 @@
+2017-11-01  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        Use LazyNeverDestroyed instead of DEFINE_GLOBAL
+        https://bugs.webkit.org/show_bug.cgi?id=174979
+
+        Reviewed by Yusuke Suzuki.
+
+        DEFINE_GLOBAL is not used anymore. Remove it.
+
+        * WTF.xcodeproj/project.pbxproj: Removed StaticConstructors.h
+        * config.h: Removed definitions of SKIP_STATIC_CONSTRUCTORS_ON_MSVC and SKIP_STATIC_CONSTRUCTORS_ON_GCC.
+        * wtf/CMakeLists.txt: Removed StaticConstructors.h
+        * wtf/StaticConstructors.h: Removed.
+
 2017-10-30  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [WPE] Fix build warnings
index 287815d..997ec31 100644 (file)
                A8A4730D151A825B004123FF /* Spectrum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Spectrum.h; sourceTree = "<group>"; };
                A8A4730E151A825B004123FF /* StackBounds.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackBounds.cpp; sourceTree = "<group>"; };
                A8A4730F151A825B004123FF /* StackBounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackBounds.h; sourceTree = "<group>"; };
-               A8A47310151A825B004123FF /* StaticConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticConstructors.h; sourceTree = "<group>"; };
                A8A47311151A825B004123FF /* StdLibExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdLibExtras.h; sourceTree = "<group>"; };
                A8A47313151A825B004123FF /* StringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringExtras.h; sourceTree = "<group>"; };
                A8A47314151A825B004123FF /* Hasher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hasher.h; sourceTree = "<group>"; };
                                FEDACD3C1630F83F00C69634 /* StackStats.h */,
                                313EDEC9778E49C9BEA91CFC /* StackTrace.cpp */,
                                EF7D6CD59D8642A8A0DA86AD /* StackTrace.h */,
-                               A8A47310151A825B004123FF /* StaticConstructors.h */,
                                A8A47311151A825B004123FF /* StdLibExtras.h */,
                                C4F8A93619C65EB400B2B15D /* Stopwatch.h */,
                                1A6BB768162F300500DD16DB /* StreamBuffer.h */,
index ddc4f10..511658a 100644 (file)
@@ -32,9 +32,3 @@
 #endif
 
 #include <wtf/DisallowCType.h>
-
-#if COMPILER(MSVC)
-#define SKIP_STATIC_CONSTRUCTORS_ON_MSVC 1
-#else
-#define SKIP_STATIC_CONSTRUCTORS_ON_GCC 1
-#endif
index a8b8624..4c52548 100644 (file)
@@ -132,7 +132,6 @@ set(WTF_HEADERS
     StackBounds.h
     StackStats.h
     StackTrace.h
-    StaticConstructors.h
     StdLibExtras.h
     Stopwatch.h
     StringExtras.h
diff --git a/Source/WTF/wtf/StaticConstructors.h b/Source/WTF/wtf/StaticConstructors.h
deleted file mode 100644 (file)
index d559af7..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef StaticConstructors_h
-#define StaticConstructors_h
-
-// We need to avoid having static constructors. We achieve this
-// with two separate methods for GCC and MSVC. Both methods prevent the static
-// initializers from being registered and called on program startup. On GCC, we
-// declare the global objects with a different type that can be POD default
-// initialized by the linker/loader. On MSVC we use a special compiler feature
-// to have the CRT ignore our static initializers. The constructors will never
-// be called and the objects will be left uninitialized.
-//
-// With both of these approaches, we must define and explicitly call an init
-// routine that uses placement new to create the objects and overwrite the
-// uninitialized placeholders.
-//
-// This is not completely portable, but is what we have for now without
-// changing how a lot of code accesses these global objects.
-
-#ifdef SKIP_STATIC_CONSTRUCTORS_ON_MSVC
-// - Assume that all includes of this header want ALL of their static
-//   initializers ignored. This is currently the case. This means that if
-//   a .cc includes this header (or it somehow gets included), all static
-//   initializers after the include will not be executed.
-// - We do this with a pragma, so that all of the static initializer pointers
-//   go into our own section, and the CRT won't call them. Eventually it would
-//   be nice if the section was discarded, because we don't want the pointers.
-//   See: http://msdn.microsoft.com/en-us/library/7977wcck(VS.80).aspx
-#pragma warning(disable:4075)
-#pragma init_seg(".unwantedstaticinits")
-#endif
-
-#ifndef SKIP_STATIC_CONSTRUCTORS_ON_GCC
-    // Define an global in the normal way.
-#define DEFINE_GLOBAL(type, name, ...) \
-    const type name;
-
-#else
-// Define an correctly-sized array of pointers to avoid static initialization.
-// Use an array of pointers instead of an array of char in case there is some alignment issue.
-#define DEFINE_GLOBAL(type, name, ...) \
-    void * name[(sizeof(type) + sizeof(void *) - 1) / sizeof(void *)];
-#endif
-
-#endif // StaticConstructors_h
index 981dfaa..17a897c 100644 (file)
@@ -1,3 +1,21 @@
+2017-11-01  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        Use LazyNeverDestroyed instead of DEFINE_GLOBAL
+        https://bugs.webkit.org/show_bug.cgi?id=174979
+
+        Reviewed by Yusuke Suzuki.
+
+        No new tests since there should be no behavioral change.
+
+        * DerivedSources.cpp: Remove the warning of StaticConstructors.h.
+        * WebCore.order: Removed
+        * config.h: Removed definitions of SKIP_STATIC_CONSTRUCTORS_ON_MSVC and SKIP_STATIC_CONSTRUCTORS_ON_GCC.
+        * dom/QualifiedName.cpp:
+        (WebCore::createQualifiedName): Deleted.
+        * dom/QualifiedName.h: Removed createQualifiedName.
+        * dom/make_names.pl:
+        (printCppHead): Do not include StaticConstructors.h.
+
 2017-11-01  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Always include TextureMapper.cmake
index 52a61fb..e2ab09b 100644 (file)
 #include "JSXPathNSResolver.cpp"
 #include "JSXPathResult.cpp"
 #include "JSXSLTProcessor.cpp"
-
-// On MSVC, including StaticConstructors.h causes all global objects not to be
-// automatically initialized by the C runtime. This is useful in some specific
-// cases (e.g., the *Names.cpp files), but can be dangerous in others. We don't
-// want StaticConstructors.h to "pollute" all the source files we #include here
-// accidentally, so we'll throw an error whenever any file includes it.
-#ifdef StaticConstructors_h
-#error Do not include any file in DerivedSources.cpp that includes StaticConstructors.h
-#endif
index 1ce9651..6322c63 100644 (file)
@@ -885,7 +885,6 @@ __ZN7WebCore20AutoscrollControllerC1Ev
 __ZN7WebCore19AnimationControllerC1EPNS_5FrameE
 __ZNK7WebCore9FrameTree6parentEv
 __ZN7WebCore9HTMLNames4initEv
-__ZN7WebCore19createQualifiedNameEPvPN3WTF10StringImplERKNS1_12AtomicStringE
 __ZN3WTF9HashTableIPN7WebCore13QualifiedName17QualifiedNameImplES4_NS_17IdentityExtractorENS1_17QualifiedNameHashENS1_23QualifiedNameHashTraitsES7_E16lookupForWritingINS_22IdentityHashTranslatorIS6_EES4_EENSt3__14pairIPS4_bEERKT0_
 __ZN3WTF9HashTableIPN7WebCore13QualifiedName17QualifiedNameImplES4_NS_17IdentityExtractorENS1_17QualifiedNameHashENS1_23QualifiedNameHashTraitsES7_E18addPassingHashCodeINS_24HashSetTranslatorAdapterINS1_25QNameComponentsTranslatorEEENS1_23QualifiedNameComponentsESD_EENS_18HashTableAddResultINS_17HashTableIteratorIS4_S4_S5_S6_S7_S7_EEEERKT0_RKT1_
 __ZN3WTF9HashTableIPN7WebCore13QualifiedName17QualifiedNameImplES4_NS_17IdentityExtractorENS1_17QualifiedNameHashENS1_23QualifiedNameHashTraitsES7_E20fullLookupForWritingINS_24HashSetTranslatorAdapterINS1_25QNameComponentsTranslatorEEENS1_23QualifiedNameComponentsEEENSt3__14pairINSF_IPS4_bEEjEERKT0_
@@ -893,7 +892,6 @@ __ZN3WTF9HashTableIPN7WebCore13QualifiedName17QualifiedNameImplES4_NS_17Identity
 __ZN3WTF9HashTableIPN7WebCore13QualifiedName17QualifiedNameImplES4_NS_17IdentityExtractorENS1_17QualifiedNameHashENS1_23QualifiedNameHashTraitsES7_E6rehashEi
 __ZN3WTF12StringHasher10hashMemoryILm24EEEjPKv
 __ZN7WebCore25QNameComponentsTranslator9translateERPNS_13QualifiedName17QualifiedNameImplERKNS_23QualifiedNameComponentsEj
-__ZN7WebCore19createQualifiedNameEPvPN3WTF10StringImplE
 __ZN7WebCore13QualifiedName4initEv
 __ZN7WebCore17MediaFeatureNames4initEv
 __ZN7WebCore8SVGNames4initEv
index d3dee99..ed25055 100644 (file)
 
 #include <wtf/DisallowCType.h>
 
-#if COMPILER(MSVC)
-#define SKIP_STATIC_CONSTRUCTORS_ON_MSVC 1
-#else
-#define SKIP_STATIC_CONSTRUCTORS_ON_GCC 1
-#endif
-
 #if PLATFORM(WIN)
 #if PLATFORM(WIN_CAIRO)
 #undef USE_CG
index 07cd76c..986292f 100644 (file)
@@ -69,14 +69,4 @@ unsigned QualifiedName::QualifiedNameImpl::computeHash() const
     return hashComponents(components);
 }
 
-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, const StaticStringImpl* name)
-{
-    new (NotNull, reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom(), AtomicString(name), nullAtom());
-}
-
 }
index 6228cac..8b762e5 100644 (file)
@@ -136,9 +136,6 @@ struct QualifiedNameHash {
     static const bool safeToCompareToEmptyOrDeleted = false;
 };
 
-void createQualifiedName(void* targetAddress, const StaticStringImpl* name);
-void createQualifiedName(void* targetAddress, const StaticStringImpl* name, const AtomicString& nameNamespace);
-
 inline String QualifiedName::toString() const
 {
     if (!hasPrefix())
index 4bf4c0f..43e282b 100755 (executable)
@@ -136,9 +136,6 @@ END
     print F StaticString::GenerateStringAsserts(\%parameters);
 
     for my $name (sort keys %parameters) {
-        # 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 "    ${name}.construct(&${name}Data);\n";
     }
 
@@ -572,7 +569,6 @@ sub printCppHead
     print F "#endif\n\n";
 
     print F "#include \"${namespace}Names.h\"\n\n";
-    print F "#include <wtf/StaticConstructors.h>\n";
 
     print F "namespace WebCore {\n\n";
     print F "namespace ${namespace}Names {\n\n";