Skip to content
Snippets Groups Projects
Commit 92ca4220 authored by Yuri Kunde Schlesner's avatar Yuri Kunde Schlesner
Browse files

Kernel: Allow clearing request_objects to re-use buffer space

Reduces the necessary allocation to max(in_handles, out_handles) rather
than (in_handles + out_handles).
parent 8cb65fe6
No related branches found
No related tags found
No related merge requests found
...@@ -62,6 +62,9 @@ class RequestBuilder : public RequestHelperBase { ...@@ -62,6 +62,9 @@ class RequestBuilder : public RequestHelperBase {
public: public:
RequestBuilder(Kernel::HLERequestContext& context, Header command_header) RequestBuilder(Kernel::HLERequestContext& context, Header command_header)
: RequestHelperBase(context, command_header) { : RequestHelperBase(context, command_header) {
// From this point we will start overwriting the existing command buffer, so it's safe to
// release all previous incoming Object pointers since they won't be usable anymore.
context.ClearIncomingObjects();
cmdbuf[0] = header.raw; cmdbuf[0] = header.raw;
} }
......
...@@ -35,6 +35,10 @@ u32 HLERequestContext::AddOutgoingHandle(SharedPtr<Object> object) { ...@@ -35,6 +35,10 @@ u32 HLERequestContext::AddOutgoingHandle(SharedPtr<Object> object) {
return request_handles.size() - 1; return request_handles.size() - 1;
} }
void HLERequestContext::ClearIncomingObjects() {
request_handles.clear();
}
ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf, ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf,
Process& src_process, Process& src_process,
HandleTable& src_table) { HandleTable& src_table) {
......
...@@ -110,6 +110,13 @@ public: ...@@ -110,6 +110,13 @@ public:
*/ */
u32 AddOutgoingHandle(SharedPtr<Object> object); u32 AddOutgoingHandle(SharedPtr<Object> object);
/**
* Discards all Objects from the context, invalidating all ids. This may be called after reading
* out all incoming objects, so that the buffer memory can be re-used for outgoing handles, but
* this is not required.
*/
void ClearIncomingObjects();
private: private:
friend class Service::ServiceFrameworkBase; friend class Service::ServiceFrameworkBase;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment