This reduces the size of both the mjs file (which contains the JS implementations) and the wasm file
(which includes these names as import/export names).
The savings here is relatively small for most apps.
A main impetus for this is the useful side-effect that it makes the names more stable. By assigning
names after TFA has run, the indices don't change when an unused JS method is added/removed. This
helps make the ir_tests more stable.
Change-Id: If47e3460d060a979bd41ef430c13c6828d98b549
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494720
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
After mixin transformation, original members of mixins should not be
called. Only their clones in the mixin application classes can be
called.
By removing their bodies we can reduce code size and avoid any
complexity related to super-invocations of abstract members.
Change-Id: I0ae1bbac6e4c82356841fdc870bfd8ca1bac8fb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497102
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This reverts commit 264098c85f.
Currently outline transformations aren't run via the incremental
compiler which causes problems in
https://dart-review.googlesource.com/c/sdk/+/491702 which fixes it by
calling the current transformation in the incremental compiler. This
calls it twice though (because it's run again in
`frontend_server/lib/compute_kernel.dart`, but removing it there doesn't
work because a filtering is done which doesn't apply through the
incremental compiler.
This CL splits up the outline transformation stage into a call that can
actually transform the libraries and one that can do the filtering,
which should fix the issue.
Original CL was reverted because it caused errors in google3. The
original CL is in patchset 1. The error has been reproduced and
recreated in a test added in patchset 2. The fix is in patchset 3.
The dwds failure @
https://github.com/dart-lang/webdev/actions/runs/24516059718/job/71660245069
has been verified as fixed as well.
The problem was this:
Previously outline transformations were not run by the incremental
compiler, but only outside. When it was moved to the incremental
compiler it had on old - outdated - `target` which for the ddc/dart2js
summary target would hold a list of source files that it was initially
created with, not the ones currently being compiled. This meant that the
transformation step that removed "unrelated" libraries actually removed
the newly compiled libraries instead. It could cause one of two issues:
1) Empty output: With no overlap between the combined output of the
compile and the sources of the first compile (i.e. the ones in the
outdated `target`) all libraries were filtered out. If a later
compile was given this as a summary input the compile could fail with
a file not found error because the given summary - which should
contain the missing library didn't.
2) Non-empty output: With an overlap between the combined output of the
compile and the sources of the first compile only the overlap would
be included. In practise this would mean that the output would be a
(potentially partial) copy of the first compile. If then a later
compile was given both the summary from the first compile and the
output with the copy it would throw when loading because it got the
same library from two different summaries.
Change-Id: If712663acdbd7d25ccb3beab54a7efac0c0b0568
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496181
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This adds a new lint that was requested in order to support the primary
constructors feature.
This also enables the existing fix to remove the keyword and adds some
tests for the new use of the fix.
Change-Id: Iae3c86ca87a2af6abb82488e218d839a06699778
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496741
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Create `TypeParameterElementImpl` instances when their owning elements
are constructed, instead of materializing them later in builders,
fragment linkers, and bundle reading. This makes ownership explicit in
the element model.
Update synthetic executable construction in inheritance handling to
build fresh type parameter and formal parameter elements. Top-merge and
covariance inheritance were previously able to reuse fragments from
other executables, which could attach fragments to the wrong element and
produce invalid synthetic members for generic signatures.
For type aliases, serialize the first fragment directly instead of a
fragment list. This matches how type alias elements are constructed and
avoids a separate read-time step that recreated type parameter elements.
Bump the data version for the format change.
Change-Id: If4f203f65fb11bcd0ffd1dcc0e47956b9fb2597b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496780
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Expand the test library builder so more unit-style type system tests can
construct declarations through LibrarySpec instead of assembling
elements and fragments by hand.
Add support for imports and external libraries, enums, mixins, extension
types, type aliases, class mixins, type parameter bounds and variances,
and additional parsed type forms needed by these tests. Also add shared
helpers in type_system_base to build test libraries with the mock SDK
libraries and wire in the type provider and type system.
Migrate the affected tests to describe their libraries declaratively and
look up the resulting elements from the built library. This removes a
large amount of bespoke test-only element construction, drops helper
APIs that were only needed for hand-built declarations, and makes these
tests exercise element shapes that are closer to normal analyzer code.
Change-Id: Ic4180a64a5309b87b942f95ff45f682fbb8399df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496664
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
The change in [0] increased the language version of pkg/dart2wasm. That
in return changes how the package is formatted by the autoformatter.
This CL runs now the formatter to re-format the code. Unfortunately this
makes blame lists worse. But not doing it will make us have to disable
auto-formatting before saving files which is very annoying.
[0] https://dart-review.googlesource.com/c/sdk/+/487944
Change-Id: Ie3cbdc58bbd7f5aba187470554b7c958719fa795
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496940
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Previously the context allocation strategy was created in the
constructor of `InferenceVisitorImpl`. Since the strategy manages the
creation of scopes and contexts, the area of effect of those were
limited by the area of application of the `InferenceVisitorImpl`
object. This is in conflict with the implementation of type inference
in constructors, where each of the constructor initializers and the
constructor body are infered by a distinct `InferenceVisotorImpl`
object. The changes in this CL allow a single strategy object to be
shared amont multiple instances of `InferenceVisitorImpl`, allowing
the scopes and contexts of constructors to be shared.
Part of https://github.com/dart-lang/sdk/issues/61572
Change-Id: I27ad0ebf7dd9708293404af7cb004bbd639c193a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496620
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This CL adds an implementation of anonymous `=>` methods in the CFE
which is sufficiently complete to handle the existing test cases in
language/anonymous_methods/expression.
Coverage is handled by adding magic comments to ignore the fact that new
code is not covered by existing testcases. This will be settled in a
separate CL.
To keep the failures visible, the failures in configurations
dart2js-hostasserts-linux-d8-try, dart2js-linux-chrome-try,
dart2js-minified-linux-d8-try, and ddc-linux-chrome-try have not been
approved. It seems likely to me that those are bugs in dart2js and in
DDC.
Change-Id: Ia70fedd4de6166d6a3bf8a108f49728b6e16c9f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494440
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This reduces essentials main module around -0.4% and possibly
opens up for changes in the inlining (specifically to possibly
not force-inline all initializers anymore)
This shrinks the amount of information
* initializer result values
* the body parameters
* the allocator needs to forward less from initializer to body
We do that by analyzing constructor parameters to see
which parameters are needed for the constructor
Change-Id: I967fa4102ea6e9d498ff07aedabc368b038e1085
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496341
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Make VM always return empty array in the response.
Current implementation for this field comes with a bunch of complexity
because it locks message handler and then invokes Dart code which
makes it difficult to reason about various invariants. This code is
furthermore demonstrated to cause deadlocks. Given that nobody uses
it - it is simpler to remove this code altogether.
Fixes https://github.com/flutter/flutter/issues/185156
TEST=ci
Change-Id: I497210e0f1542860caa0d765d634f8ec6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496340
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Keep track of the most recent same-named fragment even when it has a
different declaration kind. This lets augmentation validation
distinguish between a missing target and a target whose kind does not
match the augmentation.
Store this information on elements, serialize it through summaries, and
use it during error verification. When an augmentation finds a previous
declaration with the same name but a different kind, report
`augmentationOfDifferentDeclarationKind` and attach a context message
that points to the original declaration instead of falling back to
`augmentationWithoutDeclaration`.
This improves diagnostics for both top-level and member declarations,
including combinations such as constructors vs fields, methods vs
accessors, and functions vs variables.
Change-Id: Ic794c437fa160bb29d25f90559b544a7282ca697
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494301
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Create `TypeParameterElementImpl` instances when fragments are built or
read, instead of synthesizing them lazily from
`TypeParameterFragmentImpl.element`.
This makes fragment-to-element wiring explicit and predictable across
the element model. To support this, accesses to `typeParameters` now
ensure that resolution has been read before returning element-backed
data.
The bundle format is adjusted so that type parameter metadata remains on
fragments, while variance, bounds, and default types are serialized with
the corresponding elements. This keeps the eager element creation model
consistent when reading summaries.
As part of this cleanup, generic function types and formal parameters
now create their nested type parameter elements up front, and
declarations that cannot have type parameters stop serializing empty
type parameter lists.
Change-Id: Ifcdc05bcccd2de6ae88d8102b10efe9a144e2545
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Rename the bundle read/write helpers so their names reflect whether they
operate on elements, fragments, or whole library fragments. This makes
the serialization flow easier to follow and keeps the reader and writer
structured around the same concepts.
Also extract small helpers for imports, exports, parts, type parameters,
and formal parameters, so the bundle layout is spelled out more directly
instead of being spread across larger methods.
While doing this, move import prefix `enclosingFragment` wiring into the
`libraryImports` setter on `LibraryFragmentImpl`. This keeps prefix
fragments attached consistently whether they come from the library
builder or from summary deserialization.
Change-Id: I78f66f3e8a33d6c0dbf32bf9976ed666ceb6422c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496500
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
The old flag described a resolver behavior and defaulted to true, which
made persisted element data less explicit and caused many declarations
to carry the flag even when their type did not actually come from an
initializer. The new flag records the underlying fact we care about:
whether top-level inference produced the element's type from its
initializer.
Make top-level inference return both the inferred type and whether it
was derived from the initializer, and store that result on the element
when the type is computed. Use this recorded fact when choosing the
context type for initializer resolution, so only declarations whose type
was taken from the initializer fall back to `UnknownInferredType`.
Update the stored flags, manifest matching, result printers, and
serialized expectations to reflect the renamed and narrower semantics,
and bump the analysis driver data version for the format change.
Change-Id: I120f3cc289454c8ffc0963dcb028e2d5250f16da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496220
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Propagate flags to top-level variable accessors
Record `isAbstract` on top-level variable fragments and copy it to the
synthetic getter and setter fragments built from those variables. Also
mark those accessors as complete declarations when the originating
variable is external or not abstract. o later linking and element model
expectations stay consistent.
Change-Id: I36edfab18feaa2e2d9f8dca20dad837bd82f0836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495943
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This reverts commit b3d9c8a297.
Reason for revert: b/503506653
Original change's description:
> [kernel/cfe/etc] Split outline transformation into performOutlineTransformations and performOutlineComponentOperations
>
> Currently outline transformations aren't run via the incremental
> compiler which causes problems in
> https://dart-review.googlesource.com/c/sdk/+/491702 which fixes it by
> calling the current transformation in the incremental compiler. This
> calls it twice though (because it's run again in
> `frontend_server/lib/compute_kernel.dart`, but removing it there doesn't
> work because a filtering is done which doesn't apply through the
> incremental compiler.
>
> This CL splits up the outline transformation stage into a call that can
> actually transform the libraries and one that can do the filtering,
> which should fix the issue.
>
> Change-Id: I5ae3477ebfe580dca372ea792924cdfb79979b35
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495700
> Commit-Queue: Jens Johansen <jensj@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
Change-Id: I961a7d2e09f64f4b2e4dc9e45e1f3572f3f2cdeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496260
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Replace the hand-written header flag formatting for elements and
fragments with writeHeaderFlags(...flagsForTesting). This makes the
printed output come from the same generated flag definitions as the
element model instead of maintaining separate lists of writeIf calls.
Mark computed element flags such as hasDefaultValue, hasInitializer, and
hasNonFinalField in the generated metadata, and add the missing
generated overrides needed to expose them through flagsForTesting. This
also lets the shared path report flags such as isSimplyBounded and
hasEnclosingTypeParameterReference consistently.
Because hasNonFinalField now needs to round-trip through bundles for
enums, update the bundle reader and writer and bump the data version.
Change-Id: I7c126fe4bc69fd6b191f339ddc420b05cd8b5ee7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495860
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>