Changeset 185824 in webkit
- Timestamp:
- Jun 22, 2015, 5:06:46 AM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
Platform/IPC/unix/ConnectionUnix.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r185822 r185824 1 2015-06-22 Zan Dobersek <zdobersek@igalia.com> 2 3 [WK2] ConnectionUnix should use FastMalloc to allocate on-heap resources 4 https://bugs.webkit.org/show_bug.cgi?id=146143 5 6 Reviewed by Carlos Garcia Campos. 7 8 IPC handling in Unix-specific IPC::Connection implementation should use 9 FastMalloc to allocate on-heap resources, instead of allocating via the 10 system allocator. 11 12 The AttachmentInfo class is marked as allocatable through FastMalloc. 13 That way it can be allocated through FastMalloc while still handled 14 through std::unique_ptr<>. 15 16 The char[] arrays in readBytesFromSocket() and Connection::sendOutgoingMessage() 17 are now handled through a MallocPtr<> object. 18 19 In Connection::sendOutgoingMessage(), both the AttachmentInfo[] and char[] 20 arrays are now only allocated if there are actual attachments contained 21 in the message. The code that's conditioned with a non-empty attachments 22 Vector is now also grouped together, in a single branch. 23 24 * Platform/IPC/unix/ConnectionUnix.cpp: 25 (IPC::readBytesFromSocket): 26 (IPC::Connection::sendOutgoingMessage): 27 1 28 2015-06-22 Gyuyoung Kim <gyuyoung.kim@webkit.org> 2 29 -
trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
r183746 r185824 95 95 96 96 class AttachmentInfo { 97 WTF_MAKE_FAST_ALLOCATED; 97 98 public: 98 99 AttachmentInfo() … … 275 276 276 277 message.msg_controllen = CMSG_SPACE(sizeof(int) * attachmentMaxAmount); 277 auto attachmentDescriptorBuffer = std::make_unique<char[]>(message.msg_controllen);278 memset(attachmentDescriptorBuffer.get(), 0, message.msg_controllen);278 MallocPtr<char> attachmentDescriptorBuffer = MallocPtr<char>::malloc(sizeof(char) * message.msg_controllen); 279 memset(attachmentDescriptorBuffer.get(), 0, sizeof(char) * message.msg_controllen); 279 280 message.msg_control = attachmentDescriptorBuffer.get(); 280 281 … … 439 440 iov[0].iov_len = sizeof(messageInfo); 440 441 441 auto attachmentInfo = std::make_unique<AttachmentInfo[]>(attachments.size()); 442 443 size_t attachmentFDBufferLength = 0; 444 if (!attachments.isEmpty()) { 445 for (size_t i = 0; i < attachments.size(); ++i) { 446 if (attachments[i].fileDescriptor() != -1) 447 attachmentFDBufferLength++; 448 } 449 } 450 auto attachmentFDBuffer = std::make_unique<char[]>(CMSG_SPACE(sizeof(int) * attachmentFDBufferLength)); 442 std::unique_ptr<AttachmentInfo[]> attachmentInfo; 443 MallocPtr<char> attachmentFDBuffer; 451 444 452 445 if (!attachments.isEmpty()) { 453 446 int* fdPtr = 0; 454 447 448 size_t attachmentFDBufferLength = std::count_if(attachments.begin(), attachments.end(), 449 [](const Attachment& attachment) { 450 return attachment.fileDescriptor() != -1; 451 }); 452 455 453 if (attachmentFDBufferLength) { 454 attachmentFDBuffer = MallocPtr<char>::malloc(sizeof(char) * CMSG_SPACE(sizeof(int) * attachmentFDBufferLength)); 455 456 456 message.msg_control = attachmentFDBuffer.get(); 457 457 message.msg_controllen = CMSG_SPACE(sizeof(int) * attachmentFDBufferLength); … … 466 466 } 467 467 468 attachmentInfo = std::make_unique<AttachmentInfo[]>(attachments.size()); 468 469 int fdIndex = 0; 469 470 for (size_t i = 0; i < attachments.size(); ++i) {
Note:
See TracChangeset
for help on using the changeset viewer.