Changeset 269969 in webkit


Ignore:
Timestamp:
Nov 18, 2020 10:42:36 AM (3 years ago)
Author:
Wenson Hsieh
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.

Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r269966 r269969  
     12020-11-18  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Clean up some code in SharedDisplayListHandle
     4        https://bugs.webkit.org/show_bug.cgi?id=219089
     5
     6        Reviewed by Geoff Garen.
     7
     8        Currently, `reservedCapacityAtStart` is defined as a constant 16 bytes, which is enough to encompass the
     9        contents of the header structure in a shared display list handle (i.e. an 8-byte atomic for the lock, and
     10        another 8 bytes for the unread count).
     11
     12        Instead of hard-coding this, we could simply make this a constexpr function that returns the size of
     13        `DisplayListSharedMemoryHeader` (rounded up to ensure alignment of all display list item data).
     14
     15        No change in behavior.
     16
     17        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
     18        (WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayList):
     19        (WebKit::RemoteRenderingBackend::didCreateSharedDisplayListHandle):
     20        * Shared/SharedDisplayListHandle.h:
     21        (WebKit::SharedDisplayListHandle::headerSize):
     22        * WebProcess/GPU/graphics/DisplayListWriterHandle.cpp:
     23        (WebKit::DisplayListWriterHandle::resetWritableOffsetIfPossible):
     24        * WebProcess/GPU/graphics/DisplayListWriterHandle.h:
     25        (WebKit::DisplayListWriterHandle::DisplayListWriterHandle):
     26        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
     27        (WebKit::RemoteRenderingBackendProxy::createItemBuffer):
     28
     29        Also add a static assert that the size of a newly allocated buffer is larger than the reserved header capacity.
     30
    1312020-11-18  Per Arne Vollan  <pvollan@apple.com>
    232
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp

    r269943 r269969  
    199199        // Otherwise, continue reading the next display list item buffer from the start.
    200200        m_nextItemBufferToRead = { };
    201         applyDisplayListsFromHandle(*imageBuffer, *nextHandle, SharedDisplayListHandle::reservedCapacityAtStart);
     201        applyDisplayListsFromHandle(*imageBuffer, *nextHandle, SharedDisplayListHandle::headerSize());
    202202    }
    203203}
     
    244244    if (m_nextItemBufferToRead == identifier) {
    245245        m_nextItemBufferToRead = { };
    246         wakeUpAndApplyDisplayList(identifier, SharedDisplayListHandle::reservedCapacityAtStart, destinationBufferIdentifier);
     246        wakeUpAndApplyDisplayList(identifier, SharedDisplayListHandle::headerSize(), destinationBufferIdentifier);
    247247    }
    248248}
  • trunk/Source/WebKit/Shared/SharedDisplayListHandle.h

    r269682 r269969  
    3838    virtual ~SharedDisplayListHandle() = default;
    3939
    40     static constexpr auto reservedCapacityAtStart = 2 * sizeof(uint64_t);
     40    static constexpr size_t headerSize()
     41    {
     42        return roundUpToMultipleOf<sizeof(std::max_align_t)>(sizeof(DisplayListSharedMemoryHeader));
     43    }
    4144
    4245    SharedMemory& sharedMemory() { return m_sharedMemory.get(); }
  • trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.cpp

    r269682 r269969  
    6969bool DisplayListWriterHandle::resetWritableOffsetIfPossible()
    7070{
    71     if (m_writableOffset <= SharedDisplayListHandle::reservedCapacityAtStart) {
    72         RELEASE_ASSERT(m_writableOffset == SharedDisplayListHandle::reservedCapacityAtStart);
     71    if (m_writableOffset <= SharedDisplayListHandle::headerSize()) {
     72        RELEASE_ASSERT(m_writableOffset == SharedDisplayListHandle::headerSize());
    7373        return true;
    7474    }
     
    7777        return false;
    7878
    79     m_writableOffset = SharedDisplayListHandle::reservedCapacityAtStart;
     79    m_writableOffset = SharedDisplayListHandle::headerSize();
    8080    return true;
    8181}
  • trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.h

    r269682 r269969  
    5050    DisplayListWriterHandle(WebCore::DisplayList::ItemBufferIdentifier identifier, Ref<SharedMemory>&& sharedMemory)
    5151        : SharedDisplayListHandle(identifier, WTFMove(sharedMemory))
    52         , m_writableOffset(SharedDisplayListHandle::reservedCapacityAtStart)
     52        , m_writableOffset(SharedDisplayListHandle::headerSize())
    5353    {
    5454    }
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp

    r269943 r269969  
    240240
    241241    static constexpr size_t defaultSharedItemBufferSize = 1 << 16;
    242 
    243     auto sharedMemory = SharedMemory::allocate(std::max(defaultSharedItemBufferSize, capacity + SharedDisplayListHandle::reservedCapacityAtStart));
     242    static_assert(defaultSharedItemBufferSize > SharedDisplayListHandle::headerSize());
     243
     244    auto sharedMemory = SharedMemory::allocate(std::max(defaultSharedItemBufferSize, capacity + SharedDisplayListHandle::headerSize()));
    244245    if (!sharedMemory)
    245246        return { };
Note: See TracChangeset for help on using the changeset viewer.