Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 20dee432499d1fd7fa1abcaf3f3a408989a68a95
https://github.com/WebKit/WebKit/commit/20dee432499d1fd7fa1abcaf3f3a408989a68a95
Author: Nitin Mahendru <[email protected]>
Date: 2024-06-20 (Thu, 20 Jun 2024)
Changed paths:
M Source/WebCore/PAL/pal/PALSwift.h
M Source/WebCore/PAL/pal/PALSwift/CryptoKitShim.swift
M Source/WebCore/crypto/cocoa/CryptoAlgorithmAESGCMMac.cpp
M Source/WebCore/crypto/cocoa/CryptoAlgorithmAESKWMac.cpp
M Source/WebCore/crypto/cocoa/CryptoAlgorithmECDHMac.cpp
M Source/WebCore/crypto/cocoa/CryptoAlgorithmECDSAMac.cpp
M Source/WebCore/crypto/cocoa/CryptoAlgorithmEd25519Cocoa.cpp
M Source/WebCore/crypto/cocoa/CryptoAlgorithmHKDFMac.cpp
M Source/WebCore/crypto/cocoa/CryptoAlgorithmX25519Cocoa.cpp
M Source/WebCore/crypto/cocoa/CryptoKeyECMac.cpp
Log Message:
-----------
Avoid copying for return values from swift
https://bugs.webkit.org/show_bug.cgi?id=275619
rdar://129772363
Reviewed by David Kilzer.
In the existing Swift-Cpp interop interface, when C++ tries to extract values
out of swift structs, it generates a Copy as swift structs are value types.
Even if we declare the same structure in C++ and construct it on swift side
with std::optional in it, and then get the value on C++ side, it still
generates a copy. That's because
`Cpp.makeOptional` that is being removed here cannot take an rvalue
reference(no support in swift).
With the current interop features, the best solution for now is to remove
optionals and return an empty vector in error scenarios.
This should be a reasonable mitigation as the hot path "should" be success in
which case the vector returned actually holds a useful value.
In errors, yes, an empty vector will be returned(adding std::optional was a
solution for that problem) but that seems to add extra copies which we
would like to avoid if possible.
* Source/WebCore/PAL/pal/PALSwift.h:
(Cpp::makeOptional): Deleted.
* Source/WebCore/PAL/pal/PALSwift/CryptoKitShim.swift:
(AesKw.wrap(_:using:)):
(AesKw.unwrap(_:using:)):
(ECImportReturnValue.errorCode):
(ECKey.importX963Pub(_:curve:)):
(ECKey.exportX963Pub):
(ECKey.importCompressedPub(_:curve:)):
(ECKey.importX963Private(_:curve:)):
(ECKey.exportX963Private):
(ECKey.sign(_:hashFunction:)):
(ECKey.deriveBits(_:)):
(AesGcmReturnValue.cipherText): Deleted.
(AesGcmReturnValue.errorCode): Deleted.
(AesKwReturnValue.errorCode): Deleted.
(AesKwReturnValue.result): Deleted.
(ECReturnValue.errorCode): Deleted.
(ECReturnValue.signature): Deleted.
(ECReturnValue.keyBytes): Deleted.
(ECReturnValue.key): Deleted.
(EdReturnValue.errorCode): Deleted.
(EdReturnValue.signature): Deleted.
(EdReturnValue.keyBytes): Deleted.
(HKDFReturnValue.errorCode): Deleted.
(HKDFReturnValue.key): Deleted.
* Source/WebCore/crypto/cocoa/CryptoAlgorithmAESGCMMac.cpp:
(WebCore::encryptCryptoKitAESGCM):
* Source/WebCore/crypto/cocoa/CryptoAlgorithmAESKWMac.cpp:
(WebCore::wrapKeyAESKWCryptoKit):
(WebCore::unwrapKeyAESKWCryptoKit):
* Source/WebCore/crypto/cocoa/CryptoAlgorithmECDHMac.cpp:
(WebCore::platformDeriveBitsCC):
(WebCore::platformDeriveBitsCryptoKit):
* Source/WebCore/crypto/cocoa/CryptoAlgorithmECDSAMac.cpp:
(WebCore::signECDSACryptoKit):
(WebCore::verifyECDSACryptoKit):
* Source/WebCore/crypto/cocoa/CryptoAlgorithmEd25519Cocoa.cpp:
(WebCore::signEd25519CryptoKit):
(WebCore::verifyEd25519CryptoKit):
* Source/WebCore/crypto/cocoa/CryptoAlgorithmHKDFMac.cpp:
(WebCore::platformDeriveBitsCryptoKit):
* Source/WebCore/crypto/cocoa/CryptoAlgorithmX25519Cocoa.cpp:
(WebCore::deriveBitsCryptoKit):
* Source/WebCore/crypto/cocoa/CryptoKeyECMac.cpp:
(WebCore::CryptoKeyEC::platformImportRaw):
(WebCore::CryptoKeyEC::platformExportRaw const):
(WebCore::CryptoKeyEC::platformImportJWKPrivate):
(WebCore::CryptoKeyEC::platformAddFieldElements const):
(WebCore::CryptoKeyEC::platformImportSpki):
(WebCore::CryptoKeyEC::platformExportSpki const):
(WebCore::CryptoKeyEC::platformImportPkcs8):
(WebCore::CryptoKeyEC::platformExportPkcs8 const):
Canonical link: https://commits.webkit.org/280218@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes