Introduce V8<GeneratedCallbackFunction>::InvokeAndCatch() [chromium/src : main]

0 views
Skip to first unread message

Andrey Kosyakov (Gerrit)

unread,
Dec 11, 2025, 6:48:26 PM (3 days ago) Dec 11
to Nate Chapin, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
Attention needed from Nate Chapin

Andrey Kosyakov voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ibc0df892f2248c7cd6ec915b291acf581c208b35
Gerrit-Change-Number: 7253204
Gerrit-PatchSet: 2
Gerrit-Owner: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Comment-Date: Thu, 11 Dec 2025 23:48:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Chapin (Gerrit)

unread,
Dec 11, 2025, 6:55:17 PM (3 days ago) Dec 11
to Andrey Kosyakov, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
Attention needed from Andrey Kosyakov

Nate Chapin voted and added 2 comments

Votes added by Nate Chapin

Code-Review+1

2 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Nate Chapin . unresolved

For thoroughness, would you mind posting an example of the generated code?

File third_party/blink/renderer/bindings/scripts/bind_gen/callback_function.py
Line 492, Patchset 2 (Latest): assert cg_context.callback_function
Nate Chapin . unresolved

Why is this in the middle, instead of at the top?

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ibc0df892f2248c7cd6ec915b291acf581c208b35
Gerrit-Change-Number: 7253204
Gerrit-PatchSet: 2
Gerrit-Owner: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Comment-Date: Thu, 11 Dec 2025 23:55:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrey Kosyakov (Gerrit)

unread,
Dec 11, 2025, 9:24:05 PM (3 days ago) Dec 11
to Nate Chapin, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org

Andrey Kosyakov voted and added 2 comments

Votes added by Andrey Kosyakov

Commit-Queue+1

2 comments

Patchset-level comments
File-level comment, Patchset 2:
Nate Chapin . resolved

For thoroughness, would you mind posting an example of the generated code?

Andrey Kosyakov

Done (in the CL description)

File third_party/blink/renderer/bindings/scripts/bind_gen/callback_function.py
Line 492, Patchset 2: assert cg_context.callback_function
Nate Chapin . resolved

Why is this in the middle, instead of at the top?

Andrey Kosyakov

Because that's where a similar `if` in the code that I used as reference :-) Moved it to the top.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ibc0df892f2248c7cd6ec915b291acf581c208b35
    Gerrit-Change-Number: 7253204
    Gerrit-PatchSet: 6
    Gerrit-Owner: Andrey Kosyakov <ca...@chromium.org>
    Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
    Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-Comment-Date: Fri, 12 Dec 2025 02:23:52 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Nate Chapin <jap...@chromium.org>
    satisfied_requirement
    open
    diffy

    Andrey Kosyakov (Gerrit)

    unread,
    Dec 11, 2025, 10:26:35 PM (3 days ago) Dec 11
    to Nate Chapin, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org

    Andrey Kosyakov voted Commit-Queue+2

    Commit-Queue+2
    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ibc0df892f2248c7cd6ec915b291acf581c208b35
    Gerrit-Change-Number: 7253204
    Gerrit-PatchSet: 6
    Gerrit-Owner: Andrey Kosyakov <ca...@chromium.org>
    Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
    Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-Comment-Date: Fri, 12 Dec 2025 03:26:23 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Chromium LUCI CQ (Gerrit)

    unread,
    Dec 11, 2025, 11:07:37 PM (3 days ago) Dec 11
    to Andrey Kosyakov, Nate Chapin, AyeAye, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org

    Chromium LUCI CQ submitted the change with unreviewed changes

    Unreviewed changes

    2 is the latest approved patch-set.
    The change was submitted with unreviewed changes in the following files:

    ```
    The name of the file: third_party/blink/renderer/bindings/scripts/bind_gen/callback_function.py
    Insertions: 2, Deletions: 3.

    @@ -463,6 +463,7 @@
    def make_invoke_and_catch_function(cg_context, function_name,
    invoke_function_name):
    assert isinstance(cg_context, CodeGenContext)
    + assert cg_context.callback_function

    T = TextNode
    F = FormatNode
    @@ -489,8 +490,6 @@
    class_name=cg_context.class_name)
    func_decl = func_def.make_decl(nodiscard=True)

    - assert cg_context.callback_function
    -
    body = func_def.body
    body.extend([
    T("v8::TryCatch try_catch(GetIsolate());"),
    @@ -499,7 +498,7 @@
    api_func_name=invoke_function_name,
    arg_names=", ".join(arg_names)),
    CxxLikelyIfNode(cond="result.IsJust()",
    - attribute=None,
    + attribute="[[likely]]",
    body=T("return base::ok({});".format(
    "" if is_void else "result.FromJust()"))),
    T("return base::unexpected(ScriptValue(GetIsolate(), try_catch.Exception()));"
    ```

    Change information

    Commit message:
    Introduce V8<GeneratedCallbackFunction>::InvokeAndCatch()

    ... to reduce boilerplate for callers that need to retrieve potential
    exceptions to pass them further.

    Example generated method:

    ```
    base::expected<ScriptValue, ScriptValue> V8Mapper::InvokeAndCatch(
    bindings::V8ValueOrScriptWrappableAdapter arg0_receiver,
    const ScriptValue& arg1_element,
    uint64_t arg2_index) {
    v8::TryCatch try_catch(GetIsolate());

    auto result = Invoke(arg0_receiver, arg1_element, arg2_index);
    if (result.IsJust()) [[likely]] {
    return base::ok(result.FromJust());
    }
    return base::unexpected(ScriptValue(GetIsolate(),
    try_catch.Exception()));
    }
    ```
    Bug: 462010740
    Change-Id: Ibc0df892f2248c7cd6ec915b291acf581c208b35
    Reviewed-by: Nate Chapin <jap...@chromium.org>
    Commit-Queue: Andrey Kosyakov <ca...@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1557828}
    Files:
    • M third_party/blink/renderer/bindings/scripts/bind_gen/callback_function.py
    • M third_party/blink/renderer/core/dom/observable.cc
    Change size: L
    Delta: 2 files changed, 131 insertions(+), 153 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Nate Chapin
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ibc0df892f2248c7cd6ec915b291acf581c208b35
    Gerrit-Change-Number: 7253204
    Gerrit-PatchSet: 7
    Gerrit-Owner: Andrey Kosyakov <ca...@chromium.org>
    Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
    Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages