Introduce UnionReturnProxy to make returning a union cheaper [chromium/src : main]

0 views
Skip to first unread message

Andrey Kosyakov (Gerrit)

unread,
Mar 5, 2026, 6:44:10 PM (2 days ago) Mar 5
to Nate Chapin, Michael Lippautz, Francois Pierre Doray, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Francois Pierre Doray, Michael Lippautz and Nate Chapin

Andrey Kosyakov added 1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Andrey Kosyakov . resolved

Nate, Michael and François, WDYT?
This is a proof-of-concept that shows a fairly simple approach to avoid a heap allocation for calls that may return more than one member types. It essentially performs an eager `ToV8()` conversion on the creation side rather than deferring it to the generated bindings layer, bypassing not only the heap alloc but also extra dispatch by member type.
The downsides include that we have to pass ScriptState (as it's needed for the conversion) and, at least currently, can't do this for methods with optional params (due to generated code explicitly expecting V8Union... return type, but we may be able to fix it).

Open in Gerrit

Related details

Attention is currently required from:
  • Francois Pierre Doray
  • Michael Lippautz
  • 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: Ibe4187281525a35508cc4cdb0b4119abdf4d7a90
Gerrit-Change-Number: 7640317
Gerrit-PatchSet: 2
Gerrit-Owner: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Francois Pierre Doray <fdo...@chromium.org>
Gerrit-Reviewer: Michael Lippautz <mlip...@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: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Francois Pierre Doray <fdo...@chromium.org>
Gerrit-Comment-Date: Thu, 05 Mar 2026 23:43:58 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Chapin (Gerrit)

unread,
Mar 5, 2026, 6:50:21 PM (2 days ago) Mar 5
to Andrey Kosyakov, Michael Lippautz, Francois Pierre Doray, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Andrey Kosyakov, Francois Pierre Doray and Michael Lippautz

Nate Chapin voted and added 2 comments

Votes added by Nate Chapin

Code-Review+1

2 comments

Commit Message
Line 7, Patchset 2 (Latest):Introduce UnionReturnProxy to make returning a union cheaper
Nate Chapin . unresolved

Breadcrumb for future readers: Maybe spell out that this is for cases where we are actually "returning a union" (i.e., there are muliple types we might return), and cases that always return the same type can return that type directly?

File third_party/blink/renderer/bindings/scripts/bind_gen/union.py
Line 1132, Patchset 2 (Latest): TextNode("using Ret = bindings::UnionReturnProxy<{}>;".format(
Nate Chapin . unresolved

Nit: spell this out? `ReturnProxy`? `OptimizedReturnProxy`?

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
  • Francois Pierre Doray
  • Michael Lippautz
    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: Ibe4187281525a35508cc4cdb0b4119abdf4d7a90
    Gerrit-Change-Number: 7640317
    Gerrit-PatchSet: 2
    Gerrit-Owner: Andrey Kosyakov <ca...@chromium.org>
    Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
    Gerrit-Reviewer: Francois Pierre Doray <fdo...@chromium.org>
    Gerrit-Reviewer: Michael Lippautz <mlip...@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-Attention: Michael Lippautz <mlip...@chromium.org>
    Gerrit-Attention: Francois Pierre Doray <fdo...@chromium.org>
    Gerrit-Comment-Date: Thu, 05 Mar 2026 23:50:11 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrey Kosyakov (Gerrit)

    unread,
    Mar 5, 2026, 7:14:37 PM (2 days ago) Mar 5
    to Nate Chapin, Michael Lippautz, Francois Pierre Doray, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
    Attention needed from Francois Pierre Doray and Michael Lippautz

    Andrey Kosyakov voted and added 2 comments

    Votes added by Andrey Kosyakov

    Commit-Queue+1

    2 comments

    Commit Message
    Line 7, Patchset 2:Introduce UnionReturnProxy to make returning a union cheaper
    Nate Chapin . resolved

    Breadcrumb for future readers: Maybe spell out that this is for cases where we are actually "returning a union" (i.e., there are muliple types we might return), and cases that always return the same type can return that type directly?

    Andrey Kosyakov

    Done

    File third_party/blink/renderer/bindings/scripts/bind_gen/union.py
    Line 1132, Patchset 2: TextNode("using Ret = bindings::UnionReturnProxy<{}>;".format(
    Nate Chapin . resolved

    Nit: spell this out? `ReturnProxy`? `OptimizedReturnProxy`?

    Andrey Kosyakov

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Francois Pierre Doray
    • Michael Lippautz
    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: Ibe4187281525a35508cc4cdb0b4119abdf4d7a90
      Gerrit-Change-Number: 7640317
      Gerrit-PatchSet: 4
      Gerrit-Owner: Andrey Kosyakov <ca...@chromium.org>
      Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
      Gerrit-Reviewer: Francois Pierre Doray <fdo...@chromium.org>
      Gerrit-Reviewer: Michael Lippautz <mlip...@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: Michael Lippautz <mlip...@chromium.org>
      Gerrit-Attention: Francois Pierre Doray <fdo...@chromium.org>
      Gerrit-Comment-Date: Fri, 06 Mar 2026 00:14:25 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Nate Chapin <jap...@chromium.org>
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages