binder: Use variant for backend specific Parcel fields
This frees up some space to add RPC binder specific bookkeeping to
Parcel. `variant` has a size overhead of one pointer, but since there is
at least one pointer worth of fields in each case, it works out as an
overall win. We could probably do it cheaper by using a union and hiding
a bit field somewhere to indicate the active case, but that isn't
necessary yet.
Bug: 185909244
Test: TH
Change-Id: Id53ea0cbfe51b3246e6f9f1f3d9df7c8c193808e
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp
index 2a8e9c1..c6460b8 100644
--- a/libs/binder/RpcState.cpp
+++ b/libs/binder/RpcState.cpp
@@ -601,10 +601,8 @@
if (rpcReply->status != OK) return rpcReply->status;
data.release();
- reply->ipcSetDataReference(rpcReply->data, command.bodySize - offsetof(RpcWireReply, data),
- nullptr, 0, cleanup_reply_data);
-
- reply->markForRpc(session);
+ reply->rpcSetDataReference(session, rpcReply->data,
+ command.bodySize - offsetof(RpcWireReply, data), cleanup_reply_data);
return OK;
}
@@ -824,11 +822,9 @@
// transaction->data is owned by this function. Parcel borrows this data and
// only holds onto it for the duration of this function call. Parcel will be
// deleted before the 'transactionData' object.
- data.ipcSetDataReference(transaction->data,
+ data.rpcSetDataReference(session, transaction->data,
transactionData.size() - offsetof(RpcWireTransaction, data),
- nullptr /*object*/, 0 /*objectCount*/,
do_nothing_to_transact_data);
- data.markForRpc(session);
if (target) {
bool origAllowNested = connection->allowNested;