Changeset 137328 in webkit
- Timestamp:
- Dec 11, 2012 9:41:27 AM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r137318 r137328 1 2012-12-11 Andreas Kling <akling@apple.com> 2 3 CoreIPC: ArgumentEncoder should have an inline buffer. 4 <http://webkit.org/b/104622> 5 6 Reviewed by Anders Carlsson. 7 8 Add a 4K inline buffer to CoreIPC::ArgumentEncoder to avoid malloc/free churn. 9 It was dominating the transient allocations graph in Instruments. 10 11 * Platform/CoreIPC/ArgumentEncoder.cpp: 12 (CoreIPC::ArgumentEncoder::ArgumentEncoder): 13 (CoreIPC::ArgumentEncoder::grow): 14 * Platform/CoreIPC/ArgumentEncoder.h: 15 (CoreIPC::ArgumentEncoder::buffer): 16 (ArgumentEncoder): 17 (CoreIPC::ArgumentEncoder::usesInlineBuffer): 18 1 19 2012-12-11 Mike West <mkwst@chromium.org> 2 20 -
trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp
r131990 r137328 40 40 ArgumentEncoder::ArgumentEncoder() 41 41 : m_buffer(0) 42 , m_bufferPointer(0)43 42 , m_bufferSize(0) 44 , m_bufferCapacity( 0)43 , m_bufferCapacity(inlineBufferSize) 45 44 { 46 45 } … … 69 68 if (alignedSize + size > m_bufferCapacity) { 70 69 size_t newCapacity = std::max(alignedSize + size, std::max(static_cast<size_t>(32), m_bufferCapacity + m_bufferCapacity / 4 + 1)); 71 // Use system malloc / realloc instead of fastMalloc due to72 // fastMalloc using MADV_FREE_REUSABLE which doesn't work with73 // mach messages with OOL message and MACH_MSG_VIRTUAL_COPY.74 // System malloc also calls madvise(MADV_FREE_REUSABLE) but after first75 // checking via madvise(CAN_REUSE) that it will succeed. Should this76 // behavior change we'll need to revisit this.77 if (!m_buffer)78 m_buffer = static_cast<uint8_t*>(malloc(newCapacity));79 else80 m_buffer = static_cast<uint8_t*>(realloc(m_buffer, newCapacity));81 70 82 if (!m_buffer) 83 CRASH(); 71 if (newCapacity > inlineBufferSize) { 72 // Use system malloc / realloc instead of fastMalloc due to 73 // fastMalloc using MADV_FREE_REUSABLE which doesn't work with 74 // mach messages with OOL message and MACH_MSG_VIRTUAL_COPY. 75 // System malloc also calls madvise(MADV_FREE_REUSABLE) but after first 76 // checking via madvise(CAN_REUSE) that it will succeed. Should this 77 // behavior change we'll need to revisit this. 78 if (!m_buffer) 79 m_buffer = static_cast<uint8_t*>(malloc(newCapacity)); 80 else 81 m_buffer = static_cast<uint8_t*>(realloc(m_buffer, newCapacity)); 82 83 if (!m_buffer) 84 CRASH(); 85 86 if (usesInlineBuffer()) 87 memcpy(m_buffer, m_inlineBuffer, m_bufferCapacity); 88 } 84 89 85 90 m_bufferCapacity = newCapacity; … … 87 92 88 93 m_bufferSize = alignedSize + size; 89 m_bufferPointer = m_buffer + alignedSize + size; 90 91 return m_buffer + alignedSize; 94 return buffer() + alignedSize; 92 95 } 93 96 -
trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h
r132169 r137328 99 99 } 100 100 101 uint8_t* buffer() const { returnm_buffer; }101 uint8_t* buffer() { return usesInlineBuffer() ? m_inlineBuffer : m_buffer; } 102 102 size_t bufferSize() const { return m_bufferSize; } 103 103 … … 109 109 110 110 private: 111 static const size_t inlineBufferSize = 4096; 112 bool usesInlineBuffer() const { return m_bufferCapacity <= inlineBufferSize; } 111 113 uint8_t* grow(unsigned alignment, size_t size); 112 114 113 115 uint8_t* m_buffer; 114 uint8_t* m_bufferPointer;115 116 116 117 size_t m_bufferSize; … … 118 119 119 120 Vector<Attachment> m_attachments; 121 122 uint8_t m_inlineBuffer[inlineBufferSize]; 120 123 }; 121 124
Note: See TracChangeset
for help on using the changeset viewer.