mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-06-18 07:43:37 +00:00
Mach transport already sends payloads as out-of-line virtual-copy regions, but the receive path immediately copied each payload into a new Vector and deallocated the kernel mapping. That made the IPC IO thread touch every byte before the main thread could decode the message. Add ReceivedMessageBytes as the raw-message byte storage and let the Mach transport adopt the OOL region directly. The mapping now lives until the raw message storage is destroyed, so invalid descriptor paths and normal queue teardown both release it through the same destructor. Socket transports keep their existing receive copy path by wrapping vectors in the same storage type, and the direct raw-message consumers now decode from its ReadonlyBytes view.
41 lines
915 B
C++
41 lines
915 B
C++
/*
|
|
* Copyright (c) 2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Platform.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <AK/Vector.h>
|
|
|
|
namespace IPC {
|
|
|
|
class ReceivedMessageBytes {
|
|
public:
|
|
ReceivedMessageBytes();
|
|
ReceivedMessageBytes(ReceivedMessageBytes const&);
|
|
ReceivedMessageBytes(ReceivedMessageBytes&&);
|
|
~ReceivedMessageBytes();
|
|
|
|
ReceivedMessageBytes& operator=(ReceivedMessageBytes const&);
|
|
ReceivedMessageBytes& operator=(ReceivedMessageBytes&&);
|
|
|
|
static ReceivedMessageBytes from_vector(Vector<u8>);
|
|
#if defined(AK_OS_MACOS)
|
|
static ReceivedMessageBytes adopt_vm_region(void*, size_t);
|
|
#endif
|
|
|
|
ReadonlyBytes bytes() const;
|
|
bool is_empty() const { return bytes().is_empty(); }
|
|
|
|
private:
|
|
class Impl;
|
|
|
|
explicit ReceivedMessageBytes(NonnullRefPtr<Impl>);
|
|
|
|
RefPtr<Impl> m_impl;
|
|
};
|
|
|
|
}
|