LibIPC: Take MessageBuffer by lvalue reference in post_message()
Change post_message(MessageBuffer) to post_message(MessageBuffer&) to avoid copying the MessageBuffer onto the stack. MessageBuffer contains a Vector<u8, 1024> with a 1024-byte inline buffer, so passing by value was adding over 1 KiB to the stack frame of handle_messages(). This reduces the handle_messages() stack frame from 1328 bytes to 224 bytes, which matters because handle_messages() sits near the base of the call stack when GC runs its conservative stack scan in response to IPC requests.
This commit is contained in:
parent
1d89128164
commit
ec55c80929
3 changed files with 5 additions and 4 deletions
|
|
@ -34,10 +34,11 @@ bool ConnectionBase::is_open() const
|
|||
|
||||
ErrorOr<void> ConnectionBase::post_message(Message const& message)
|
||||
{
|
||||
return post_message(TRY(message.encode()));
|
||||
auto buffer = TRY(message.encode());
|
||||
return post_message(buffer);
|
||||
}
|
||||
|
||||
ErrorOr<void> ConnectionBase::post_message(MessageBuffer buffer)
|
||||
ErrorOr<void> ConnectionBase::post_message(MessageBuffer& buffer)
|
||||
{
|
||||
// NOTE: If this connection is being shut down, but has not yet been destroyed,
|
||||
// the socket will be closed. Don't try to send more messages.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
[[nodiscard]] bool is_open() const;
|
||||
ErrorOr<void> post_message(Message const&);
|
||||
ErrorOr<void> post_message(MessageBuffer);
|
||||
ErrorOr<void> post_message(MessageBuffer&);
|
||||
|
||||
void shutdown();
|
||||
virtual void die() { }
|
||||
|
|
|
|||
|
|
@ -658,7 +658,7 @@ void generate_proxy_method(SourceGenerator& message_generator, Endpoint const& e
|
|||
} else {
|
||||
// Async messages silently ignore send failures (e.g. peer disconnected).
|
||||
message_generator.append(R"~~~());
|
||||
(void)m_connection.post_message(move(message_buffer)); )~~~");
|
||||
(void)m_connection.post_message(message_buffer); )~~~");
|
||||
}
|
||||
|
||||
message_generator.appendln(R"~~~(
|
||||
|
|
|
|||
Loading…
Reference in a new issue