[L] Change in dart/sdk[main]: [dart2wasm] Simd for vector math

0 views
Skip to first unread message

Kevin Moore (Gerrit)

unread,
Feb 6, 2026, 1:59:02 AM (12 days ago) Feb 6
to Nate Biggs, Martin Kustermann, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Martin Kustermann and Nate Biggs

Kevin Moore voted and added 1 comment

Votes added by Kevin Moore

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Kevin Moore . resolved

The world of SIMD vector optimization is CRAZY!

Open in Gerrit

Related details

Attention is currently required from:
  • Martin Kustermann
  • Nate Biggs
Submit Requirements:
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ifa5ba0fb265b0fa46c0a3469d9331f32a025c9ec
Gerrit-Change-Number: 478860
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-Attention: Martin Kustermann <kuste...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 06:58:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Kevin Moore (Gerrit)

unread,
Feb 6, 2026, 3:02:17 AM (12 days ago) Feb 6
to Commit Queue, Nate Biggs, Martin Kustermann, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Martin Kustermann and Nate Biggs

Kevin Moore added 2 comments

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Kevin Moore . resolved

The one question I have...

File tests/web/wasm/simd/vector_test.dart
Line 214, Patchset 3 (Latest):WasmF64x2 get _zeroF64x2 => WasmF64x2.splat(WasmF64.fromDouble(0.0));
Kevin Moore . unresolved

There should be SOME way to make this a const, right?

Open in Gerrit

Related details

Attention is currently required from:
  • Martin Kustermann
  • Nate Biggs
Submit Requirements:
  • 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: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ifa5ba0fb265b0fa46c0a3469d9331f32a025c9ec
Gerrit-Change-Number: 478860
Gerrit-PatchSet: 3
Gerrit-Owner: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-Attention: Martin Kustermann <kuste...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 08:02:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Martin Kustermann (Gerrit)

unread,
Feb 6, 2026, 6:18:35 AM (12 days ago) Feb 6
to Kevin Moore, Commit Queue, Nate Biggs, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Kevin Moore and Nate Biggs

Martin Kustermann voted and added 11 comments

Votes added by Martin Kustermann

Code-Review+1

11 comments

Patchset-level comments
Martin Kustermann . resolved

lgtm with comments

File pkg/dart2wasm/lib/intrinsics.dart
Line 1525, Patchset 3 (Latest): if (lanesExp is ConstantExpression &&
Martin Kustermann . unresolved

As more instructions accept lane arguments, I think it makes sense to introduce a helper method here: `List<int> _extractLaneIndices()`

(similar to our existing `_extractMemoryOperands`, `extractIntValue`, etc)

File sdk/lib/_wasm/wasm_types.dart
Line 408, Patchset 3 (Latest): external bool get allTrue;
Martin Kustermann . unresolved

Should we have this for all shapes?

Line 465, Patchset 3 (Latest): external factory WasmF64x2.fromDoubles(double lane0, double lane1);
Martin Kustermann . unresolved

Could we rename this to e.g. `WasmF64x2.fromLaneValues()` (or some better name) and make the arguments `WasmF64`?

Then we can add also `WasmF32x4.fromLaneValues()`, `WasmI8x16.fromLanValues()` etc

Line 505, Patchset 3 (Latest): external WasmF64x2 pmin(WasmF64x2 other);
Martin Kustermann . unresolved

Could you add it to WasmF32x4 as well?

Line 522, Patchset 3 (Latest): external WasmF64x2 shuffle(List<int> lanes);
Martin Kustermann . unresolved

It seems the actual shuffle is an operation on 3 operands: `(v128, v128, i8[16]) -> v128`. So if we expose the shuffle instruction, why not expose it with full power?


If this is only about permuting the contents of one v128 value, then why not expose `swizzle` instead?

File tests/web/wasm/simd/simd_test.dart
Line 521, Patchset 3 (Latest): // Expect.equals(vPmin.extractLane(0).toDouble(), 10.5);
Martin Kustermann . unresolved

What is this commented code here?

(Did antigravity write it, tests were not passing and the solution was to comment out the code to make tests pass 😄)

Line 528, Patchset 3 (Latest): // vPmax = v1.pmax(vNaN); // pmax(10.5, NaN) -> 10.5
Martin Kustermann . unresolved

The difference between min/max and pmin/pmax are handling of NaNs, so it seems relevant to test those.

File tests/web/wasm/simd/vector_test.dart
Line 39, Patchset 3 (Latest): other.runtimeType == runtimeType &&
Martin Kustermann . unresolved

I don't think we should compare `runtimeType`.

Line 129, Patchset 3 (Latest): .abs()
Martin Kustermann . unresolved

Why the `.abs()` calls here? Shouldn't they be all non-negative?

Line 214, Patchset 3 (Latest):WasmF64x2 get _zeroF64x2 => WasmF64x2.splat(WasmF64.fromDouble(0.0));
Kevin Moore . unresolved

There should be SOME way to make this a const, right?

Martin Kustermann

Probably

You can add a const constructor:
```
class WasmV128 {
@pragma('wasm:entry-point')
final List<Object> laneValues;

const WasmV128.literal(this.laneValues);
}
extension type const WasmF64x2(WasmV128 value) {
const WasmF64x2.literal(WasmF64 a, WasmF64 b) : this(WasmV128.literal([a, b]));
}
```
and add corresponding backend support (you can have a look at how we do it for `WasmI32.literal` and `WasmArray.literal`)

Then you can probably use `const WasmF64x2.literal(...)`

Open in Gerrit

Related details

Attention is currently required from:
  • Kevin Moore
  • Nate Biggs
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: Ifa5ba0fb265b0fa46c0a3469d9331f32a025c9ec
Gerrit-Change-Number: 478860
Gerrit-PatchSet: 3
Gerrit-Owner: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Attention: Kevin Moore <kev...@google.com>
Gerrit-Comment-Date: Fri, 06 Feb 2026 11:18:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Kevin Moore <kev...@google.com>
satisfied_requirement
open
diffy

Nate Biggs (Gerrit)

unread,
Feb 10, 2026, 2:46:07 AM (8 days ago) Feb 10
to Kevin Moore, Martin Kustermann, Commit Queue, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Kevin Moore

Nate Biggs added 3 comments

Patchset-level comments
Nate Biggs . resolved

Forgot to send these last week.

File tests/web/wasm/simd/simd_vector.dart
Line 39, Patchset 1: other.runtimeType == runtimeType &&
Nate Biggs . unresolved

It's generally not great to compare `runtimeType`. If the subtypes shouldn't be equal to each other they should override `==` themselves. `OffsetBase` shouldn't have an `==`.

Line 47, Patchset 1:final class Offset extends OffsetBase {
Nate Biggs . unresolved

Not that it matters for a test but it seems like maybe these could even be extension types on `WasmF64x2` so you don't even need the wrapper object. The static type system can make sure you don't mess up `Offset` vs. `Size` but there's no reason for the runtime type system to worry about it.

I guess unless you really need the `==` and `toString`. I would say in this case just letting `==` fall through to `WasmV128.==` works.

Open in Gerrit

Related details

Attention is currently required from:
  • Kevin Moore
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: Ifa5ba0fb265b0fa46c0a3469d9331f32a025c9ec
Gerrit-Change-Number: 478860
Gerrit-PatchSet: 3
Gerrit-Owner: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-Attention: Kevin Moore <kev...@google.com>
Gerrit-Comment-Date: Tue, 10 Feb 2026 07:46:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
open
diffy

Kevin Moore (Gerrit)

unread,
2:51 PM (6 hours ago) 2:51 PM
to Martin Kustermann, Commit Queue, Nate Biggs, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org

Kevin Moore voted and added 11 comments

Votes added by Kevin Moore

Commit-Queue+1

11 comments

Patchset-level comments
File pkg/dart2wasm/lib/intrinsics.dart
Line 1525, Patchset 3: if (lanesExp is ConstantExpression &&
Martin Kustermann . resolved

As more instructions accept lane arguments, I think it makes sense to introduce a helper method here: `List<int> _extractLaneIndices()`

(similar to our existing `_extractMemoryOperands`, `extractIntValue`, etc)

Kevin Moore

Done

File sdk/lib/_wasm/wasm_types.dart
Line 408, Patchset 3: external bool get allTrue;
Martin Kustermann . resolved

Should we have this for all shapes?

Kevin Moore

They are available for all integer types. Will follow-up with the rest

Line 465, Patchset 3: external factory WasmF64x2.fromDoubles(double lane0, double lane1);
Martin Kustermann . resolved

Could we rename this to e.g. `WasmF64x2.fromLaneValues()` (or some better name) and make the arguments `WasmF64`?

Then we can add also `WasmF32x4.fromLaneValues()`, `WasmI8x16.fromLanValues()` etc

Kevin Moore

Done

Line 505, Patchset 3: external WasmF64x2 pmin(WasmF64x2 other);
Martin Kustermann . resolved

Could you add it to WasmF32x4 as well?

Kevin Moore

I'm focusing on WasmF64x2 – will follow-up

Line 522, Patchset 3: external WasmF64x2 shuffle(List<int> lanes);
Martin Kustermann . resolved

It seems the actual shuffle is an operation on 3 operands: `(v128, v128, i8[16]) -> v128`. So if we expose the shuffle instruction, why not expose it with full power?


If this is only about permuting the contents of one v128 value, then why not expose `swizzle` instead?

Kevin Moore

Done

File tests/web/wasm/simd/simd_test.dart
Line 521, Patchset 3: // Expect.equals(vPmin.extractLane(0).toDouble(), 10.5);
Martin Kustermann . resolved

What is this commented code here?

(Did antigravity write it, tests were not passing and the solution was to comment out the code to make tests pass 😄)

Kevin Moore

Done

Line 528, Patchset 3: // vPmax = v1.pmax(vNaN); // pmax(10.5, NaN) -> 10.5
Martin Kustermann . resolved

The difference between min/max and pmin/pmax are handling of NaNs, so it seems relevant to test those.

Kevin Moore

Done

File tests/web/wasm/simd/vector_test.dart
Line 39, Patchset 3: other.runtimeType == runtimeType &&
Martin Kustermann . resolved

I don't think we should compare `runtimeType`.

Kevin Moore

Done

Line 129, Patchset 3: .abs()
Martin Kustermann . resolved

Why the `.abs()` calls here? Shouldn't they be all non-negative?

Kevin Moore

Done

Line 214, Patchset 3:WasmF64x2 get _zeroF64x2 => WasmF64x2.splat(WasmF64.fromDouble(0.0));
Kevin Moore . resolved

There should be SOME way to make this a const, right?

Martin Kustermann

Probably

You can add a const constructor:
```
class WasmV128 {
@pragma('wasm:entry-point')
final List<Object> laneValues;

const WasmV128.literal(this.laneValues);
}
extension type const WasmF64x2(WasmV128 value) {
const WasmF64x2.literal(WasmF64 a, WasmF64 b) : this(WasmV128.literal([a, b]));
}
```
and add corresponding backend support (you can have a look at how we do it for `WasmI32.literal` and `WasmArray.literal`)

Then you can probably use `const WasmF64x2.literal(...)`

Kevin Moore

Will do it in a follow-up!

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: Ifa5ba0fb265b0fa46c0a3469d9331f32a025c9ec
Gerrit-Change-Number: 478860
Gerrit-PatchSet: 5
Gerrit-Owner: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-Comment-Date: Tue, 17 Feb 2026 19:51:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Martin Kustermann <kuste...@google.com>
Comment-In-Reply-To: Kevin Moore <kev...@google.com>
satisfied_requirement
open
diffy

Kevin Moore (Gerrit)

unread,
2:59 PM (6 hours ago) 2:59 PM
to Martin Kustermann, Commit Queue, Nate Biggs, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Nate Biggs

Kevin Moore added 2 comments

File tests/web/wasm/simd/simd_vector.dart
Line 39, Patchset 1: other.runtimeType == runtimeType &&
Nate Biggs . resolved

It's generally not great to compare `runtimeType`. If the subtypes shouldn't be equal to each other they should override `==` themselves. `OffsetBase` shouldn't have an `==`.

Kevin Moore

Done

Line 47, Patchset 1:final class Offset extends OffsetBase {
Nate Biggs . resolved

Not that it matters for a test but it seems like maybe these could even be extension types on `WasmF64x2` so you don't even need the wrapper object. The static type system can make sure you don't mess up `Offset` vs. `Size` but there's no reason for the runtime type system to worry about it.

I guess unless you really need the `==` and `toString`. I would say in this case just letting `==` fall through to `WasmV128.==` works.

Kevin Moore

I want to stay kinda close to the Flutter behavior, so I'm leaving this here for now.

I LOVE the extension type of WasmF64x2 – but there is no path to making that a real change to Flutter.

Open in Gerrit

Related details

Attention is currently required from:
  • Nate Biggs
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: Ifa5ba0fb265b0fa46c0a3469d9331f32a025c9ec
Gerrit-Change-Number: 478860
Gerrit-PatchSet: 5
Gerrit-Owner: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Comment-Date: Tue, 17 Feb 2026 19:59:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nate Biggs <nate...@google.com>
satisfied_requirement
open
diffy

Nate Bosch (Gerrit)

unread,
5:00 PM (4 hours ago) 5:00 PM
to Kevin Moore, Martin Kustermann, Commit Queue, Nate Biggs, dart2js-te...@google.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Kevin Moore and Nate Biggs

Nate Bosch added 1 comment

Patchset-level comments
Nate Bosch . unresolved

Can you add details about how the code is changing to the commit message?

go/cl-descriptions

Open in Gerrit

Related details

Attention is currently required from:
  • Kevin Moore
  • Nate Biggs
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: Ifa5ba0fb265b0fa46c0a3469d9331f32a025c9ec
Gerrit-Change-Number: 478860
Gerrit-PatchSet: 5
Gerrit-Owner: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Kevin Moore <kev...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Nate Biggs <nate...@google.com>
Gerrit-CC: Nate Bosch <nbo...@google.com>
Gerrit-Attention: Nate Biggs <nate...@google.com>
Gerrit-Attention: Kevin Moore <kev...@google.com>
Gerrit-Comment-Date: Tue, 17 Feb 2026 22:00:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages