Commit Graph

2171 Commits

Author SHA1 Message Date
Ivan Inozemtsev 5536cac9c4 [release] Increase version on main to 3.12
Change-Id: I278eb371cd7e8d776a71c1c6f6920b9d0f5598bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460043
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-01-07 00:02:21 -08:00
Johnni Winther 97d965db2a [kernel] Update supportsLateFields reference in documentation
`supportsLateFields` is replaced by `isLateLocalLoweringEnabled` and `isLateFieldLoweringEnabled`. This updates the reference to it in
`Target.supportsLateLoweringSentinel` documentation.

Change-Id: I55f69ea6c5cf5ad590e73e9d224f0a7450872352
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470660
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-01-05 02:56:51 -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
Chloe Stefantsova e1d5dc8c35 [cfe] Assign captured contexts to FunctionNodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Id6293f6300436d252a52e973cba6cd52cda48758
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468281
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-12-16 05:14:41 -08:00
Chloe Stefantsova 87032377ee [cfe] Use ExpressionVariable in ForInStatement and similar nodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I4f02718dc292b0e18f1fb4858ee31b4c645597a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-11 01:38:24 -08:00
Chloe Stefantsova 95df731257 [cfe] Use VariableInitialization in ForStatement and similar nodes
This change is similar to
https://github.com/dart-lang/sdk/commit/c97e2554ee3b21b0b0146ca41be969dd8531986d,
where ExpressionVariable was used in VariableGet and VariableSet.

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

Change-Id: Id9fa5302adcf8c773cec8478a31948b54c8393b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-08 04:56:51 -08:00
Chloe Stefantsova 6209d8dd0b [cfe] Implement trivial context allocation strategy for local variables
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I7569168e6595e88e2bda25a122f3b238c188b381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466080
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-05 06:59:29 -08:00
Johnni Winther 0f6928c311 [kerne] Add verification of annotation nodes
This adds verification of annotation nodes after constant evaluation should only be ConstantExpression or InvalidExpression.

Prompted by https://github.com/dart-lang/sdk/issues/62096 which crashes from an unexpected annotation expression, like an InvalidExpression.

Change-Id: I91b723f3804694dd317396e2a7a80d50a06b225d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465040
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-12-01 01:38:15 -08:00
Johnni Winther 1a1d7da7a3 [cfe] Use InvalidInitializer
Change-Id: Id4e1df17a14955b58e8db50abefb3ac4bbf1eaf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464686
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-11-27 05:15:04 -08:00
Johnni Winther 4338105c13 [kernel] Make InvalidExpression.message non-nullable
Change-Id: I0b88dfa01a8e2caae8631266310aa3b0a5f5e0bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464685
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-27 05:15:04 -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
Johnni Winther 5bc2037cb0 [kernel] Implement InvalidInitializer
This updates the Initializer classes such that InvalidInitializer has a message and will throw at runtime, similar to InvalidExpression. All initializers have positions and only FieldInitializer and SuperInitializer have an isSynthetic field.

TEST=pkg/front_end/testcases/general/invalid_initializer.dart

Change-Id: Ic444bb1dc273b433ac70249240527d115deaa332
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463661
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-27 01:53:23 -08:00
Chloe Stefantsova c94482a3b5 [cfe] Add text serialization for VariableInitialization
This is a step towards better visualisation of the new variable nodes
emitted by the CFE.

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

Change-Id: If39f609627044b97967ed82683bbf49bb02edd5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464182
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-11-26 03:11:52 -08:00
Jens Johansen 80217511f9 [CFE/kernel] Clear invalidated ClassHierarchySubtypes
Fixes https://github.com/flutter/flutter/issues/178740

Change-Id: Ia7b11ac9785c5bac9a2fec722bd7a4c610171d11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464380
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-11-25 02:01:16 -08:00
Nate Biggs 52be04e90a [dart2wasm][vm] Fix deferred loading with mixin deduplication.
Now moves mixin applications into their own libraries that can be
imported separately from the rest of the code in the originating
library.

Then adds an import to the new library containing the mixin application
to any libraries that use it.

This ensures the import graph is accurate while only making sure it
remains minimal.

TEST=Added case to pkg/vm testcases.

Bug: https://github.com/dart-lang/sdk/issues/43089
Change-Id: I56b6ea1db8261e0d0508c2d7e62d0c13fbe9678b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457260
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-21 10:29:51 -08:00
Alexander Markov d1e27305f7 [kernel] Print 'const' flag of procedures
Change-Id: Iab43421596f649cccd26657d82d08696140ce105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463503
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2025-11-21 03:17:14 -08:00
Chloe Stefantsova a4d6787112 [cfe] Start emititng new variable nodes when the experiment is on
As a part of this CL, the following was changed:

* Instead of `VariableInitialization` implementing `VariableDeclaration`, `VariableDeclaration` now implements `VariableInitialization`.
* `InternalLocalVariable` now implements `LocalVariable`. It delegates most of its members to the variable it wraps around, and the implementations of the `TreeNode` members are throwing.
* Some tests in the bytecode generator under the experimental type started to fail and are skipped.

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

Change-Id: I06b391cc762d5935f528d208ff5e27eccf311a47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462981
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-11-20 01:33:37 -08:00
Chloe Stefantsova cb559f1870 [cfe] Introduce InternalExpressionVariable
`VariableDeclarationImpl` is re-defined in terms of
`InternalExpressionVariable` and `InternalExpressionVariableMixin`.
`InternalLocalVariable` is introduced similarly.

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

Change-Id: I5cb16828687a715cf0f9049338bf461e5ff67f1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462422
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-11-18 03:18:33 -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
Chloe Stefantsova c97e2554ee [cfe] Make VariableGet and VariableSet abstract interfaces
This change is similar to
https://dart-review.googlesource.com/c/sdk/+/456620 and
https://dart-review.googlesource.com/c/sdk/+/458520 and prepares the
CFE to emit new variable nodes when the experimental flag is on.

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

Change-Id: I78cff188c3a94de337d7114c7496552733b2e208
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461421
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-11-14 03:09:49 -08:00
Chloe Stefantsova 63b34b2e1f [cfe] Implement VariableDeclarations on the new nodes
The nodes that now conform to VariableDeclarations are Variable,
LocalVariable, SyntheticVariable, ThisVariable, FunctionParameter,
PositionalParameter, NamedParameter, and VariableStatement.

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

Change-Id: I6b38d2756662b5bd729d65158621f56791dce829
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-11-10 06:26:34 -08:00
Chloe Stefantsova 756dbcde19 [cfe] Make TypeParameter an abstract interface
The concrete implementation is named `NominalTypeParameter`. The
change is needed as a transition step to the new encoding for
variables in Kernel.

This change is similar to
https://dart-review.googlesource.com/c/sdk/+/456620

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

Change-Id: I9e4107b50a0790008d65a5ee94a4ff06a1b48052
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458520
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-30 09:01:30 -07:00
Chloe Stefantsova dc2a0aae7d [cfe] Always query for ranked superclass info in least upper bound
Previously, the info was inconsistently queried, leading to
nondeterministic behaviors.

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

Change-Id: I5d47d0f29b0e78d2834ae3c5793fd05171cf9156
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457360
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
2025-10-29 03:10:46 -07:00
Johnni Winther 6d70657fad [kernel] Add RedirectingFactoryInvocation
This adds an internal wrapper expression for redirecting factory invocations. This holds a reference to the original redirecting factory constructor along with the resulting invocation of the generative or factory constructor. The node is removed during constant evaluation and only available to backends through the pre-modular transformations.

TEST=existing

Change-Id: I35c19766117ab2942aefddb4ccebcd2df66babf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454820
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-28 03:03:44 -07: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
Chloe Stefantsova 06e54c8c24 [cfe] Make VariableDeclaration an abstract interface
The concrete implementation is named `VariableStatement`. The change
is needed as a transition step to the new encoding for variables in
Kernel.

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

Change-Id: Ib333f28e9998f2e758a18e4ad4b0a3cf4d642013
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456620
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-22 23:11:39 -07:00
Chloe Stefantsova a03be0a31a [cfe] Enable CFE unit testing for closure context lowering
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ie44241a3aae78ae766cf06e8da5dc5c167242591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-21 07:04:46 -07:00
Chloe Stefantsova cad0aae004 [cfe] Introduce Kernel AST node for the closure expreiment
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Iee3c2a223f4c44f5528016082cf3a068b401d87d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454061
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-17 02:16:25 -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
Ivan Inozemtsev 1974c2360e [release] Increase version on main to 3.11
Change-Id: I54e1e60e05ce31b77b02745870c80a878918793a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449805
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-10-06 18:46:13 -07:00
Chloe Stefantsova ec92547b99 [model][vm] Add Target flag for Closure Contexts in AST experiment
The flag is enabled in some of the bytecode generator tests.

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

TEST=existing

Change-Id: I65f491d90aad3a8d923f1a740012bad0ae8f318a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451280
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-09-25 08:02:49 -07:00
Jens Johansen 9e89e9145b [CFE] Fix crash in expression evaluation related to type parameters
Change-Id: I9e86877a75c937fbb313ad1e492e15ced4a1be9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448400
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-09-05 00:05:41 -07:00
Paul Berry bea092d844 [kernel/_fe_analyzer_shared] Share demangleMixinApplicationName.
It's not necessary for `package:kernel` and
`package:_fe_analyzer_shared` to have duplicate implementations of
this method. `package:kernel` depends on
`package:_fe_analyzer_shared`, so they can share one definition.

Change-Id: I6a6a696462a0e22a2ea818c42f58187c45821afc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447842
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-09-02 07:51:58 -07:00
Chloe Stefantsova 1a7e1134ab [model] Share implementation of chooseTypes between Analyzer and CFE
Part of https://github.com/dart-lang/sdk/issues/54902

Change-Id: I7b83f7634940d24ba4406c476f9cd63dcfafff57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446660
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-08-26 00:41:33 -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
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
Jens Johansen 3175e427d8 [CFE] Keep const locals by default; expression evaluation can evaluate const locals
Note: Const locals are still off for VM aot and dart2js for the entry
points I've found in an attempt to retain the old behaviour there.
It might be better if those targets could remove such locals in a
whole-world analysis instead.

 * Keep const locals by default (except as noted above). Update the
   verifier to accept that. For the platforms this has increased the
   size by at most 6584 bytes. With this the VM will pass in any const
   locals as it does normal locals, but as the variable is never
   captured it will never pass a const local defined in a method when
   inside a local function in that method.
 * Change the dart scope calculation(s) to return the found variables
   instead of just the types of the found variables.
 * When the incremental compilers expression compilation - via the dart
   scope calculation - finds a const local that it wasn't told about, it
   will pass it on as an extra variable that it knows about, allowing
   for evaluating const locals in the case not covered by the first
   bullet.

With luck this can in future CLs be extended to know about other
variables that we're not told about, allowing to give a message saying
something like
"yes, we know what 'foo' is, but you can't currently use it" as wanted
in for instance https://github.com/dart-lang/sdk/issues/60316 and
https://github.com/dart-lang/sdk/issues/53996.

Tested: Existing tests for existing functionality; new tests for the new
Change-Id: I1ec24350273e6f81574bb2888f6bf46e3b8b1b47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445461
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2025-08-19 04:30:41 -07:00
Jens Johansen 9b157b67e3 Format {_fe_analyzer_shared,front_end,kernel}/lib; update generated files to match package version
For the generated files (e.g. codes) we had gotten into a scenario
where the auto generated files was forced to be formatted as short
style, but if asking the dart formatter to format the
_fe_analyzer_shared file it would be formatted in long style because the
minimum version for _fe_analyzer_shared is now 3.7.

This CL updates the generators for the generated files to pass the
language version from the package config to the formatter.

Change-Id: I986ce1b5ff65244499ab5a277e78124f372ee46d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444300
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-08-07 06:07:21 -07:00
Jens Johansen dfba8a7ca9 [CFE] Remove more allocation from iterators
These are from `_Array.iterator` whereas the previous ones was from,
iirc, `List.iterator`.

* 7.41mb Import.finalizeImports
* 1.13mb FindTypeVisitor.visitInterfaceType
* 856.39kb new NamedTypeBuilderImpl
* 815.92kb BodyBuilder.createSuperParametersAsArguments

(values from uprobe)

When compiling the CFE with the CFE I get this:

```
msec task-clock:u: -5.6347% +/- 0.5257% (-321.96 +/- 30.04) (5713.89 -> 5391.92)
page-faults:u: 5.9842% +/- 0.0970% (6310.26 +/- 102.33) (105449.48 -> 111759.74)
cycles:u: -6.0829% +/- 0.5338% (-1447602857.06 +/- 127036484.81) (23797839542.02 -> 22350236684.96)
instructions:u: -4.9550% +/- 0.0008% (-1364113249.40 +/- 214444.14) (27529935457.16 -> 26165822207.76)
branch-misses:u: -5.7909% +/- 2.2880% (-5395643.76 +/- 2131857.44) (93173948.12 -> 87778304.36)
seconds time elapsed: -5.6275% +/- 0.5257% (-0.32 +/- 0.03) (5.72 -> 5.40)
seconds user: -6.0582% +/- 0.5861% (-0.33 +/- 0.03) (5.47 -> 5.13)
Scavenge(   new space) goes from 63 to 61
Evacuate(store buffer) goes from 2 to 3
MarkSweep(   old space) goes from 1 to 0
```

As before the changes here are mostly "bogus" and likely caused by the
GC being weird, see also
https://dart-review.googlesource.com/c/sdk/+/438722 and
https://dart-review.googlesource.com/c/sdk/+/438681.

It does seem to consistently change the number of new space GCs though
(65 -> 63 -> (here) 61).

Change-Id: I18ef712394c1d98b8ed15c7fe6c4ac32fa9bc2e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438682
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-07-31 01:52:02 -07:00
Johnni Winther f49d92aba9 [cfe] Use LookupResult for constructor lookup
This adds `LookupResult.isInvalidLookup` to the handle invalid lookup
results and uses this to avoid a lot of cascading error messages.

This is a step towards removing ProblemBuilder, AmbiguousBuilder and
reliance on `NamedBuilder.isDuplicate` in lookups.

Change-Id: Ia9d558ce55b45567607282295dd1e54e6187f9c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441880
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2025-07-29 04:41:21 -07:00
Ivan Inozemtsev e694eb261a [release] Bump version on main to 3.10
Change-Id: I502950fa3cf72958628512634ad0d62ca54f61cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434804
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-07-14 22:47:12 -07:00
Jens Johansen 84e279d279 [CFE] Remove ~19 mb of allocations caused by iterators etc
* Remove ~2.8mb of iterators in SourceMethodBuilder
* Remove ~0.7mb of iterators in calculateBounds
* Remove ~1.7 mb of iterators in ClassMembersNodeBuilder.build
* Remove ~1.9mb of iterators in BuilderFactory.computeBuildersByName
* Remove ~3mb of iterables and iterators in findRecordUseAnnotation
* Remove ~3mb of allocations from List.iterator in InferenceVisitorBase._inferInvocation
* Another ~6.3mb of iterables in various places in chunks of ~100-800kb.

Running a benchmark of the CFE compiling the CFE I get this:

```
msec task-clock:u: -5.9719% +/- 0.3845% (-342.77 +/- 22.07) (5739.61 -> 5396.84)
page-faults:u: -2.6307% +/- 0.0630% (-2951.12 +/- 70.63) (112178.18 -> 109227.06)
cycles:u: -6.1751% +/- 0.3921% (-1471343183.50 +/- 93434420.74) (23827045867.84 -> 22355702684.34)
instructions:u: -5.0116% +/- 0.0006% (-1385443477.90 +/- 176957.44) (27644543467.86 -> 26259099989.96)
branch-misses:u: -6.0357% +/- 1.7661% (-5562845.14 +/- 1627775.60) (92165665.40 -> 86602820.26)
seconds time elapsed: -5.9868% +/- 0.3830% (-0.34 +/- 0.02) (5.75 -> 5.40)
seconds user: -6.0365% +/- 0.4515% (-0.33 +/- 0.02) (5.47 -> 5.14)
seconds sys: -4.6542% +/- 3.6415% (-0.01 +/- 0.01) (0.27 -> 0.26)
Scavenge(   new space) goes from 64 to 63
MarkSweep(   promotion) goes from 9 to 8
Evacuate(store buffer) goes from 2 to 1
```

Worth noticing, though, is that the before numbers (e.g. 5739.61 ms
task-clock:u) is very close to the before numbers from
https://dart-review.googlesource.com/c/sdk/+/438681 (5767.31 ms) and not
the after numbers on that cl (5478.56 ms) --- so something weird is
going on here.

Change-Id: I67248bbde47900435ababcb1a2d5ecff2dde5c13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438722
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-04 05:59:12 -07:00
Chloe Stefantsova 7b541da59b [cfe] Use exhaustiveness in computing nullability of intersection
This is a follow-up for
https://dart-review.googlesource.com/c/sdk/+/436620/comment/cddbbd38_1d23184c/

Change-Id: Ib473db14c6088ceb99034a6762ec75edccb4b5c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438723
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-07-04 05:19:14 -07:00
Jens Johansen c812abd7bf [kernel] Don't allocate contexts in BinaryPrinter._ensureCanonicalName
When compiling the cfe with an aot-compiled cfe this removes ~43 mb of context allocations in `BinaryPrinter._ensureCanonicalName` and has these changes when benchmarking:

```
msec task-clock:u: -5.0067% +/- 0.6053% (-288.75 +/- 34.91) (5767.31 -> 5478.56)
page-faults:u: 2.7077% +/- 0.1426% (2942.48 +/- 155.01) (108670.96 -> 111613.44)
cycles:u: -5.3274% +/- 0.6265% (-1278360098.44 +/- 150341087.36) (23995901283.80 -> 22717541185.36)
instructions:u: -4.3319% +/- 0.0009% (-1195734804.64 +/- 241700.46) (27602908367.64 -> 26407173563.00)
branch-misses:u: -3.4011% +/- 3.0065% (-3245774.08 +/- 2869267.25) (95434325.44 -> 92188551.36)
seconds time elapsed: -5.0025% +/- 0.6041% (-0.29 +/- 0.03) (5.77 -> 5.48)
seconds user: -5.3148% +/- 0.6838% (-0.29 +/- 0.04) (5.52 -> 5.22)
Scavenge(   new space) goes from 65 to 64
MarkSweep(   promotion) goes from 10 to 9
Evacuate(store buffer) goes from 2 to 1
```

although most of it is probably a happy accident with the GCs.

Compiling the analysis server only gives:

```

page-faults:u: 0.6385% +/- 0.1266% (1058.68 +/- 209.95) (165813.00 -> 166871.68)
instructions:u: -0.0158% +/- 0.0005% (-6794934.20 +/- 222091.71) (42904117069.28 -> 42897322135.08)
Scavenge(   new space) goes from 103 to 101
```
Change-Id: I85ceece0df699bb2393f3ab72fe6130134b49132
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438681
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-03 03:39:14 -07:00
Chloe Stefantsova 433c0998d0 [cfe] Remove Nullability.legacy
TEST=existing

Change-Id: Id924e4ef64ddabc1986cb885f558382ff139b481
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436620
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-07-02 23:50:12 -07:00
Chloe Stefantsova 150e8cbe97 [cfe] Upate pre-Null Safe naming in the CFE
Change-Id: I45e8dc703ce7810e6df5a328b3829dc86a128792
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436241
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-06-23 03:17:42 -07:00
Johnni Winther a04c0d4221 [cfe] Include library of private names in ast-to-text
This adds the library reference of private names of other libraries in
the ast-to-text of member declarations. This prepares for a fix of the
library used for private constructor tear offs.

TEST=existing

Change-Id: I65a30f6446b6e2cd15291327babb7fcacb36c4ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434640
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-06-17 06:15:43 -07:00