[L] Change in dart/sdk[main]: [dart2wasm] Remove synthesizing values from nothing

0 views
Skip to first unread message

Martin Kustermann (Gerrit)

unread,
May 12, 2026, 1:58:37 PM (19 hours ago) May 12
to Srujan Gaddam, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Srujan Gaddam

Martin Kustermann voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Srujan Gaddam
Submit Requirements:
  • requirement 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ie30df3bd68553724437607bab3163c98f5467efe
Gerrit-Change-Number: 501061
Gerrit-PatchSet: 17
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Srujan Gaddam <sru...@google.com>
Gerrit-Attention: Srujan Gaddam <sru...@google.com>
Gerrit-Comment-Date: Tue, 12 May 2026 17:58:32 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Srujan Gaddam (Gerrit)

unread,
May 12, 2026, 8:28:34 PM (13 hours ago) May 12
to Martin Kustermann, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Martin Kustermann

Srujan Gaddam voted and added 1 comment

Votes added by Srujan Gaddam

Code-Review+1

1 comment

Patchset-level comments
File-level comment, Patchset 17 (Latest):
Srujan Gaddam . resolved

Thanks for the in-depth commit messages as always!

Open in Gerrit

Related details

Attention is currently required from:
  • Martin Kustermann
Submit Requirements:
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ie30df3bd68553724437607bab3163c98f5467efe
Gerrit-Change-Number: 501061
Gerrit-PatchSet: 17
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Srujan Gaddam <sru...@google.com>
Gerrit-Attention: Martin Kustermann <kuste...@google.com>
Gerrit-Comment-Date: Wed, 13 May 2026 00:28:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Martin Kustermann (Gerrit)

unread,
3:22 AM (6 hours ago) 3:22 AM
to Srujan Gaddam, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart2wasm-t...@google.com, rev...@dartlang.org

Martin Kustermann voted and added 1 comment

Votes added by Martin Kustermann

Commit-Queue+2

1 comment

Patchset-level comments
Martin Kustermann . resolved

Thanks, Srujan!

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ie30df3bd68553724437607bab3163c98f5467efe
Gerrit-Change-Number: 501061
Gerrit-PatchSet: 17
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Srujan Gaddam <sru...@google.com>
Gerrit-Comment-Date: Wed, 13 May 2026 07:22:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

dart-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)

unread,
3:22 AM (6 hours ago) 3:22 AM
to Martin Kustermann, Srujan Gaddam, dart2wasm-t...@google.com, rev...@dartlang.org

dart-...@luci-project-accounts.iam.gserviceaccount.com submitted the change

Change information

Commit message:
[dart2wasm] Remove synthesizing values from nothing

When there's no expression on the stack but we expect something on the
stack, then the code should be unreachable.

Though the current code would just synthesize a value that matches
the expected type (`convertType(voidMarker, <some type>)`). This
is problematic: If we ever used that synthesized value we may
have incorrect program behavior.

Now there were some valid uses where we synthesize values

* A function that has `void` return type but no explicit return
=> Here we should synthesize `null`
* Synthesize `null` in cases where we know it's not going to be used
=> e.g. for CFE desugaring of `a[i] = b` is roughly
`let tmp = b in (let ignored = a.[]=(tmp) in b)`
where we synthesize `null` as `a.[]=(tmp)` result,
`ignored` isn't used.
* ...

With this CL we no longer allow synthesizing a value of a type
out of thin air, instead all the places where this occurs have
to do that explicitly.

There's some impurities around how setters and index setters
are handled today (and even after this CL). Those impurities
start all the way at CFE, which treats setters and index
setters very differently. See the CFE issue [0].

For those we have two choices:

* special case all call sites that require synthesizing
null values
* special case all call sites that require dropping an
auto synthesized null value

This CL now marks instance setter/index-setter methods as
requiring auto-synthesizeing null values on usage sites and
make code that doesn't need them explicitly drop them.

Somewhat related to this change is how we deal with `void`
on the Dart <-> Wasm Import / Wasm Export boundary: When we
call an imported wasm function that has `void` as return
type (meaning no return values) we have to synthesize a `null`
(as the caller may "use"/"observe" the `void`).

=> We now are more strict and instead use `WasmVoid` as type
instead of allowing `void` as type on the import/export
functions.

[0] https://github.com/dart-lang/sdk/issues/63360
Change-Id: Ie30df3bd68553724437607bab3163c98f5467efe
Reviewed-by: Srujan Gaddam <sru...@google.com>
Commit-Queue: Martin Kustermann <kuste...@google.com>
Files:
  • M pkg/dart2wasm/lib/code_generator.dart
  • M pkg/dart2wasm/lib/dispatch_table.dart
  • M pkg/dart2wasm/lib/ffi_native_transformer.dart
  • M pkg/dart2wasm/lib/functions.dart
  • M pkg/dart2wasm/lib/intrinsics.dart
  • M pkg/dart2wasm/lib/record_class_generator.dart
  • M pkg/dart2wasm/lib/translator.dart
  • M pkg/dart2wasm/test/ir_tests/dyn_closure.wat
  • M pkg/dart2wasm/test/ir_tests/dyn_closure_function_apply.wat
  • M pkg/dart2wasm/test/ir_tests/dyn_closure_function_apply_named.wat
  • M sdk/lib/_internal/wasm/lib/invoke_main_patch.dart
  • M sdk/lib/_internal/wasm/lib/js_helper_patch.dart
Change size: L
Delta: 12 files changed, 156 insertions(+), 95 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Srujan Gaddam
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ie30df3bd68553724437607bab3163c98f5467efe
Gerrit-Change-Number: 501061
Gerrit-PatchSet: 18
Gerrit-Owner: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Srujan Gaddam <sru...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages