Skip to content

Conversation

donny-dont
Copy link
Contributor

@donny-dont donny-dont commented May 8, 2023

5841938

Clean up Win32Handle implementation
https://bugs.webkit.org/show_bug.cgi?id=256498

Reviewed by Fujii Hironori.

Make `Win32Handle` look like `MachSendPort` so it has a similar
interface.

* Source/WTF/wtf/PlatformWin.cmake:
* Source/WTF/wtf/win/MemoryFootprintWin.cpp:
* Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp:
* Source/WTF/wtf/win/Win32Handle.cpp: Added.
* Source/WTF/wtf/win/Win32Handle.h:
* Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
* Source/WebKit/Platform/IPC/Connection.h:
* Source/WebKit/Platform/IPC/win/ArgumentCodersWin.cpp:
* Source/WebKit/Platform/IPC/win/ConnectionWin.cpp:
* Source/WebKit/Platform/IPC/win/IPCSemaphoreWin.cpp:
* Source/WebKit/Platform/win/SharedMemoryWin.cpp:
* Source/WebKit/UIProcess/Launcher/win/ProcessLauncherWin.cpp:

Canonical link: https://commits.webkit.org/263991@main

cef6e5b

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🛠 gtk
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🧪 gtk-wk2
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 tv 🧪 mac-AS-debug-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 🧪 merge ✅ 🛠 watch ✅ 🛠 jsc-mips
✅ 🛠 watch-sim ✅ 🧪 jsc-mips-tests

@donny-dont donny-dont self-assigned this May 8, 2023
@donny-dont donny-dont added the Platform Portability improvements and other general platform improvements not driven directly by site bugs. label May 8, 2023
@donny-dont donny-dont force-pushed the eng/Clean-up-Win32Handle-implementation branch from a729953 to e38e2b0 Compare May 9, 2023 00:07
@donny-dont donny-dont force-pushed the eng/Clean-up-Win32Handle-implementation branch from e38e2b0 to 5ec8245 Compare May 9, 2023 01:10
@donny-dont donny-dont marked this pull request as ready for review May 9, 2023 23:14
@donny-dont donny-dont requested a review from cdumez as a code owner May 9, 2023 23:14
@donny-dont donny-dont requested a review from fujii May 9, 2023 23:14
@fujii
Copy link
Contributor

fujii commented May 10, 2023

I don't know why Win32Handle has to be non-copyable.
std::unique_ptr<T> is non-copyable because its ownership is unique.
std::shared_ptr<T> isn't non-copyable because it can copy.
Win32Handle is actually copyable. So, you can have Win32Handle::duplicate().

@donny-dont
Copy link
Contributor Author

Its more about explicit ownership and being very explicit when you're duplicating a handle which follows along with what is happening in the UnixFileDescriptor implementation.

@donny-dont donny-dont force-pushed the eng/Clean-up-Win32Handle-implementation branch from 5ec8245 to cdc45d2 Compare May 10, 2023 17:09
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all handle like objects should be eventually have the same interface:
Win32Handle, MachSendRight, UnixFileDescriptor.

For adoption tag: I'd prefer the unfication happens in other direction, e.g. removal of the public adoption constructor and tag.

All webkit types seem to use specific adoption constructor function:

  • MachSendRight::adopt
  • adoptRef(T*)
  • others

This means that there is no other precedent to use adopt tag except UnixFileDescriptor.

Instead, I'd propose we have:

  • Win32Handle::adopt
  • UnixFileDescriptor::adopt
  • MachSendRight::adopt

@donny-dont donny-dont force-pushed the eng/Clean-up-Win32Handle-implementation branch from cdc45d2 to e0a1ca3 Compare May 11, 2023 20:15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed. Please remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed. Please remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed. Please remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed. Please remove it. Move this code to copy().

@donny-dont donny-dont force-pushed the eng/Clean-up-Win32Handle-implementation branch from e0a1ca3 to fdfe305 Compare May 11, 2023 22:01
@donny-dont donny-dont force-pushed the eng/Clean-up-Win32Handle-implementation branch from fdfe305 to cef6e5b Compare May 11, 2023 22:10
@donny-dont donny-dont added the merge-queue Applied to send a pull request to merge-queue label May 11, 2023
https://bugs.webkit.org/show_bug.cgi?id=256498

Reviewed by Fujii Hironori.

Make `Win32Handle` look like `MachSendPort` so it has a similar
interface.

* Source/WTF/wtf/PlatformWin.cmake:
* Source/WTF/wtf/win/MemoryFootprintWin.cpp:
* Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp:
* Source/WTF/wtf/win/Win32Handle.cpp: Added.
* Source/WTF/wtf/win/Win32Handle.h:
* Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
* Source/WebKit/Platform/IPC/Connection.h:
* Source/WebKit/Platform/IPC/win/ArgumentCodersWin.cpp:
* Source/WebKit/Platform/IPC/win/ConnectionWin.cpp:
* Source/WebKit/Platform/IPC/win/IPCSemaphoreWin.cpp:
* Source/WebKit/Platform/win/SharedMemoryWin.cpp:
* Source/WebKit/UIProcess/Launcher/win/ProcessLauncherWin.cpp:

Canonical link: https://commits.webkit.org/263991@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Clean-up-Win32Handle-implementation branch from cef6e5b to 5841938 Compare May 11, 2023 23:54
@webkit-commit-queue
Copy link
Collaborator

Committed 263991@main (5841938): https://commits.webkit.org/263991@main

Reviewed commits have been landed. Closing PR #13611 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 5841938 into WebKit:main May 11, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 11, 2023
return INVALID_HANDLE_VALUE;

auto processHandle = ::GetCurrentProcess();
HANDLE duplicate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the call fails, you might have uninitialized value here.. The docs don't say..

Copy link
Contributor

@fujii fujii May 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Portability improvements and other general platform improvements not driven directly by site bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants