Skip to content

[webkitscmpy] List reviewers for pull-request - #14

Closed
JonWBedard wants to merge 1 commit into
WebKit:mainfrom
JonWBedard:eng/reviewers
Closed

JonWBedard wants to merge 1 commit into
WebKit:mainfrom
JonWBedard:eng/reviewers

Conversation

@JonWBedard

Copy link
Copy Markdown
Member

0da8261

[webkitscmpy] List reviewers for pull-request
https://bugs.webkit.org/show_bug.cgi?id=231577
<rdar://problem/84146807 >

Reviewed by NOBODY (OOPS!).

* Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py:
(BitBucket.request): Add state to created pull-reqest.
* Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py:
(GitHub):
(GitHub._users): Vend json representation of user for username.
(GitHub.request): Filter review details, add users endpoint.
* Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
(PullRequest.main): Match both closed and opened pull-requests.
* Scripts/libraries/webkitscmpy/webkitscmpy/pull_request.py:
(PullRequest): Remove state.
(PullRequest.__init__): Add opened flag, reviewers and generator.
(PullRequest.reviewers): List the users who are reviewing this change.
(PullRequest.approvers): List the users who have aproved this change.
(PullRequest.blockers): List the users that are blocking this change from landing.
(PullRequest.opened): Check the pull-request is opened.
(PullRequest.State): Deleted.
* Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py:
(BitBucket.PRGenerator.PullRequest): Set opened flag, specify reviewers.
(BitBucket.PRGenerator.find): Filter by opened flag instead of state.
(BitBucket.PRGenerator.update): Set generator.
(BitBucket.PRGenerator.reviewers): Set reviewer lists.
* Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:
(GitHub.PRGenerator.PullRequest): Set opened flag, pass generator.
(GitHub.PRGenerator.find): Filter by opened flag instead of state.
(GitHub.PRGenerator.update): Set generator and opened flag.
(GitHub.PRGenerator._contributor): Find contributor matching username.
(GitHub.PRGenerator.reviewers): Populate lists of reviewers for a pull-request.
* Scripts/libraries/webkitscmpy/webkitscmpy/remote/scm.py:
(Scm.PRGenerator.find): Filter via opened flag instead of state.
(Scm.PRGenerator.reviewers): Function which populates reviewer lists for a pull-request.
* Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:

https://bugs.webkit.org/show_bug.cgi?id=231577
<rdar://problem/84146807>

Reviewed by NOBODY (OOPS!).

* Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py:
(BitBucket.request): Add state to created pull-reqest.
* Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py:
(GitHub):
(GitHub._users): Vend json representation of user for username.
(GitHub.request): Filter review details, add users endpoint.
* Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
(PullRequest.main): Match both closed and opened pull-requests.
* Scripts/libraries/webkitscmpy/webkitscmpy/pull_request.py:
(PullRequest): Remove state.
(PullRequest.__init__): Add opened flag, reviewers and generator.
(PullRequest.reviewers): List the users who are reviewing this change.
(PullRequest.approvers): List the users who have aproved this change.
(PullRequest.blockers): List the users that are blocking this change from landing.
(PullRequest.opened): Check the pull-request is opened.
(PullRequest.State): Deleted.
* Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py:
(BitBucket.PRGenerator.PullRequest): Set opened flag, specify reviewers.
(BitBucket.PRGenerator.find): Filter by opened flag instead of state.
(BitBucket.PRGenerator.update): Set generator.
(BitBucket.PRGenerator.reviewers): Set reviewer lists.
* Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:
(GitHub.PRGenerator.PullRequest): Set opened flag, pass generator.
(GitHub.PRGenerator.find): Filter by opened flag instead of state.
(GitHub.PRGenerator.update): Set generator and opened flag.
(GitHub.PRGenerator._contributor): Find contributor matching username.
(GitHub.PRGenerator.reviewers): Populate lists of reviewers for a pull-request.
* Scripts/libraries/webkitscmpy/webkitscmpy/remote/scm.py:
(Scm.PRGenerator.find): Filter via opened flag instead of state.
(Scm.PRGenerator.reviewers): Function which populates reviewer lists for a pull-request.
* Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
@JonWBedard JonWBedard self-assigned this Oct 12, 2021
@JonWBedard

Copy link
Copy Markdown
Member Author

@JonWBedard JonWBedard closed this Oct 13, 2021
@JonWBedard
JonWBedard deleted the eng/reviewers branch October 19, 2021 22:03
webkit-early-warning-system pushed a commit to hyjorc1/WebKit that referenced this pull request Nov 19, 2022
…a rejected promise

https://bugs.webkit.org/show_bug.cgi?id=247785
rdar://102325201

Reviewed by Yusuke Suzuki.

Rest parameter should be caught in async function. So, running this
JavaScript program should print "caught".
```
async function f(...[[]]) { }
f().catch(e => print("caught"));
```

V8 (used console.log)
```
$ node input.js
caught
```

GraalJS
```
$ js input.js
caught
```

https://tc39.es/ecma262/#sec-async-function-definitions
...
AsyncFunctionDeclaration[Yield, Await, Default] :
    async [no LineTerminator here] function BindingIdentifier[?Yield, ?Await] ( FormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
    [+Default] async [no LineTerminator here] function ( FormalParameters[~Yield, +Await] ) { AsyncFunctionBody }

AsyncFunctionExpression :
    async [no LineTerminator here] function BindingIdentifier[~Yield, +Await]opt ( FormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
...

According to the spec, it indicates `FormalParameters` is used for Async
Function, where `FormalParameters` can be converted to `FunctionRestParameter`.

https://tc39.es/ecma262/#sec-parameter-lists
...
FormalParameters[Yield, Await] :
    [empty]
    FunctionRestParameter[?Yield, ?Await]
    FormalParameterList[?Yield, ?Await]
    FormalParameterList[?Yield, ?Await] ,
    FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await]
...

And based on RS: EvaluateAsyncFunctionBody, it will invoke the promise.reject
callback function with abrupt value ([[value]] of non-normal completion record).

https://tc39.es/ecma262/#sec-runtime-semantics-evaluateasyncfunctionbody
...
2. Let declResult be Completion(FunctionDeclarationInstantiation(functionObject, argumentsList)).
3. If declResult is an abrupt completion, then
    a. Perform ! Call(promiseCapability.[[Reject]], undefined, « declResult.[[Value]] »).
...

In that case, any non-normal results of evaluating rest parameters should be
caught and passed to the reject callback function.

To resolve this problem, we should allow the emitted RestParameterNode be wrapped
by the catch handler for promise. However, we should remove `m_restParameter` and
emit rest parameter byte code in `initializeDefaultParameterValuesAndSetupFunctionScopeStack`
if we can prove that change has no side effect. In that case, we can only use one
exception handler.

Current fix is to add another exception handler. And move the handler byte codes to
the bottom of code block in order to make other byte codes as much compact as possible.

Input:
```
async function f(arg0, ...[[]]) { }
f();
```

Dumped Byte Codes:
```
...

bb#2
Predecessors: [ WebKit#1 ]
[  20] mov                dst:loc9, src:<JSValue()>(const0)
...

bb#3
Predecessors: [ WebKit#2 ]
[  29] get_rest_length    dst:loc11, numParametersToSkip:1
...

bb#12
Predecessors: [ WebKit#8 WebKit#9 WebKit#10 ]
[ 138] new_func_exp       dst:loc10, scope:loc4, functionDecl:0
...

bb#13
Predecessors: [ ]
[ 170] catch              exception:loc10, thrownValue:loc8
[ 174] jmp                targetLabel:8(->182)
Successors: [ WebKit#15 ]

bb#14
Predecessors: [ WebKit#7 WebKit#11 ]
[ 176] catch              exception:loc10, thrownValue:loc8
[ 180] jmp                targetLabel:2(->182)
Successors: [ WebKit#15 ]

bb#15
Predecessors: [ WebKit#13 WebKit#14 ]
[ 182] mov                dst:loc12, src:Undefined(const1)
...

Exception Handlers:
	 1: { start: [  20] end: [  29] target: [ 170] } synthesized catch
	 2: { start: [  29] end: [ 138] target: [ 176] } synthesized catch
```

* JSTests/stress/catch-rest-parameter.js: Added.
(throwError):
(shouldThrow):
(async f):
(throwError.async f):
(throwError.async let):
(async let):
(x.async f):
(x):
(async shouldThrow):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::initializeDefaultParameterValuesAndSetupFunctionScopeStack):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:

Canonical link: https://commits.webkit.org/256864@main
cdumez pushed a commit to cdumez/WebKit that referenced this pull request Jan 15, 2023
    Fix TypeError in parameter destructuring in async function should be a rejected promise
    https://bugs.webkit.org/show_bug.cgi?id=247785
    rdar://102325201

    Reviewed by Yusuke Suzuki.

    Rest parameter should be caught in async function. So, running this
    JavaScript program should print "caught".
    ```
    async function f(...[[]]) { }
    f().catch(e => print("caught"));
    ```

    V8 (used console.log)
    ```
    $ node input.js
    caught
    ```

    GraalJS
    ```
    $ js input.js
    caught
    ```

    https://tc39.es/ecma262/#sec-async-function-definitions
    ...
    AsyncFunctionDeclaration[Yield, Await, Default] :
        async [no LineTerminator here] function BindingIdentifier[?Yield, ?Await] ( FormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
        [+Default] async [no LineTerminator here] function ( FormalParameters[~Yield, +Await] ) { AsyncFunctionBody }

    AsyncFunctionExpression :
        async [no LineTerminator here] function BindingIdentifier[~Yield, +Await]opt ( FormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
    ...

    According to the spec, it indicates `FormalParameters` is used for Async
    Function, where `FormalParameters` can be converted to `FunctionRestParameter`.

    https://tc39.es/ecma262/#sec-parameter-lists
    ...
    FormalParameters[Yield, Await] :
        [empty]
        FunctionRestParameter[?Yield, ?Await]
        FormalParameterList[?Yield, ?Await]
        FormalParameterList[?Yield, ?Await] ,
        FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await]
    ...

    And based on RS: EvaluateAsyncFunctionBody, it will invoke the promise.reject
    callback function with abrupt value ([[value]] of non-normal completion record).

    https://tc39.es/ecma262/#sec-runtime-semantics-evaluateasyncfunctionbody
    ...
    2. Let declResult be Completion(FunctionDeclarationInstantiation(functionObject, argumentsList)).
    3. If declResult is an abrupt completion, then
        a. Perform ! Call(promiseCapability.[[Reject]], undefined, « declResult.[[Value]] »).
    ...

    In that case, any non-normal results of evaluating rest parameters should be
    caught and passed to the reject callback function.

    To resolve this problem, we should allow the emitted RestParameterNode be wrapped
    by the catch handler for promise. However, we should remove `m_restParameter` and
    emit rest parameter byte code in `initializeDefaultParameterValuesAndSetupFunctionScopeStack`
    if we can prove that change has no side effect. In that case, we can only use one
    exception handler.

    Current fix is to add another exception handler. And move the handler byte codes to
    the bottom of code block in order to make other byte codes as much compact as possible.

    Input:
    ```
    async function f(arg0, ...[[]]) { }
    f();
    ```

    Dumped Byte Codes:
    ```
    ...

    bb#2
    Predecessors: [ WebKit#1 ]
    [  20] mov                dst:loc9, src:<JSValue()>(const0)
    ...

    bb#3
    Predecessors: [ WebKit#2 ]
    [  29] get_rest_length    dst:loc11, numParametersToSkip:1
    ...

    bb#12
    Predecessors: [ WebKit#8 WebKit#9 WebKit#10 ]
    [ 138] new_func_exp       dst:loc10, scope:loc4, functionDecl:0
    ...

    bb#13
    Predecessors: [ ]
    [ 170] catch              exception:loc10, thrownValue:loc8
    [ 174] jmp                targetLabel:8(->182)
    Successors: [ WebKit#15 ]

    bb#14
    Predecessors: [ WebKit#7 WebKit#11 ]
    [ 176] catch              exception:loc10, thrownValue:loc8
    [ 180] jmp                targetLabel:2(->182)
    Successors: [ WebKit#15 ]

    bb#15
    Predecessors: [ WebKit#13 WebKit#14 ]
    [ 182] mov                dst:loc12, src:Undefined(const1)
    ...

    Exception Handlers:
    	 1: { start: [  20] end: [  29] target: [ 170] } synthesized catch
    	 2: { start: [  29] end: [ 138] target: [ 176] } synthesized catch
    ```

    * JSTests/stress/catch-rest-parameter.js: Added.
    (throwError):
    (shouldThrow):
    (async f):
    (throwError.async f):
    (throwError.async let):
    (async let):
    (x.async f):
    (x):
    (async shouldThrow):
    * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
    (JSC::BytecodeGenerator::BytecodeGenerator):
    (JSC::BytecodeGenerator::initializeDefaultParameterValuesAndSetupFunctionScopeStack):
    * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:

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

Canonical link: https://commits.webkit.org/252432.994@safari-7614-branch
webkit-commit-queue pushed a commit to Constellation/WebKit that referenced this pull request Jan 24, 2023
https://bugs.webkit.org/show_bug.cgi?id=251063
rdar://104585575

Reviewed by Mark Lam and Justin Michaud.

This patch enhances CallFrame::dump to support wasm frames in btjs stacktrace.
The example is as follows.

    frame #0: 0x00000001035fca78 JavaScriptCore`JSC::functionBreakpoint(globalObject=0x000000012f410068, callFrame=0x000000016fdfa9d0) at JSDollarVM.cpp:2273:9 [opt]
    frame WebKit#1: 0x000000010ec44204 0x10eccc5dc
    frame WebKit#2: 0x000000010eccc5dc callback#Dwaxn6 [Baseline bc#50](Undefined)
    frame WebKit#3: 0x000000010ec4ca84 wasm-stub [WasmToJS](Wasm::Instance: 0x10d29da40)
    frame WebKit#4: 0x000000010ed0c060 <?>.wasm-function[1] [OMG](Wasm::Instance: 0x10d29da40)
    frame WebKit#5: 0x000000010ed100d0 jsToWasm#CWTx6k [FTL bc#22](Cell[JSModuleEnvironment]: 0x12f524540, Cell[WebAssemblyFunction]: 0x10d06a3a8, 1, 2, 3)
    frame WebKit#6: 0x000000010ec881b0 #D5ymZE [Baseline bc#733](Undefined, Cell[Generator]: 0x12f55c180, 1, Cell[Object]: 0x12f69dfc0, 0, Cell[JSLexicalEnvironment]: 0x12f52cee0)
    frame WebKit#7: 0x000000010ec3c008 asyncFunctionResume#A4ayYg [LLInt bc#49](Undefined, Cell[Generator]: 0x12f55c180, Cell[Object]: 0x12f69dfc0, 0)
    frame WebKit#8: 0x000000010ec3c008 promiseReactionJobWithoutPromise#D0yDF1 [LLInt bc#25](Undefined, Cell[Function]: 0x12f44f3c0, Cell[Object]: 0x12f69dfc0, Cell[Generator]: 0x12f55c180)
    frame WebKit#9: 0x000000010ec80ec0 promiseReactionJob#EdShZz [Baseline bc#74](Undefined, Undefined, Cell[Function]: 0x12f44f3c0, Cell[Object]: 0x12f69dfc0, Cell[Generator]: 0x12f55c180)
    frame WebKit#10: 0x000000010ec3c728
    frame WebKit#11: 0x0000000103137560 JavaScriptCore`JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) [inlined] JSC::JITCode::execute(this=<unavailable>, vm=<unavailable>, protoCallFrame=<unavailable>) at JITCodeInlines.h:42:38 [opt]
    frame WebKit#12: 0x0000000103137524 JavaScriptCore`JSC::Interpreter::executeCall(this=<unavailable>, lexicalGlobalObject=<unavailable>, function=<unavailable>, callData=<unavailable>, thisValue=<unavailable>, args=<unavailable>) at Interpreter.cpp:1093:27 [opt]
    frame WebKit#13: 0x000000010349d6d0 JavaScriptCore`JSC::runJSMicrotask(globalObject=0x000000012f410068, identifier=(m_identifier = 81), job=JSValue @ x22, argument0=JSValue @ x26, argument1=JSValue @ x25, argument2=<unavailable>, argument3=<unavailable>) at JSMicrotask.cpp:98:9 [opt]
    frame WebKit#14: 0x00000001039dfc54 JavaScriptCore`JSC::VM::drainMicrotasks() (.cold.1) at VM.cpp:0:9 [opt]
    frame WebKit#15: 0x00000001035e58a4 JavaScriptCore`JSC::VM::drainMicrotasks() [inlined] JSC::MicrotaskQueue::dequeue(this=<unavailable>) at VM.cpp:0:9 [opt]
    frame WebKit#16: 0x00000001035e5894 JavaScriptCore`JSC::VM::drainMicrotasks(this=0x000000012f000000) at VM.cpp:1255:46 [opt]
    ...

* Source/JavaScriptCore/interpreter/CallFrame.cpp:
(JSC::CallFrame::dump const):

Canonical link: https://commits.webkit.org/259262@main
CGQAQ pushed a commit to CGQAQ/WebKit that referenced this pull request Aug 25, 2023
Wowfunhappy referenced this pull request in Wowfunhappy/WebKit Jun 18, 2026
The backport installed a global NSEvent monitor (+[WKView installEventMonitorOnce]) that intercepted mouse/scroll/key events and dispatched them to WKView, on the belief that layer-tree mirror subviews intercepted hit-testing. That was a MISDIAGNOSIS: WKView hosts the WebContent layer tree as a plain CALayer sublayer of its backing layer (MinimalPageClient enterAcceleratedCompositingMode/setRemoteLayerTreeRootNode, [[m_view layer] addSublayer:]) with ZERO NSView subviews. CALayers don't participate in NSView -hitTest:, so nothing ever intercepted events. Worse, the monitor consumed events before -[NSWindow sendEvent:] (where AppKit activates the window on click), creating the very click-to-activate problem it then re-patched.

Remove the monitor and rely on AppKit's natural responder chain; WKView's own scrollWheel:/keyDown:/mouseDown:/mouseMoved: handlers receive events directly. Keep the -hitTest: override as upstream-equivalent insurance (upstream WebViewImpl::hitTest does the same redirect).

Verified live: main-view links/scroll/typing/right-click; hover (#17) fires :hover on a fresh page AND with the address bar focused; Reader scroll (#39) works via natural routing to the topmost ReaderWKView; and every secondary WKView that relied on the monitor -- uBlock popover (#14/#23), Web Inspector (#16), App Store (#72), Top Sites (#13), Preferences>Extensions (#24) -- stays interactive. No crashes. Retires the #62 event-monitor keystone and supersedes #39's monitor routing. (The DDG-logo black box, a separate #56 IOSurface-backing symptom, is root-caused but not fixed here.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
airspeedswift added a commit to airspeedswift/webkit that referenced this pull request Nov 24, 2026
…to Swift (WebKit#14)

* Add module map entries for the Private Click Measurement headers

WebKit_Internal has no module for
NetworkProcess/PrivateClickMeasurement, so Swift in WebKit cannot name
PCM::ManagerInterface, PrivateClickMeasurementManager, PCM::Database,
PCM::Store, PCM::NetworkLoader or PCM::Client (the last is included by
PrivateClickMeasurementManager.h). Add one submodule per header, in the
form the map already uses.

Mark as SWIFT_UNSAFE the functions whose contract is checked only by
debug ASSERTs or depends on process-global state, which the entries
would otherwise make callable from safe Swift: PCM::Database::create and
interruptAllDatabases, PCM::NetworkLoader::start and
allowTLSCertificateChainForLocalPCMTesting (assigns a process-wide
static RetainPtr with no synchronization),
PCM::initializePCMStorageInDirectory and PCM::doDailyActivityInManager.

PrivateClickMeasurementManager.h no longer includes NetworkProcess.h and
NetworkLoadParameters.h, which neither it nor
PrivateClickMeasurementManager.cpp uses and which would make the
NetworkProcess headers importable through its submodule.

No change to generated code.

* Pass NetworkLoader::Callback one Response

NetworkLoader::Callback was CompletionHandler<void(const String&, const
RefPtr<JSON::Object>&)>. A Swift closure cannot be passed for it,
because a Swift closure can stand in only for a CompletionHandler that
takes at most one argument, by value if it is copyable. Pass the error
description and the JSON object as one NetworkLoader::Response. The five
call sites in PrivateClickMeasurementManager.cpp read the two fields
from the Response.

No change in behavior.

* Take the PrivateClickMeasurement static functions' arguments by value

parseAttributionRequest, parseAttributionRequestQuery,
tokenPublicKeyURL(RegistrableDomain),
tokenSignatureURL(RegistrableDomain), appStoreURLAdamID and
calculateAndUpdateDestinationUnlinkableToken took const references.
A later commit implements the first, third and fourth in Swift as @cxx
@implementation statics, which cannot declare a reference parameter, so
they take URL and RegistrableDomain by value. The last two stay C++
and will hand their argument to a Swift function, so they take it by
value too. parseAttributionRequestQuery, the private helper of the
first, takes its URL by value as well, though nothing needs it: a later
commit deletes it and replaces it with a Swift function.

Callers that passed an lvalue now copy it at the call (once per click or
redirect, not per resource). No change in results.

* Take the Private Click Measurement manager and database arguments by value

Members that a later commit implements in Swift in
PrivateClickMeasurementManager and PCM::Database, the ManagerInterface
members they override and the ManagerProxy overrides took const
references and rvalue references, which a Swift @cxx @implementation
cannot declare. Take their arguments by value:
- handleAttribution, migratePrivateClickMeasurementFromLegacyStorage,
  setTokenPublicKeyURLForTesting, setTokenSignatureURLForTesting,
  setAttributionReportURLsForTesting,
  setPCMFraudPreventionValuesForTesting and
  setPrivateClickMeasurementAppBundleIDForTesting, in ManagerInterface,
  PrivateClickMeasurementManager and ManagerProxy;
- PCM::Database's attributePrivateClickMeasurement and
  clearSentAttribution, and insertPrivateClickMeasurement, which stays
  C++ and takes its argument by value like the other two.
Members with a CompletionHandler, the stores, private helpers and
allowTLSCertificateChainForLocalPCMTesting (which keeps its const&
parameter) are unchanged.

At the call in NetworkSession::handlePrivateClickMeasurementConversion,
firstPartyForCookies and appBundleID are now moved (their last use) in
the lambda, where requestURL is copied, and appBundleID in the redirect
path; requestURL and redirectRequest.firstPartyForCookies() are copied
in the redirect path, where they are const references. PersistentStore
moves sourceSite, destinationSite and applicationBundleIdentifier in its
lambda. Other callers pass rvalues and move as before.

No change in behavior.

* Pass PCM::Store's attribution handlers their results by value

PCM::Store::attributePrivateClickMeasurement's handler took two rvalue
references, std::optional<AttributionSecondsUntilSendData>&& and
DebugInfo&&, which a Swift closure cannot fill in: it takes at most one
argument, and a copyable one by value. Pass them as the two fields of
one PCM::AttributionResult, by value. EphemeralStore and PersistentStore
build it where they called the handler with two arguments, and the
manager's lambda reads its fields. Store.h includes
PrivateClickMeasurementDebugInfo.h, since DebugInfo is now a member.

For the same reason allAttributedPrivateClickMeasurement's handler takes
its Vector<WebCore::PrivateClickMeasurement> by value.

No change in behavior.

* Isolate the values PersistentStore passes to the PCM work queue

PersistentStore::insertPrivateClickMeasurement and
attributePrivateClickMeasurement move a PrivateClickMeasurement and an
AttributionTriggerData into a lambda that runs on the shared work queue.
attributePrivateClickMeasurement already isolates the other values it
captures; neither function isolated these two, so their Strings (and the
RegistrableDomain, nonce and token Strings inside the trigger data)
shared non-atomic StringImpl reference counts between the main thread
and the queue while the caller kept using its own copy.
PrivateClickMeasurement::isolatedCopy() && has the same problem for
m_attributionTriggerData: it moves it without isolating it, and
Manager's firePendingAttributionRequests passes an attribution to
fireConversionRequest, which keeps a copy in a NetworkLoader callback,
then passes the original to clearSentAttribution.

Capture an isolated copy in all three places (insert, attribute,
clearSentAttribution) through file-local isolatedCopy() functions in
PersistentStore.cpp: one for AttributionTriggerData, which has none, and
one for PrivateClickMeasurement that also isolates its trigger data.
WebCore's PrivateClickMeasurement::isolatedCopy() is unchanged.

Values and order are unchanged. Cost: one String copy per shared string
per click, conversion or sent report.

* Add SWIFT_PRIVATE_FILEID to PrivateClickMeasurementManager and PCM::Database

Name the Swift file that implements each class, as GPUProcess.h does, so
that file, and no other, can use its private members (both build
systems turn on ImportNonPublicCxxMembers): the manager's state and the
database's private helpers. A later commit adds both files.
The attribute is an annotation: no change to generated code or callers.
PrivateClickMeasurementManager.h adds the <wtf/SwiftBridging.h> include.

* Build WebKit's Swift helpers for WTF's completion handlers with the WebKit Swift toolchain

WTFCompletionHandler+Extras.swift, which defines CxxCompletionHandler and
the conformances of WTF's completion handler types, is compiled out when
SWIFT_WEBKIT_TOOLCHAIN is defined, so the static analyzer bots, which
build with --swift-conditions=SWIFT_WEBKIT_TOOLCHAIN, skip it. A later
commit adds Swift that replaces C++ and builds its callbacks with
CxxCompletionHandler, so it cannot be compiled out the same way.

Drop !SWIFT_WEBKIT_TOOLCHAIN from the file's condition. Without
SWIFT_WEBKIT_TOOLCHAIN the two conditions are the same, so no generated
code changes.

The file has not been built with SWIFT_WEBKIT_TOOLCHAIN defined; if the
org.webkit.swift toolchain rejects it, the Private Click Measurement
Swift has to be left out of those bots' builds instead.

* Add Private Click Measurement benchmarks

Add TestWebKitAPI benchmarks for Private Click Measurement:
PrivateClickMeasurementBench (WebCore: trigger URL parsing, attribution,
report and token JSON and URLs, token crypto) and
PrivateClickMeasurementStoreBench (the store, manager and database
through the testing SPI). By default each test runs one pass and checks
its checksum; WEBKIT_RUN_BENCHMARKS=1 repeats it and prints the time.

* Implement Private Click Measurement's parsing, database logic and manager in Swift

Implement Private Click Measurement's trigger parsing and validation,
attribution, report and token JSON and URLs, unlinkable and secret token
handling, PCM::Database's logic around its queries, and
PrivateClickMeasurementManager in Swift, and delete the C++ they
replace. The daemon's message dispatch, the manager proxy, the network
loader and the stores are unchanged, apart from three type
aliases in PCM::Store.

C++ keeps the SQL statements; the instance members of
PrivateClickMeasurement and the PCM value types, since Swift cannot
implement a C++ value type's instance members, and three of
PrivateClickMeasurement's static members (those whose logic moved call
a Swift function); the manager members that take a
CompletionHandler&&, which Swift cannot implement; the CryptoKit token
calls, since CryptoKitPrivate does not import into Swift; the manager's
calls through its UniqueRef client, its timer and the network loader;
the creation of its store; and the public key's SHA-256, since Swift cannot name PAL's
CryptoDigest.

Behavior is unchanged, console and log messages included.

Speed: of 22 PrivateClickMeasurementBench benchmarks, 3 are faster (by
4% to 17%) and none is slower beyond noise; the 9
PrivateClickMeasurementStoreBench benchmarks are within noise.

Tests: TestWebKitAPI's PrivateClickMeasurement tests (39) in Debug; none
of the 27 layout tests in http/tests/privateClickMeasurement changes
result; and the benchmarks' checksums against the C++ build.

---------

Co-authored-by: Ben Cohen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant