Title: [150079] trunk/Source/WebKit2
Revision
150079
Author
jocelyn.turco...@digia.com
Date
2013-05-14 10:55:42 -0700 (Tue, 14 May 2013)

Log Message

[Win] REGRESSION(r149944): mmap is not available on Windows
https://bugs.webkit.org/show_bug.cgi?id=116015

Reviewed by Anders Carlsson.

Use fastAlloc/fastFree for platforms other than OS(DARWIN) where
using mmap is not necessary and maybe not available.

* Platform/CoreIPC/ArgumentEncoder.cpp:
(CoreIPC::allocBuffer):
(CoreIPC::freeBuffer):
(CoreIPC::ArgumentEncoder::~ArgumentEncoder):
(CoreIPC::ArgumentEncoder::grow):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (150078 => 150079)


--- trunk/Source/WebKit2/ChangeLog	2013-05-14 17:55:27 UTC (rev 150078)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-14 17:55:42 UTC (rev 150079)
@@ -1,3 +1,19 @@
+2013-05-14  Jocelyn Turcotte  <jocelyn.turco...@digia.com>
+
+        [Win] REGRESSION(r149944): mmap is not available on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=116015
+
+        Reviewed by Anders Carlsson.
+
+        Use fastAlloc/fastFree for platforms other than OS(DARWIN) where
+        using mmap is not necessary and maybe not available.
+
+        * Platform/CoreIPC/ArgumentEncoder.cpp:
+        (CoreIPC::allocBuffer):
+        (CoreIPC::freeBuffer):
+        (CoreIPC::ArgumentEncoder::~ArgumentEncoder):
+        (CoreIPC::ArgumentEncoder::grow):
+
 2013-05-14  Zan Dobersek  <zdober...@igalia.com>
 
         [GTK] Move generated ColorData.cpp, WebKitFontFamilyNames.(cpp|h) build targets into libPlatform

Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp (150078 => 150079)


--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp	2013-05-14 17:55:27 UTC (rev 150078)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp	2013-05-14 17:55:42 UTC (rev 150079)
@@ -29,10 +29,32 @@
 #include "DataReference.h"
 #include <algorithm>
 #include <stdio.h>
+
+#if OS(DARWIN)
 #include <sys/mman.h>
+#endif
 
 namespace CoreIPC {
 
+static inline void* allocBuffer(size_t size)
+{
+#if OS(DARWIN)
+    return mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+#else
+    return fastMalloc(size);
+#endif
+}
+
+static inline void freeBuffer(void* addr, size_t size)
+{
+#if OS(DARWIN)
+    munmap(addr, size);
+#else
+    UNUSED_PARAM(size);
+    fastFree(addr);
+#endif
+}
+
 PassOwnPtr<ArgumentEncoder> ArgumentEncoder::create()
 {
     return adoptPtr(new ArgumentEncoder);
@@ -49,7 +71,7 @@
 ArgumentEncoder::~ArgumentEncoder()
 {
     if (m_buffer != m_inlineBuffer)
-        munmap(m_buffer, m_bufferCapacity);
+        freeBuffer(m_buffer, m_bufferCapacity);
 
 #if !USE(UNIX_DOMAIN_SOCKETS)
     // FIXME: We need to dispose of the attachments in cases of failure.
@@ -73,14 +95,14 @@
         while (newCapacity < alignedSize + size)
             newCapacity *= 2;
 
-        uint8_t* newBuffer = static_cast<uint8_t*>(mmap(0, newCapacity, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0));
+        uint8_t* newBuffer = static_cast<uint8_t*>(allocBuffer(newCapacity));
         if (!newBuffer)
             CRASH();
 
         memcpy(newBuffer, m_buffer, m_bufferSize);
 
         if (m_buffer != m_inlineBuffer)
-            munmap(m_buffer, m_bufferCapacity);
+            freeBuffer(m_buffer, m_bufferCapacity);
 
         m_buffer = newBuffer;
         m_bufferCapacity = newCapacity;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to