Commit Graph

1939 Commits

Author SHA1 Message Date
Johnni Winther e16a4e76e6 [cfe] Use flatten(T) as future value type for pre-nnbd async functions
Change-Id: I38d537112e66c08bb06bc2493b3126b5f8f797b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239022
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 10:42:22 +00:00
Johnni Winther a6acb1a5f0 [cfe] Include the future value type in ast-to-text
This is in preparation for including a "futureValueType" for
non-nnbd async functions.

TEST=existing

Change-Id: I15cf5e58623df07fe3c670aa866b7b04805c0f3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238703
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 10:37:25 +00:00
Chloe Stefantsova ab62c34398 [cfe] Account for overall nullability of FutureOrType in UP
Closes https://github.com/dart-lang/sdk/issues/48631

Change-Id: I944da3a7f086a3d080de4f51bd99aa002f88cae6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239024
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-03-28 07:43:48 +00:00
Johnni Winther c4eb880cac [cfe] Rename LibraryBuilder getters to [libraryBuilder]
Change-Id: I13ebe337ee3c032b02c6a4e437762ccc2ddfedde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237692
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-21 08:41:37 +00:00
Johnni Winther acc535dfab [cfe] Show annotations on library dependencies
This updates ast-to-text to show the annotations on import/exports. A
test is added that uses augmentation libraries to show that the
annotations are not currently ascribed to the correct library dependency.

Change-Id: I340c1ab920b16ff08dd9ac36ee9be4d2d651b4a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237301
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-17 09:38:25 +00:00
Chloe Stefantsova ad3d2eb5c4 [cfe] Adjust nullability of UP when r.h.s. is an intersection
Closes https://github.com/dart-lang/sdk/issues/48373

Change-Id: I9ec2211c6deccbc7c26e831863f9a9b05833380f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-03-14 15:44:38 +00:00
Johnni Winther d380ae8d48 [cfe] Run commands of tool/fasta.dart in the same VM
This changes tool/fasta.dart to run the subcommand in the same VM when
no VM arguments are specified. This speeds up the tool and as a
consequence speeds up the tool/update_all.dart and
tool/update_expectation.dart tools.

Change-Id: I80b61a692a3ac2e15a7d1d097e65e1efbf9e4aee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236560
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-10 15:23:15 +00:00
Alexander Markov d0e8ef9816 [vm,kernel] Move transformations maintained by the VM team from pkg/kernel to pkg/vm
These transformations are maintained by the VM team and keeping them
in pkg/kernel would put a burden on the CFE team after code reviews
are tightened to require OWNERS approval.

TEST=ci

Change-Id: I931033ba987d17a2c9c6d80a16dad09bfbaa0572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234905
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-03-03 15:04:10 +00:00
Johnni Winther be7ff1daf6 [cfe] Add MacroSerializer
This adds a [MacroSerializer] interface to abstract how URIs are
created for precompiled macro components.

Two strategies are added. The existing solution using a temporary
directory in TempDirMacroSerializer and a new solution using the
recently added (experimental) Isolate.createUriForKernelBlob feature
in IsolateSerializer.

Change-Id: Id7117cc518f09e9b3762d6ca924c788c81fd9ac0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234282
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-02-25 10:40:04 +00:00
Martin Kustermann f50b3a52e4 [vm] Make async lowering no longer use optional parameters
This CL

  * Makes :async_op only have two parameters: We take advantage
    of the fact that errors not only have exception != null but
    also stacktrace != null.
  * Makes :async_op have no optional parameters. This reduces
    code size significantly.
  * Removes unused parameter in _awaitHelper calls
  * Wrap the then callback instead of the error callback. (needed
    to make optional parameters required)

This results in 2% code savings on a big g3 app.
The size of :async_op shrinks on average by 11%

TEST=ci

Change-Id: I38d5fba4ebebc780b48dac5aa6a250d2c7952bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233362
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 12:09:42 +00:00
Alexander Thomas 30beab0f43 [infra] Add OWNERS to the Dart SDK
* Add team "groups" in tools/OWNERS_<group name>.
* Add top-level OWNERS as a fallback.
* Add OWNERS for all top-level directories.
* Add OWNERS to all packages.

For additional background information see go/dart-sdk-owners.

TEST=No op until code-owners is enabled.
Bug: b/200915407
Change-Id: I7fe6116cc599c749cd50ca16151d6d6a801d99d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229147
Reviewed-by: Jonas Termansen <sortie@google.com>
2022-02-14 14:06:34 +00:00
Nate Bosch 33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00
Martin Kustermann 4eaacc3df9 [vm] Improve async performance by taking advantage of static types of returned values
In general any async function can return X or Future<X>. Though the
future implementation has to do different things depending on which case
we're in. It does so by using a `<obj> is Future<T>` test. This test is very
expensive if many different classes flow into `<obj>`.

Though most functions do not return `Future` objects from async
functions. We can determine that statically by looking if any returned
expression could be a future. If not, we can bypass the `is Future<T>`
test entirely.

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

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

Change-Id: If655bdbdddc214dd7b12be9905b3c788252547d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230662
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-04 22:06:59 +00:00
Jens Johansen 1044d83ab7 [kernel] Spell check kernel/bin
Change-Id: I1433d7940f9a20b70793c8e0ea801d16aa3f9eb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231201
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-02-02 12:20:46 +00:00
Jens Johansen 0794821969 [kernel] Add tool for comparing class hierarchies of two dills
This CL adds a tool that can compare the class hierarchies of two dill files.
Currently it only checks for public classes and their public supertypes.
We could extend the tool later if needed.

Currently it gives this for flutter:

```
$ out/ReleaseX64/dart pkg/kernel/bin/compare_hierarchies.dart /path/to/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill /path/to/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/platform_strong.dill "dart:nativewrappers#NativeFieldWrapperClass1"
(1): /path/to/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill
(2): /path/to/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/platform_strong.dill

Missing classes in lib dart:_internal
In (2) but not in (1): [VMLibraryHooks, Lists, VMInternalsForTesting, ClassID]

Missing classes in lib dart:ui
In (1) but not in (2): [PlatformViewRegistry]

Class(ColorFilter) in dart.ui from (2) has these extra supertypes: [ImageFilter (dart:ui)]
```

where the last line is https://github.com/dart-lang/sdk/issues/48245

It gives this for the dart sdk:
```
$ out/ReleaseX64/dart pkg/kernel/bin/compare_hierarchies.dart out/ReleaseX64/vm_platform_strong.dill out/ReleaseX64/ddc_platform_sound.dill "dart:nativewrappers#NativeFieldWrapperClass1"
(1): out/ReleaseX64/vm_platform_strong.dill
(2): out/ReleaseX64/ddc_platform_sound.dill

Missing classes in lib dart:_internal
In (1) but not in (2): [VMLibraryHooks, Lists, VMInternalsForTesting, ClassID]
```

which seems fine (dart:_internal after all)

Change-Id: I03c0dbcc3e5058a0c7d6a996b511cf6d449dd4f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-02-02 10:47:25 +00:00
Aske Simon Christensen 8df763f266 Prepare for sharing TFA and patch files between the VM and dart2wasm.
The VM patch files contain many annotations that guide the TFA and the
VM compilation pipeline. Most of these are not relevant to dart2wasm,
and having the TFA look at these when running inside dart2wasm leads to
sub-optimal, and sometimes even unsound, results.

In order to enable sharing of patch files between the VM and dart2wasm,
the annotation parser is given a target flag to control which
annotations it should recognize and how to parse them. The annotation
parser thus becomes an abstraction layer between the concrete
annotations in the patch files and the parsed annotations that the TFA
sees.

Additionally, external members used by dart2wasm don't always have
external names. To support this, the signature shaker must skip all
external members, not just the ones with an external name. This makes no
difference for the VM, since all of its external members either have an
external name or are implemented in a patch file, making them no longer
external.

TEST=ci + upcoming dart2wasm CL
Change-Id: Id425dd1ccc5560721034ae83c8cdc1593801a4e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231102
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-02-01 21:08:46 +00:00
Jens Johansen adb1dc9380 [VM] [CFE]: Make VM send over type information for expression compilation
Missing:
* Function types.
* Type variables in bounds, like "method<T, S extends T>() {}" and
  "method<T extends Foo<T>>() {}"

This is in many ways a follow-up to
https://dart-review.googlesource.com/c/sdk/+/212286

TEST=service and (cfe) expression suite tests added.

Change-Id: I20472b59ed73e9845f073e176d73b2c213f9407a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-28 07:49:21 +00:00
Jens Johansen 441dca77fd [CFE][kernel] Use .of instead of .from
This CL replaces most usages of `.from` (e.g.
`List<String>.from(variable)`) to use `.of` instead.

This is done because code like
`List<String> foo = new List<String>.from([null])`
is valid and gives no warnings or errors.

Using `.of` instead will give an error.
Also `.of` appears to be slightly faster.

Change-Id: I1b4327be228b77e6a3e9faa283f8ce64f0565608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228642
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-24 14:38:36 +00:00
Jens Johansen ae593598f8 [dart:ffi] Only operate on transitive dependencies of dart:ffi
This CL does two things:
* "Reenable" the skipping of the dart:ffi transformation entirely when
  the application does not use dart:ffi. This was originally added in
  ad596359a6 but was logically disabled in 4558112105 when dart:core
  started depending on it. Here we now ignore (real) dart:* libraries
  when looking for dependencies of dart:ffi.
* Find the subset of the just compiled libraries that transitively
  depend on dart:ffi and just run the dart:ffi transformation on those
  libraries.


For dart2js that doesn't use dart:ffi at all we go from:

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.003428: Transformed ffi natives in 51ms.
0:00:09.203442: Transformed ffi annotations in 199ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.098175: Transformed ffi natives in 52ms.
0:00:09.296847: Transformed ffi annotations in 198ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:08.854341: Transformed ffi natives in 57ms.
0:00:09.061804: Transformed ffi annotations in 207ms.
```

to

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.138651: Skipped ffi transformation in 1ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.242590: Skipped ffi transformation in 1ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.163885: Skipped ffi transformation in 1ms.
```

When compiling the flutter gallery app that does depend on dart:ffi we go from:

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.344955: Transformed ffi natives in 78ms.
0:00:16.777218: Transformed ffi annotations in 432ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.994674: Transformed ffi natives in 80ms.
0:00:16.472779: Transformed ffi annotations in 478ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.027488: Transformed ffi natives in 81ms.
0:00:16.491362: Transformed ffi annotations in 463ms.
```

to

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.991628: Transformed ffi natives in 30ms.
0:00:16.226564: Transformed ffi annotations in 234ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.184984: Transformed ffi natives in 29ms.
0:00:16.404439: Transformed ffi annotations in 219ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.933513: Transformed ffi natives in 27ms.
0:00:16.145640: Transformed ffi annotations in 212ms.
```

TEST=Assuming tests already exists.

Change-Id: Ie13be1924d3439cb710c782af81e1e42cda2a838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228001
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-17 09:43:14 +00:00
Chloe Stefantsova 442836bce4 [cfe] Fail early on some subtype checks instead of crashing
Some subtype tests are crashing due to infinite recursion. It is a
known issue. An example of such test is FutureOr<T> against
FutureOr<S> where T and S are type variables declared as T extends
FutureOr<T> and S extends FutureOr<S>.

In some cases it's possible to fail early instead of crashing, for
exmaple, by checking Future-branch of the left-hand side first before
checking the type argumennt of FutureOr which would lead to the
infinite recursion. This CL does that, allowing some more type checks
to pass instead of crashing.

Change-Id: I075aa65522510db1a97ac2a8de7278a3ce3f400c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227820
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-01-13 11:22:16 +00:00
Liam Appelbe 9d79a890f3 [vm] Adding branch coverage RPC to source report
TEST=Unit tests and an integration test
Bug: https://github.com/dart-lang/coverage/issues/141
Change-Id: I84958091dc6f9753f5e9446bb3517a8099019981
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222541
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-01-12 19:12:04 +00:00
Johnni Winther 8510f27d37 [cfe] Change encoding of supported dart: libraries
This CL changes the way dart: libraries are considered supported when
used in conditional imports or bool.fromEnvironment constant using
the "dart.library.*" values.

Library nodes now has an isUnsupported flag which is set according to
the "supported" property in the libraries specification. Furthermore
the Target now supplies a DartLibrarySupport interface that allows
targets to override whether dart: libraries are unsupported.

This allows the JIT/AOT to use the same platform file but still
consider dart:mirrors unsupported in AOT mode, and dart2js to consider
the internal library `dart:_dart2js_runtime_metrics` supported.

Furthermore, the internal handling is changed so that condition imports
and bool.fromEnvironments constants are computed through the same logic
for "dart.library.*" values, avoiding the need for passing these values
through the environment.

TEST=pkg/front_end/testcases/general/supported_libraries/main

Closes https://github.com/dart-lang/sdk/issues/48057
Closes https://github.com/dart-lang/sdk/issues/47814
Closes https://github.com/dart-lang/sdk/issues/47243
Closes https://github.com/dart-lang/sdk/issues/32657
Closes https://github.com/dart-lang/sdk/issues/36460

Change-Id: Ie8f8dff99167de64ced51b71d89918bf0f3bbd13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227020
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-01-11 14:52:38 +00:00
William Hesse 05b19a2218 Bump SDK version to 2.17
TEST=Standard CQ

Change-Id: I0eba9fa6eaa73bf9da8abdd93645a8e6eb8e601b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226691
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2022-01-10 11:05:10 +00:00
Johnni Winther 7695118aa2 [cfe] Add Class.isMacro
This adds support for detecting macro classes from .dill

TEST=pkg/front_end/testcases/macros/macro_class.dart

Change-Id: I8d45cafff1b4edaff7e090384be1a1cf9c8087ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224948
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-12-22 11:49:01 +00:00
Johnni Winther 81ee883c98 [cfe] Separate entry-point read from imports/exports/parts
This separates the reading of entry-points, which do not have an
accessor library, from reading of imports, exports and parts, which must
have an access library.

This change also disallows access to platform private libraries, like
dart:_internal, as entry-points.

Change-Id: I017ca30231eb99dc8463266dca0973a02f6f0e30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223423
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2021-12-15 11:42:42 +00:00
Alexander Markov 1777f769ab [vm/aot] Visit TypeParameterType.promotedBound in tree shaker
If tree shaker doesn't visit TypeParameterType.promotedBound which
contains the only reference to a particular class it may remove that
class, leaving a dangling reference from promotedBound. After that
kernel AST serialization would crash with "Missing canonical name for
Reference" error.

This change also fixes TypeParameterType.visitChildren.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_47878.dart
Fixes https://github.com/dart-lang/sdk/issues/47878

Change-Id: I555261713240bf0be412db27efb68f32cfd8008b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222781
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-12-09 20:58:20 +00:00
Johnni Winther 0e4e2be639 [cfe] Split computation of hierarchy and members
This CL splits the ClassHierarchyBuilder implementation into two parts:
1) ClassHierarchyBuilder (using ClassHierarchyNode and
   ClassHierarchyNodeBuilder) which computes the superclass/
   superinterface relations.
2) ClassMembersBuilder (using ClassMembersNode and
   ClassMembersNodeBuilder) which computes the class members.

The CL prepares for supporting subtype queries from the macro generation
at point in time where members can still be added to the classes.

Change-Id: Ic28fc6eddd1b651916de46583aeed791ce81e844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222461
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2021-12-09 17:31:27 +00:00
Johnni Winther 2b4934a54d [cfe,dart2js] Reuse field reference for static late lowering
In response to https://github.com/flutter/flutter/issues/89740 and
https://github.com/flutter/flutter/issues/94561

Change-Id: I22c100a575b91e70a2c5835b8db6dd450f319ce7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221947
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-12-07 21:12:17 +00:00
Johnni Winther 6b4b1a0fef [cfe] Reimplement topological sort
This replaces the previous implementation (and the topological sort of
classes, on which it was based) which was O(|vertices|*|edges|). The new
implementation is O(|vertices|+|edges|).

Change-Id: I4f5f1e63b4c7dd67d6f17c087724c20d4d33bf83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221820
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-12-02 15:31:37 +00:00
Johnni Winther aa5c2b3da6 [cfe] Handle field/getter/setter in ReferenceName equality
ReferenceName is used in equivalence testing to match reference
reguardless of whether the reference have associated nodes or
canonical names. The implementation didn't previously account for
fields, getters and setters with the same simple name, and would
wrongfully equate them.

Change-Id: Iacc8e0eb2c5c04a3cf11c3b5104a8f0441cf3ab6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221621
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-11-30 12:37:55 +00:00
Johnni Winther eda10ffe4b [cfe] Add test for compilation sequence to macro test
This CL adds a test for the minimal sequence of compilation steps
that need to be performed to compile the test while ensuring that
macro declarations are compiled before any application.

Change-Id: Icd6b9140e60d35d2b2b034c16e0807262f971418
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220768
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-11-23 09:40:21 +00:00
Clement Skau edc0675e6e [vm] Adds offsets to sync gen.
Sync generators contain two implicit wrappers (:sync_op_gen
and :sync_op), which do not directly correspond to any user
code - and therefore do not have fileOffsets.

Some tools however rely on fileOffsets to e.g. compute code
coverage, so this change adds fileOffset inherited from the
non-synthetic code to :sync_op_gen and :sync_op.

Bug: https://github.com/dart-lang/sdk/issues/47681
Change-Id: I0c54bc3eaf5892e591fead845b5d31d2dfc9481f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220543
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-11-18 12:31:16 +00:00
Johnni Winther cb1f1b8102 [cfe] Migrate text serialization suite
Change-Id: Ib44e1c69f5e9aa0e17794b647c50b28fe4cf3d62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220741
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-11-18 12:07:26 +00:00
Joshua Litt 3d1f6a48b7 [dart2js] Add dart2js target to build summaries.
Change-Id: I1ef0b3f87124333e44cb15001c556b1767ddf28f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219841
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-11-18 00:58:40 +00:00
Alexander Thomas 55134ad5c8 Bump SDK version to 2.16
TEST=Standard CQ
Change-Id: I8598e2102df2990396afa3e56ad4a41120c5dee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219787
Auto-Submit: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-11-10 12:51:46 +00:00
Kevin Moore 632f3428f3 Update dependencies in unpublished packages
TEST=No SDK affect. Just helping our outdated package tracking

Change-Id: I0d392694e9eb926f60667508b55094ffa208db18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218381
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-10-28 15:46:08 +00:00
Johnni Winther 114ad79698 [cfe] Ensure separation between StaticGet/StaticTearOff/ConstructorTearOff
Change-Id: I5b8d1103c10fecaf8fdaa69ee62215deb7eebc38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217641
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-10-26 04:53:00 +00:00
Johnni Winther c206ec38ce [cfe] Pass ReferenceFromIndex to value class transformation
This fixes fuzz testing for value_class/empty,
value_class/explicit_mixin, and value_class/value_mixin_error

Change-Id: Ia098b3ed5b8a028f1a28c5579fe5df11e5a92ff0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217185
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-10-19 10:02:38 +00:00
Johnni Winther 565d0977d1 [cfe] Handle Procedure.signatureType in transformers
Change-Id: I2e32883c2e2cebaa48335d1aa3a1d1834d3a8106
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217182
Reviewed-by: Chloe Stefantsova <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-10-19 09:24:07 +00:00
Alexander Thomas 52294b4056 [testing] Remove self-check runtime
This config hasn't been running at least since Dart 2.0. This basically
reverts https://codereview.chromium.org/2549793002.

test.py no longer supports these options:
* --skip-compilation (skipped compilation commands)
* --runtime=self-check (ran the self-check tests)

Change-Id: I135c8d488a9319ee3482131cd22eb7cd3dfa3f25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217003
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-10-15 09:43:22 +00:00
Johnni Winther 56490f9776 [cfe] Add Procedure.signatureType
The added field holds the interface signature type for a Procedure when
this is different from the class signature type (implied by the function
parameters and return type). This is needed for forwarding semi stubs
when its declared type is different from the called super member.

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

TEST=pkg/front_end/testcases/general/implement_semi_stub.dart and more

Change-Id: I4a7cdc9d564fb0a59e7b06e83646b5410d8d82f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216420
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <dmitryas@google.com>
2021-10-13 11:31:16 +00:00
Chloe Stefantsova d83e78c7a3 [cfe] Account for bounds changes in override substitution
Closes https://github.com/dart-lang/sdk/issues/47311.

Bug: https://github.com/dart-lang/sdk/issues/47311
Change-Id: I0ef3245f5a69951c323dc4a592e2c8ce194f59f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215763
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-10-12 09:46:25 +00:00
Johnni Winther 3aaea30f10 [cfe] Pass references to lowered tear-offs
TEST=existing

Change-Id: I7e2625f87b357ceec45ec2664f7444af38ec0cf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215402
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-05 09:20:41 +00:00
Johnni Winther 5b7968346d [kernel] Add Field.fieldReference
This adds a third reference to Field declaration, so that we know have
three references, one for each use case:

1) fieldReference used for initialization; in FieldInitializer and as
   the key in the InstanceConstant.fieldValues map.
2) getterReference used for reading; in InstanceGet, StaticGet and
   SuperPropertyGet
3) setterReference used for writing; in InstanceSet, StaticSet and
   SuperPropertySet

TEST=existing

Change-Id: I223f130e808e7f19a831c1fe5e3a4725d1bcdc3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203770
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-24 12:01:08 +00:00
Chloe Stefantsova 65184a9ff4 [cfe] Don't serialize an empty show/hide clause
TEST=existing

Change-Id: Ie63444c4dbeaa45b38fd195e554780f14fed878e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213767
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-23 14:01:54 +00:00
Johnni Winther 6c4b75237a [kernel] Rename isFieldFormal to isInitializingFormal
+ update ast-to-text, including previous renames of covariant

TEST=existing

Change-Id: Ia29847cba791096ccd9c6c383a1b633a6150cd94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214042
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <dmitryas@google.com>
2021-09-22 15:56:07 +00:00
Lasse R.H. Nielsen 18f37dd8f3 Add extension name getter on Enum.
We use an extension getter instead of an instance getter because
it doesn't conflict with any potential existing or future enums
which want an element named `name`.
Keeping the namespace for enum elements open is a priority.
We currently only reserve `index` and `values`.

BUG: https://github.com/dart-lang/language/issues/1511

Fixes language issue #1511, which is a long-standing request,
and should replace a number of alternative implementations
which are based on parsing the `toString()`.


This version has two fields on the shared superclass, the index
and private name, and has a separate `toString` for each `enum` class
which hard-codes that enum's class name.

An earlier version had both `"name"` and `"ClassName.name"` as fields
to be able to reuse the same `toString` method on all enum classes,
but that cost too much for JS compiled code.
Even having just `ClassName.` as a field and then combining inside
`toString` requires more code to create the enum instances.
Instead this version hardcodes the `ClassName.` string once
in the `toString` method, which means each enum class has its own
toString (which can *potentially* be tree-shaken then.)

This still tree-shakes slightly worse than the previous implementation
where every enum class had its own `index` and `_name` fields
independent of each other, which could then be tree-shaken independently.
However, the `index` was already made an interface member with the
addition of the `Enum` interface, so code which accesses `.index`
on something of the `Enum` supertype could prevent tree-shaking of
all enum classes' `index` fields.
Likewise any general access to the "name" of an enum would necessarily
do the same for the name.
This CL makes up for some of that by sharing more implementation
between enum classes.

DartVM AOT CodeSize impact: ~0.15% regression on gallery (little less on big g3 app)

TEST= New tests added to enum_test.dart

Change-Id: Id25334e6c987f470f558de3c141d0e3ff542b020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210480
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-22 14:20:16 +00:00
Chloe Stefantsova 684e8cf9f7 [cfe] Distinguish between call-site access kind in shown members
Change-Id: Ie893e1b9ef46ccfb3a86393cec4342845af49f2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213765
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
2021-09-22 10:13:37 +00:00
Sam Rawlins 8d04e49078 Remove redundant imports
Each of these imports removed is redundant with
'package:kernel/ast.dart'.

Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: Ia9bc08b4ffd863572c84fe8a4fa465d2e8e04f7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213845
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-09-20 15:25:01 +00:00
Ben Konyi c51f885613 [ Debugger ] Allow for setting breakpoints on conditional statements
with simple boolean conditions

Fixes https://github.com/flutter/devtools/issues/3289

TEST=runtime/observatory/tests/service/breakpoint_on_simple_conditions_test.dart

Change-Id: I5ed0b78b4e462615d0d0c7dff1581b38dcf00aee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213421
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-16 16:12:17 +00:00