Commit Graph

24182 Commits

Author SHA1 Message Date
Ryan Macnak fc750ac8e0 [build] Remove unsigned executable memory permissions from the AOT runtime on Mac.
Snapshots are now generally signed Mach-O dylibs loaded by dlopen, instead of ELF files mapped executable by the VM's loader.

TEST=ci
Change-Id: Id19877bed0bd0282b320f070904a848b0c076a54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505200
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-06-01 07:21:29 -07:00
Konstantin Shcheglov 0e976d5ab1 Augment. Report recursiveInterfaceInheritance on the clause, if self-reference.
Report direct recursive interface inheritance diagnostics on the
inheritance clause that introduces the cycle, rather than on the class
or mixin name. This gives a more precise target for self-references in
extends, implements, on, and with clauses.

Track recursive inheritance reporting per interface element across
fragments so that augmentation clauses can produce the specific
diagnostic when they introduce the cycle. Defer the generic cycle
diagnostic while earlier fragments still have later augmentations to
inspect, and use the element target as the fallback location for
indirect cycles.

Update diagnostic expectations to match the new locations and cover
augmentation and part-file cases for recursive extends, implements, on,
and with clauses.

Change-Id: I480a56e4b766d704c290d67d9ca4f6a73a2f655b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507300
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-29 12:57:07 -07:00
Yash(VictoWolf) 16441c6025 Clarify WebSocket.addError behavior
Document that WebSocket.addError does not transmit an error event to the
remote peer and only reports the error locally.

Changes:
* sdk/lib/_http/websocket.dart

Bug: dart-lang/sdk#45733
Change-Id: I8913ac4fb466e9d613b3f0c5f0727640c9d9a913
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502500
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2026-05-29 08:23:06 -07:00
Alexander Aprelev 02b30d5275 [vm/shared] Implement Isolate pinToCurrentThread, isPinnedToCurrentThread.
TEST=threading_pinning_test

Change-Id: I9a80543a06dbf51c070fed5c0e64eeba247497de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497126
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-05-29 07:58:23 -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
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 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
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
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
Erik Ernst 3263555dc5 Start implementation of anonymous block methods
This CL introduces support for anonymous block methods (that is,
`e.{ print(this); }` as opposed to `e.=> print(this);`). It introduces
the notion of a `ReturnContext` which is used to change the semantics
of a return statement when it returns from an anonymous method (where
it works like a `break` that terminates the execution of the block
which is the body of the enclosing anonymous method), but keeps the
semantics of return statements returning from a function (including
function literals) still have the same semantics as today.

Change-Id: I404459361fbb7c2e495e46d1bd29924063f3aac4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503800
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-05-27 06:04:46 -07:00
Sergey G. Grekhov 0124cf29fe [co19] Roll co19 to 8a302a4666a9adae63b52fb49f37e7407935f13c
2026-05-22 sgrekhov22@gmail.com Fixes dart-lang/co19#3810. Fix typos in static_member_and_instance_member_t06.dart (dart-lang/co19#3811)
2026-05-21 sgrekhov22@gmail.com dart-lang/co19#2303. Add missing `Directory.create(Sync)` tests (dart-lang/co19#3806)
2026-05-21 sgrekhov22@gmail.com dart-lang/co19#2303. Make `Link.create()` tests stronger (dart-lang/co19#3809)
2026-05-21 sgrekhov22@gmail.com dart-lang/co19#2303. Make `Link.createSync()` tests stronger (dart-lang/co19#3808)
2026-05-21 sgrekhov22@gmail.com dart-lang/co19#2119. Remove unused imports (dart-lang/co19#3807)
2026-05-20 sgrekhov22@gmail.com Fixes dart-lang/co19#3803. Updated tests for abstract variable augmenting a getter/setter (dart-lang/co19#3804)
2026-05-20 sgrekhov22@gmail.com dart-lang/co19#2119. Remove invalid test attributeChanged_A01_t01.dart (dart-lang/co19#3805)
2026-05-19 sgrekhov22@gmail.com dart-lang/co19#2303. Refactoring. Make names of auxiliary functions more clear (dart-lang/co19#3802)
2026-05-18 sgrekhov22@gmail.com dart-lang/co19#2303. Add more tests for File.create(Sync) method (dart-lang/co19#3797)
2026-05-18 sgrekhov22@gmail.com Fixes dart-lang/co19#3799. Update expected errors in applying_augmentations_A04_t03.dart (dart-lang/co19#3801)
2026-05-12 sgrekhov22@gmail.com Fixes dart-lang/co19#2162. Add more member conflict tests and test cases. (dart-lang/co19#3796)
2026-05-12 sgrekhov22@gmail.com Add tests for LUB calculation (dart-lang/co19#3790)
2026-05-12 sgrekhov22@gmail.com Add flow analysis test for `await Never` (dart-lang/co19#3795)
2026-05-11 sgrekhov22@gmail.com Fixes dart-lang/co19#3791. Update error expectations in initializers_t04.dart (dart-lang/co19#3793)
2026-05-08 sgrekhov22@gmail.com Fixes dart-lang/co19#3788. App tests for `FileSystemEntity.parentOf()` (dart-lang/co19#3789)

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

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,dart2js-minified-linux-d8-try
Change-Id: I50c3d1b1cb62b4cd7b370591c9131a3ff6b61d38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505780
Auto-Submit: Sergey Grekhov <sgrekhov22@gmail.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-05-26 02:13:45 -07:00
Nate Bosch b162f6717d [io] Fix FileSystemEntity.type and Link.exists with IOOverrides
Fixes #63418

When IOOverrides are active, `fseGetType` and `fseGetTypeSync` used
`utf8.encode(path)` which does not null-terminate the path. Native
APIs require null-terminated paths. Through luck the sync path worked
but the async path failed with `notFound`.

Update them to use `FileSystemEntity._toUtf8Array(path)` which correctly
null-terminates the path.

Tested: added a regression test to tests/standalone/io/io_override_test.dart

TAG=agy
CONV=ab6af504-d536-4a8d-88be-bc487b60e24d
R=bkonyi@google.com

CoreLibraryReviewExempt: No API changes.
Change-Id: I24e31efdcbecc703800b96a144e41a095a445cff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505201
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
2026-05-22 14:13:35 -07:00
Paul Berry 4b88e5ab0f Bump package:expect version in standalone package tests.
The tests in `tests/standalone/package/` don't use the top level
`package_config.json` file; they use their own internal file, which
apparently hasn't been updated recently. This change bumps the version
of `package:expect` in that file to version 3.13, which will allow
`package:expect` to start using Dart language 3.13 features without
breaking tests.

Change-Id: Ia2975d540aa503e8f69944e0e1c275c56a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505580
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-05-22 08:04:08 -07:00
Simon Binder 3196571c9b [dart2wasm] Move wasm-js interop to dart:_js_interop_wasm
Some features in `dart:_wasm` are relevant for all WebAssembly targets
(like interop types or memory intrinsics). Others, in particular the
helper methods to convert between `WasmExternRef` and `JSAny`, don't
make sense for the standalone target.

To be able to remove the `js_interop` library from the standalone
target, we need to stop importing it from `dart:_wasm`. To prepare that
step, this moves the helpers to a new library (`dart:_js_interop_wasm`)
and re-exports them from `dart:_wasm`.

Once Flutter has migrated to the new import, the export can be removed.

Bug: https://github.com/dart-lang/sdk/issues/63166
Change-Id: I13fe875e509a13d16c48d420a5927d3130b90736
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505080
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Simon Binder <oss@simonbinder.eu>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-22 04:06:27 -07:00
Erik Ernst 945978f5c0 Change code generation for dart2js to enable capturing
This CL changes the code generation for `dart2js` (and not for any other
backend) such that the variable holding the receiver of an anonymous
method invocation is declared as a normal local variable rather than
being a `Let` variable. This is needed because `dart2js` supports
capturing the former, but not the latter.

Change-Id: I054805f7006306186f2c6dfe36d7162b42293ae1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503420
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
2026-05-21 04:22:30 -07:00
Martin Kustermann 84704290ab [vm] Change various external FFI declarations from Object to Object?
The C side can return any object, including `null`, we should therefore
change those declarations to return top type / `Object?`.

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

TEST=https://dartbug.com/63411

CoreLibraryReviewExempt: Internal only changes
Change-Id: I6478e39113fba5d422059de62b88fe738ddbfc05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504920
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-20 02:28:18 -07:00
Simon Binder 58f9d88fb2 [dart2wasm, standalone] Migrate String
This migrates the `String` implementation from using JS interop to
explicit host imports for the standalone target.

This moves a few helper methods shared between the JS and standalone
targets to `dart:_string_helper`. This also moves the embedder regexp
implementation to `dart:_string` to be able to access internals in some
string methods (similar to how the JS implementation special-cases
`JSSyntaxRegExp`).

This removes the final real use of JS-interop in the standalone target.
So, we can:

 - Remove internal JS helper libraries from the target.
 - Skip JS-interop transformations in the compiler.
 - Stop emitting a helper module and support script.

Because `js_interop` is imported in `dart:_wasm`, we can't remove the
library entirely. This replaces it with a stub to avoid compilation
errors, a proper removal is tracked in dartbug.com/63166.

Change-Id: Ide495c210c3a272438deebf8fe4f3f44ba314ffa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501960
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-20 00:22:27 -07:00
Ryan Macnak d36adbacaf [vm] Remove the VM isolate.
The former contents of the VM isolate are now included into each isolate group. This makes each isolate group's heap independent, and in particular allows each heap to be allocated to a separate pointer cage (not done in this CL).

The duplicated stubs that allowed PC relative calls are removed, since the originals can now be the target of PC relative calls.

The bootstrapping needing to load an AppJIT or AppAOT snapshot is reduced to allocating the oddballs. The code is entirely dropped in the AOT runtime, but the JIT runtime still has it to allow for flags to affect the compilation of the stub code. Further refactoring might be able to remove this for the JIT runtime too, with only gen_snapshot knowing how to bootstrap.

Class serialization no longer distinguishes predefined classes.

The page containing null is marked as never-evacuate. null, false and true must not move because the compiler relies on their low bits having certain patterns for some optimizations. (Previously, the entire VM isolate heap never moved.)

Compaction is disabled for IA32. Due to register pressure, some stub calls must not use a scratch register and embed the address of Code.

The page containing the call-through-safepoint stub is frozen when running with --write-protect-code and the stub is created at runtime (instead of loaded from an AppJIT or AppAOT snapshot). This stub must remain executable even during a safepoint, as a foreign call might during return during a safepoint and only block after the stub directs it to the runtime.

The snapshot symbols are renamed to kDartSnapshotData and kDartSnapshotText. There is no need to distinguish the VM isolate's snapshot, and snaphots are per isolate group not per isolate. Aliases with the old names are added to ease migration.

Some global flags that were automatically set based on the VM isolate's snapshot are now isolate group flags and automatically set by the isolate group's snapshot.

TEST=ci
Change-Id: Iee82016057d609112e9b021d178fc3d4d18b5044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500621
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-18 11:35:03 -07:00
Kallen Tu 2edcad4892 [tests] Primary constructors: Format and generate errors for all tests.
Cleaned up and formatted the tests, regenerated some errors where they were "unspecified", and removed the experiment flag enabling in each test.

Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: Ic5b652af660cbc4f71731b1547c7a58c7726faca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503500
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-05-18 10:00:37 -07:00
Konstantin Shcheglov 5ed538a532 Bug fix: implement missing diagnostic implementsSuperClassConstraint.
It is disabled when augmentations feature is enabled.

This is not a breaking change, because CFE did report this error.

The relevant reason is indirect, not a single sentence saying “on A
implements A is forbidden”.

Spec chain:

1. In dartLangSpec.tex:6019, a mixin declaration is modeled as:

`mixin N<T...> on T1, ..., Tn implements I1, ..., Ik { ... }`

2. In dartLangSpec.tex:6065, the mixin interface M_I is defined as if
by:

`abstract class N<T...> implements T1, ..., Tn, I1, ..., Ik { ... }`

and dartLangSpec.tex:6078 says it is a compile-time error for the mixin
if that synthetic class declaration would be a compile-time error.

3. In dartLangSpec.tex:5189, class superinterfaces say:

It is a compile-time error if two elements in the type list of the
IMPLEMENTS clause of a class C specifies the same type T.

So:

`mixin M on A implements A {}`

is checked like:

`abstract class M implements A, A {}`

which violates the duplicate implements type rule.

Change-Id: I29e5fa17c47d111346ef6a6e321ab5dbab985ad1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503501
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-18 07:55:50 -07:00
peeefour 1d80afe498 [vm/io] Range check Socket_SendMessage arguments
Closes https://github.com/dart-lang/sdk/pull/63365

GitOrigin-RevId: 344604dd1a17b73c6665026e7e75693fe0fa7ca7
Change-Id: I8f51d5735a56564f2181bcd1206c9cfdff80f077
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502960
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-13 03:40:04 -07:00
Erik Ernst 96a4dd4c19 Modify property promotion: only this
https://dart-review.googlesource.com/c/sdk/+/498840 added support for
promotion of properties (private, final instance variables with a name
which isn't used much for other purposes) in the context of anonymous
methods.

This CL reduces the set of situations where this feature is enabled such
that only `this` will allow property promotions to be carried in (such
that `this._x` is promoted in `v.=> this._x` when `v` is such that
`v._x` has been promoted before the anonymous method occurs). It also
generalizes the mechanism such that property promotions are carried out
(so we can do `if (v.=> _x is int) v._x.isEven;`).

Tests has been adjusted accordingly.

Change-Id: Ibe70713d3d9c89a6d95f9c3dd28df8f147cb518d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502660
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-05-13 00:08:24 -07:00
Nate Biggs 63d042fe0d [dart2wasm] Fix dynamic dispatch table population for multiple modules.
When deferred loading was enabled the dynamic dispatch class ID table
was incorrectly assigning class IDs to the wrong module. If a contiguous
target segment included classes/targets from different modules, all of
them were getting assigned to the module of the first class/target in
that segment.

This was causing spurious NSM exceptions as the necessary rows in the
table might not be populated for a dynamic call if the module the
segment was assigned to wasn't loaded yet.

To fix this we end the segment if the next target does not belong to the
same module as the active segment.

The new test fails with an NSM exception prior to this fix.

Change-Id: I07bc4fdb5a8bff1bfad5fe17f45c8076a965a775
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502860
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-05-12 12:54:38 -07:00
Modestas Valauskas 754239b077 [core] Add trailingZeroBitCount and oneBitCount to int
Adds two new getters to int for bit-counting: trailingZeroBitCount
(ctz) and oneBitCount (popcount). On native platforms they operate
on the full 64-bit two's-complement representation; on the web they
operate on the least-significant 32 bits.

Implementations:
- VM: unified C++ natives Integer_trailingZeroBitCount /
  Integer_oneBitCount on _IntegerImplementation, using
  Utils::CountTrailingZeros64 and Utils::CountOneBits64. The receiver
  may be _Smi or _Mint at runtime.
- dart2js / DDC: clz32-based ctz and a SWAR popcount.
- dart2wasm: inlined i64.ctz and i64.popcnt intrinsics.

leadingZeroBitCount (clz) is intentionally excluded from this CL: its
result depends on the platform integer width (e.g. 1.leadingZeroBitCount
is 31 on web, 63 on native), and the same value can be derived from
the existing bitLength getter when needed.

Asm intrinsification on native architectures is intentionally left for
a separate follow-up CL.

Work towards https://github.com/dart-lang/sdk/issues/6486 (this CL
covers popcount and ctz from the bit-twiddling list; clz, rotate,
reverse, and others remain).

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

Bug: https://github.com/dart-lang/sdk/issues/52673
Bug: https://github.com/dart-lang/sdk/issues/38346
TEST=tests/corelib/int_bit_count_test

Change-Id: I8a5cdb5c91360478f47bbd6b9c84ca1c477aa8c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498041
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2026-05-12 05:49:31 -07:00
Alvin 7bc22cf877 [vm/io] Range check SynchronousSocket_WriteList arguments
Closes https://github.com/dart-lang/sdk/pull/63358

GitOrigin-RevId: 1a5eb0d7e11fca131a721cd0535954f96ac1dfaf
Change-Id: I670ebdd4fadef383872a9d719efa22d6479b812d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502441
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-12 00:32:52 -07:00
Nate Biggs 0af31e37bb [dart2wasm] Fix context collection emptiness false positive.
In some cases, closure contexts were being left out of the parent chain
of their children because they were empty at the time the child closure
was created. If a usage appeared later in the visit of the parent, the
context would no longer be empty but the child would already be created
without a parent.

This was easiest to recreate in sync* function because unlike async, it
doesn't introduce hoisted helper variables (these immediately mark the
parent as non-empty).

In the attached bug the repro only happens with named parameters because
TFA transforms the named parameter into a Let that introduces a variable
before the closure with the usage in the let body after the closure. The
new test explicitly introduces the same pattern of a variable declared
before the closure and used after it.

The fix here is to not eagerly check for emptiness of the parents.
Instead we post-process the Contexts and relink the parent tree skipping
any empty nodes.

Bug: https://github.com/dart-lang/sdk/issues/63264
Change-Id: I2f75506b9fa879544b1a606d8f157fbd44ba8ce2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500680
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-05-07 09:21:19 -07:00
Erik Ernst 1b75e2701c Support promotion of instance variables with anonymous methods
This CL adds support for promotion of certain private final instance
variables along with anonymous methods. The promotions do not differ
from the ones which are already available in Dart without anonymous
methods, but it requires some generalizations to handle the changing
value of `this` which is made possible by anonymous methods.

Change-Id: I720a5fa6d29a8a7d19bb2e167dc135f97492b525
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498840
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-07 05:39:13 -07:00
Konstantin Shcheglov 0a5604c223 Support for cross-file context messages in test_runner/.
Bug: https://github.com/dart-lang/sdk/issues/63318
Change-Id: Ie02aef92d9ab0e04ce864a85ed6071d5e4b5e14f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500820
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-06 13:23:57 -07:00
mohammadmseet-hue 794b281da3 fix: cap uncompressed WebSocket frame size to prevent peer-induced OOM
Closes https://github.com/dart-lang/sdk/pull/63257

GitOrigin-RevId: 47b50221f808d62c660d855b10cc1f22981c996a
Change-Id: I8c42b12277982caf0da5a627dc8de12102595d0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498460
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-06 04:54:42 -07:00
Johnni Winther a782aed439 [cfe][PrimaryConstructors] Add AsyncModifier
This adds an AsyncModifier class that holds both the AsyncMarker, used in the kernel encoding, and the file offset of the async modifier. This is used throughout the front end and ensures that the correct offset is used for errors reported on the async modifier.

Change-Id: If16d293ffb9b2e8fa8eca8c65f7548d920c5d56b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-06 01:35:05 -07:00
Alexander Aprelev 00cda4d60f [ffi/isolate_group] Move IsolateGroupBound callbacks from isolate to isolate group.
This allows creation of isolategroup-bound callbacks when isolate is not available. For example, to support proposed Isolate::onEvent/Isolate::handleEvent api https://github.com/dart-lang/language/blob/main/working/333%20-%20shared%20memory%20multithreading/shared_native_memory.md#additional-isolate-apis.

BUG=https://github.com/dart-lang/sdk/issues/63291
TEST=isolate_group_bound_callback_test

CoreLibraryReviewExempt: vm ffi-specific comments changes
Change-Id: I9a757a39ba8e152db64f59a66d337ca672103277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499661
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-05-05 08:37:06 -07:00
Ivan Ugryumov 6dd8ad5397 Add InterfaceAddress for broadcast address support
Closes https://github.com/dart-lang/sdk/pull/63088

GitOrigin-RevId: c72afbbbf2774fd4c3c3f83b69c30e86e4302abd
Change-Id: I2462f006dcbe2256b019c5b13674ca0d93838fc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/492180
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-05 01:15:37 -07:00
mohammadmseet-hue 4d6c9b756c fix: reject Set-Cookie with SameSite=None but no Secure attribute
Closes https://github.com/dart-lang/sdk/pull/63254

GitOrigin-RevId: 18d7d0e46c31783ff200657c0f81d029e9a64231
Change-Id: I3019e7733b6e2a3e1634b6bb7f8bb5e17be35d4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498423
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-05 00:53:33 -07:00
Kallen Tu 8bfb683892 Enable 'primary-constructors' feature flag.
This CL enables the primary constructors feature by default in Dart 3.13.

The primary constructors feature is a brevity feature. There are no new semantics, but it allows us to express declarations in a less verbose way.

This feature allows one constructor and a set of instance variables to be specified in the header of a declaration.

Currently a declaration with a constructor and some fields is written as:

```dart
// Current syntax.
class Point {
  int x;
  int y;
  Point(this.x, this.y);
}
```

With a primary constructor, we would write the above as:

```
class Point(var int x, var int y);
```

If a primary constructor needs an initializer list or a body, they can be
specified inside the class using the `this` body syntax:

```dart
class Point(var int x, var int y) {
  this : assert(x >= 0) {
    print('Point created at $x, $y');
  }
}
```

As part of this feature, you can also use the `new` and `factory` keywords to
declare constructors in the class body without repeating the class name:
```dart
class Point {
  int x, y;

  // Equivalent to Point(this.x, this.y)
  new(this.x, this.y);

  // Equivalent to Point.origin()
  new origin() : x = 0, y = 0;

  // Equivalent to factory Point.clone(Point other)
  factory clone(Point other) => Point(other.x, other.y);
}
```

To learn more about the feature, check out the feature specification located here: https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md

Tested: Has existing language, CFE, analyzer, analysis server tests.
Bug: https://github.com/dart-lang/sdk/issues/61524
Change-Id: I296f2fcd918b87bf2a1dd00256340759866c2423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489241
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-05-04 15:09:49 -07:00
Paul Berry 9dfa6738c9 Revert "[flow analysis] Fix unsound type promotion in inner async/generator functions."
This reverts commit 3eb697c0af.

Reason for revert: Internal Google3 breakages

Original change's description:
> [flow analysis] Fix unsound type promotion in inner async/generator functions.
>
> An `await` expression or `yield` statement suspends the current
> function and allows other code in the same isolate to execute. In the
> case of nested functions, an `await` or `yield` in the inner function
> can allow the outer function to continue executing. That means that if
> the inner function promotes a local variable belonging to the outer
> function, then it isn't sound to carry that promotion past an `await`
> or `yield`.
>
> This change fixes the unsoundness by adding a flow analysis method
> `suspension`, which the shared type analysis logic uses to tell flow
> analysis that an `await` or `yield` has been found. The `suspension`
> method un-does the promotions of any variables that might be written
> to while the inner function is suspended.
>
> Fixes https://github.com/dart-lang/sdk/issues/62889.
>
> Change-Id: I77eaf997159819a7c50f44b67174d2aa6a6a6964
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499382
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>

Change-Id: I187ba9a347394946ecc8749d35dc7914d271b90a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500540
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-05-04 10:37:11 -07:00
Lasse R.H. Nielsen f35a3fcce4 Add alternatives for functions that should be deprecated.
`List.unmodifiable` and `Map.unmodifiable` is as badly typed
as `List.from` and `Map.from`, but does not have a better-typed
`.of` constructor. This adds such, to give a migration target
when deprecating the badly typed constructors.

The `Future.delayed` with no second argument is also unsafely
typed, it fails if the type argument is not nullable.
The `Future.pause` creates `Future<void>` instead.

CoreLibraryReviewExempt: No new or platform specific behavior.
Change-Id: Iba101b3dc62f412003abd501fa042aca0ce63116
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499280
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2026-05-04 08:08:35 -07:00
Paul Berry 3eb697c0af [flow analysis] Fix unsound type promotion in inner async/generator functions.
An `await` expression or `yield` statement suspends the current
function and allows other code in the same isolate to execute. In the
case of nested functions, an `await` or `yield` in the inner function
can allow the outer function to continue executing. That means that if
the inner function promotes a local variable belonging to the outer
function, then it isn't sound to carry that promotion past an `await`
or `yield`.

This change fixes the unsoundness by adding a flow analysis method
`suspension`, which the shared type analysis logic uses to tell flow
analysis that an `await` or `yield` has been found. The `suspension`
method un-does the promotions of any variables that might be written
to while the inner function is suspended.

Fixes https://github.com/dart-lang/sdk/issues/62889.

Change-Id: I77eaf997159819a7c50f44b67174d2aa6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499382
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2026-05-01 07:16:25 -07:00
Paul Berry 07b9707d96 [front end] Perform hoisting after coercion.
Coercion from `dynamic` to a non-top type has observable effects,
since it may throw an exception. Therefore it's important that any
tree manipulations that are performed as part of type inference (such
as hoisting of named arguments that precede unnamed ones) preserve the
order of coercions relative to expression evaluation.

Prior to this change, the following code:

    f(n: e1, e2)

Would get transformed into:

    let tmp = e1 in f(coerce(e2), n: coerce(tmp))

And so the coercion of e1 would not happen until after the evaluation
of e2.

With this change, the code is transformed into:

    let tmp = coerce(e1) in f(coerce(e2), n: tmp)

Which (correctly) coerces e1 before evaluating e2.

Fixes https://github.com/dart-lang/sdk/issues/63150.

Change-Id: Iee33c162c7cc3a9b0a8b03bde211bf926a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498980
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-30 11:05:39 -07:00
mohammadmseet-hue c5d23e0df3 fix: HTTP request smuggling via Transfer-Encoding token whitespace
Closes https://github.com/dart-lang/sdk/pull/63250

GitOrigin-RevId: 7c6b7bf7d033dd31dc23a7cc3a30b3dc4db41d16
Change-Id: I573328660bbef7ec9cd829ec376fcee894a6bc34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498420
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-30 00:52:02 -07:00
mohammadmseet-hue 890f7e8aa9 fix: do not forward Authorization/Cookie to subdomains on redirect
Closes https://github.com/dart-lang/sdk/pull/63256

GitOrigin-RevId: 1cf4d94690343b4df087e7c583154a36580fff71
Change-Id: I186e9338e36ee72714d385444e6fbf3b217ec4ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498424
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-04-29 00:54:05 -07:00
Martin Kustermann b8b0cad67a [dart2wasm] Make most void functions have no return values
This gives around 0.2% improvement in compressed e main module.

In Dart a function with `void` return type can actually return values
that callers can observe. But most of the time this doesn't happen, most
times those functions return `null` values and callers don't observe
them.

Let's use inferred return value information to see if a function is
guaranteed to only return `null`. If so we make the wasm function
signature not return any values. Callers will then synthesize a `null`
which may immediatly be dropped or (in rare cases) actually be used.

This leads to less less instructions in the callee (as a callee doesn't
need to push the null onto the stack) and the caller (as the caller
doesn't have to drop it from the stack).

Change-Id: I3ed1be7592798ad0c697c5bc3ab2c4b64c156f03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497620
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-04-28 00:20:02 -07:00
mohammadmseet-hue 75479bc7a7 fix: reject HTTP requests with Transfer-Encoding not ending in chunked
Closes https://github.com/dart-lang/sdk/pull/63251

GitOrigin-RevId: 55ef08553ee65ab1052a46b92ff57f097863c340
Change-Id: Ibd3e93b553e046962bba36ec683b0d2bb157b264
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498401
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-27 23:59:39 -07:00
Srujan Gaddam 94e1217774 Reland "[dart:js_interop] Make JSFunction and JSExportedDartFunction generic"
This is a reland of commit e7dbd6ba48

Original change's description:
> [dart:js_interop] Make JSFunction and JSExportedDartFunction generic
>
> Fixes https://github.com/dart-lang/sdk/issues/54557
>
> The generic type in JSExportedDartFunction corresponds to the
> static type of the function it wrapped, whereas for JSFunction,
> it's purely a descriptor of the JS function.
>
> When calling JSExportedDartFunction, a cast is now introduced
> to cast it to T.
>
> When calling isA, the type in JSExportedDartFunction is passed
> along to check that the value that is wrapped is that function
> type. Because the T in JSFunction is descriptive, e.g.
> isA<JSFunction<int Function()>>() does no such check.
>
> ____
>
> Also cleans up:
>
> - isA<JSTypedArray>() logic to use intrinsic functions
> - some expectation files to be consistent for both dart2js and ddc.
>
> CoreLibraryReviewExempt: Backend-specific library with needed reviews.
> Change-Id: I1a55c4386e416fa4ccabe06ac5051f41c2e2e95a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496820
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

CoreLibraryReviewExempt: Reland.
Change-Id: I29d706aa4967fd80390e8cb37f8144603ec007f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498100
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-04-27 20:32:55 -07:00
Nate Biggs 3d2d6492c1 Add 'external-effect' pragma support to all the backends.
Call sites targeting a procedure annotated with `external-effect` will
not produce any code, including the argument which will not be
evaluated.

However, the single parameter will be treated as 'live' for the purposes
of any global analysis the backends do. This is useful for things like
protobuf shaking where a user may want to retain certain protobuf
messages without actually emitting the code that retains those messages.

Today this functionality is available internally in the vm and wasm SDK
libraries. dart2js has similar functionality represented via the
opaqueTrue and opaqueFalse booleans (which will cause conditional
branches to get shaken after analysis). This will replace dart2js's
opaque(True/False).

This also adds validation to the frontend to ensure a method annotated
with 'external-effect' is well-formed.

Change-Id: If1c4096673e655c58fe7638840a16125003e7809
Tested: Backend tests for codegen were added. A frontend test was added for the validation. A language test was added to confirm the behavior.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476020
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-04-27 09:42:38 -07:00
Simon Binder 03fd5927a4 [dart2wasm, standalone]: Avoid importing js-string constants
dart2wasm imports strings as globals for which JavaScript engines would
provide the respective values. The standalone target needs to support
all WebAssembly runtimes, so it can't rely on this mechanism.

Instead, this imports functions to convert a WebAssembly arrays of char
codes or ASCII bytes into a string. For now, these functions have to
return JS strings since the rest of the SDK relies on that. In the
future, embedders would be able to return any string implementation as
an externref.

Because calling host functions is invalid in constant contexts, string
constants can't be regular globals. For now, this uses the default
non-eager constant implementation with one initialization function per
string constant. Eventually, we should probably initialize these
strings in a WASM start function instead.

TEST=pkg/dart2wasm/test/standalone_test.dart
Change-Id: I93b7c3846fbe99daa8ffa31e452f62672b61ce4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495020
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-04-24 10:49:11 -07:00
Kallen Tu 77cf3047a3 Dot Shorthands: Const selector chains.
I changed the parsing of const dot shorthands to parse the entire selector chain in `parsePrecedenceExpression` rather than parsing them in `parseConstExpression`. We were originally parsing the initial expression before the `.` and only flagging that as a dot shorthand which prevented any chaining on const constructors. Const expressions with chained methods/property accesses were not being flagged as a dot shorthand so we weren’t saving the context type properly which led to producing the “unknown context type” error.

Before:
```
class C {
  const new someConstCtor();
  C method() => this;
}

C c = const .someConstCtor.method();
// (const .someConstCtor) is parsed and handled as a const constructor
// (const .someConstCtor) is handled as a dot shorthand, context is
// saved on only this AST and not the outer chain.
// Then we parse the rest of the selector chain (.method())
//
// Error: No context type for (const .someConstCtor.method())
```

After:
```
class C {
  const new someConstCtor();
  C method() => this;
}

C c = const .someConstCtor.method();
// (const .someConstCtor) is parsed and handled as a const constructor.
// Then we parse the rest of the selector chain (.method())
// (const .someConstCtor.method()) is handled as a dot shorthand, context is saved for this outer node.
//
// OK. No error because we are able to retrieve the type for the
// entire dot shorthand chain.
```

Fixes: https://github.com/dart-lang/sdk/issues/63119
Change-Id: I3308d8eb7ce101466be257aba6b5448921bff136
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-04-24 10:40:26 -07:00
Srujan Gaddam 442bdeda4a Revert "[dart:js_interop] Make JSFunction and JSExportedDartFunction generic"
This reverts commit e7dbd6ba48.

Reason for revert: Broke flutter_analyze

Original change's description:
> [dart:js_interop] Make JSFunction and JSExportedDartFunction generic
>
> Fixes https://github.com/dart-lang/sdk/issues/54557
>
> The generic type in JSExportedDartFunction corresponds to the
> static type of the function it wrapped, whereas for JSFunction,
> it's purely a descriptor of the JS function.
>
> When calling JSExportedDartFunction, a cast is now introduced
> to cast it to T.
>
> When calling isA, the type in JSExportedDartFunction is passed
> along to check that the value that is wrapped is that function
> type. Because the T in JSFunction is descriptive, e.g.
> isA<JSFunction<int Function()>>() does no such check.
>
> ____
>
> Also cleans up:
>
> - isA<JSTypedArray>() logic to use intrinsic functions
> - some expectation files to be consistent for both dart2js and ddc.
>
> CoreLibraryReviewExempt: Backend-specific library with needed reviews.
> Change-Id: I1a55c4386e416fa4ccabe06ac5051f41c2e2e95a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496820
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I98447c8c95906feb7f8f1a57859a24fc8e4966d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498080
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
2026-04-24 09:31:08 -07:00
Srujan Gaddam e7dbd6ba48 [dart:js_interop] Make JSFunction and JSExportedDartFunction generic
Fixes https://github.com/dart-lang/sdk/issues/54557

The generic type in JSExportedDartFunction corresponds to the
static type of the function it wrapped, whereas for JSFunction,
it's purely a descriptor of the JS function.

When calling JSExportedDartFunction, a cast is now introduced
to cast it to T.

When calling isA, the type in JSExportedDartFunction is passed
along to check that the value that is wrapped is that function
type. Because the T in JSFunction is descriptive, e.g.
isA<JSFunction<int Function()>>() does no such check.

____

Also cleans up:

- isA<JSTypedArray>() logic to use intrinsic functions
- some expectation files to be consistent for both dart2js and ddc.

CoreLibraryReviewExempt: Backend-specific library with needed reviews.
Change-Id: I1a55c4386e416fa4ccabe06ac5051f41c2e2e95a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496820
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-04-23 20:55:26 -07:00
Simon Binder 0ae4f93e29 [dart2wasm,standalone] Split patch files by whether they use JS interop
This is a re-land of 152cc24, which has been reverted in 3f9ae7. Unlike
the original change, this doesn't alter the `dart:_wasm` library.
We can revisit an API split to remove `js_interop` APIs there once the
standalone target has progressed further.

Original change's description:
> [dart2wasm] Split patch files by whether they use JS interop
>
> The eventual goal of the `dart2wasm_standalone` platform is to not rely
> on a JavaScript environment, which requires rewriting everything that
> currently relies on `js_interop` or `JS()` helpers.
>
> Since most of the patches are still written in Dart and we don't want
> to duplicate that code for the standalone target, this splits patch
> files by whether they rely on JS-interop or not. The main entrypoint
> for each patch (e.g. `lib/_internal/wasm/lib/core_patch.dart`) no
> longer relies on JS-interop and can safely be used in the standalone
> target. Part files that previously needed to use JS-interop have been
> moved into separate patches now, which allows us to migrate them
> incrementally.
>
> In some cases, it was easier to add new patch files:
>
> - Similar to the split between `boxed_int` and the `toString` helper
>   patch, we now have the same for `boxed_double`.
> - The functionality to copy from JS typed data wrappers into Dart typed
>   lists wouldn't work with standalone, so I've moved it into a separate
>   method we can patch to be a noop.
> - `dart:_wasm` exposes APIs to convert between `JSAny` and `externref`.
>   This is part of a public API, but I had to move those declarations
>   into a patch file because they wouldn't work with standalone.
>   Arguably, a separate library (`dart:_wasm_js_interop`?) would be
>   cleaner but it might be fine as long as `dart:_wasm` is experimental?
>
> For now, new patch files relying on JS interop are also applied to the
> standalone target. They are marked with a comment indicating that they
> need to be migrated though.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try
Change-Id: I98a628f96cba7e0f0af7e86e058cda43c2c73898
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495302
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-04-22 23:54:32 -07:00