Changeset 158890 in webkit
- Timestamp:
- Nov 7, 2013 5:54:28 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r158889 r158890 1 2013-11-07 Anders Carlsson <andersca@apple.com> 2 3 Get rid of the out-of-line memory attachment type 4 https://bugs.webkit.org/show_bug.cgi?id=124023 5 6 Reviewed by Andreas Kling. 7 8 We're only using out-of-line memory for when the message body is too big, so 9 isolate that code in Connection and get rid of the out of line attachment type. 10 11 * Platform/CoreIPC/Attachment.cpp: 12 (CoreIPC::Attachment::Attachment): 13 * Platform/CoreIPC/Attachment.h: 14 (CoreIPC::Attachment::port): 15 (CoreIPC::Attachment::disposition): 16 * Platform/CoreIPC/mac/ConnectionMac.cpp: 17 (CoreIPC::Connection::sendOutgoingMessage): 18 (CoreIPC::createMessageDecoder): 19 1 20 2013-11-07 Simon Fraser <simon.fraser@apple.com> 2 21 -
trunk/Source/WebKit2/Platform/CoreIPC/Attachment.cpp
r141619 r158890 40 40 Attachment::Attachment(mach_port_name_t port, mach_msg_type_name_t disposition) 41 41 : m_type(MachPortType) 42 , m_port(port) 43 , m_disposition(disposition) 42 44 { 43 m_port.port = port;44 m_port.disposition = disposition;45 }46 47 Attachment::Attachment(void* address, mach_msg_size_t size, mach_msg_copy_options_t copyOptions, bool deallocate)48 : m_type(MachOOLMemoryType)49 {50 m_oolMemory.address = address;51 m_oolMemory.size = size;52 m_oolMemory.copyOptions = copyOptions;53 m_oolMemory.deallocate = deallocate;54 45 } 55 46 -
trunk/Source/WebKit2/Platform/CoreIPC/Attachment.h
r141619 r158890 45 45 #if OS(DARWIN) 46 46 MachPortType, 47 MachOOLMemoryType,48 47 #elif USE(UNIX_DOMAIN_SOCKETS) 49 48 SocketType, … … 54 53 #if OS(DARWIN) 55 54 Attachment(mach_port_name_t port, mach_msg_type_name_t disposition); 56 Attachment(void* address, mach_msg_size_t size, mach_msg_copy_options_t copyOptions, bool deallocate);57 55 #elif USE(UNIX_DOMAIN_SOCKETS) 58 56 Attachment(int fileDescriptor, size_t); … … 66 64 67 65 // MachPortType 68 mach_port_name_t port() const { ASSERT(m_type == MachPortType); return m_port.port; }69 mach_msg_type_name_t disposition() const { ASSERT(m_type == MachPortType); return m_port.disposition; }66 mach_port_name_t port() const { return m_port; } 67 mach_msg_type_name_t disposition() const { return m_disposition; } 70 68 71 // MachOOLMemoryType72 void* address() const { ASSERT(m_type == MachOOLMemoryType); return m_oolMemory.address; }73 mach_msg_size_t size() const { ASSERT(m_type == MachOOLMemoryType); return m_oolMemory.size; }74 mach_msg_copy_options_t copyOptions() const { ASSERT(m_type == MachOOLMemoryType); return m_oolMemory.copyOptions; }75 bool deallocate() const { ASSERT(m_type == MachOOLMemoryType); return m_oolMemory.deallocate; }76 69 #elif USE(UNIX_DOMAIN_SOCKETS) 77 70 size_t size() const { return m_size; } … … 90 83 91 84 #if OS(DARWIN) 92 union { 93 struct { 94 mach_port_name_t port; 95 mach_msg_type_name_t disposition; 96 } m_port; 97 struct { 98 void* address; 99 mach_msg_size_t size; 100 mach_msg_copy_options_t copyOptions; 101 bool deallocate; 102 } m_oolMemory; 103 }; 85 mach_port_name_t m_port; 86 mach_msg_type_name_t m_disposition; 104 87 #elif USE(UNIX_DOMAIN_SOCKETS) 105 88 int m_fileDescriptor; -
trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp
r157894 r158890 202 202 if (type == Attachment::MachPortType) 203 203 numberOfPortDescriptors++; 204 else if (type == Attachment::MachOOLMemoryType)205 numberOfOOLMemoryDescriptors++;206 204 } 207 205 … … 213 211 messageBodyIsOOL = true; 214 212 215 attachments.append(Attachment(encoder->buffer(), encoder->bufferSize(), MACH_MSG_VIRTUAL_COPY, false));216 213 numberOfOOLMemoryDescriptors++; 217 214 messageSize = machMessageSize(0, numberOfPortDescriptors, numberOfOOLMemoryDescriptors); … … 221 218 222 219 mach_msg_header_t* header = reinterpret_cast<mach_msg_header_t*>(&buffer); 223 header->msgh_bits = isComplex ? MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND | MACH_MSGH_BITS_COMPLEX, 0) :MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);220 header->msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0); 224 221 header->msgh_size = messageSize; 225 222 header->msgh_remote_port = m_sendPort; … … 232 229 233 230 if (isComplex) { 231 header->msgh_bits |= MACH_MSGH_BITS_COMPLEX; 232 234 233 mach_msg_body_t* body = reinterpret_cast<mach_msg_body_t*>(header + 1); 235 234 body->msgh_descriptor_count = numberOfPortDescriptors + numberOfOOLMemoryDescriptors; 236 237 235 uint8_t* descriptorData = reinterpret_cast<uint8_t*>(body + 1); 236 238 237 for (size_t i = 0; i < attachments.size(); ++i) { 239 238 Attachment attachment = attachments[i]; … … 248 247 descriptorData += sizeof(mach_msg_port_descriptor_t); 249 248 break; 250 case Attachment::MachOOLMemoryType:251 descriptor->out_of_line.address = attachment.address();252 descriptor->out_of_line.size = attachment.size();253 descriptor->out_of_line.copy = attachment.copyOptions();254 descriptor->out_of_line.deallocate = attachment.deallocate();255 descriptor->out_of_line.type = MACH_MSG_OOL_DESCRIPTOR;256 257 descriptorData += sizeof(mach_msg_ool_descriptor_t);258 break;259 249 default: 260 250 ASSERT_NOT_REACHED(); 261 251 } 252 } 253 254 if (messageBodyIsOOL) { 255 mach_msg_descriptor_t* descriptor = reinterpret_cast<mach_msg_descriptor_t*>(descriptorData); 256 257 descriptor->out_of_line.address = encoder->buffer(); 258 descriptor->out_of_line.size = encoder->bufferSize(); 259 descriptor->out_of_line.copy = MACH_MSG_VIRTUAL_COPY; 260 descriptor->out_of_line.deallocate = false; 261 descriptor->out_of_line.type = MACH_MSG_OOL_DESCRIPTOR; 262 263 descriptorData += sizeof(mach_msg_ool_descriptor_t); 262 264 } 263 265 … … 327 329 descriptorData += sizeof(mach_msg_port_descriptor_t); 328 330 break; 329 case MACH_MSG_OOL_DESCRIPTOR:330 attachments[numDescriptors - i - 1] = Attachment(descriptor->out_of_line.address, descriptor->out_of_line.size, descriptor->out_of_line.copy, descriptor->out_of_line.deallocate);331 descriptorData += sizeof(mach_msg_ool_descriptor_t);332 break;333 331 default: 334 332 ASSERT(false && "Unhandled descriptor type"); … … 339 337 mach_msg_descriptor_t* descriptor = reinterpret_cast<mach_msg_descriptor_t*>(descriptorData); 340 338 ASSERT(descriptor->type.type == MACH_MSG_OOL_DESCRIPTOR); 341 Attachment messageBodyAttachment(descriptor->out_of_line.address, descriptor->out_of_line.size, 342 descriptor->out_of_line.copy, descriptor->out_of_line.deallocate); 343 344 uint8_t* messageBody = static_cast<uint8_t*>(messageBodyAttachment.address()); 345 size_t messageBodySize = messageBodyAttachment.size(); 339 340 uint8_t* messageBody = static_cast<uint8_t*>(descriptor->out_of_line.address); 341 size_t messageBodySize = descriptor->out_of_line.size; 346 342 347 343 auto decoder = std::make_unique<MessageDecoder>(DataReference(messageBody, messageBodySize), std::move(attachments)); 348 344 349 vm_deallocate(mach_task_self(), reinterpret_cast<vm_address_t>( messageBodyAttachment.address()), messageBodyAttachment.size());345 vm_deallocate(mach_task_self(), reinterpret_cast<vm_address_t>(descriptor->out_of_line.address), descriptor->out_of_line.size); 350 346 351 347 return decoder;
Note: See TracChangeset
for help on using the changeset viewer.