Commit Graph

3593 Commits

Author SHA1 Message Date
Parker Lougheed 84088f6a8b [ddc] Migrate stack_trace_mapper to static JS interop
Also removes the dependency on `package:js` as this was the only remaining usage.

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

Change-Id: Icba5bce7fbc087ed2284754656bf06493c516009
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510100
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-06-11 09:32:44 -07:00
Johnni Winther 6b693e00bc [kernel][Contexts] Add VariableDeclaration
This adds a VariableDeclaration node which is used in ForStatement instead of VariableStatement.

This is a step towards removing the initializer from Variable. Long term, VariableDeclaration will own the initializer expression for variables and function parameters will have a defaultValue property instead of using the initializer property for the default value.

TEST=existing

Change-Id: I4a663eeb6006a0f9f098fb2b3e3b502d2ae583b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505681
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2026-05-27 00:41:34 -07:00
Johnni Winther 80c9d57250 [kernel][Contexts] Rename VariableDeclaration to Variable
This is a step towards split variables from their declarations as part of encoding variables and their usage more precisely.

TEST=existing

Change-Id: I4a0eeb2947bdebce3667afda4e6cfbfdf5d7de18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504201
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
2026-05-21 01:51:10 -07:00
Nicholas Shahan 68a3d4e688 [ddc] Allow blocks to appear in scope offset test
With the addition of the const constructors in extension types there
are now blocks appearing in SDK outline .dills.

The missing file offsets were added in
https://dart-review.googlesource.com/c/sdk/+/497842.

Fixes: https://github.com/dart-lang/sdk/issues/63226
Change-Id: I7e40578927008f39c54366f39bef300dbcb45e27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504400
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-05-19 10:26:05 -07:00
Johnni Winther e30cd0322c [cfe][Contexts] Split VariableDeclaration and VariableStatement
This separates VariableDeclaration from Statement. VariableDeclaration no longer implements Statement and variable declared in a block or in a for-statement are now wrapped by a VariableStatement.

Currently there are two VariableStatement implementations; LegacyVariableStatement for variables in the current model, called LegacyVariable, and VariableInitialization for variables used in the new, still experimental, encoding that supports scope computation.

This CL is a step towards realigning the AST nodes to the new model in which each kind of variable has its own distinct subclass. (LocalVariable, PositionalParameter, NamedParameter, SyntheticVariable, etc.)

Note that it is not the intent to use VariableStatement in ForStatement going forward but that will be handled in a follow-up.

TEST=existing.

Change-Id: I5b309cd62c9b138f95b74fb054686edffa49a393
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502681
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-18 05:49:28 -07:00
Erik Ernst 8028bd03fb Resolve test failures with web configurations
This CL adds code such that web compilers can recognize that `Let` nodes
can have a non-temporary variable as parameter. Before this CL, ddc
configurations fail in many anonymous method tests because the given
explicitly declared parameter isn't made available to the body of the
anonymous method.

Bug: https://github.com/dart-lang/sdk/issues/63184
Change-Id: I308c89e91e3856a06fa8f003d213cda0d93ae261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498060
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-05-09 07:13:11 -07:00
Nicholas Shahan 77c65d60ec [ddc] Fix type in matcher in scope offset test
It looks like the type expectation in the block visitor of this test
has always been wrong and we might have never visited a block before.

It looks like fixing the failing type expectation reveals an actual
failure that this test is trying to catch: The block node doesn't
have a valid offset.

Issue: https://github.com/dart-lang/sdk/issues/63226
Change-Id: I4b8d7b60350b627e10a974a2d794db1973b3fff1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502184
Reviewed-by: Nate Biggs <natebiggs@google.com>
Auto-Submit: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-05-08 12:57:06 -07:00
Nicholas Shahan de18b40933 [ddc] Split hot restart into two phases
Exposes two new methods `hotRestartBegin()` and `hotRestartEnd()` in
the `DartDevEmbedder`. This provides a more customizable loading
of sources across the variety of environments we are supporting.

Change-Id: Id7a35695234f0625fe4de1d67c9d5a8055bad461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500240
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-05-08 11:43:35 -07:00
Jens Johansen 3ecf2aa096 [CFE/DDC] Move renaming of late lowerings to dart scope calculator
Small step towards https://github.com/dart-lang/sdk/issues/62645

Change-Id: Ia4e8b0f5943049a6592722ca228498f501feff9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500420
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-05-06 23:45:17 -07:00
Jens Johansen ec5e71ead4 [CFE] Rename additionalDills to additionalDillModules; don't use it to load platform
* Rename additionalDills to additionalDillModules to indicate that it
   is used to load a "module", not any old dill file.
 * Where additionalDills was used to provide the platform use sdkSummary
   instead.
 * Remove unused constructor in KernelCompilationResults.

Tested: Existing tests.
Change-Id: I5f73f61db73b2bc932c211fb0b2e66ec2f5c50c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495981
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-01 00:57:31 -07:00
Jens Johansen 18b76c4567 [kernel/CFE] Move dart_scope_calculator to CFE
Wanting to use for instance "extractLocalName" from the front_end it can
no longer stay in kernel.

Change-Id: I8dec4d187cdfbc8a50a2a997fa3a3db9adb0786a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498900
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-30 23:21:58 -07:00
Kilian Schulte 9e8fdef17c Add annotation-based creation location tracking
Closes https://github.com/dart-lang/sdk/pull/63011

GitOrigin-RevId: 926534c2f5d3cd1e9629cf25f6b028ab34c00e64
Change-Id: I88460a060faabeae8f611e88f23b2eb5fc99f21a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491702
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2026-04-28 03:06:03 -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
kryxen 95c1a0df7f [vm] Apply FFI use-site rewrite in expression evaluation
Run FFI use-site transformation during expression compilation so
evaluate/evaluateInFrame handles FFI use-site APIs (for example,
StructPointer.ref and sizeOf<T>()).

[vm/tests] Add regression for FFI use-site rewrite in compileExpression

R=dacoharkes@google.com, jensj@google.com, leonsenft@google.com

Change-Id: If28f2db1ddbd16931ca441a743041aea496e4f78
Tested: python3 tools/test.py -m release -c dartk -r vm -a arm64 pkg/vm/test/incremental_compiler_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483480
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: kryxen <kryxen.dev@gmail.com>
Commit-Queue: Michael Goderbauer <goderbauer@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
2026-03-26 01:46:34 -07:00
Lasse R.H. Nielsen 56505e0575 Stop using Match.group.
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)

Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-20 09:09:46 -07:00
pq a5bcbf8c1a [deps] bump tools to pull in new unified_analytics
See: https://github.com/dart-lang/tools/issues/2343

This includes a few test updates to play nice w/ changes to `package_config` (https://github.com/dart-lang/tools/pull/2340).



Change-Id: Ia01b9172230a8c3045092d6c3da006e4bfaf3221
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488240
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2026-03-17 11:53:55 -07:00
Paul Berry 7e4e0326d7 Bump web packages to language version 3.12.
This CL is part of an effort to bump the SDK requirement to `3.12.0-0`
for all the packages in `pkg` that are not published to `pub`, so that
we can get better testing of the "private named parameters" feature.

(Packages that *are* published to `pub` can't be safely bumped yet,
because SDK 3.12 hasn't been released, and I don't want to block those
packages' ability to publish useful updates to customers.)

This change covers the following packages, which are owned by
OWNERS_WEB:
- pkg/_js_interop_checks/pubspec.yaml
- pkg/compiler/pubspec.yaml
- pkg/dart2js_info/pubspec.yaml
- pkg/dart2js_runtime_metrics/pubspec.yaml
- pkg/dart2js_tools/pubspec.yaml
- pkg/dev_compiler/pubspec.yaml
- pkg/js_ast/pubspec.yaml
- pkg/js_runtime/pubspec.yaml
- pkg/js_shared/pubspec.yaml
- pkg/modular_test/pubspec.yaml
- pkg/node_preamble/pubspec.yaml
- pkg/reload_test/pubspec.yaml
- pkg/sourcemap_testing/pubspec.yaml

Changes to `pubspec.yaml` files were made manually.

Changes to `.dart` files were made automatically (with a few
exceptions), using `dart fix` to migrate to using private named
parameters where it is possible to do so without changing
semantics. Note that this migration is conservative; see
https://github.com/dart-lang/sdk/issues/58607 for details.

The exceptions are:
- pkg/compiler/test/codesize/swarm/DataSource.dart
- pkg/compiler/test/codesize/swarm/Views.dart
- pkg/compiler/test/codesize/swarm/swarm_ui_lib/layout/GridLayout.dart
- pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/ClickBuster.dart
- pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Scrollbar.dart
- pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Scroller.dart
- pkg/dev_compiler/test/sourcemap/testfiles/next_through_is_and_as_test.dart

For these files, there was no need to migrate to using private named
parameters, however the language version bump caused flow analysis to
improve, so some additional dead code was detected that hadn't been
detected previously. I reasoned that it's better to minimize changes
to testcases, so rather than deleting the dead code, I just added
`ignore` comments to prevent the bots from failing.

Change-Id: I04f5280d7cedef0a6f0ef718133a03d06a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487945
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-03-16 09:59:07 -07:00
Sam Rawlins db0b22988e dev_compiler: Remove unused parameters
Fixes https://github.com/dart-lang/sdk/issues/62767

Change-Id: If572e082827b34e2c7ca78daeb9a82d3e50df911
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484786
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-03 10:39:40 -08:00
Nicholas Shahan e8e746df59 [ddc] Add missing runtime covariant bound check
In some class hierarchies a covariant bound check on a method type
parameter was missing leading to unsoundness.

Fixes: https://github.com/dart-lang/sdk/issues/62732
Change-Id: I147bc801ef8ffb40acfe6b703b7bdf0afe4cf552
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483625
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2026-02-27 14:27:20 -08:00
Nicholas Shahan 4f3fa67529 [ddc] Fix type error message
* Clarifies the language in the error message for a covariant bounds check failure.
* Fixes the type name printing in the error message.

Before:
```
type `Instance of 'Rti'` does not extend `Instance of 'Rti'` of `H`.
```

After:
```
The type argument `List<Object>` is not a subtype of the type
variable bound `List<int>` of type variable `H`.
```

Issue: https://github.com/dart-lang/sdk/issues/62732
Change-Id: If3cd7138b0488062ff31991162250cbaca26dda7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482341
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2026-02-25 13:12:26 -08:00
Jonas Finnemann Jensen bc8929e7c6 Skip Version: ${Platform.version} comment when dart:io is unavailable
In an ideal world, we'd have access to the version of the current Dart SDK,
but other means when compiling for web. But at the moment we don't.

It should probably just be in the _compilation environment_ as suggested in
https://dartbug.com/54785

But until such time, I suggest we just opt to not include the version comment,
when `dart:io` is unavailable.

We could also go through all of dev_compiler and wrap all references to `Platform`
from `dart:io`. But I need this to make a clientside dartpad work. And I think
this is sufficient (if not I'll come back asking for more).

In an ideal world, we would also add tests to ensure that `Platform` isn't used.
But in the future, I plan to build and test the dartpad compilation environment
inside the sdk repository, thus, new usage of `Platform` will then break those tests.

Change-Id: I952c1794c43169c12f3e8099ad0773e5e59c6206
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481560
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
2026-02-19 11:16:40 -08:00
FMorschel aeadcbbca8 [linter, DAS] Makes use_null_aware_elements to report on cascade elements
Fixes: https://github.com/dart-lang/sdk/issues/62660
Change-Id: I8daee991353cae128ea84cf8d71ee430a884f550
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480560
Reviewed-by: Nate Biggs <natebiggs@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-02-16 23:32:59 -08:00
Nicholas Shahan e7d8b99bb6 [ddc] Use LibraryBundleCompiler in expression eval
When the canary and ddc modules flags are passed together use the
expression compiler worker uses the LibraryBundleCompiler to compile
the expression to be evaluated. This ensures the compiler JavaScript
matches the expected format and representation of the compiled library.

Change-Id: I4667522a6640707265a3f38770a17fd696c840f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479400
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2026-02-10 16:58:36 -08:00
Nicholas Shahan 5fd3ccd4d0 [ddc] Fix sourcemap for field initializers
New source locations were added for field initializers to support
upcoming primary constructor work.
See: https://dart-review.googlesource.com/c/sdk/+/468780

This change ensures the initializer assignment statements we add to
the constructor body are fully mapped.

Without this change the new initializer assignment wasn't getting a
mapping so it continued from whatever appeared before it.

Change-Id: Id6ba0619e49e4a517ea36ffa728cf0c1502a14e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469300
Auto-Submit: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-12-21 15:08:42 -08:00
Ben Konyi 364b36691c Reland "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
This reverts commit c616db31d2.

Reason for revert: Fix landed downstream in Flutter engine: https://github.com/flutter/flutter/pull/180127

Original change's description:
> Revert "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
>
> This reverts commit b5e60be49d.
>
> Reason for revert: broke Flutter web engine tests
>
> Original change's description:
> > [ DDC / CFE ] Add support for allowing imports of unsupported libraries
> >
> > This change adds support for allowing for imports of unsupported
> > platform-specific libraries when the
> > `--include-unsupported-platform-library-stubs` flag is provided to the
> > CFE.
> >
> > This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
> > `TargetFlags`, which `Target`s can use to conditionally return different
> > `DartLibrarySupport` objects with different supported/unsupported
> > library sets.
> >
> > A `checkForUnsupportedDartColonImports` function has been added to
> > `Target` that uses the value of `dartLibrarySupport` to determine if
> > there's any unsupported library imports. This function is called after
> > the various transformation operations provided by the `Target`
> > implementation, meaning the import of an unsupported library specified
> > in `dartLibrarySupport` will now result in a compilation error (this
> > includes `dart:mirrors` imports for VM targets when mirrors are
> > disabled, which was previously handled by the VM itself).
> >
> > Related to https://github.com/dart-lang/sdk/issues/62125
> >
> > TEST=Tests added / modified
> >
> > Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
> > Reviewed-by: Nicholas Shahan <nshahan@google.com>
> > Reviewed-by: Johnni Winther <johnniwinther@google.com>
> > Commit-Queue: Ben Konyi <bkonyi@google.com>
>
> Change-Id: I0b59f00e55a2424f783351abd977eb38409ce01f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469100
> Reviewed-by: Nate Biggs <natebiggs@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

Change-Id: I1ae2eac675432286aebabea3c1f58caf35a27fbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469240
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-12-19 12:53:22 -08:00
Alexander Markov c616db31d2 Revert "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
This reverts commit b5e60be49d.

Reason for revert: broke Flutter web engine tests

Original change's description:
> [ DDC / CFE ] Add support for allowing imports of unsupported libraries
>
> This change adds support for allowing for imports of unsupported
> platform-specific libraries when the
> `--include-unsupported-platform-library-stubs` flag is provided to the
> CFE.
>
> This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
> `TargetFlags`, which `Target`s can use to conditionally return different
> `DartLibrarySupport` objects with different supported/unsupported
> library sets.
>
> A `checkForUnsupportedDartColonImports` function has been added to
> `Target` that uses the value of `dartLibrarySupport` to determine if
> there's any unsupported library imports. This function is called after
> the various transformation operations provided by the `Target`
> implementation, meaning the import of an unsupported library specified
> in `dartLibrarySupport` will now result in a compilation error (this
> includes `dart:mirrors` imports for VM targets when mirrors are
> disabled, which was previously handled by the VM itself).
>
> Related to https://github.com/dart-lang/sdk/issues/62125
>
> TEST=Tests added / modified
>
> Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

Change-Id: I0b59f00e55a2424f783351abd977eb38409ce01f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469100
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2025-12-18 09:47:11 -08:00
Ben Konyi b5e60be49d [ DDC / CFE ] Add support for allowing imports of unsupported libraries
This change adds support for allowing for imports of unsupported
platform-specific libraries when the
`--include-unsupported-platform-library-stubs` flag is provided to the
CFE.

This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
`TargetFlags`, which `Target`s can use to conditionally return different
`DartLibrarySupport` objects with different supported/unsupported
library sets.

A `checkForUnsupportedDartColonImports` function has been added to
`Target` that uses the value of `dartLibrarySupport` to determine if
there's any unsupported library imports. This function is called after
the various transformation operations provided by the `Target`
implementation, meaning the import of an unsupported library specified
in `dartLibrarySupport` will now result in a compilation error (this
includes `dart:mirrors` imports for VM targets when mirrors are
disabled, which was previously handled by the VM itself).

Related to https://github.com/dart-lang/sdk/issues/62125

TEST=Tests added / modified

Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-12-17 09:30:38 -08:00
Ben Konyi df3e4046b4 [ SDK ] Add js_dev_runtime stubs for dart:ffi
This will allow for developer tooling to still compile applications with
`dart:ffi` imports for web targets.

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

CoreLibraryReviewExempt: Not changing implementations, just adding stubs
Change-Id: I7347dc81c8bffe0becaf4b1d002d6aca2de60244
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464960
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-12-17 09:26:12 -08:00
Slava Egorov b3857af0e5 Bump core to 58b0a108b4d1310465e8482d6629357891df1cb1
Changes:
```
> git log --format="%C(auto) %h %s" 5c3e2c3..58b0a10
 https://dart.googlesource.com/core.git/+/58b0a108 Make it possible to add default subcommand (925)
 https://dart.googlesource.com/core.git/+/e43ff949 feat(collection): Replace quickSort with pdqsort for performance and robustness (922)
 https://dart.googlesource.com/core.git/+/f2efaaf3 Bump actions/checkout from 5.0.0 to 6.0.0 in the github-actions group (924)
 https://dart.googlesource.com/core.git/+/33b52327 Add `separated`, `separatedList` and `separate` to iterables and lists. (919)
 https://dart.googlesource.com/core.git/+/20ed9668 Add use_null_aware_elements to recommended (923)
 https://dart.googlesource.com/core.git/+/e6c3810c [crypto] remove the -wip to release new version (921)
 https://dart.googlesource.com/core.git/+/f7a786ac Bump actions/stale from 10.0.0 to 10.1.0 in the github-actions group (920)
 https://dart.googlesource.com/core.git/+/018e1dc7 fix(crypto): update conditional import for js interop library (915)
 https://dart.googlesource.com/core.git/+/9fefb52b Make Int64 default constructor non-const in native mode (916)
 https://dart.googlesource.com/core.git/+/f00841de Bump the github-actions group with 2 updates (914)
 https://dart.googlesource.com/core.git/+/7fee9c06 Fix `Int64.operator ==` (911)
 https://dart.googlesource.com/core.git/+/a4dc8738 Implement `Int64` as a wrapper for `int` when targeting native and Wasm (905)
 https://dart.googlesource.com/core.git/+/1aa58ef5 [fixnum] update the min. required dart sdk (907)
 https://dart.googlesource.com/core.git/+/60f2b5d3 Run fixnum tests with dart2wasm (906)

```
Diff: https://dart.googlesource.com/core.git/+/5c3e2c38df268be2347f3aad30ced0147dd012bb..58b0a108b4d1310465e8482d6629357891df1cb1/

Change-Id: Ibde49f27d1d26b8fc1aad3fd7df3efd924796b33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467361
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-12-12 00:42:31 -08:00
Nicholas Shahan a49b6c3cc0 [ddc] Add size metrics to library bundle output
Embeds the size of the original Dart source files and the output
JavaScript files into an argument of the `defineLibrary()` method.

Following changes will add the usages of these values to the embedder.

Change-Id: Ibbfaa9f559248f391df6a733a0f8621f3e9edd83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467420
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2025-12-10 14:42:52 -08:00
Nicholas Shahan bc3a70cdc8 [ddc] Format and cleanup comments in the embedder
* Preparation for merging this file with the internal version.
* Fixes lint violations and consistency issues in the docs and formatting.

Change-Id: Ib563a3bb834509de819895ea99483fab7d0e4bb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465485
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-12-02 10:53:30 -08:00
Johnni Winther 2352407600 [kernel] Remove unused Target.instantiateNoSuchMethodError
TEST=existing

Change-Id: I38c4f97116f36c4cae079439367afc746415205c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464683
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-11-27 01:56:08 -08:00
Nicholas Shahan c2c5357a25 [front_end] Add option for expanded invalidation
In this mode when an edit only touches the body of a mixin
(not the public API) libraries that apply the mixin will also
be invalidated.

Add mixin invalidation test.

Issue: https://github.com/dart-lang/sdk/issues/61864
Change-Id: Id4dde67364dcef958ae1e0e0bbf124cec389f5f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459343
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-14 08:53:51 -08:00
Nicholas Shahan 59905c43f1 [ddc] Avoid passing previous dill for standalone hot restart tests
A hot restart should create a fresh compile and reset the chain of
history for hot reload changes. In the "standalone" test suite
(without the use of the frontend server) this should be achieved by
not passing the previous .dill file when compiling with DDC.

Change-Id: If729e62d3f65fd263d5b40d5dad9a5d4ed0d5839
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450184
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-11-07 16:24:54 -08:00
Johnni Winther baf4639de7 [kernel] Add *InternalNodeMixin visitor mixins
This adds mixins for visitors that implement handling of internal nodes. These nodes are replaced during constant evaluation and should there not be handle by backends.

TEST=existing

Change-Id: Iec76af357c11fd54e97a4db82c7aa52e31ba9dd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456680
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-10-27 15:02:28 -07:00
Nicholas Shahan 1c0c66f680 [ddc] Remove lib/ directories from source maps
Given the existing assumptions that original source files will be
served in a directory structure similar to layout defined by the
package_config.json but without `lib/` directories this change
attempts to detect when a source map contains sources from multiple
lib directories and clean them up from the relative paths.

The strategy used relies on passing a package_config.json as a signal
to detect when sources come from different packages.

Fixes: https://github.com/dart-lang/webdev/issues/1692
Issue: https://github.com/dart-lang/sdk/issues/40251

Change-Id: I6b82b33bae485d74fc61ef118dbe9ffddafab9a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456500
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-10-22 17:04:33 -07:00
Chloe Stefantsova a478a4418c [cfe] Add experimental visitor mixins and experimental type
This CL reduces the noise of future CFE experiments in the
backends. Whenever new nodes will be added as an experiment, the
related exception-throwing implementations will be added to the
mixins, eliminating the need to add the visit methods to the backend
code directly. The experimental type addresses a similar issue in
exhaustive switch statements and expressions.

TEST=existing

Change-Id: I1a021e11a159a992500c42287cbe6ef027bf54a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455080
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-10-17 02:16:25 -07:00
Mayank Patke 5c2fec9eac [ddc] Add line terminators to .map, .metadata, and .symbols
Standard utilities like `cat` expect files to be newline-terminated, so
this change lets these files play nicely in build rules, for example.

Change-Id: I6a6a6964b32dce7d2d73a402fa4eb2842b296621
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454540
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-10-13 19:17:50 -07:00
Nicholas Shahan cff9ab2c8e [ddc] Add hot reload checks in aysnc bodies
Treats async code like function expressions when adding extra
checks for correctness after a hot reload. This is intended to handle
the cases where code that was statically sound and enqueued before the
reload actually runs after a reload when the soundness may no longer
be valid.

Change-Id: I42cd010175126748937d7df830875bc5b850a565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444368
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-09-30 15:06:34 -07:00
Nicholas Shahan 3f2801d63f [ddc] Avoid revisiting sub-expressions on chained invocations
Similar to https://dart-review.googlesource.com/c/sdk/+/445540 this
avoids compilation timeouts by avoiding recompiling the receiver in long
chains of invocations.

Guards all of the soundness checking behind a single generation check.
This was already true for nested calls but not for chains of invocations.

This also resolves a correctness issue where sub expressions of the
receiver in chained calls would be evaluated multiple times at runtime.

Change-Id: Iaf192a639e90d77995da55c7fa9c248e7bb93491
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450183
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-09-22 14:25:22 -07:00
Nicholas Shahan 9ed1efe74a [ddc] Use typed ArgResults helper methods
Change-Id: I906c3cc5d9b80b5d6818cf0af779cc2de56d4db7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449364
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-09-12 16:30:39 -07:00
Jens Johansen e9a99cd479 [DDC] Expression evaluation: Translate script uri if it is a package uri
Turns out we'll sometimes be given the script uri as a package uri,
so we have to support that.
To further complicate things we're not necessarily given a package
config to translate from so we need to use the kernel component as a
backup.

Change-Id: I06ceb136b0b03164aaf7412d5332ae9c4c3338c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447220
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-08-28 01:32:40 -07:00
Simon Binder afa127b1c6 Support renaming fields for JS object literals
This respects the `@JS()` annotation on parameters of external
factories in JS extension types to customize the keys of created object
literals.

Closes https://github.com/dart-lang/sdk/issues/55138

Change-Id: Idebeee922d2080356fd7449f639ecd2ae9ee5fc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445840
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2025-08-26 13:17:30 -07:00
Jens Johansen 1f845d1eb7 [CFE] Expression evaluation: Use dynamic get etc and fixup names to access private stuff when possible
For expression evaluation we want to be "more than dart" in that if for
instance we can see (in the debugger) that a List contains `B`s (even
if it's typed as containing `A`s) we'd like to be able to access things
on `B` (without manually having to cast to either `B` or `dynamic`).

Furthermore - when we in the debugger can see that it's a `B`, and that
`B` has, say, a field `_privateField` or a method `_privateMethod` we'd
like to be able to access that even if `B` is in another library.

This CL - for expression evaluation - makes dynamic accesses and calls
where we would normally issue a "missing getter" (etc) error, and tries
to create a `Name` so private access is possible.

Change-Id: I887318a50413e9a5f11ec685b27719edd312dca0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446260
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-08-26 00:27:19 -07:00
Jens Johansen abfa152cfc [kernel/DDC] DDC shouldn't crash when trying to translate line/column to offset for expresion compilation
Follow-up to https://dart-review.googlesource.com/c/sdk/+/446042.

Change-Id: Icfbaa763a6d6089a74f62088602c07c478520741
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446420
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-08-24 23:50:07 -07:00
Nate Biggs e6f188b3fa [ddc] Avoid revisiting subexpressions during hot reload invocation rewriting.
In extreme cases with deeply nested invocations in closures, this can lead to an exponential recursive call pattern.

For example: https://github.com/spebbe/dartz/blob/8bf79e746d11e6a66c868027e5e1a25fdd270f45/lib/src/either.dart#L108

Moves all nested checks onto a single branch so that there is a single branch with no checks when the generation is the same, and another branch with all the necessary checks when the generation is different.

Bug: https://github.com/flutter/flutter/issues/173700
Change-Id: I3167a96e3ead67fd1d5c763ef2a7309d82c1a7c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445540
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-08-22 20:48:35 -07:00
Nicholas Shahan bd691da600 [ddc] Add expression eval tests for dot shorthands
Ensures dot shorthands are usable from expression evaluation on the web.

Change-Id: Ia5e5c54f0de0c2237d6d01b4658723f5188bd460
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446500
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-08-22 14:39:05 -07:00
Jens Johansen a79b7c6c35 [kernel/CFE/DDC] Remove old DartScopeBuilder; use new one
Change-Id: I4805c47958e2d4fbc19acbdada23cad014c3a747
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446042
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-08-21 23:14:41 -07:00
Srujan Gaddam 3b39c2637b [ddc] Separate _emitObjectLiteral out from _emitArgumentList
Currently _emitArgumentList handles arguments for Dart
members, JS interop members, and object literal constructors.
It requires an Arguments node, which we end up synthesizing,
which messes with parent pointers erroneously. We also have
to separate out the arguments and do additional checks later
to detect whether the arguments passed correspond to an
object literal constructor.

Instead, we should create the resulting expression directly
in a helper method. A map is passed so that the names of
arguments can be easily changed when we handle @JS renaming
on object literal constructors. Lastly, we need to avoid
wrapping the values with assertInterop in the case where the
constructor is from a dart:js_interop interface. That library
only statically allows Functions to be passed if they're
externalized, in which case we shouldn't tell users to wrap
the Function with allowInterop (which doesn't exist anyways in
dart:js_interop).

Change-Id: If6fdc706e80837ab2b698cca704ffd9f08aed28a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446184
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2025-08-21 15:25:57 -07:00
Nicholas Shahan 39d2b206fa [ddc] Add expression eval tests for local consts
See: https://dart-review.googlesource.com/c/sdk/+/445461
Change-Id: Ic819199a1afe515dcda05aa04fc3e1664a39055b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446001
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-08-20 09:26:00 -07:00