[webkit-changes] [WebKit/WebKit] b21cd3: [WK2] Use Span encoding, decoding in ArgumentCoder...

Žan Doberšek noreply at github.com
Wed Jan 18 04:25:03 PST 2023


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

  Changed paths:
    M Source/WebKit/Platform/IPC/ArgumentCoders.cpp
    M Source/WebKit/Platform/IPC/ArgumentCoders.h

  Log Message:
  -----------
  [WK2] Use Span encoding, decoding in ArgumentCoder specializations
https://bugs.webkit.org/show_bug.cgi?id=250646

Reviewed by Kimmo Kinnunen.

Spread use of Span-based encoding and decoding in existing ArgumentCoder
specializations in favor of fixed-length-data methods.

When size of data is encoded along with the data itself, encoding and decoding
can be done through the Span object, yielding to the Span specialization of the
ArgumentCoder template. When size is fixed, shared across different spans or is
basis for further logic during encoding, the span areas are handled directly
through the encoder's encodeSpan() or decoder's decodeSpan() methods.

Decoder::decodeSpan() internally validates the passed-in size value for possible
overflow in combination with the size of the specified type, and also ensures
that the remaining buffer is large enough to hold the desired amount of data.
This allows for replacing a larger amount of logic around existing calls to
existing fixed-length Decoder methods.

In ArrayReferenceTuple specialization of ArgumentCoder, some additional cleanup
is done. Size value is now encoded and decoded as a size_t. For decoding,
overflow checks for each type are now done through a fold expression before
decoding the span areas.

In Vector specialization of ArgumentCoder for arithmetic values, a Span object
is now used to encode and decode the Vector data, simplifying the specialization
by a lot.

SHA1::Digest is a std::array object, and its ArgumentCoder specialization can be
generalized later to cover any std::array object of trivially-copyable values.
For now, the existing specialization is simplified to just encoding and decoding
the span area.

ArgumentCoder specializations for string types also adopt encoding and decoding
of character data through span areas.

* Source/WebKit/Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<CString>::encode):
(IPC::ArgumentCoder<CString>::decode):
(IPC::ArgumentCoder<String>::encode):
(IPC::decodeStringText):
(IPC::ArgumentCoder<String>::decode):
(IPC::ArgumentCoder<StringView>::encode):
(IPC::ArgumentCoder<SHA1::Digest>::encode): Deleted.
(IPC::ArgumentCoder<SHA1::Digest>::decode): Deleted.
* Source/WebKit/Platform/IPC/ArgumentCoders.h:
(IPC::ArgumentCoder<SHA1::Digest>::encode):
(IPC::ArgumentCoder<SHA1::Digest>::decode):

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




More information about the webkit-changes mailing list