mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 09:54:42 +00:00
Bug 1748280 - Gecko Profiler: Fix std::tuple deserialization. r=gerald
I'm gonna guess there was no existing use of the tuple serialization/deserialization code, because `Bytes` doesn't exist in the deserializer, and cannot possibly function properly on tuple members that serialize to a non-constant size, since it's called on a default-constructed tuple. This patch took inspiration in the deserializer for Variant and seems to work fine. Differential Revision: https://phabricator.services.mozilla.com/D135028
This commit is contained in:
parent
6f3e18ab53
commit
2ff8332d74
@ -994,9 +994,22 @@ struct ProfileBufferEntryWriter::Serializer<std::tuple<Ts...>> {
|
||||
|
||||
template <typename... Ts>
|
||||
struct ProfileBufferEntryReader::Deserializer<std::tuple<Ts...>> {
|
||||
template <size_t I>
|
||||
static void TupleIReadInto(ProfileBufferEntryReader& aER,
|
||||
std::tuple<Ts...>& aTuple) {
|
||||
aER.ReadIntoObject(std::get<I>(aTuple));
|
||||
}
|
||||
|
||||
template <size_t... Is>
|
||||
static void TupleReadInto(ProfileBufferEntryReader& aER,
|
||||
std::tuple<Ts...>& aTuple,
|
||||
std::index_sequence<Is...>) {
|
||||
(TupleIReadInto<Is>(aER, aTuple), ...);
|
||||
}
|
||||
|
||||
static void ReadInto(ProfileBufferEntryReader& aER,
|
||||
std::tuple<Ts...>& aTuple) {
|
||||
aER.ReadBytes(&aTuple, Bytes(aTuple));
|
||||
TupleReadInto(aER, aTuple, std::index_sequence_for<Ts...>());
|
||||
}
|
||||
|
||||
static std::tuple<Ts...> Read(ProfileBufferEntryReader& aER) {
|
||||
@ -1055,8 +1068,20 @@ struct ProfileBufferEntryWriter::Serializer<Tuple<Ts...>> {
|
||||
|
||||
template <typename... Ts>
|
||||
struct ProfileBufferEntryReader::Deserializer<Tuple<Ts...>> {
|
||||
template <size_t I>
|
||||
static void TupleIReadInto(ProfileBufferEntryReader& aER,
|
||||
Tuple<Ts...>& aTuple) {
|
||||
aER.ReadIntoObject(Get<I>(aTuple));
|
||||
}
|
||||
|
||||
template <size_t... Is>
|
||||
static void TupleReadInto(ProfileBufferEntryReader& aER, Tuple<Ts...>& aTuple,
|
||||
std::index_sequence<Is...>) {
|
||||
(TupleIReadInto<Is>(aER, aTuple), ...);
|
||||
}
|
||||
|
||||
static void ReadInto(ProfileBufferEntryReader& aER, Tuple<Ts...>& aTuple) {
|
||||
aER.ReadBytes(&aTuple, Bytes(aTuple));
|
||||
TupleReadInto(aER, aTuple, std::index_sequence_for<Ts...>());
|
||||
}
|
||||
|
||||
static Tuple<Ts...> Read(ProfileBufferEntryReader& aER) {
|
||||
|
Loading…
Reference in New Issue
Block a user