-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Use move semantics for SharedMemory::Handle #12995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use move semantics for SharedMemory::Handle #12995
Conversation
|
EWS run on previous version of this PR (hash 95eab95) Details
|
95eab95 to
07f99b2
Compare
|
EWS run on previous version of this PR (hash 07f99b2) Details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't SharedMemory::Handle essentially just an integer (or 2 with the size)? If so, it doesn't seem like there would be much benefit to moving it around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch started when I asked @kkinnunen-apple about what the behavior of SharedMemory::map was supposed to be with regards to the handle passed in. The behavior was not consistent between the different backend implementations, Win, Unix, Cocoa. I found this out when enabling GPU Process on PlayStation where the Unix variant of SharedMemory::createHandle asserted but the Windows one was fine.
So @kkinnunen-apple expressed a plan to refactor SharedMemory::map to take a Handle&& but wasn't available to work on it till later. Since I was broken I took a stab at this. I THINK I replicated their plan but I'll let them chime in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 This is more about transferring ownership when optimizing copies. Seems fine.
07f99b2 to
e098478
Compare
|
EWS run on previous version of this PR (hash e098478) Details
|
kkinnunen-apple
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start! Still a bit of work to do, though! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to remove the "mutable" from " m_handle;" declarations above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this indicates a contagiousness of the change:
All the types that contain SharedMemoryHandle must now support move semantics also.
So before on Cocoa, SharedMemory::map did not mutate the handle. This meant that the ShareableBitmapHandle handle here would stay intact and operational after ShareableBitmap::create(). Now, after your change, the m_handle is moved away and the ShareableBitmapHandle is rendered inoperable.
It is unknown if any code relied on the ShareableBitmapHandle staying operable.
Thus to prove correctness, the approach would be to first make ShareableBitmapHandle movable, land that, and then continue with this patch.
RefPtr<ShareableBitmap> ShareableBitmap::create(const ShareableBitmapHandle& handle, SharedMemory::Protection protection)
->
RefPtr<ShareableBitmap> ShareableBitmap::create(ShareableBitmapHandle&& handle, SharedMemory::Protection protection)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lacks WTFMove (the compiler will tell you this, though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here StreamServerConnectionBuffer::Handle is a function where the author already thought that handles have to have move semantics as the consumption operation, and thus already declared Handle as && so you don't need to do the same thing as with ShareableBitmap/ShareableResource. 😉
e098478 to
d953dee
Compare
|
EWS run on previous version of this PR (hash d953dee) Details |
d953dee to
ab14f05
Compare
|
EWS run on previous version of this PR (hash ab14f05) Details |
ab14f05 to
aada203
Compare
|
EWS run on previous version of this PR (hash aada203) Details
|
aada203 to
c52ac16
Compare
|
EWS run on previous version of this PR (hash c52ac16) Details
|
c52ac16 to
b987200
Compare
|
EWS run on previous version of this PR (hash b987200) Details
|
b987200 to
9f11c7c
Compare
|
EWS run on previous version of this PR (hash 9f11c7c) Details
|
9f11c7c to
0af1cec
Compare
|
EWS run on previous version of this PR (hash 0af1cec) Details
|
0af1cec to
85b409b
Compare
|
EWS run on previous version of this PR (hash 85b409b) Details
|
85b409b to
1b27815
Compare
|
EWS run on current version of this PR (hash 1b27815) Details
|
|
EWS run on current version of this PR (hash 1b27815) Details
|
https://bugs.webkit.org/show_bug.cgi?id=255745 Reviewed by Kimmo Kinnunen. Use move semantics to signify ownership of the `SharedMemory::Handle`. * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp: * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h: * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h: * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp: * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp: * Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.cpp: * Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.h: * Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h: * Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm: * Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp: * Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.h: * Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp: * Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h: * Source/WebKit/Platform/IPC/SharedBufferReference.cpp: * Source/WebKit/Platform/IPC/StreamServerConnectionBuffer.h: * Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp: * Source/WebKit/Platform/SharedMemory.h: * Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp: * Source/WebKit/Platform/unix/SharedMemoryUnix.cpp: * Source/WebKit/Platform/win/SharedMemoryWin.cpp: * Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: * Source/WebKit/Shared/ShareableBitmap.cpp: * Source/WebKit/Shared/ShareableResource.cpp: * Source/WebKit/Shared/WebCompiledContentRuleListData.cpp: * Source/WebKit/Shared/WebCoreArgumentCoders.cpp: * Source/WebKit/Shared/WebHitTestResultData.cpp: * Source/WebKit/Shared/WebHitTestResultData.h: * Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm: * Source/WebKit/UIProcess/mac/WebPageProxyMac.mm: * Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp: * Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp: * Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp: * Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: * Source/WebKit/WebProcess/GPU/webrtc/RemoteVideoFrameObjectHeapProxyProcessor.cpp: * Source/WebKit/WebProcess/GPU/webrtc/RemoteVideoFrameObjectHeapProxyProcessor.h: * Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp: * Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp: * Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h: * Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp: * Source/WebKit/WebProcess/Storage/WebSWClientConnection.h: * Source/WebKit/WebProcess/Storage/WebSWOriginTable.cpp: * Source/WebKit/WebProcess/Storage/WebSWOriginTable.h: * Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp: * Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.cpp: * Source/WebKit/WebProcess/WebPage/VisitedLinkTableController.h: * Source/WebKit/WebProcess/WebPage/WebPage.cpp: * Source/WebKit/WebProcess/WebPage/WebPage.h: Canonical link: https://commits.webkit.org/263809@main
1b27815 to
a6579e4
Compare
|
Committed 263809@main (a6579e4): https://commits.webkit.org/263809@main Reviewed commits have been landed. Closing PR #12995 and removing active labels. |
🧪 style
a6579e4
1b27815