[webkit-changes] [WebKit/WebKit] 1e7b93: Use more std::span<uint8_t> in IPC::Decoder

Commit Queue noreply at github.com
Wed Sep 13 09:50:23 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1e7b936a641ccf787c0362a26d984a65463429ca
      https://github.com/WebKit/WebKit/commit/1e7b936a641ccf787c0362a26d984a65463429ca
  Author: David Kilzer <ddkilzer at apple.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    M Source/JavaScriptCore/runtime/ArrayBuffer.cpp
    M Source/JavaScriptCore/runtime/ArrayBuffer.h
    M Source/WTF/wtf/Algorithms.h
    M Source/WebKit/NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm
    M Source/WebKit/Platform/IPC/Decoder.cpp
    M Source/WebKit/Platform/IPC/Decoder.h
    M Source/WebKit/Platform/IPC/JSIPCBinding.cpp
    M Source/WebKit/Platform/IPC/JSIPCBinding.h
    M Source/WebKit/Platform/IPC/StreamClientConnection.h
    M Source/WebKit/Platform/IPC/StreamServerConnection.cpp
    M Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm
    M Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp
    M Source/WebKit/Platform/IPC/win/ConnectionWin.cpp
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Scripts/webkit/tests/MessageNames.h
    M Source/WebKit/Shared/IPCTester.cpp
    M Source/WebKit/UIProcess/LegacySessionStateCodingNone.cpp
    M Source/WebKit/UIProcess/WebProcessProxy.cpp
    M Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp
    M Source/WebKit/webpushd/WebPushDaemon.mm
    M Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm
    M Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp
    M Tools/TestWebKitAPI/Tests/IPC/IPCTestUtilities.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm

  Log Message:
  -----------
  Use more std::span<uint8_t> in IPC::Decoder
https://bugs.webkit.org/show_bug.cgi?id=261228
<rdar://115075685>

Reviewed by Chris Dumez.

Switch IPC::Decoder to use DataReference (std::span<const uint8_t>).

Other changes of note:
- Add support for std::span<uint8_t> when creating JSC::ArrayBuffer.
- Add a utility method for std::span to <wtf/Algorithms.h>.
- Introduce MessageName::Invalid and initialize
  IPC::Decoder::m_message_name to that value.
- IPC::Decoder objects now fit in 64 bytes.
- IPC::Decoder now calls m_bufferDeallocator when marked invalid,
  and clears m_buffer.

* Source/JavaScriptCore/runtime/ArrayBuffer.cpp:
(JSC::ArrayBuffer::create): Add.
(JSC::ArrayBuffer::tryCreate): Add.
* Source/JavaScriptCore/runtime/ArrayBuffer.h:
(JSC::ArrayBuffer::create): Add.
(JSC::ArrayBuffer::tryCreate): Add.

* Source/WTF/wtf/Algorithms.h:
(WTF::spanReinterpretCast): Add.

* Source/WebKit/NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm:
(WebKit::WebPushD::Connection::performSendWithAsyncReplyWithoutUsingIPCConnection const):
* Source/WebKit/Platform/IPC/Decoder.cpp:
(IPC::copyBuffer):
(IPC::Decoder::create):
- Remove duplicate code for one overloaded method.
(IPC::Decoder::Decoder):
- Delete default constructor.
(IPC::Decoder::~Decoder):
(IPC::Decoder::unwrapForTesting):
* Source/WebKit/Platform/IPC/Decoder.h:
(IPC::Decoder::buffer const): Switch to return DataReference.
(IPC::Decoder::currentBufferPosition const): Delete.
- Rename to currentBufferOffset() since this returns an offset from the
  start of the buffer.
(IPC::Decoder::currentBufferOffset const):
(IPC::Decoder::length const): Delete.
(IPC::Decoder::isValid const):
(IPC::Decoder::markInvalid):
- Now calls m_bufferDeallocator and clear m_buffer on invalidation.
(IPC::alignedBufferIsLargeEnoughToContain):
- Simplify logic because we are no longer using two pointer addresses.
(IPC::Decoder::decodeSpan):
* Source/WebKit/Platform/IPC/JSIPCBinding.cpp:
(IPC::putJSValueForDecodedArgumentAtIndexOrArrayBufferIfUndefined):
* Source/WebKit/Platform/IPC/JSIPCBinding.h:
(IPC::putJSValueForDecodeArgumentInArray):
* Source/WebKit/Platform/IPC/StreamClientConnection.h:
(IPC::StreamClientConnection::trySendSyncStream):
* Source/WebKit/Platform/IPC/StreamServerConnection.cpp:
(IPC::StreamServerConnection::dispatchStreamMessages):
(IPC::StreamServerConnection::processSetStreamDestinationID):
(IPC::StreamServerConnection::dispatchStreamMessage):
(IPC::StreamServerConnection::dispatchOutOfStreamMessage):
* Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::createMessageDecoder):
* Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::processMessage):
* Source/WebKit/Platform/IPC/win/ConnectionWin.cpp:
(IPC::Connection::readEventHandler):
* Source/WebKit/Scripts/webkit/messages.py:
(generate_message_names_header):
- Add MessageName::Invalid.
* Source/WebKit/Scripts/webkit/tests/MessageNames.h: Ditto.
* Source/WebKit/Shared/IPCTester.cpp:
(WebKit::defaultTestDriver):
(WebKit::sendTestMessage):
* Source/WebKit/UIProcess/LegacySessionStateCodingNone.cpp:
(WebKit::decodeLegacySessionState):
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::shouldSendPendingMessage):
* Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp:
(WebKit::IPCTestingAPI::JSMessageListener::didReceiveMessage):
(WebKit::IPCTestingAPI::JSMessageListener::willSendMessage):
* Source/WebKit/webpushd/WebPushDaemon.mm:
(WebPushD::WebPushDaemon::connectionEventHandler):
* Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm:
(WebPushTool::Connection::performSendWithAsyncReplyWithoutUsingIPCConnection const):
* Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp:
(TestWebKitAPI::ArgumentCoderEncoderDecoderTest<IPC::Encoder>::createDecoder const):
(TestWebKitAPI::ArgumentCoderEncoderDecoderTest<IPC::StreamConnectionEncoder>::createDecoder const):
(TestWebKitAPI::TYPED_TEST_P):
* Tools/TestWebKitAPI/Tests/IPC/IPCTestUtilities.h:
(TestWebKitAPI::copyViaEncoder):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:
(TestWebKitAPI::WebPushXPCConnectionMessageSender::performSendWithAsyncReplyWithoutUsingIPCConnection const):

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




More information about the webkit-changes mailing list