Skip to content
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 Markable instead of std::optional when storing UUIDs in structs #9433

Conversation

achristensen07
Copy link
Contributor

@achristensen07 achristensen07 commented Feb 1, 2023

4c52b06

Use Markable instead of std::optional when storing UUIDs in structs
https://bugs.webkit.org/show_bug.cgi?id=251485
rdar://104902597

Reviewed by Yusuke Suzuki.

This removes unnecessary and unused padding bytes, decreasing memory use.

* Source/WTF/wtf/UUID.h:
(WTF::UUID::MarkableTraits::isEmptyValue):
(WTF::UUID::MarkableTraits::emptyValue):
* Source/WebCore/Modules/push-api/PushSubscriptionIdentifier.h:
* Source/WebKit/NetworkProcess/NetworkSession.h:
* Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::decode):
* Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h:
* Source/WebKit/Platform/IPC/DaemonCoders.h:
* Source/WebKit/Shared/WebPushDaemonConnectionConfiguration.h:
* Source/WebKit/Shared/WebPushDaemonConnectionConfiguration.serialization.in:
* Source/WebKit/UIProcess/Extensions/WebExtensionControllerConfiguration.h:
(WebKit::WebExtensionControllerConfiguration::identifier const):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
(WebKit::WebsiteDataStoreConfiguration::identifier const):
* Source/WebKit/webpushd/PushClientConnection.h:
(WebPushD::ClientConnection::dataStoreIdentifier const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:

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

b2b2f97

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe   πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ›  gtk   πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac   πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1   πŸ§ͺ api-gtk
  πŸ›  πŸ§ͺ jsc βœ… πŸ›  tv   πŸ§ͺ mac-wk2 βœ… πŸ›  jsc-armv7
βœ… πŸ›  πŸ§ͺ jsc-arm64   πŸ›  tv-sim   πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ jsc-armv7-tests
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress βœ… πŸ›  jsc-mips
βœ… πŸ›  πŸ§ͺ merge   πŸ›  watch-sim βœ… πŸ§ͺ jsc-mips-tests

@achristensen07 achristensen07 self-assigned this Feb 1, 2023
@achristensen07 achristensen07 added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label Feb 1, 2023
@@ -117,7 +117,7 @@ std::optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters
if (!sessionID)
return std::nullopt;

std::optional<std::optional<UUID>> dataStoreIdentifier;
std::optional<Markable<UUID>> dataStoreIdentifier;
Copy link
Member

Choose a reason for hiding this comment

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

We can just decode it into std::optional, and then we can assign it to markable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is more correct. I really ought to just make it NetworkSessionCreationParameters.serialization.in which would generate this, but that should probably be a separate PR.

@@ -50,7 +51,7 @@ class WebExtensionControllerConfiguration : public API::ObjectImpl<API::Object::
explicit WebExtensionControllerConfiguration(IsPersistent);
explicit WebExtensionControllerConfiguration(const UUID&);

std::optional<UUID> identifier() const { return m_identifier; }
Markable<UUID> identifier() const { return m_identifier; }
Copy link
Member

Choose a reason for hiding this comment

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

You can continue returning std::optional if it is better since Markable <-> std::optional conversion can happen implicitly. So, I would recommend using std::optional usually, and using Markable only when we store it to the member.

@@ -59,7 +60,7 @@ class WebsiteDataStoreConfiguration : public API::ObjectImpl<API::Object::Type::
Ref<WebsiteDataStoreConfiguration> copy() const;

bool isPersistent() const { return m_isPersistent == IsPersistent::Yes; }
std::optional<UUID> identifier() const { return m_identifier; }
Markable<UUID> identifier() const { return m_identifier; }
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

@@ -66,7 +66,7 @@ class ClientConnection : public RefCounted<ClientConnection>, public CanMakeWeak
bool hostAppHasPushInjectEntitlement();

const String& pushPartitionString() const { return m_pushPartitionString; }
std::optional<UUID> dataStoreIdentifier() const { return m_dataStoreIdentifier; }
Markable<UUID> dataStoreIdentifier() const { return m_dataStoreIdentifier; }
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

@@ -529,7 +529,7 @@ async function disableShowNotifications()
TestWebKitAPI::Util::run(&ready);
}

const std::optional<UUID>& dataStoreIdentifier() { return m_dataStoreIdentifier; }
const Markable<UUID>& dataStoreIdentifier() { return m_dataStoreIdentifier; }
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

@achristensen07 achristensen07 force-pushed the eng/Use-Markable-instead-of-stdoptional-when-storing-UUIDs-in-structs branch from 12c32e8 to b2b2f97 Compare February 1, 2023 07:09
@achristensen07 achristensen07 added the merge-queue Applied to send a pull request to merge-queue label Feb 1, 2023
https://bugs.webkit.org/show_bug.cgi?id=251485
rdar://104902597

Reviewed by Yusuke Suzuki.

This removes unnecessary and unused padding bytes, decreasing memory use.

* Source/WTF/wtf/UUID.h:
(WTF::UUID::MarkableTraits::isEmptyValue):
(WTF::UUID::MarkableTraits::emptyValue):
* Source/WebCore/Modules/push-api/PushSubscriptionIdentifier.h:
* Source/WebKit/NetworkProcess/NetworkSession.h:
* Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::decode):
* Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h:
* Source/WebKit/Platform/IPC/DaemonCoders.h:
* Source/WebKit/Shared/WebPushDaemonConnectionConfiguration.h:
* Source/WebKit/Shared/WebPushDaemonConnectionConfiguration.serialization.in:
* Source/WebKit/UIProcess/Extensions/WebExtensionControllerConfiguration.h:
(WebKit::WebExtensionControllerConfiguration::identifier const):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
(WebKit::WebsiteDataStoreConfiguration::identifier const):
* Source/WebKit/webpushd/PushClientConnection.h:
(WebPushD::ClientConnection::dataStoreIdentifier const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:

Canonical link: https://commits.webkit.org/259665@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Use-Markable-instead-of-stdoptional-when-storing-UUIDs-in-structs branch from b2b2f97 to 4c52b06 Compare February 1, 2023 08:21
@webkit-commit-queue
Copy link
Collaborator

Committed 259665@main (4c52b06): https://commits.webkit.org/259665@main

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

@webkit-commit-queue webkit-commit-queue merged commit 4c52b06 into WebKit:main Feb 1, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).
Projects
None yet
4 participants