Title: [269969] trunk/Source/WebKit
Revision
269969
Author
[email protected]
Date
2020-11-18 10:42:36 -0800 (Wed, 18 Nov 2020)

Log Message

Clean up some code in SharedDisplayListHandle
https://bugs.webkit.org/show_bug.cgi?id=219089

Reviewed by Geoff Garen.

Currently, `reservedCapacityAtStart` is defined as a constant 16 bytes, which is enough to encompass the
contents of the header structure in a shared display list handle (i.e. an 8-byte atomic for the lock, and
another 8 bytes for the unread count).

Instead of hard-coding this, we could simply make this a constexpr function that returns the size of
`DisplayListSharedMemoryHeader` (rounded up to ensure alignment of all display list item data).

No change in behavior.

* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayList):
(WebKit::RemoteRenderingBackend::didCreateSharedDisplayListHandle):
* Shared/SharedDisplayListHandle.h:
(WebKit::SharedDisplayListHandle::headerSize):
* WebProcess/GPU/graphics/DisplayListWriterHandle.cpp:
(WebKit::DisplayListWriterHandle::resetWritableOffsetIfPossible):
* WebProcess/GPU/graphics/DisplayListWriterHandle.h:
(WebKit::DisplayListWriterHandle::DisplayListWriterHandle):
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::createItemBuffer):

Also add a static assert that the size of a newly allocated buffer is larger than the reserved header capacity.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (269968 => 269969)


--- trunk/Source/WebKit/ChangeLog	2020-11-18 18:35:12 UTC (rev 269968)
+++ trunk/Source/WebKit/ChangeLog	2020-11-18 18:42:36 UTC (rev 269969)
@@ -1,3 +1,33 @@
+2020-11-18  Wenson Hsieh  <[email protected]>
+
+        Clean up some code in SharedDisplayListHandle
+        https://bugs.webkit.org/show_bug.cgi?id=219089
+
+        Reviewed by Geoff Garen.
+
+        Currently, `reservedCapacityAtStart` is defined as a constant 16 bytes, which is enough to encompass the
+        contents of the header structure in a shared display list handle (i.e. an 8-byte atomic for the lock, and
+        another 8 bytes for the unread count).
+
+        Instead of hard-coding this, we could simply make this a constexpr function that returns the size of
+        `DisplayListSharedMemoryHeader` (rounded up to ensure alignment of all display list item data).
+
+        No change in behavior.
+
+        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+        (WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayList):
+        (WebKit::RemoteRenderingBackend::didCreateSharedDisplayListHandle):
+        * Shared/SharedDisplayListHandle.h:
+        (WebKit::SharedDisplayListHandle::headerSize):
+        * WebProcess/GPU/graphics/DisplayListWriterHandle.cpp:
+        (WebKit::DisplayListWriterHandle::resetWritableOffsetIfPossible):
+        * WebProcess/GPU/graphics/DisplayListWriterHandle.h:
+        (WebKit::DisplayListWriterHandle::DisplayListWriterHandle):
+        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
+        (WebKit::RemoteRenderingBackendProxy::createItemBuffer):
+
+        Also add a static assert that the size of a newly allocated buffer is larger than the reserved header capacity.
+
 2020-11-18  Per Arne Vollan  <[email protected]>
 
         [macOS] Fix message filter sandbox violation

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (269968 => 269969)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2020-11-18 18:35:12 UTC (rev 269968)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2020-11-18 18:42:36 UTC (rev 269969)
@@ -198,7 +198,7 @@
         }
         // Otherwise, continue reading the next display list item buffer from the start.
         m_nextItemBufferToRead = { };
-        applyDisplayListsFromHandle(*imageBuffer, *nextHandle, SharedDisplayListHandle::reservedCapacityAtStart);
+        applyDisplayListsFromHandle(*imageBuffer, *nextHandle, SharedDisplayListHandle::headerSize());
     }
 }
 
@@ -243,7 +243,7 @@
 
     if (m_nextItemBufferToRead == identifier) {
         m_nextItemBufferToRead = { };
-        wakeUpAndApplyDisplayList(identifier, SharedDisplayListHandle::reservedCapacityAtStart, destinationBufferIdentifier);
+        wakeUpAndApplyDisplayList(identifier, SharedDisplayListHandle::headerSize(), destinationBufferIdentifier);
     }
 }
 

Modified: trunk/Source/WebKit/Shared/SharedDisplayListHandle.h (269968 => 269969)


--- trunk/Source/WebKit/Shared/SharedDisplayListHandle.h	2020-11-18 18:35:12 UTC (rev 269968)
+++ trunk/Source/WebKit/Shared/SharedDisplayListHandle.h	2020-11-18 18:42:36 UTC (rev 269969)
@@ -37,7 +37,10 @@
 public:
     virtual ~SharedDisplayListHandle() = default;
 
-    static constexpr auto reservedCapacityAtStart = 2 * sizeof(uint64_t);
+    static constexpr size_t headerSize()
+    {
+        return roundUpToMultipleOf<sizeof(std::max_align_t)>(sizeof(DisplayListSharedMemoryHeader));
+    }
 
     SharedMemory& sharedMemory() { return m_sharedMemory.get(); }
     const SharedMemory& sharedMemory() const { return m_sharedMemory.get(); }

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.cpp (269968 => 269969)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.cpp	2020-11-18 18:35:12 UTC (rev 269968)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.cpp	2020-11-18 18:42:36 UTC (rev 269969)
@@ -68,8 +68,8 @@
 
 bool DisplayListWriterHandle::resetWritableOffsetIfPossible()
 {
-    if (m_writableOffset <= SharedDisplayListHandle::reservedCapacityAtStart) {
-        RELEASE_ASSERT(m_writableOffset == SharedDisplayListHandle::reservedCapacityAtStart);
+    if (m_writableOffset <= SharedDisplayListHandle::headerSize()) {
+        RELEASE_ASSERT(m_writableOffset == SharedDisplayListHandle::headerSize());
         return true;
     }
 
@@ -76,7 +76,7 @@
     if (unreadBytes())
         return false;
 
-    m_writableOffset = SharedDisplayListHandle::reservedCapacityAtStart;
+    m_writableOffset = SharedDisplayListHandle::headerSize();
     return true;
 }
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.h (269968 => 269969)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.h	2020-11-18 18:35:12 UTC (rev 269968)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.h	2020-11-18 18:42:36 UTC (rev 269969)
@@ -49,7 +49,7 @@
 private:
     DisplayListWriterHandle(WebCore::DisplayList::ItemBufferIdentifier identifier, Ref<SharedMemory>&& sharedMemory)
         : SharedDisplayListHandle(identifier, WTFMove(sharedMemory))
-        , m_writableOffset(SharedDisplayListHandle::reservedCapacityAtStart)
+        , m_writableOffset(SharedDisplayListHandle::headerSize())
     {
     }
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (269968 => 269969)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp	2020-11-18 18:35:12 UTC (rev 269968)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp	2020-11-18 18:42:36 UTC (rev 269969)
@@ -239,8 +239,9 @@
     }
 
     static constexpr size_t defaultSharedItemBufferSize = 1 << 16;
+    static_assert(defaultSharedItemBufferSize > SharedDisplayListHandle::headerSize());
 
-    auto sharedMemory = SharedMemory::allocate(std::max(defaultSharedItemBufferSize, capacity + SharedDisplayListHandle::reservedCapacityAtStart));
+    auto sharedMemory = SharedMemory::allocate(std::max(defaultSharedItemBufferSize, capacity + SharedDisplayListHandle::headerSize()));
     if (!sharedMemory)
         return { };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to