Changeset 262032 in webkit
- Timestamp:
- May 21, 2020 3:30:01 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r262024 r262032 1 2020-05-21 Alex Christensen <achristensen@webkit.org> 2 3 Use an OptionSet instead of uint8_t for MessageFlags 4 https://bugs.webkit.org/show_bug.cgi?id=212230 5 <rdar://problem/63496543> 6 7 Reviewed by Darin Adler. 8 9 I also reduce the encoding size of OptionSet. 10 11 * Platform/IPC/ArgumentCoders.h: 12 (IPC::ArgumentCoder<OptionSet<T>>::encode): 13 (IPC::ArgumentCoder<OptionSet<T>>::decode): 14 * Platform/IPC/Decoder.cpp: 15 (IPC::Decoder::isSyncMessage const): 16 (IPC::Decoder::shouldDispatchMessageWhenWaitingForSyncReply const): 17 (IPC::Decoder::shouldUseFullySynchronousModeForTesting const): 18 * Platform/IPC/Decoder.h: 19 * Platform/IPC/Encoder.cpp: 20 (IPC::Encoder::isSyncMessage const): 21 (IPC::Encoder::shouldDispatchMessageWhenWaitingForSyncReply const): 22 (IPC::Encoder::setIsSyncMessage): 23 (IPC::Encoder::setShouldDispatchMessageWhenWaitingForSyncReply): 24 (IPC::Encoder::setFullySynchronousModeForTesting): 25 (IPC::Encoder::messageFlags): 26 (IPC::Encoder::messageFlags const): 27 * Platform/IPC/Encoder.h: 28 * Platform/IPC/MessageFlags.h: 29 (): Deleted. 30 1 31 2020-05-21 John Wilander <wilander@apple.com> 2 32 -
trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h
r259940 r262032 56 56 static void encode(Encoder& encoder, const OptionSet<T>& optionSet) 57 57 { 58 encoder << (static_cast<uint64_t>(optionSet.toRaw()));58 encoder << optionSet.toRaw(); 59 59 } 60 60 61 61 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, OptionSet<T>& optionSet) 62 62 { 63 uint64_tvalue;63 typename OptionSet<T>::StorageType value; 64 64 if (!decoder.decode(value)) 65 65 return false; … … 71 71 static Optional<OptionSet<T>> decode(Decoder& decoder) 72 72 { 73 Optional< uint64_t> value;73 Optional<typename OptionSet<T>::StorageType> value; 74 74 decoder >> value; 75 75 if (!value) -
trunk/Source/WebKit/Platform/IPC/Decoder.cpp
r261672 r262032 27 27 #include "Decoder.h" 28 28 29 #include "ArgumentCoders.h" 29 30 #include "DataReference.h" 30 31 #include "MessageFlags.h" … … 93 94 bool Decoder::isSyncMessage() const 94 95 { 95 return m_messageFlags & SyncMessage;96 return m_messageFlags.contains(MessageFlags::SyncMessage); 96 97 } 97 98 98 99 ShouldDispatchWhenWaitingForSyncReply Decoder::shouldDispatchMessageWhenWaitingForSyncReply() const 99 100 { 100 if (m_messageFlags & DispatchMessageWhenWaitingForSyncReply)101 if (m_messageFlags.contains(MessageFlags::DispatchMessageWhenWaitingForSyncReply)) 101 102 return ShouldDispatchWhenWaitingForSyncReply::Yes; 102 if (m_messageFlags & DispatchMessageWhenWaitingForUnboundedSyncReply)103 if (m_messageFlags.contains(MessageFlags::DispatchMessageWhenWaitingForUnboundedSyncReply)) 103 104 return ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC; 104 105 return ShouldDispatchWhenWaitingForSyncReply::No; … … 107 108 bool Decoder::shouldUseFullySynchronousModeForTesting() const 108 109 { 109 return m_messageFlags & UseFullySynchronousModeForTesting;110 return m_messageFlags.contains(MessageFlags::UseFullySynchronousModeForTesting); 110 111 } 111 112 -
trunk/Source/WebKit/Platform/IPC/Decoder.h
r261672 r262032 31 31 #include "StringReference.h" 32 32 #include <wtf/EnumTraits.h> 33 #include <wtf/OptionSet.h> 33 34 #include <wtf/Vector.h> 34 35 … … 41 42 class DataReference; 42 43 class ImportanceAssertion; 43 enum class ShouldDispatchWhenWaitingForSyncReply; 44 enum class MessageFlags : uint8_t; 45 enum class ShouldDispatchWhenWaitingForSyncReply : uint8_t; 44 46 45 47 class Decoder { … … 192 194 Vector<Attachment> m_attachments; 193 195 194 uint8_tm_messageFlags;196 OptionSet<MessageFlags> m_messageFlags; 195 197 MessageName m_messageName; 196 198 -
trunk/Source/WebKit/Platform/IPC/Encoder.cpp
r261672 r262032 30 30 #include "MessageFlags.h" 31 31 #include <algorithm> 32 #include < stdio.h>32 #include <wtf/OptionSet.h> 33 33 34 34 #if OS(DARWIN) … … 82 82 bool Encoder::isSyncMessage() const 83 83 { 84 return *buffer() & SyncMessage;84 return messageFlags().contains(MessageFlags::SyncMessage); 85 85 } 86 86 87 87 ShouldDispatchWhenWaitingForSyncReply Encoder::shouldDispatchMessageWhenWaitingForSyncReply() const 88 88 { 89 if ( *buffer() & DispatchMessageWhenWaitingForSyncReply)89 if (messageFlags().contains(MessageFlags::DispatchMessageWhenWaitingForSyncReply)) 90 90 return ShouldDispatchWhenWaitingForSyncReply::Yes; 91 if ( *buffer() & DispatchMessageWhenWaitingForUnboundedSyncReply)91 if (messageFlags().contains(MessageFlags::DispatchMessageWhenWaitingForUnboundedSyncReply)) 92 92 return ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC; 93 93 return ShouldDispatchWhenWaitingForSyncReply::No; … … 97 97 { 98 98 if (isSyncMessage) 99 *buffer() |= SyncMessage;99 messageFlags().add(MessageFlags::SyncMessage); 100 100 else 101 *buffer() &= ~SyncMessage;101 messageFlags().remove(MessageFlags::SyncMessage); 102 102 } 103 103 … … 106 106 switch (shouldDispatchWhenWaitingForSyncReply) { 107 107 case ShouldDispatchWhenWaitingForSyncReply::No: 108 *buffer() &= ~(DispatchMessageWhenWaitingForSyncReply | DispatchMessageWhenWaitingForUnboundedSyncReply); 108 messageFlags().remove(MessageFlags::DispatchMessageWhenWaitingForSyncReply); 109 messageFlags().remove(MessageFlags::DispatchMessageWhenWaitingForUnboundedSyncReply); 109 110 break; 110 111 case ShouldDispatchWhenWaitingForSyncReply::Yes: 111 *buffer() |= DispatchMessageWhenWaitingForSyncReply;112 *buffer() &= ~DispatchMessageWhenWaitingForUnboundedSyncReply;112 messageFlags().add(MessageFlags::DispatchMessageWhenWaitingForSyncReply); 113 messageFlags().remove(MessageFlags::DispatchMessageWhenWaitingForUnboundedSyncReply); 113 114 break; 114 115 case ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC: 115 *buffer() |= DispatchMessageWhenWaitingForUnboundedSyncReply;116 *buffer() &= ~DispatchMessageWhenWaitingForSyncReply;116 messageFlags().remove(MessageFlags::DispatchMessageWhenWaitingForSyncReply); 117 messageFlags().add(MessageFlags::DispatchMessageWhenWaitingForUnboundedSyncReply); 117 118 break; 118 119 } … … 121 122 void Encoder::setFullySynchronousModeForTesting() 122 123 { 123 *buffer() |= UseFullySynchronousModeForTesting;124 messageFlags().add(MessageFlags::UseFullySynchronousModeForTesting); 124 125 } 125 126 … … 173 174 } 174 175 176 OptionSet<MessageFlags>& Encoder::messageFlags() 177 { 178 // FIXME: We should probably pass an OptionSet<MessageFlags> into the Encoder constructor instead of encoding defaultMessageFlags then using this to change it later. 179 static_assert(sizeof(OptionSet<MessageFlags>::StorageType) == 1, "Encoder uses the first byte of the buffer for message flags."); 180 return *reinterpret_cast<OptionSet<MessageFlags>*>(buffer()); 181 } 182 183 const OptionSet<MessageFlags>& Encoder::messageFlags() const 184 { 185 return *reinterpret_cast<OptionSet<MessageFlags>*>(buffer()); 186 } 187 175 188 uint8_t* Encoder::grow(size_t alignment, size_t size) 176 189 { -
trunk/Source/WebKit/Platform/IPC/Encoder.h
r261672 r262032 36 36 37 37 class DataReference; 38 enum class ShouldDispatchWhenWaitingForSyncReply;38 enum class MessageFlags : uint8_t; 39 39 enum class MessageName : uint16_t; 40 enum class ShouldDispatchWhenWaitingForSyncReply : uint8_t; 40 41 41 42 class Encoder final { … … 117 118 118 119 void encodeHeader(); 120 const OptionSet<MessageFlags>& messageFlags() const; 121 OptionSet<MessageFlags>& messageFlags(); 119 122 120 123 MessageName m_messageName; -
trunk/Source/WebKit/Platform/IPC/MessageFlags.h
r247868 r262032 24 24 */ 25 25 26 #ifndef MessageFlags_h 27 #define MessageFlags_h 26 #pragma once 28 27 29 28 namespace IPC { 30 29 31 enum MessageFlags{30 enum class MessageFlags : uint8_t { 32 31 SyncMessage = 1 << 0, 33 32 DispatchMessageWhenWaitingForSyncReply = 1 << 1, … … 36 35 }; 37 36 38 enum class ShouldDispatchWhenWaitingForSyncReply { No, Yes, YesDuringUnboundedIPC }; 37 enum class ShouldDispatchWhenWaitingForSyncReply : uint8_t { 38 No, 39 Yes, 40 YesDuringUnboundedIPC, 41 }; 39 42 40 43 } // namespace IPC 41 42 #endif // MessageFlags_h
Note: See TracChangeset
for help on using the changeset viewer.