[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andersca at apple.com
andersca at apple.com
Wed Dec 22 11:44:52 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 2e05645905d7fe17a4ffddc30f3e1dd88fb8e06e
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Aug 5 18:03:02 2010 +0000
Add shared memory abstraction
https://bugs.webkit.org/show_bug.cgi?id=43535
<rdar://problem/8275295>
Reviewed by Adam Roben.
* Platform/SharedMemory.h: Added.
(WebKit::SharedMemory::):
(WebKit::SharedMemory::size):
Return the size, in bytes, of the shared memory object.
(WebKit::SharedMemory::data):
Return a pointer to the shared memory object.
* Platform/mac/SharedMemoryMac.cpp: Added.
(WebKit::SharedMemory::Handle):
A shared memory handle, which can be passed in a CoreIPC Connection.
(WebKit::SharedMemory::create):
Allocate the shared memory.
(WebKit::SharedMemory::~SharedMemory):
Deallocate the shared memory.
(WebKit::SharedMemory::createHandle):
Create a mach port and pass it to the handle.
(WebKit::SharedMemory::systemPageSize):
Return the system page size, in bytes.
* Platform/win/SharedMemoryWin.cpp: Added.
Add stubbed out version.
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:
Add files.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64765 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index c361658..2a58a58 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,42 @@
+2010-08-04 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Adam Roben.
+
+ Add shared memory abstraction
+ https://bugs.webkit.org/show_bug.cgi?id=43535
+ <rdar://problem/8275295>
+
+ * Platform/SharedMemory.h: Added.
+ (WebKit::SharedMemory::):
+ (WebKit::SharedMemory::size):
+ Return the size, in bytes, of the shared memory object.
+
+ (WebKit::SharedMemory::data):
+ Return a pointer to the shared memory object.
+
+ * Platform/mac/SharedMemoryMac.cpp: Added.
+ (WebKit::SharedMemory::Handle):
+ A shared memory handle, which can be passed in a CoreIPC Connection.
+
+ (WebKit::SharedMemory::create):
+ Allocate the shared memory.
+
+ (WebKit::SharedMemory::~SharedMemory):
+ Deallocate the shared memory.
+
+ (WebKit::SharedMemory::createHandle):
+ Create a mach port and pass it to the handle.
+
+ (WebKit::SharedMemory::systemPageSize):
+ Return the system page size, in bytes.
+
+ * Platform/win/SharedMemoryWin.cpp: Added.
+ Add stubbed out version.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ * win/WebKit2.vcproj:
+ Add files.
+
2010-08-05 Jian Li <jianli at chromium.org>
Reviewed by David Levin.
diff --git a/WebKit2/Platform/SharedMemory.h b/WebKit2/Platform/SharedMemory.h
new file mode 100644
index 0000000..68675fe
--- /dev/null
+++ b/WebKit2/Platform/SharedMemory.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SharedMemory_h
+#define SharedMemory_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+class SharedMemory : public RefCounted<SharedMemory> {
+public:
+ enum Protection {
+ ReadOnly,
+ ReadWrite
+ };
+
+ class Handle : Noncopyable {
+ public:
+ Handle();
+ ~Handle();
+
+ void encode(CoreIPC::ArgumentEncoder&) const;
+ static bool decode(CoreIPC::ArgumentDecoder&, Handle&);
+
+ private:
+ friend class SharedMemory;
+#if PLATFORM(MAC)
+ mutable mach_port_t m_port;
+#endif
+ size_t m_size;
+ };
+
+ // Create a shared memory object with the given size. Will return 0 on failure.
+ static PassRefPtr<SharedMemory> create(size_t);
+
+ // Create a shared memory object from the given handle and the requested protection. Will return 0 on failure.
+ static PassRefPtr<SharedMemory> create(const Handle&, Protection);
+
+ ~SharedMemory();
+
+ bool createHandle(Handle&, Protection);
+
+ size_t size() const { return m_size; }
+ void* data() const { return m_data; }
+
+ // Return the system page size in bytes.
+ static unsigned systemPageSize();
+
+private:
+ size_t m_size;
+ void* m_data;
+};
+
+};
+
+#endif // SharedMemory_h
diff --git a/WebKit2/Platform/mac/SharedMemoryMac.cpp b/WebKit2/Platform/mac/SharedMemoryMac.cpp
new file mode 100644
index 0000000..a0b4d53
--- /dev/null
+++ b/WebKit2/Platform/mac/SharedMemoryMac.cpp
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "SharedMemory.h"
+
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+#include "Arguments.h"
+#include "MachPort.h"
+#include <mach/mach_vm.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+SharedMemory::Handle::Handle()
+ : m_port(MACH_PORT_NULL)
+ , m_size(0)
+{
+}
+
+SharedMemory::Handle::~Handle()
+{
+ if (m_port)
+ mach_port_deallocate(mach_task_self(), m_port);
+}
+
+void SharedMemory::Handle::encode(CoreIPC::ArgumentEncoder& encoder) const
+{
+ ASSERT(m_port);
+ ASSERT(m_size);
+
+ encoder.encodeUInt64(m_size);
+ encoder.encode(CoreIPC::MachPort(m_port, MACH_MSG_TYPE_COPY_SEND));
+ m_port = MACH_PORT_NULL;
+}
+
+bool SharedMemory::Handle::decode(CoreIPC::ArgumentDecoder& decoder, Handle& handle)
+{
+ ASSERT(!handle.m_port);
+ ASSERT(!handle.m_size);
+
+ uint64_t size;
+ if (!decoder.decodeUInt64(size))
+ return false;
+
+ CoreIPC::MachPort machPort;
+ if (!decoder.decode(CoreIPC::Out(machPort)))
+ return false;
+
+ handle.m_size = size;
+ handle.m_port = machPort.port();
+ return true;
+}
+
+static inline void* toPointer(mach_vm_address_t address)
+{
+ return reinterpret_cast<void*>(static_cast<uintptr_t>(address));
+}
+
+static inline mach_vm_address_t toVMAddress(void* pointer)
+{
+ return static_cast<mach_vm_address_t>(reinterpret_cast<uintptr_t>(pointer));
+}
+
+PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
+{
+ mach_vm_address_t address;
+ kern_return_t kr = mach_vm_allocate(mach_task_self(), &address, round_page(size), VM_FLAGS_ANYWHERE);
+ if (kr != KERN_SUCCESS)
+ return 0;
+
+ RefPtr<SharedMemory> sharedMemory(adoptRef(new SharedMemory));
+ sharedMemory->m_size = size;
+ sharedMemory->m_data = toPointer(address);
+
+ return sharedMemory.release();
+}
+
+static inline vm_prot_t machProtection(SharedMemory::Protection protection)
+{
+ switch (protection) {
+ case SharedMemory::ReadOnly:
+ return VM_PROT_READ;
+ case SharedMemory::ReadWrite:
+ return VM_PROT_READ | VM_PROT_WRITE;
+ }
+
+ ASSERT_NOT_REACHED();
+ return VM_PROT_NONE;
+}
+
+PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection)
+{
+ if (!handle.m_port)
+ return 0;
+
+ // Map the memory.
+ vm_prot_t vmProtection = machProtection(protection);
+ mach_vm_address_t mappedAddress;
+ kern_return_t kr = mach_vm_map(mach_task_self(), &mappedAddress, handle.m_size, 0, VM_FLAGS_ANYWHERE, handle.m_port, 0, false, vmProtection, vmProtection, VM_INHERIT_NONE);
+ if (kr != KERN_SUCCESS)
+ return 0;
+
+ RefPtr<SharedMemory> sharedMemory(adoptRef(new SharedMemory));
+ sharedMemory->m_size = handle.m_size;
+ sharedMemory->m_data = toPointer(mappedAddress);
+
+ return sharedMemory.release();
+}
+
+SharedMemory::~SharedMemory()
+{
+ if (!m_data)
+ return;
+
+ kern_return_t kr = mach_vm_deallocate(mach_task_self(), toVMAddress(m_data), round_page(m_size));
+ ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
+}
+
+bool SharedMemory::createHandle(Handle& handle, Protection protection)
+{
+ ASSERT(!handle.m_port);
+ ASSERT(!handle.m_size);
+
+ mach_vm_address_t address = toVMAddress(m_data);
+ memory_object_size_t size = round_page(m_size);
+
+ // Create a mach port that represents the shared memory.
+ mach_port_t port;
+ kern_return_t kr = mach_make_memory_entry_64(mach_task_self(), &size, address, machProtection(protection), &port, MACH_PORT_NULL);
+ if (kr != KERN_SUCCESS)
+ return false;
+
+ handle.m_port = port;
+ handle.m_size = size;
+
+ return true;
+}
+
+unsigned SharedMemory::systemPageSize()
+{
+ return vm_page_size;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/Platform/win/SharedMemoryWin.cpp b/WebKit2/Platform/win/SharedMemoryWin.cpp
new file mode 100644
index 0000000..ab59b95
--- /dev/null
+++ b/WebKit2/Platform/win/SharedMemoryWin.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "SharedMemory.h"
+
+#include "NotImplemented.h"
+
+namespace WebKit {
+
+SharedMemory::Handle::Handle()
+{
+ notImplemented();
+}
+
+SharedMemory::Handle::~Handle()
+{
+ notImplemented();
+}
+
+void SharedMemory::Handle::encode(CoreIPC::ArgumentEncoder& encoder) const
+{
+ notImplemented();
+}
+
+bool SharedMemory::Handle::decode(CoreIPC::ArgumentDecoder& decoder, Handle& handle)
+{
+ notImplemented();
+ return false;
+}
+
+PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
+{
+ notImplemented();
+ return 0;
+}
+
+PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection)
+{
+ notImplemented();
+ return 0;
+}
+
+SharedMemory::~SharedMemory()
+{
+ notImplemented();
+}
+
+bool SharedMemory::createHandle(Handle& handle, Protection protection)
+{
+ notImplemented();
+ return false;
+}
+
+unsigned SharedMemory::systemPageSize()
+{
+ static unsigned pageSize = 0;
+
+ if (!pageSize) {
+ SYSTEM_INFO systemInfo;
+ ::GetSystemInfo(&systemInfo);
+ pageSize = systemInfo.dwPageSize;
+ }
+
+ return pageSize;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index f6266f5..dcca43f 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -41,6 +41,8 @@
1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */; };
1A24B5F211F531E800C38269 /* MachUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24B5F011F531E800C38269 /* MachUtilities.cpp */; };
1A24B5F311F531E800C38269 /* MachUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24B5F111F531E800C38269 /* MachUtilities.h */; };
+ 1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24BED3120894D100FBB059 /* SharedMemory.h */; };
+ 1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */; };
1A30066E1110F4F70031937C /* ResponsivenessTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A30066C1110F4F70031937C /* ResponsivenessTimer.h */; };
1A30EAC6115D7DA30053E937 /* ConnectionMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A30EAC5115D7DA30053E937 /* ConnectionMac.cpp */; };
1A3E736111CC2659007BD539 /* WebPlatformStrategies.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3E735F11CC2659007BD539 /* WebPlatformStrategies.h */; };
@@ -345,6 +347,8 @@
1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPRuntimeUtilities.h; sourceTree = "<group>"; };
1A24B5F011F531E800C38269 /* MachUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MachUtilities.cpp; sourceTree = "<group>"; };
1A24B5F111F531E800C38269 /* MachUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachUtilities.h; sourceTree = "<group>"; };
+ 1A24BED3120894D100FBB059 /* SharedMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedMemory.h; sourceTree = "<group>"; };
+ 1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryMac.cpp; sourceTree = "<group>"; };
1A30066C1110F4F70031937C /* ResponsivenessTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResponsivenessTimer.h; sourceTree = "<group>"; };
1A30EAC5115D7DA30053E937 /* ConnectionMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConnectionMac.cpp; sourceTree = "<group>"; };
1A3E735F11CC2659007BD539 /* WebPlatformStrategies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlatformStrategies.h; sourceTree = "<group>"; };
@@ -775,6 +779,7 @@
1A24B5F111F531E800C38269 /* MachUtilities.h */,
C0E3AA481209E45000A49D01 /* ModuleMac.mm */,
BC0092F5115837A300E0AE2A /* RunLoopMac.mm */,
+ 1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */,
BC0092F6115837A300E0AE2A /* WorkQueueMac.cpp */,
);
path = mac;
@@ -1171,6 +1176,7 @@
BC8780FB1161C2B800CC2768 /* PlatformProcessIdentifier.h */,
BC2E6E771141970C00A63B1E /* RunLoop.cpp */,
BC2E6E781141970C00A63B1E /* RunLoop.h */,
+ 1A24BED3120894D100FBB059 /* SharedMemory.h */,
BC2E6E7C1141970C00A63B1E /* WorkItem.h */,
BC2E6E7D1141970C00A63B1E /* WorkQueue.cpp */,
BC2E6E7E1141970C00A63B1E /* WorkQueue.h */,
@@ -1375,6 +1381,7 @@
C0E3AA7C1209E83C00A49D01 /* Module.h in Headers */,
516A4A59120A1AB500C05B7F /* WKError.h in Headers */,
516A4A5D120A2CCD00C05B7F /* WebError.h in Headers */,
+ 1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1582,6 +1589,7 @@
C0E3AA7A1209E83000A49D01 /* ModuleMac.mm in Sources */,
C0E3AA7B1209E83500A49D01 /* Module.cpp in Sources */,
516A4A5A120A1AB500C05B7F /* WKError.cpp in Sources */,
+ 1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index 14c1b9d..524ecd6 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -1361,9 +1361,14 @@
>
</File>
<File
+ RelativePath="..\Platform\SharedMemory.h"
+ >
+ </File>
+ <File
RelativePath="..\Platform\WorkItem.h"
>
</File>
+ </File>
<File
RelativePath="..\Platform\WorkQueue.cpp"
>
@@ -1384,6 +1389,10 @@
>
</File>
<File
+ RelativePath="..\Platform\win\SharedMemoryWin.cpp"
+ >
+ </File>
+ <File
RelativePath="..\Platform\win\WorkQueueWin.cpp"
>
</File>
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list