Changeset 158890 in webkit


Ignore:
Timestamp:
Nov 7, 2013 5:54:28 PM (10 years ago)
Author:
andersca@apple.com
Message:

Get rid of the out-of-line memory attachment type
https://bugs.webkit.org/show_bug.cgi?id=124023

Reviewed by Andreas Kling.

We're only using out-of-line memory for when the message body is too big, so
isolate that code in Connection and get rid of the out of line attachment type.

  • Platform/CoreIPC/Attachment.cpp:

(CoreIPC::Attachment::Attachment):

  • Platform/CoreIPC/Attachment.h:

(CoreIPC::Attachment::port):
(CoreIPC::Attachment::disposition):

  • Platform/CoreIPC/mac/ConnectionMac.cpp:

(CoreIPC::Connection::sendOutgoingMessage):
(CoreIPC::createMessageDecoder):

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r158889 r158890  
     12013-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
    1202013-11-07  Simon Fraser  <simon.fraser@apple.com>
    221
  • trunk/Source/WebKit2/Platform/CoreIPC/Attachment.cpp

    r141619 r158890  
    4040Attachment::Attachment(mach_port_name_t port, mach_msg_type_name_t disposition)
    4141    : m_type(MachPortType)
     42    , m_port(port)
     43    , m_disposition(disposition)
    4244{
    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;
    5445}
    5546
  • trunk/Source/WebKit2/Platform/CoreIPC/Attachment.h

    r141619 r158890  
    4545#if OS(DARWIN)
    4646        MachPortType,
    47         MachOOLMemoryType,
    4847#elif USE(UNIX_DOMAIN_SOCKETS)
    4948        SocketType,
     
    5453#if OS(DARWIN)
    5554    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);
    5755#elif USE(UNIX_DOMAIN_SOCKETS)
    5856    Attachment(int fileDescriptor, size_t);
     
    6664
    6765    // 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; }
    7068
    71     // MachOOLMemoryType
    72     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; }
    7669#elif USE(UNIX_DOMAIN_SOCKETS)
    7770    size_t size() const { return m_size; }
     
    9083
    9184#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;
    10487#elif USE(UNIX_DOMAIN_SOCKETS)
    10588    int m_fileDescriptor;
  • trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp

    r157894 r158890  
    202202        if (type == Attachment::MachPortType)
    203203            numberOfPortDescriptors++;
    204         else if (type == Attachment::MachOOLMemoryType)
    205             numberOfOOLMemoryDescriptors++;
    206204    }
    207205   
     
    213211        messageBodyIsOOL = true;
    214212
    215         attachments.append(Attachment(encoder->buffer(), encoder->bufferSize(), MACH_MSG_VIRTUAL_COPY, false));
    216213        numberOfOOLMemoryDescriptors++;
    217214        messageSize = machMessageSize(0, numberOfPortDescriptors, numberOfOOLMemoryDescriptors);
     
    221218
    222219    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);
    224221    header->msgh_size = messageSize;
    225222    header->msgh_remote_port = m_sendPort;
     
    232229
    233230    if (isComplex) {
     231        header->msgh_bits |= MACH_MSGH_BITS_COMPLEX;
     232
    234233        mach_msg_body_t* body = reinterpret_cast<mach_msg_body_t*>(header + 1);
    235234        body->msgh_descriptor_count = numberOfPortDescriptors + numberOfOOLMemoryDescriptors;
    236 
    237235        uint8_t* descriptorData = reinterpret_cast<uint8_t*>(body + 1);
     236
    238237        for (size_t i = 0; i < attachments.size(); ++i) {
    239238            Attachment attachment = attachments[i];
     
    248247                descriptorData += sizeof(mach_msg_port_descriptor_t);
    249248                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;
    259249            default:
    260250                ASSERT_NOT_REACHED();
    261251            }
     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);
    262264        }
    263265
     
    327329            descriptorData += sizeof(mach_msg_port_descriptor_t);
    328330            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;
    333331        default:
    334332            ASSERT(false && "Unhandled descriptor type");
     
    339337        mach_msg_descriptor_t* descriptor = reinterpret_cast<mach_msg_descriptor_t*>(descriptorData);
    340338        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;
    346342
    347343        auto decoder = std::make_unique<MessageDecoder>(DataReference(messageBody, messageBodySize), std::move(attachments));
    348344
    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);
    350346
    351347        return decoder;
Note: See TracChangeset for help on using the changeset viewer.