Commit Graph

113742 Commits

Author SHA1 Message Date
Modestas Valauskas 415b040d6f Reland "[vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable"
The previous attempt was reverted because it broke unoptimized JIT
on ARM 32. This reland force-optimizes the two getters.

Stacks on top of the int.{trailingZeroBitCount,oneBitCount} API CL
(commit 754239b077). Both getters route through OTHER_RECOGNIZED_LIST
when a hardware fast path is available; otherwise the newly added
Dart bodies inline at call sites via vm:prefer-inline. The C++
natives are removed.

Backend codegen
---------------
ARM64:     NEON CNT + UADDLV (popcount); RBIT + CLZ (ctz).
ARM:       NEON CNT + VPADDL chain (popcount); RBIT + CLZ on the
           register pair (ctz).
x64:       popcntq when TargetCPUFeatures::popcnt_supported();
           LoadImmediate(64) + rep_bsfq for ctz (decodes as tzcnt
           on BMI1+, preserves dest on zero otherwise).
RISC-V 64: cpop / ctz when RV_baseline includes Zbb.

Per-arch availability is encapsulated in
UnaryInt64OpInstr::IsSupported(Token::Kind).

Apple M-series ARM64, AOT (us/iter, lower is better):
  cardinality.swar              371
  cardinality.accelerated       154    (2.4x)
  forEachSetBit.swar          19031
  forEachSetBit.accelerated    4988    (3.8x)
  select.swar                   199
  select.accelerated             77    (2.6x)
  complementCardinality.swar    399
  complementCardinality.accel   152    (2.6x)

Work towards https://github.com/dart-lang/sdk/issues/6486 (popcount
and ctz intrinsification).

Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
BitSet implementation).

Fixes https://github.com/dart-lang/sdk/issues/52673
Fixes https://github.com/dart-lang/sdk/issues/38346
Fixes https://github.com/dart-lang/sdk/issues/63436
Issue https://github.com/dart-lang/sdk/issues/10212
Issue https://github.com/dart-lang/sdk/issues/5798
TEST=tests/corelib/int_bit_count_test

Cq-Include-Trybots: luci.dart.try:vm-linux-release-simarm-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
Change-Id: Ib812cbaec6e371b9720df7a543411f78e524cac1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506060
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-29 06:01:17 -07:00
Jonas Finnemann Jensen abbd9e33ca Use relative paths in gn rules to avoid build issues in tripple headed golem build
Change-Id: Ib0b045a5a7c78d69ccd1aa2150a80d9665d8c90a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507400
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
2026-05-29 05:38:04 -07:00
Johnni Winther b49f544446 [cfe][Contexts] Infer all initializers as one
This updates the resolver to infer all initializers together with the same visitor, avoiding a lot of book keeping needed to pass and compute scope provider info.

Change-Id: If30ee2b3ed4694af9c28af7a2fad3c2252fba0b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507081
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-29 05:27:03 -07:00
Johnni Winther 06e0f58562 [cfe][Contexts][InternalNodes] Add helpers for creating variables
This adds helpers for creating variables corresponding to the new variable model. This prepares for removing the LegacyVariable and only createing the variables.

This includes a fix for using the new LocalVariable for FunctionDeclaration.

Change-Id: Ib82e12ceb11cf6aa80185bdfeb559461c641dc15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506241
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-29 05:27:03 -07:00
Chloe Stefantsova 849c282e06 [cfe] Add more checks to verification of new variables
* Check that all variables are assigned a context.
* Check that the variable appears exactly once in its enclosing
contexts.
* Check that the variables can be found in their contexts.

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I3ed837c538a4b9933d556cc1f9643422b75a5aa0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507120
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-29 03:52:14 -07:00
Modestas Valauskas 062123bcf5 [vm] Remove unused Integer_parse native
The Integer_parse VM native has no Dart-side caller. int.parse is
implemented entirely in Dart in
sdk/lib/_internal/vm_shared/lib/integers_patch.dart (_tryParseSmi
and _parseRadix). Removes the native entry and drops a stale
reference in the comment on the shared ParseInteger helper, which
is still used by Integer_fromEnvironment.

TEST=ci

Change-Id: I8d034e3081c09357094abc6415fc709e3edbea07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507322
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-29 03:37:25 -07:00
Johnni Winther 02046380d1 [cfe][Contexts][InternalNodes] Add internal nodes for FunctionNode, FunctionExpression and FunctionDeclaration
This adds internal nodes for FunctionNode, FunctionExpression and FunctionDeclaration which require InternalVariable rather than Variable. This is in preparation for using the new variable model by default.

Change-Id: I3c29954bcaae555c20b37e6a3ba1e70d959f1559
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506941
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-29 02:41:29 -07:00
Jonas Finnemann Jensen 8c42f67d35 [dartpad] Part 1-8 squashed into a single commmit.
Reviewed in https://dart-review.googlesource.com/c/sdk/+/497583

[dartpad] Part 1: Protocol and Scaffolding

This sets up folders for `package:dartpad` and `package:dartpad_worker`,

R=athom@google.com, sigurdm@google.com

including:
 * `OWNERS` files,
 * Protocol definition,
 * Exceptions, and,
 * Virtual file system utilities.

[dartpad] Part 2: HotReloadCompiler

Adds the hot reload compiler logic to dartpad_worker.

This is models on dartdevc with `--reload-last-accepted-kernel` and
`--reload-delta-kernel` options. I don't think this does an incremental
compilation, instead it does a modular compilation. Meaning, we can have
a huge collection of precompiled DDC modules and the compiler just gets
a DDC outline/summary dill files for these modules. But on the other hand
the actual code that is compiled will be recompiled on every compile()
call.

This is very important for flutter_web.js / flutter_web.dill where the
precompiled DDC modules is around 60 MB in total. The fact that
package:flutter is precompiled into flutter_web.js is critical for
compilation performance for small dartpad-style example apps.

The downside is that unlike incremental compilation with _frontendserver_,
if the user were to install package:http and use it in the app they are
compiling then every `compile()` call will recompile `package:http`.
Where as with _frontendserver_ we'd be able to invalidate specific files,
and only those would be recompiled.

This leaves future work to either:
 * (A) Add support for modular compilation to _frontendserver_, such that
   we can do incremental compilation without having to first compile all
   of `package:flutter`.
 * (B) Refactor compilation strategy implemented here, to leverage
   modular further. We could for example compile all dependencies from
   `PUB_CACHE` into a `pub_cache_outline.dill` inside the dartpad worker.
   Then recompilation would only touch the user-code. Granted this is
   still less than ideal.

At the moment the lack of incremental compilation is not a blocker,
current dartpad doesn't have incremental compilation, but granted it also
only supported a single file. This dartpad environment will support
multiple files, but adding many files will result in poor performance
until we refactor and figure out how to do incremental compilation.
Hence, why we shouldn't block progress waiting for incremental compilation
to work.

R=nshahan@google.com

[dartpad] Part 3: Pub execution wrapper

Adds the internal wrapper for executing pub commands inside the
worker's virtual file system.

R=sigurdm@google.com

[dartpad] Part 4: Language Server wrapper

Adds the internal wrapper for spawning and communicating with the
Dart LSP inside the DartPad worker.

R=scheglov@google.com

[dartpad] Part 5: DartPad Worker

Implements the main worker entrypoint, RPC message handling. The
`bin/worker.dart` is what will be compiled to WASM and will run as a
_Web Worker_.

R=sigurdm@google.com

[dartpad] Part 6: DartPad Client library

The public-facing `dartpad` library that developers use to embed
the compilation environment in their web applications.

This finishes `package:dartpad`featuring:
 * `DartPad.create()`, which creates a _Web Worker_ running the compiled
   `pkg/dartpad_worker/bin/worker.dart`, and returns a `DartPad` instance
   wrapping RPC calls into the _Web Worker_.
 * `Sandbox.createIFrame()` which creates a _sandboxed iframe_ containing
   precompiled DDC modules from the SDK assets and `sandbox.js` for
   wrapping `ddc_module_loader.js` with an RPC interface. This returns a
   `Sandbox` instance wrapping RPC calls into the _sandboxed iframe_,
   making it easy to load modules, run library entrypoints (main()),
   initiate hot-reload, or launch a flutter app.

This is an initial API design that works. There are minor inconsistencies
and improvements that we should do. But I propose that we do so in
follow-up PRs.

R=sigurdm@google.com

[dartpad] Part 7: Build Targets

Adds a `dartpad` target to the Dart SDK, which produces:
```
out/ReleaseX64/dartpad/
├── dart
│   ├── dart_sdk.js.map
│   ├── sdk.js
│   └── sdk.tar
├── ddc_module_loader.js
├── sandbox.js
├── worker.loader.js
├── worker.mjs
├── worker.support.js
├── worker.wasm
└── worker.wasm.map
```

The `dartpad/` output folder is intended to be used as `assetBaseUrl` in
client libraries provided in `package:dartpad`. And the `dartpad/dart/`
folder is intended to be used as `sdkLocation`. These files are not
intended to be distributed along side the normal Dart SDK, instead we'll
publish them on a CDN and let people use `package:dartpad` to point at
these files. If they want to self-host everything, they can copy from our
CDN or rebuild the files using a local Dart SDK checkout.

These files are also necessary for testing, to ensure that we have proper
integration tests for `pkg/dartpad_worker/`. As we will want to publish
these files on a CDN the actual compiled size in release-mode matters,
thus, we have enabled wasm optimizations steps in this mode.

R=rmacnak@google.com

[dartpad] Part 8: Tests for `package:dartpad` and `pkg/dartpad_worker/`.

We have 3 kinds of tests:
 * Unit tests (vm, browser or both),
 * Worker tests (vm and browser),
 * Integration tests (browser-only).

As the Dart SDK test runner simply executes `*_test.dart` files with
`dart` and doesn't support compiling tests to the browser, launching and
running tests in the browser, we employ `dart test` to run tests. We do
this by having `pkg/dartpad_worker/dart_test.yaml` specify that
`dart test` should look for files names `test_*.dart`, and we then create
`pkg/dartpad_worker/test/ci_test.dart´ to be a single test that simply
runs `dart test` as a subprocess. Thus, the only test file triggered by
Dart SDK test runner is `ci_test.dart`, and if you locally run `dart test`
this will run the individual `test_*.dart` files.

While this hack to use `dart test` isn't ideal it gives everyone a decent
work flow. And saves us from having to invent complex test harness for
`pkg/dartpad_worker/`.

**Worker tests** defined in `test/dart/worker/` and `test/flutter/worker/`
are all imported into `test_dart_worker.dart` and
`test_flutter_worker.dart` to reduce test compilation time. These have a
non-trivial compilation time because the worker is running in the test
process. This allows testing on VM, which can be easier to debug.

**Integration tests** unlike _worker tests_ launch the worker compiled by
the `dartpad` build target in a _Web Worker_. This has less compilation
overhead for the individual tests, but involves more setup, and can be
a bit harder to debug.

Both worker and integration tests employ `test/asset_server/` which serves
assets built by the `dartpad` build target, and serves as a pub-server for
tests. It also serves assets built by `tool/setup_local_flutter.dart`
which creates flutter assets, though this is not intended to run as part
of CI, since we do not have a Flutter checkout available. Thus, for the
time being flutter testing is local only. Maybe, later we'll move this
script to another repository.

R=sigurdm@google.com

Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-win-release-try
Change-Id: I3a99939ec5217b9f3a855fc5b9ad9699047d02cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507321
Commit-Queue: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-05-29 02:25:49 -07:00
Modestas Valauskas c26cececd3 [vm/compiler] Mark BlockEntryInstr Predecessor* overrides as final.
Add `final` to PredecessorAt and PredecessorCount on the six concrete
BlockEntryInstr subclasses (GraphEntry, JoinEntry, TargetEntry,
FunctionEntry, OsrEntry, CatchBlockEntry), so the compiler can
devirtualize the calls.

Measured on a naive 49 KLOC generated lexer with --huge_method_cutoff
gates lifted and with synchronous compilation: JIT compile drops from
~30.6s to ~27.4s (about 10%).

Work towards https://github.com/dart-lang/sdk/issues/63230

TEST=ci

Change-Id: Ia2ef2761646a4c94748bcd7dfe0591262d93cd69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505401
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
2026-05-29 01:08:04 -07:00
Hakim Jonas Ghoula f710c4338a [dart2wasm] Intrinsify math.min() and math.max() for double and int
Issue #55173.

Exposes signed min/max on WasmI64 and f64.min/f64.max on WasmF64 in
dart:_wasm, mirroring how WasmF64.sqrt is exposed today. The dart:math
min/max patches in math_patch.dart dispatch to them via runtime
`is`-checks, with @pragma('wasm:prefer-inline') so the inliner folds
the chain to the bare instruction sequence at each call site:

  T min<T extends num>(T a, T b) {
    if (a is int && b is int) return unsafeCast<T>((a as int).minS(b));
    if (a is double && b is double) return unsafeCast<T>((a as double).min(b));
    return _minSlow<T>(a, b);
  }

Wasm has no native i64 min_s/max_s, so WasmI64.minS/maxS emit the
same local.tee + i64.le_s/ge_s + select sequence. WasmF64.min/max emit
f64.min/f64.max directly.

The NaN- and signed-zero-aware fallback ladder is preserved in
`_minSlow` / `_maxSlow` (out-of-line, no pragma) and called for the
mixed and num cases. tests/lib/math/min_max_test.dart requires type
preservation between equal int and double arguments (e.g.
min(-499, -499.0) is int at line 113; max(499, 499.0) is int at
line 382), which a toDouble().max(toDouble()) fallback would not
satisfy.

Adds pkg/dart2wasm/test/ir_tests/math_min_max.dart covering min/max
for static int/int, double/double, mixed int/double, and num/num.
The .wat locks in f64.min/f64.max for the f64 paths, i64.le_s/i64.ge_s
+ select for the i64 paths, and `call $_minSlow` / `call $_maxSlow`
for mixed and num/num.

Measurements on a probe with four typed call sites (one each for
min<double>, max<double>, min<int>, max<int>, all marked
@pragma('wasm:never-inline')):

* .wasm size: 27,112 → 25,848 bytes (-4.66%). Generic $min and $max
  are eliminated by DCE.
* Runtime, 100M iterations per operation on d8, median of 10 runs:
  min<double> 543 → 213 ms (2.55x), max<double> 550 → 213 ms (2.58x),
  min<int>    552 →  65 ms (8.49x), max<int>    555 →  73 ms (7.61x).
  Checksums match between baseline and patched.

tests/lib/math/min_max_test.dart passes.

R=mkustermann@google.com, osa1@google.com

Change-Id: If8cf0a4df976f2d7f2230308905ff68491311c97
Bug: https://github.com/dart-lang/sdk/issues/55173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503740
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-29 00:03:32 -07:00
Jake Macdonald 06bdbd777f Update mcp-server command to be an alias for 'run dart_mcp_server@'
Strips the dart-lang/ai dependency from the SDK entirely, as well as the snapshot.

Bug: https://github.com/dart-lang/ai/issues/479
Change-Id: Id919c6a8fbf5fedeffb37e5181bc2fbd85adf986
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507220
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2026-05-28 12:06:25 -07:00
Alexander Aprelev 527d529493 [vm/shared] Implement Isolate runEventLoopSync.
TEST=ffi/threading_runeventloop_test

Change-Id: I2061d10d14bcdd589a4a9893f122620f8d0a4e7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497100
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-28 11:38:29 -07:00
Konstantin Shcheglov a898adf8b7 Augment. Support for abstract top-level variables and static fields.
Change-Id: Idf0ce319492c405dd06364cb6feb81e000a7c741
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506606
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-28 09:19:15 -07:00
Konstantin Shcheglov 6f804b8121 CQ. Inline _IndexMixin. Trim _IndexResult.
Change-Id: Iee776321cc5a5aad72d539dc38b6f052dccb6872
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506881
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-28 09:00:37 -07:00
Konstantin Shcheglov d68c1befce CQ. Replace 'late AnalysisDriverUnitIndex index' with '_IndexResult'.
Change-Id: I795224feff73eab3bca791db2feb49759cd7b888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506900
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-28 08:57:32 -07:00
Konstantin Shcheglov 9543bb6472 CQ. Migrate from assertErrorsInTestResult() to resolveFileWithDiagnostics().
Change-Id: I1fc158dad37eba700b8c83e288de63270cedf3b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-28 08:52:34 -07:00
Konstantin Shcheglov f81c7f2140 CQ. Migrate from assertNoErrorsInTestResult() to resolveFileWithDiagnostics().
Change-Id: I1ec29d0051a90656092df9e321fba7f1ce2b7556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506861
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-28 08:49:28 -07:00
Konstantin Shcheglov 062a1fdcc5 CQ. Migrate to assertTestCodeWithStrictCastsDiagnostics().
Change-Id: I10858511860a8c8867ddfe0d60440bb54d4385cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506860
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-28 07:54:46 -07:00
Konstantin Shcheglov 1af709f3f0 CQ. Support for multi-line messages in inline expectations.
Change-Id: Iafb0f33ed1ad7167b4155e5d2c58d3db5833fae4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506820
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-28 07:50:54 -07:00
Konstantin Shcheglov c91d6d2373 CQ. Remove assertErrorsInResolvedUnit(), assertErrorsInResult(), assertNoErrorsInResult().
Update affected tests to use resolveFileWithDiagnostics() or
resolveFilesWithDiagnostics() instead.

Change-Id: I77acc47f62640ea55dc32103b526cbe489f57e6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506742
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-28 07:46:41 -07:00
Martin Kustermann 639f505308 [dart2wasm] Change dart2wasm-mac-safari to shards=1, i.e. no shards
Change-Id: Ia87d3ff035f936f1ca18a74a4ab75d464d502dbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507020
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-05-28 06:23:29 -07:00
Jens Johansen d441e28656 [CFE/VM] Fix mixin deleting procedure-setter because of final field
Fixes https://github.com/dart-lang/sdk/issues/63440
Tested: Tests added.
Change-Id: I0bdfd71c48ecae6094557fa4f46b8fc4b50afa73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-05-28 05:15:07 -07:00
Lasse R.H. Nielsen 69e9d32e87 Retire 'privately-named-parameters' experiment flag.
Change-Id: I6526bd63be5f71090a3ea7f3c705778e7debf584
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
2026-05-28 05:13:49 -07:00
Martin Kustermann 2198d25b1e [vm/testing] Make vm/dart/gc/scavenger_abort_2_test more robust
The test tries to keep fields alive by my making a

  toString() => field1 + field2 + ...

Though some field values don't have a `+` operator (e.g. instances of `class C`).

Improving TFA precision can infer that some of these `+` operations will throw,
which then makes other `+` operations unreachable, which removes usages
of those other fields, which will tree shake those other fields, which
will make the test not test anymore what it's intended to.

=> Make the test more robust by using string concatenation instead.

Change-Id: I80788af516083ea3d78ad910eb394e4b7e122384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507000
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-28 03:49:20 -07:00
Martin Kustermann 5423762c21 [dart2wasm] Fix unreachable instance call issue
When a call is unreachable we used to generate sometimes a block with no
outputs, but callers expected an output which they may drop. That caused
stack discipline mismatch.

Instead we should simply emit an unreachable and tell the caller there's
no value.

Issue https://github.com/dart-lang/sdk/issues/63454

Change-Id: I81be6729fd578e237c4e6483539a9d53a9ed355e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506960
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-28 03:37:13 -07:00
Robert Nystrom 6c88c6f2ba Migrate pkg/smith to the new constructor syntax.
Change-Id: I5f17f4a7eddd5dd839b2061f5d4a1f33c40703a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506661
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-27 16:54:31 -07:00
Robert Nystrom 5ccd5818e0 Migrate pkg/expect to the new constructor syntax.
Change-Id: I872868b7f9dea21889aeac00a92eef0b03849354
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506603
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-27 16:17:46 -07:00
Robert Nystrom 9f11b2fd45 Migrate pkg/status_file to primary constructors and new constructor syntax.
Unlike my previous couple of CLs, I went ahead here and also migrated
most of the classes to use primary constructors since so many of them
were small and well suited for it.

In the process, I found and fixed one bug in the assist to convert to a
primary constructor:

https://dart-review.googlesource.com/c/sdk/+/506760

So I guess this CL has already paid its way. :)

Change-Id: I9b7d08e27f4ddce3f19127aaf4f14fe627b75dab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506743
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2026-05-27 15:56:27 -07:00
Paul Berry afcfbbeba8 Migrate developer experience packages to new constructor decl syntax.
(Part of https://github.com/dart-lang/sdk/issues/63288)

This change migrates the packages owned by the developer experience
team to use the new constructor declaration syntax, described in
https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations.

This change was performed in an automated fashion, by (a) bumping the
packages' SDK constraints to `3.13.0-0`, (b) enabling the lints
`unnecessary_type_name_in_constructor` and
`unnecessary_const_in_enum_constructor`, (c) fixing the resulting lint
failures using `dart fix`, and then (d) reformatting the affected
files.

To ease code review, I've reverted unrelated formatting changes.

Since this change requires bumping SDK constaints to `3.13.0-0`, it
was only performed on packages that are *not* published on
pub. (Packages that *are* published on pub should remain on lower
language versions until at least after the stable version of 3.13 is
released, so that we don't block users on the stable channel from
receiving updates to those packages.)

Change-Id: Ibb4daebafd239da58251e838ea6a3f336a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505046
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
2026-05-27 14:52:58 -07:00
Robert Nystrom 1e5aebc601 Reformat pkg/status_file.
I was starting to migrate it to use primary constructors but realized
the formatting was out of date, so I figured I may as well fix that
first so that the migration CL is easier to read.

There are no changes in this CL, I only ran `dart format .`.

Change-Id: I25f772ce0e0a00d83f1f8b561fc8bb9fe9486859
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506741
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-27 14:43:43 -07:00
Brian Wilkerson 8b555128be Support converting a declaring param to an initializing param
Server already supports the opposite, so this just makes it possible to
go both ways.

This doesn't support converting a declaring function typed parameter.
We could add that, but I'm hoping it's rare enough to not be worth doing.

Other than that, I think I've covered all the cases, but please pay
special attention to the test coverage.

Change-Id: I400204ca820d0e0f1cc44075dd54946db79b2115
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-27 14:39:09 -07:00
Paul Berry 8b66930364 [presubmits] Print stdout,stderr if CheckSorted result can't be parsed.
Previously, in the `CheckSorted` presubmit check, if
`verify_sorted_test.dart` returned a nonzero exit code but none of its
output lines contained the string `Unsorted file`, then a presubmit
failure would be generated containing an empty string, resulting in
confusing output like this:

    Running presubmit upload checks ...
      18.4s to run CheckChangeOnUpload from /home/paulberry/dart1/sdk/pkg/_fe_analyzer_shared/PRESUBMIT.py.
    ** Presubmit ERRORS: 1 **


    Presubmit checks took 21.4s to calculate.
    There were presubmit errors.

This might happen, for example, if `verify_sorted_test.dart` contained
a compile-time error or threw an unhandled exception.

With this change, the message is `CheckSorted: could not parse output
of verify_sorted_test.dart`, followed by the full stdout and stderr
from the attempt.

This should make this sort of failure a lot easier to debug.

Note: I've made this same fix before to
`pkg/_fe_analyzer_shared/PRESUBMIT.py` (see
https://dart-review.googlesource.com/c/sdk/+/485601). I didn't realize
at the time that the code was duplicated.

Note: This should make it easier to debug
https://github.com/dart-lang/sdk/issues/63464.
Change-Id: I4892dcff7ad6969ca40564c1fd7e62e36a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506605
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-05-27 14:34:26 -07:00
Konstantin Shcheglov d3a8da96a0 Augment. Rename two tests in augmentation_return_type_mismatch_test.dart
Change-Id: I1a694006a2f34951298eb6d8846c44d88a0ef391
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506502
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-27 14:13:43 -07:00
Alexander Aprelev 52fc4ee1eb [vm/fuchsia] Skip new test on fuchsia.
The test requires experimental shared data flag, which can't be passed to gen_snapshot on fuchsia at the moment.

Fixes https://github.com/dart-lang/sdk/issues/63462
TEST=ci

Change-Id: I96c5847b17625b874027e468d99a1f492fa5d17f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506701
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-27 14:08:42 -07:00
Konstantin Shcheglov 5252e5e3d3 CQ. Remove assertErrorsInFile2(), use resolveFilesWithDiagnostics().
Add helpers that resolve non-test files using the same inline diagnostic
expectation format as resolveTestCodeWithDiagnostics.
resolveFileWithDiagnostics handles a single file, while
resolveFilesWithDiagnostics writes all related files before resolving
any of them.

Add multi-file diagnostic expectation generation so context messages in
one file can be referenced from diagnostics reported in another. Teach
expectation updating how to target values in a files-to-code map using
per-entry intra-invocation ids.

Remove assertErrorsInFile2 and migrate diagnostics tests from
hand-written ExpectedError offsets to inline markers. This keeps the
diagnostic range, code, message, and cross-file context next to the code
under test, and makes expectation updates reusable for library and part
tests.

Initialize strong-mode type assertions from resolveFile so callers that
resolve files other than testFile get the same setup.

Change-Id: Ie492155b046c28a535faf21fa9a2e47797caffb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506180
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-27 14:05:36 -07:00
Robert Nystrom 2cd3ec552c Fix "Convert to a primary constructor" on generic classes.
It would incorrectly put the primary constructor parameter list before
the type's type parameter list, like:

```dart
// Before:
class C<T> {
  C();
}

// After:
class C()<T> {
}
```

This fixes it to follow the type parameter list if there is one.

Change-Id: Ib49c7df7923e9feed11f87579fefc8300c56c4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2026-05-27 13:59:34 -07:00
Paul Berry 9bd89a769d Work around issue with -r in presubmit scripts.
For some reason, when a `CheckSorted` presubmit invokes
`verify_sorted_test.dart`, the `-r` flag is preventing the compiler
from picking up the proper language version from
`.dart_tool/package_config.json`. This is interfering with my ability
to run presubmits for
https://dart-review.googlesource.com/c/sdk/+/505046.

See https://github.com/dart-lang/sdk/issues/63464 for additional
details.

As a temporary workaround, this CL removes the `-r` flag. It should be
reverted once https://github.com/dart-lang/sdk/issues/63464 has been
fixed (and the pre-built SDK has been updated to include the fix).

Change-Id: Ibc48eec4ef382d6afe17d73454f07dcd6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506700
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-05-27 13:49:54 -07:00
Sam Rawlins d0f27293ce DAS plugins: Respect the analysis roots set by "dart analyze"
Work towards https://github.com/dart-lang/sdk/issues/62686

`dart analyze` uses an 'analysis.setAnalysisRoots' "command" to let
the analysis server know that the user requested, for example,
`dart analyze foo` or `dart analyze foo/bar.dart`. This was not conveyed
to analyzer plugins, so analyzer plugins will always analyze the entire
context collection.

(For some reason, only files in the "analysis roots" were reported in
stdout; maybe DAS or dartdev does its own filtering on diagnostics.)

This change forwards the `setAnalysisRoots` request to DAS plugins using
a new protocol message that mirrors the one for the server.

We should not change the behavior of `analysis.setContextRoots` for
legacy plugins, so we keep sending that request as per usual. Then
we send `analysis.setAnalysisRoots` at the same time.

If we receive an `analysis.setAnalysisRoots` message, dispose and
delete references to the existing context collection, and instantiate
a new one, with the specified `included` and `excluded` paths.

Change-Id: I53627da1c30351a22b5e5410a557bf486620a7aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505041
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-27 13:47:02 -07:00
Ryan Macnak e991ffd37b [vm] Fix HashBytes to work with unaligned inputs.
TEST=ubsan
Bug: https://github.com/dart-lang/sdk/issues/63452
Change-Id: I112b26c08b5ae186dc5264d99edbed9e6e60368d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506660
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-27 12:55:21 -07:00
Robert Nystrom 81059a1b79 Migrate pkg/scrape to the new constructor syntax.
Change-Id: I45dcedb1ce90d7a9700a57767ae01fff5721ccfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506602
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2026-05-27 12:21:23 -07:00
Alexander Aprelev 488ba69e41 [vm/shared] Introduce isolate event loop handling dart api.
Implement api methods to create and shutdown isolates from IsolateGroup-bound callbacks (normally invoked from native code), run dart code on such isolates.
The rest of the api is not implemented yet.

TEST=tests/ffi/threading_test.dart
BUG=https://github.com/dart-lang/sdk/issues/62407
CoreLibraryReviewExempt: vm-only change to isolate library
Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486522
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-27 11:31:11 -07:00
Konstantin Shcheglov ba760c36a4 Augment. Report augmentationInducedGetterAlreadyComplete and augmentationInducedSetterAlreadyComplete.
Change-Id: I87ba9c5b6c489417173a387bded700f52b52e7ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506501
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-27 11:17:44 -07:00
Sam Rawlins 19ca914f74 Remove redundant lint rules
use_null_aware_elements is included in the lints package analysis
options.

Change-Id: I01222fc7e84be32da657f04b16e15af7d5861433
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-27 10:26:22 -07:00
Paul Berry 49597f85d9 [front_end,kernel] Add ignores for codegen to prepare for new syntax.
(Part of https://github.com/dart-lang/sdk/issues/63288)

Updates various code generators in the `front_end` and `kernel`
packages to output `ignore_for_file` comments to ignore the
`unnecessary_type_name_in_constructor` lint.

This is a first step towards migrating the `front_end` and `kernel`
packages to use the new constructor declaration syntax, since it will
allow the `unnecessary_type_name_in_constructor` lint to be enabled
without breaking generated code.

Once all the packages have had their SDK constraints bumped to a
language version that supports the new syntax, I'll update the code
generator to use the new syntax, and remove the ignores.

For more information about the new constructor declaration syntax, see
https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations.

Change-Id: I73fd960a7eea2a1a59316602c49d56816a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506380
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-05-27 10:11:50 -07:00
Sam Rawlins 0fa39c9649 linter: Switch cascade_invocations to report once for a set of cascadable statements
Fixes https://github.com/dart-lang/sdk/issues/58688

Change-Id: I022b58109deedfbd6e57e6aa5159942081e6d8fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503941
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-05-27 08:58:12 -07:00
Tess Strickland 7cd8fda37e [vm] Use Uint32Arrays for coverage arrays.
Also load/store canonical hashes in the heap for non-empty TypedData
instances in the same manner as canonical hashes for Arrays.

TEST=ci (refactoring only)

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: I54274b558fa9f0c8e304198b18cb3f0e9c3e0dfb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504600
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-27 08:18:27 -07:00
Daco Harkes da40aec0bb [deps] Roll dart-lang/native
Pass in the entry-points and OS to the link hook when the record_use
file is provided. So that different target OSes and different entry-
points are cached separately.

Also, commit skill to rev `native_rev` in DEPS. (The new agent
IDE ignores gemini.md that contained it and prefers using skills.)

Change-Id: Ic77e3ccd5915736081c01f8b75901f626f688f19
Cq-Include-Trybots: luci.dart.try:dart2wasm-asserts-linux-chrome-try,dart2wasm-asserts-minified-linux-d8-try,dart2wasm-linux-chrome-try,dart2wasm-linux-d8-try,dart2wasm-linux-firefox-try,dart2wasm-linux-jscm-chrome-try,dart2wasm-linux-optimized-jsc-try,pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart2js-canary-linux-try,dart2js-hostasserts-linux-d8-try,dart2js-linux-chrome-try,dart2js-linux-firefox-try,dart2js-mac-chrome-try,dart2js-mac-safari-try,dart2js-minified-csp-linux-chrome-try,dart2js-minified-linux-d8-try,dart2js-unit-linux-x64-release-try,dart2js-win-chrome-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506580
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
2026-05-27 07:31:46 -07:00
Sam Rawlins 37197070f8 DevTools: Run "flutter clean" after building
Fixes https://github.com/flutter/devtools/issues/9837

Change-Id: Ib770caf7409ea19970d4ff65cea7fe849a6a730c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505381
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-05-27 07:27:20 -07:00
Ryan Macnak 0ff42aac19 [vm] Fix poor hash performance of CodeSet.
Observed this taking ~2% of debug gen_snapshot time.

TEST=ci
Change-Id: I657148904fe2b5a8f3dfbd006c3d1327aa3866ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506261
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-27 07:21:32 -07:00
Ryan Macnak b0a82e98d5 [build, mac] Sign shared libraries and fix incremental build for changes to signing script or entitlement files.
TEST=ci
Change-Id: Ied90ee7b81a23de266d6f7dc5e642a820dac9248
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506341
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-27 06:34:31 -07:00