WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
43535
Add shared memory abstraction
https://bugs.webkit.org/show_bug.cgi?id=43535
Summary
Add shared memory abstraction
Anders Carlsson
Reported
2010-08-04 20:15:48 PDT
Add shared memory abstraction
Attachments
Patch
(17.34 KB, patch)
2010-08-04 20:41 PDT
,
Anders Carlsson
aroben
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Anders Carlsson
Comment 1
2010-08-04 20:30:05 PDT
<
rdar://problem/8275295
>
Anders Carlsson
Comment 2
2010-08-04 20:41:50 PDT
Created
attachment 63538
[details]
Patch
WebKit Review Bot
Comment 3
2010-08-04 20:43:31 PDT
Attachment 63538
[details]
did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebKit2/Platform/SharedMemory.h:34: Code inside a namespace should not be indented. [whitespace/indent] [4] WebKit2/Platform/win/SharedMemoryWin.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] WebKit2/Platform/mac/SharedMemoryMac.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 3 in 6 files If any of these errors are false positives, please file a bug against check-webkit-style.
Adam Roben (:aroben)
Comment 4
2010-08-05 06:26:54 PDT
Comment on
attachment 63538
[details]
Patch
> +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)); > + const_cast<Handle*>(this)->m_port = MACH_PORT_NULL; > +}
Making m_port mutable seems preferable.
> +bool SharedMemory::Handle::decode(CoreIPC::ArgumentDecoder& decoder, Handle& handle) > +{ > + ASSERT(!handle.m_port); > + ASSERT(!handle.m_size); > + > + > + uint64_t size;
Extra newline here.
> +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 = (void*)address;
Is the cast really needed? A C++ cast would be nicer if so.
> +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 = (void*)mappedAddress;
Ditto.
> +SharedMemory::~SharedMemory() > +{ > + if (!m_data) > + return; > + > + kern_return_t kr = mach_vm_deallocate(mach_task_self(), (vm_address_t)m_data, round_page(m_size));
C++ cast would be better.
> +bool SharedMemory::createHandle(Handle& handle, Protection protection) > +{ > + ASSERT(!handle.m_port); > + ASSERT(!handle.m_size); > + > + mach_vm_address_t address = (vm_address_t)m_data;
Here, too!
> +unsigned SharedMemory::systemPageSize() > +{ > + static unsigned pageSize = 0; > + > + if (!pageSize) { > + SYSTEM_INFO systemInfo; > + ::GetSystemInfo(&systemInfo); > + pageSize = systemInfo.dwPageSize; > + } > + > + return pageSize; > +}
Thanks!
> +++ b/WebKit2/win/WebKit2.vcproj > @@ -1364,6 +1364,10 @@ > RelativePath="..\Platform\WorkItem.h" > > > </File> > + <File > + RelativePath="..\Platform\SharedMemory.h" > + > > + </File>
VS wants you to use tabs. Copying-and-pasting an existing <File> element is usually the best way to go. r=me
Darin Adler
Comment 5
2010-08-05 10:56:45 PDT
Comment on
attachment 63538
[details]
Patch
> +#include <wtf/Noncopyable.h> > +#include <wtf/PassRefPtr.h> > +#include <wtf/RefCounted.h>
No need to include Noncopyable if you include RefCounted.
Anders Carlsson
Comment 6
2010-08-05 11:03:22 PDT
Committed
r64765
: <
http://trac.webkit.org/changeset/64765
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug