[webkit-changes] [WebKit/WebKit] 80ea52: [WK2] Add Span-handling methods to IPC encoder, de...

Žan Doberšek noreply at github.com
Fri Jan 13 08:46:38 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 80ea526b2a16a6365775453d8821f5d481aed02e
      https://github.com/WebKit/WebKit/commit/80ea526b2a16a6365775453d8821f5d481aed02e
  Author: Žan Doberšek <zdobersek at igalia.com>
  Date:   2023-01-13 (Fri, 13 Jan 2023)

  Changed paths:
    M Source/WebKit/Platform/IPC/ArgumentCoders.h
    M Source/WebKit/Platform/IPC/Decoder.h
    M Source/WebKit/Platform/IPC/Encoder.h
    M Source/WebKit/Platform/IPC/StreamConnectionEncoder.h
    M Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp

  Log Message:
  -----------
  [WK2] Add Span-handling methods to IPC encoder, decoder classes
https://bugs.webkit.org/show_bug.cgi?id=249732

Reviewed by Kimmo Kinnunen.

Encoder::encodeSpan() and StreamConnectionEncoder::encodeSpan() are added,
accepting a Span object and relaying the data pointer, byte size and alignment
values to their encodeFixedLengthData() methods. Once encodeSpan() is adopted
everywhere, encodeFixedLengthData() will be removable.

Decoder::decodeSpan() is added, returning a Span object for a given type and
size that spans across the appropriate area of the Decoder's data. decodeSpan()
handles overflow checking and buffer capacity validation, returning a null Span
if any of those checks fails.

Encoding of Span objects through the ArgumentCoder specialization changes a bit,
but only to match the decoding. For Spans with dynamic extent, the size is
encoded first. But if the size is empty, there's no data encoding, since there
is none. This differs from previous behavior where empty Span data would still
go through to the Encoder::encodeFixedLengthData() call and potentially align
the buffer data for the given type, something that wasn't mirrored during
decoding.

Decoding of Span objects through ArgumentCoder is a bit different to the
semantics of Decoder::decodeSpan(). For Spans with dynamic extent, in case of
zero size, a null Span is returned, i.e. null data pointer and zero size. In all
other successful cases, a non-empty Span will be returned.

Test cases are added to the ArgumentCoderTests suite, covering empty and
non-empty spans of both trivial data and aligned structs.

* Source/WebKit/Platform/IPC/ArgumentCoders.h:
* Source/WebKit/Platform/IPC/Decoder.h:
(IPC::Decoder::decodeSpan):
* Source/WebKit/Platform/IPC/Encoder.h:
(IPC::Encoder::encodeSpan):
* Source/WebKit/Platform/IPC/StreamConnectionEncoder.h:
* Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp:
(TestWebKitAPI::TYPED_TEST_P):
(TestWebKitAPI::calculateEncodedSize):

Canonical link: https://commits.webkit.org/258875@main




More information about the webkit-changes mailing list