Title: [242476] releases/WebKitGTK/webkit-2.24/Source
Revision
242476
Author
carlo...@webkit.org
Date
2019-03-05 09:21:23 -0800 (Tue, 05 Mar 2019)

Log Message

Merge r242116 - Code quality cleanup in NeverDestroyed
https://bugs.webkit.org/show_bug.cgi?id=194824

Source/WebCore:

Reviewed by Mark Lam.

name_names.pl should not just assume the layout of LazyNeverDestroyed.

* dom/make_names.pl:
(printNamesCppFile):

Source/WTF:

Reviewed by Yusuke Suzuki.

First, move data members to the end of the class per WebKit
style. Also, add forbid heap allocation since we expect the
NeverDestroyed classes to be static.

* wtf/NeverDestroyed.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/Source/WTF/ChangeLog (242475 => 242476)


--- releases/WebKitGTK/webkit-2.24/Source/WTF/ChangeLog	2019-03-05 17:21:19 UTC (rev 242475)
+++ releases/WebKitGTK/webkit-2.24/Source/WTF/ChangeLog	2019-03-05 17:21:23 UTC (rev 242476)
@@ -1,3 +1,16 @@
+2019-02-26  Keith Miller  <keith_mil...@apple.com>
+
+        Code quality cleanup in NeverDestroyed
+        https://bugs.webkit.org/show_bug.cgi?id=194824
+
+        Reviewed by Yusuke Suzuki.
+
+        First, move data members to the end of the class per WebKit
+        style. Also, add forbid heap allocation since we expect the
+        NeverDestroyed classes to be static.
+
+        * wtf/NeverDestroyed.h:
+
 2019-02-25  Sam Weinig  <s...@webkit.org>
 
         Update double-conversion to the latest version

Modified: releases/WebKitGTK/webkit-2.24/Source/WTF/wtf/NeverDestroyed.h (242475 => 242476)


--- releases/WebKitGTK/webkit-2.24/Source/WTF/wtf/NeverDestroyed.h	2019-03-05 17:21:19 UTC (rev 242475)
+++ releases/WebKitGTK/webkit-2.24/Source/WTF/wtf/NeverDestroyed.h	2019-03-05 17:21:23 UTC (rev 242476)
@@ -27,6 +27,7 @@
 
 #include <type_traits>
 #include <utility>
+#include <wtf/ForbidHeapAllocation.h>
 #include <wtf/RefCounted.h>
 
 // NeverDestroyed is a smart-pointer-like class that ensures that the destructor
@@ -43,8 +44,9 @@
 
 template<typename T> class NeverDestroyed {
     WTF_MAKE_NONCOPYABLE(NeverDestroyed);
+    WTF_FORBID_HEAP_ALLOCATION;
+public:
 
-public:
     template<typename... Args> NeverDestroyed(Args&&... args)
     {
         MaybeRelax<T>(new (storagePointer()) T(std::forward<Args>(args)...));
@@ -66,10 +68,6 @@
 
     PointerType storagePointer() const { return const_cast<PointerType>(reinterpret_cast<const T*>(&m_storage)); }
 
-    // FIXME: Investigate whether we should allocate a hunk of virtual memory
-    // and hand out chunks of it to NeverDestroyed instead, to reduce fragmentation.
-    typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_storage;
-
     template<typename PtrType, bool ShouldRelax = std::is_base_of<RefCountedBase, PtrType>::value> struct MaybeRelax {
         explicit MaybeRelax(PtrType*) { }
     };
@@ -76,6 +74,10 @@
     template<typename PtrType> struct MaybeRelax<PtrType, true> {
         explicit MaybeRelax(PtrType* ptr) { ptr->relaxAdoptionRequirement(); }
     };
+
+    // FIXME: Investigate whether we should allocate a hunk of virtual memory
+    // and hand out chunks of it to NeverDestroyed instead, to reduce fragmentation.
+    typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_storage;
 };
 
 template<typename T> NeverDestroyed<T> makeNeverDestroyed(T&&);
@@ -85,7 +87,7 @@
 // share more of the code with the main NeverDestroyed above.
 template<typename T> class LazyNeverDestroyed {
     WTF_MAKE_NONCOPYABLE(LazyNeverDestroyed);
-
+    WTF_FORBID_HEAP_ALLOCATION;
 public:
     LazyNeverDestroyed() = default;
 
@@ -124,10 +126,6 @@
         return const_cast<PointerType>(reinterpret_cast<const T*>(&m_storage));
     }
 
-    // FIXME: Investigate whether we should allocate a hunk of virtual memory
-    // and hand out chunks of it to NeverDestroyed instead, to reduce fragmentation.
-    typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_storage;
-
     template<typename PtrType, bool ShouldRelax = std::is_base_of<RefCountedBase, PtrType>::value> struct MaybeRelax {
         explicit MaybeRelax(PtrType*) { }
     };
@@ -140,6 +138,10 @@
     // It must not be initialized dynamically; that would not be thread safe.
     bool m_isConstructed;
 #endif
+
+    // FIXME: Investigate whether we should allocate a hunk of virtual memory
+    // and hand out chunks of it to NeverDestroyed instead, to reduce fragmentation.
+    typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_storage;
 };
 
 template<typename T> inline NeverDestroyed<T> makeNeverDestroyed(T&& argument)

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog (242475 => 242476)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-03-05 17:21:19 UTC (rev 242475)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-03-05 17:21:23 UTC (rev 242476)
@@ -1,3 +1,15 @@
+2019-02-26  Keith Miller  <keith_mil...@apple.com>
+
+        Code quality cleanup in NeverDestroyed
+        https://bugs.webkit.org/show_bug.cgi?id=194824
+
+        Reviewed by Mark Lam.
+
+        name_names.pl should not just assume the layout of LazyNeverDestroyed.
+
+        * dom/make_names.pl:
+        (printNamesCppFile):
+
 2019-02-26  Sihui Liu  <sihui_...@apple.com>
 
         [Mac WK2] storage/indexeddb/IDBObject-leak.html is flaky

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/make_names.pl (242475 => 242476)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/make_names.pl	2019-03-05 17:21:19 UTC (rev 242475)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/dom/make_names.pl	2019-03-05 17:21:23 UTC (rev 242476)
@@ -773,7 +773,7 @@
         print F "\n\nconst WebCore::$parameters{namespace}QualifiedName* const* get$parameters{namespace}Tags()\n";
         print F "{\n    static const WebCore::$parameters{namespace}QualifiedName* const $parameters{namespace}Tags[] = {\n";
         for my $name (sort keys %allTags) {
-            print F "        reinterpret_cast<const WebCore::$parameters{namespace}QualifiedName*>(&${name}Tag),\n";
+            print F "        &${name}Tag.get(),\n";
         }
         print F "    };\n";
         print F "    return $parameters{namespace}Tags;\n";
@@ -788,7 +788,7 @@
         print F "\n\nconst WebCore::QualifiedName* const* get$parameters{namespace}Attrs()\n";
         print F "{\n    static const WebCore::QualifiedName* const $parameters{namespace}Attrs[] = {\n";
         for my $name (sort keys %allAttrs) {
-            print F "        reinterpret_cast<const WebCore::QualifiedName*>(&${name}Attr),\n";
+            print F "        &${name}Attr.get(),\n";
         }
         print F "    };\n";
         print F "    return $parameters{namespace}Attrs;\n";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to