summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-06-10 17:57:08 -0700
committerYuri Kunde Schlesner <yuriks@yuriks.net>2017-06-11 13:10:21 -0700
commit92ca422088eb49c31e8b6146872548c456e56f3e (patch)
treea67048e517446efc43afbca27f8acc05de654604 /src
parent8cb65fe65a48988d40dd3ca2c4f673629a275b4b (diff)
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).
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/ipc_helpers.h3
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp4
-rw-r--r--src/core/hle/kernel/hle_ipc.h7
3 files changed, 14 insertions, 0 deletions
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h
index 5f370bc3b..f0d89cffe 100644
--- a/src/core/hle/ipc_helpers.h
+++ b/src/core/hle/ipc_helpers.h
@@ -62,6 +62,9 @@ class RequestBuilder : public RequestHelperBase {
public:
RequestBuilder(Kernel::HLERequestContext& context, Header 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;
}
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 656405dd6..6cf1886cf 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -35,6 +35,10 @@ u32 HLERequestContext::AddOutgoingHandle(SharedPtr<Object> object) {
return request_handles.size() - 1;
}
+void HLERequestContext::ClearIncomingObjects() {
+ request_handles.clear();
+}
+
ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf,
Process& src_process,
HandleTable& src_table) {
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index d6ebf113c..1022dece8 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -110,6 +110,13 @@ public:
*/
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:
friend class Service::ServiceFrameworkBase;