WebKit Bugzilla
Attachment 362410 Details for
Bug 194824
: Code quality cleanup in NeverDestroyed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-194824-20190219120830.patch (text/plain), 3.92 KB, created by
Keith Miller
on 2019-02-19 12:08:31 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Keith Miller
Created:
2019-02-19 12:08:31 PST
Size:
3.92 KB
patch
obsolete
>Subversion Revision: 241761 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index bd85c4e3977af05eeec4948caa2339531852f944..7ed63270ca4a3cf458d5bdc79b508799a1e15b2e 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,16 @@ >+2019-02-19 Keith Miller <keith_miller@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-16 Darin Adler <darin@apple.com> > > Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc. >diff --git a/Source/WTF/wtf/NeverDestroyed.h b/Source/WTF/wtf/NeverDestroyed.h >index c311f136ff5e5840ee5f49ee5f718686187d64c7..e7e8a7ea03989cba404eabb8253500d5c3f7f553 100644 >--- a/Source/WTF/wtf/NeverDestroyed.h >+++ b/Source/WTF/wtf/NeverDestroyed.h >@@ -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 @@ namespace WTF { > > template<typename T> class NeverDestroyed { > WTF_MAKE_NONCOPYABLE(NeverDestroyed); >- >+ WTF_FORBID_HEAP_ALLOCATION; > public: >+ > template<typename... Args> NeverDestroyed(Args&&... args) > { > MaybeRelax<T>(new (storagePointer()) T(std::forward<Args>(args)...)); >@@ -66,16 +68,16 @@ private: > > 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*) { } > }; > 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 @@ template<typename T> NeverDestroyed<T> makeNeverDestroyed(T&&); > // 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 @@ private: > 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 @@ private: > // 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)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194824
:
362406
|
362409
|
362410
|
362740
|
362741