Commit graph

2249 commits

Author SHA1 Message Date
Jens Johansen b7eb3f3c92 [CFE] Introduce forEachMember on kernel Library and class; change verifier slightly
verify_with_lazy_loading: instructions:u: -0.1311% +/- 0.0001% (-1182610.00 +/- 971.82)
verify_without_lazy_loading: instructions:u: -0.1267% +/- 0.0002% (-1124839.67 +/- 1776.77)

Change-Id: Idef856c7f6ad99c12deaa07ab95598e77a51f57e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349863
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-02-05 10:36:59 +00:00
Johnni Winther fe52b9bfe5 [macros] Add dart:_macros
This adds the dart:_macros library to the SDK and adds support for accessing dart:_macros from package:macros. The library is not used yet.

This change is needed as a prestep to adding the package:macros and using it in the CFE and analyzer, and needs to be rolled in as the checked in sdk before package:macros can be supported.

TEST=ci

Change-Id: Ife3ffd48527e3a196048d2ddf7387b8b7818f3a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348680
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-02-02 07:47:59 +00:00
Jens Johansen f0ca213d60 [CFE et al] Optimize presubmit scripts
This CL optimizes how CFE et al presubmits are run.

In the examples below we'll that it takes the presubmit time from 31+
to ~13 seconds, from 31+ to ~20 seconds and from 30+ to ~19 seconds on
a few simple cases and from 76+ to ~27 seconds in a case where files in
both _fe_analyzer_shared, front_end, frontend_server and kernel are
changed.

Before this CL, if there was changes in both front_end and
frontend_server for instance it would run one smoke-test for each.
They would each technically only test things in their own directory,
but they would do a lot of overlapping work, e.g. compiling
frontend_server also compiles front_end; the startup cost of a script
is done several times etc.

The bulk of the change in this CL is thus to only run things once.
Now, if there is a change in both front_end and frontend_server the
python presubmit will still launch a script for each, but it's just a
light-weight script that will take ~400 ms to run (on my machine) if it
decides to not do anything. What it does is that it looks at the
changed files, from that it will know which presubmits will be run and
decide which of them will actually do the work - the rest will just
exit and say "it will be tested by this other one".

Furthermore it then tries to run only the smoke tests necessary.
For instance, if you have only changed a test in front_end it will only
run the spell checker (and only for that file).
Note that this is not perfect and there can be cases where you should
get a presubmit error but wont. For instance if you remove all content
from the spellchecking dictionary file it should give you lots of
spelling mistake errors, but it won't because it won't actually run the
spell checker (as no files it should spell check was changed).
Probably you have to actively try to cheat it though, so I don't see it
as a big problem. Things will still be checked fully on the CI.

Additionally
* the generated messages will have trailing commas which speeds up
  formatting of the generated files (in the cases where the
  generated files will have to be checked).
* the explicit creation testing tool will do the outline of everything,
  but only do the bodies of the changed files.
* building the "ast model" only compiles the outline.

Left to do:
* If only changing a single test, for instance, it will only run the
  spell checker on that file, but launching the isolate its run in
  still takes ~7 seconds because it loads up other stuff too. Maybe we
  could have special entry points for cases where it only should run an
  otherwise simple test.
* The presubmit in the sdk dir (not CFE related) doesn't do well with
  many (big) changed files and testing them for formatting errors can
  easily take 10+ seconds (see example below where it contributes ~5
  seconds for instance). Maybe `dart format` could be made faster, or
  maybe the script should test more than one file at once.


*Example runs before and after*:

Change in a single test file in front_end
=========================================

Now:

```
$ time git cl presubmit -v -f
[I2024-01-25 09:46:08,391 187077 140400494405504 presubmit_support.py] Found 1 file(s).
Running Python 3 presubmit commit checks ...
Running [...]/sdk/PRESUBMIT.py
Running [...]/sdk/pkg/front_end/PRESUBMIT.py
Presubmit checks took 11.5s to calculate.
Python 3 presubmit checks passed.


real    0m12.772s
user    0m16.093s
sys     0m2.146s
```

Before:

```
$ time git cl presubmit -v -f
[I2024-01-25 10:07:08,519 200015 140338735470464 presubmit_support.py] Found 1 file(s).
Running Python 3 presubmit commit checks ...
Running [...]/sdk/PRESUBMIT.py
Running [...]/sdk/pkg/front_end/PRESUBMIT.py
  28.3s to run CheckChangeOnCommit from [...]/sdk/pkg/front_end/PRESUBMIT.py.
Presubmit checks took 30.0s to calculate.
Python 3 presubmit checks passed.


real    0m31.396s
user    2m9.500s
sys     0m11.559s
```

So from 31+ to ~13 seconds.



---------------------------------------------------------------------

Change in a single test file and a single lib file in front_end
===============================================================

Now:

```
$ time git cl presubmit -v -f
Running Python 3 presubmit commit checks ...
Running [...]/sdk/PRESUBMIT.py
Running [...]/sdk/pkg/front_end/PRESUBMIT.py
  15.9s to run CheckChangeOnCommit from [...]/sdk/pkg/front_end/PRESUBMIT.py.
Presubmit checks took 18.0s to calculate.
Python 3 presubmit checks passed.


real    0m19.365s
user    0m33.157s
sys     0m5.049s
```

Before:

```
$ time git cl presubmit -v -f
[I2024-01-25 10:08:36,277 200953 140133274818432 presubmit_support.py] Found 2 file(s).
Running Python 3 presubmit commit checks ...
Running [...]/sdk/PRESUBMIT.py
Running [...]/sdk/pkg/front_end/PRESUBMIT.py
  27.9s to run CheckChangeOnCommit from [...]/sdk/pkg/front_end/PRESUBMIT.py.
Presubmit checks took 30.0s to calculate.
Python 3 presubmit checks passed.


real    0m31.311s
user    2m9.854s
sys     0m11.898s
```

So from 31+ to ~20 seconds.

---------------------------------------------------------------------

Change only the messages file in front_end (but with generated files not changing)
==================================================================================

Now:

```
$ time git cl presubmit -v -f
[I2024-01-25 09:53:02,823 190466 140548397250432 presubmit_support.py] Found 1 file(s).
Running Python 3 presubmit commit checks ...
Running [...]/sdk/PRESUBMIT.py
Running [...]/sdk/pkg/front_end/PRESUBMIT.py
  15.6s to run CheckChangeOnCommit from [...]/sdk/pkg/front_end/PRESUBMIT.py.
Presubmit checks took 17.0s to calculate.
Python 3 presubmit checks passed.


real    0m18.326s
user    0m38.999s
sys     0m4.530s
```

Before:

```
$ time git cl presubmit -v -f
[I2024-01-25 10:10:04,431 201892 140717686302592 presubmit_support.py] Found 1 file(s).
Running Python 3 presubmit commit checks ...
Running [...]/sdk/PRESUBMIT.py
Running [...]/sdk/pkg/front_end/PRESUBMIT.py
  28.0s to run CheckChangeOnCommit from [...]/sdk/pkg/front_end/PRESUBMIT.py.
Presubmit checks took 29.2s to calculate.
Python 3 presubmit checks passed.


real    0m30.550s
user    2m9.488s
sys     0m11.689s
```

So from 30+ to ~19 seconds.

---------------------------------------------------------------------

Change several files:
```
$ git diff --stat
 pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart         | 4 ++--
 pkg/_fe_analyzer_shared/lib/src/parser/listener.dart                  | 2 ++
 pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart | 2 ++
 pkg/front_end/lib/src/base/processed_options.dart                     | 2 ++
 pkg/front_end/messages.yaml                                           | 2 +-
 pkg/front_end/tool/dart_doctest_impl.dart                             | 2 ++
 pkg/frontend_server/lib/compute_kernel.dart                           | 2 ++
 pkg/kernel/lib/ast.dart                                               | 2 ++
 8 files changed, 15 insertions(+), 3 deletions(-)
```
====================

Now:

```
[I2024-01-25 09:57:53,270 193911 140320429016960 presubmit_support.py] Found 8 file(s).
Running Python 3 presubmit commit checks ...
Running [...]/sdk/PRESUBMIT.py
Running [...]/sdk/pkg/_fe_analyzer_shared/PRESUBMIT.py
  17.8s to run CheckChangeOnCommit from [...]/sdk/pkg/_fe_analyzer_shared/PRESUBMIT.py.
Running [...]/sdk/pkg/front_end/PRESUBMIT.py
Running [...]/sdk/pkg/frontend_server/PRESUBMIT.py
Running [...]/sdk/pkg/kernel/PRESUBMIT.py
Presubmit checks took 25.3s to calculate.
Python 3 presubmit checks passed.


real    0m26.585s
user    1m8.997s
sys     0m8.742s
```

Worth noting here is that "sdk/PRESUBMIT.py" takes 5+ seconds here

Before:

```
[I2024-01-25 10:11:39,863 203026 140202046494592 presubmit_support.py] Found 8 file(s).
Running Python 3 presubmit commit checks ...
Running [...]/sdk/PRESUBMIT.py
Running [...]/sdk/pkg/_fe_analyzer_shared/PRESUBMIT.py
  14.6s to run CheckChangeOnCommit from [...]/sdk/pkg/_fe_analyzer_shared/PRESUBMIT.py.
Running [...]/sdk/pkg/front_end/PRESUBMIT.py
  28.0s to run CheckChangeOnCommit from [...]/sdk/pkg/front_end/PRESUBMIT.py.
Running [...]/sdk/pkg/frontend_server/PRESUBMIT.py
  20.9s to run CheckChangeOnCommit from [...]/sdk/pkg/frontend_server/PRESUBMIT.py.
Running [...]/sdk/pkg/kernel/PRESUBMIT.py
Presubmit checks took 75.6s to calculate.
Python 3 presubmit checks passed.


real    1m16.870s
user    3m48.784s
sys     0m23.689s
```

So from 76+ to ~27 seconds.

In response to https://github.com/dart-lang/sdk/issues/54665

Change-Id: I59a43f5009bba8c2fdcb5d3a843b4cb408499214
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348301
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-01-31 10:41:20 +00:00
Jens Johansen cdad90dfb8 [frontend_server] frontend_server_flutter_suite
Generally the test loads a big dill thats 90+% the same content as the
previous load, then verifies it.
This CL loads smarter and verifies less.

Before this CL, locally, running
pkg/frontend_server/test/frontend_server_flutter.dart took
real    24m56.080s
user    48m42.422s
sys     1m2.360s

and the suite edition (using 4 shards in isolates) took
real    15m9.196s
user    53m41.118s
sys     1m30.045s

With this CL, locally running
pkg/frontend_server/test/frontend_server_flutter.dart takes
real    5m0.206s
user    9m23.933s
sys     0m20.984s

and the suite edition takes
real    3m24.243s
user    12m0.069s
sys     0m28.131s

On the try-bot the runtime seems to have gone from ~40 minutes
to ~20 minutes, the "compile flutter tests" step from ~30 minutes to
~10 minutes and the portion of time actually running the
dart-code that compiles, loads and verifies, from ~26 minutes
to ~7 minutes.

Change-Id: I6db225c33e1c0ee817f3880327e720446150ad7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347282
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-01-26 14:28:40 +00:00
Johnni Winther 694c2911e2 [cfe] Support json_serializable macro
This refactors and update the cfe macro implementation to support
macro annotations generated by macros.

Change-Id: I6a4b669f2f01b1f2fec4efbc87271eecf397205d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346841
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-01-23 12:24:49 +00:00
Johnni Winther 8a2f6495b3 [cfe] Add isImplicitCall to DynamicInvocation
This adds an ìsImplicitCall to DynamicInvocation which is set on
expression like `d()` where `d` has type dynamic, to distinguish
the for `d.call()`.

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

Change-Id: I73beb911bdb315a510c862e6d4876cf7673ec3c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346240
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-01-19 08:39:30 +00:00
Jens Johansen 7e792e7a8b [kernel/DDC] Fix failing DDC tests; if finding no scope for offset find for a close previous offset instead
When landing https://dart-review.googlesource.com/c/sdk/+/342400
the ddc-mac builder (but not Linux and Windows) started failing.
I could reproduce on Linux though so I'm not sure why those builders
didn't fail (nor why it wasn't caught by the try bot), either way this
fixes the issues:

* Test update: E.g. a breakpoint at the end of the scope doesn't work
  because it will not be inside the (wanted) scope.
* Test update: Evalating "this" now actually works.
* Scope finding update: DDC adds sourcemapping entries for the *end* of
  things so e.g. the getter "c" will have offset and offset+1 added as
  source mappings. When translating from javascript position to dart
  position we might pick that and thus ask for the scope of offset+1,
  but nothing will be found because no node has that offset.
  Here I add a fall-back saying that if we get no results we ask again
  for the nearest lower offset.

Change-Id: I7e4430d9954466494b514cf51d999358483c9f8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345501
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
2024-01-12 08:21:00 +00:00
Chloe Stefantsova 5cf844ce12 [cfe] Adjust fallback nullability in DOWN for undetermined operands
This is the DOWN-counterpart of
https://dart-review.googlesource.com/c/sdk/+/333825 that addressed a
similar issue for UP.

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

Change-Id: I7aac1e8f1a9ca33f7612694b7ebac4f952cf3c1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345680
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-01-11 14:05:50 +00:00
Chloe Stefantsova 1eace401d2 [cfe] Use only field values in equality of record constants
Previously the static type of the record literals was also used, which
is incorrect interpretation of the equality on records.

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

Change-Id: I12fad33271e53279a3d9c8bcfd2a842ac31988a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344701
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-01-11 13:58:47 +00:00
Jens Johansen 39d68052a9 [frontend_server/DDC] Expression compilation for JavaScript can pass scriptUri
This allows using the new scope finder and facilitates expression
compilation with and in extension types.

For now the script uri is optional (and only passable in the new json
input via package:frontend_server), and only if the script uri is passed
we'll use the new scope finder.

Flutter etc should be updated to pass the new data.

Change-Id: I36eed1ea76a825e63e4c5b9ea60daf18aee39f3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342400
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
2024-01-10 10:12:22 +00:00
Jonas Termansen 8158275a94 Bump version to 3.4.
Do not revert: The main channel version must be upgraded now that the
version 3.3 beta has been cut and reverting this change puts the
release infrastructure into an unsupported state. Please fix forward
any potential problems that occur downstream and loop me into the
discussions so we can improve the release procedures in the future.

Change-Id: I8706c3d74fe0474d34a99c5cbbb8e9a88b586cdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329902
Commit-Queue: Jonas Termansen <sortie@google.com>
Reviewed-by: Kevin Chisholm <kevinjchisholm@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-01-04 16:15:09 +00:00
Ömer Sinan Ağacan 91d16af92b [kernel] Document how to compute Procedure type
Change-Id: I9772c3124a7c19e8754ba99edf355a6b76aaf1a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344520
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-01-04 12:04:12 +00:00
Jonas Termansen 68651c7d53 Let the infrastructure team bump the kernel language version.
Bug: b/318346772
Change-Id: I423655e7d1c39af38889a3014a68c747db2b4dae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344024
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
2024-01-02 14:51:46 +00:00
Jens Johansen bf96a722bc [frontend_server] CFE team takes ownership of package:frontend_server
First of we apply the wanted lints etc we prefer.
This includes but isn't limited to using types (i.e. no "var") and
being explicit about creation (i.e. no missing "new").

Change-Id: I516bccdac9760221ea5311af4567466bb4a65c77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341960
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-12-19 10:38:28 +00:00
Chloe Stefantsova 3eeba4a4e2 [cfe] Refactor FunctionNode.futureValueType into emitted value type
Previously we would encode the type of the value returned in `async`
functions as the field `futureValueType` on `FunctionNode`. For all
other kinds of functions, such as `sync`, `sync*`, and `async*`, that
field would be null. This CL renames `futureValueType` into
`emittedVAlueType`, and for functions of kinds `async`, `sync*`, and
`async*` that is expected to be the type of values emitted via
`return` or `yield` statements. For `sync` functions that field is
supposed to contain `null`.

In response to https://github.com/dart-lang/sdk/issues/54159

TEST=existing

Change-Id: I1efdbcc4e75d150f5618c7ca50cfe49a0e54fce6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341662
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-12-19 08:44:43 +00:00
Paul Berry 949f3af120 Remove kernel flag Procedure.isAbstractFieldAccessor.
This used to be used solely by field promotion, to recognize when a
getter arose from a declaration of an abstract field, so that abstract
fields would be promotable but explicitly declared abstract getters
would not be.

However, with the adoption of
https://github.com/dart-lang/language/issues/3328, both abstract
fields and abstract getters are now considered promotable, so there is
no longer any need to distinguish them.

Bug: https://github.com/dart-lang/language/issues/3328
Change-Id: Idc14512568eb0a11dae4e364df453d117adff2e3
Tested: standard presubmit bots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338643
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-14 18:06:52 +00:00
Ryan Macnak 1256db2277 [build] Python 3.12 compatibility.
Bug: https://github.com/dart-lang/sdk/issues/54306
Change-Id: I974e5e70c6c1cbb87343139a26052996d8df858f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341023
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-12-12 18:19:35 +00:00
Erik Ernst f9d64593ff Adjust UP to move the intersection type rules up
This CL implements the spec change in https://github.com/dart-lang/language/pull/3435. It changes the implementation of UP in the CFE and in the analyzer such that it matches the updated specification in language PR dart-lang/language#3435.

Change-Id: I2fb56c11e671e6917baffb89f9fb231072d22a0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333922
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2023-12-11 08:31:10 +00:00
Jens Johansen 1f9d59c807 [CFE] More dart scope calculator stuff
General approach: Find all scopes for an offset,
then pick "the right one".

This still leaves a few offsets where we can't pick 1 scope in the
(non-outline) dills in the out directory though.

More thorough testing will follow.

TEST=ci

Change-Id: I66448498e07aa03f720733bcaf167bbfa30bca2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338840
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-12-04 11:25:19 +00:00
Paul Berry e0b129d3b0 Ignore TODO in pkg/kernel.
This change prevents `TODO` comments in pkg/kernel from showing up in
Visual Studio Code's "problems" view, which makes it much easier to
see errors, warnings, and lints in that view.

With this change, Visual Studio Code now treats `TODO` comments the
same in `pkg/kernel` as they are treated in `pkg/_fe_analyzer_shared`,
`pkg/front_end`, and `pkg/analyzer`.

Change-Id: Ifeff026b9cf5ef13c8b1a4382a82441175165374
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338589
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-11-29 13:54:08 +00:00
Jens Johansen 6c9f95bd15 [CFE/DDC] Scope test adds context for type parameters; more testing
Change-Id: I218cc473ae2e48944b268094e08cf0da19a09bbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337740
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-28 07:52:32 +00:00
Martin Kustermann ebb856af29 Also add global owners to CFE/VM packages
This is a follow-up CL to [0] that tightened ownership.

[0] https://dart-review.googlesource.com/c/sdk/+/337980

TEST=ci

Change-Id: Icccdf95cec886cb03b84951949210daa71d48f2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338121
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-11-27 14:35:52 +00:00
Chloe Stefantsova b0a91e2eb4 [cfe] Only eliminate type variable itself in its bound in UP
Previously, UP was eliminating all free variables in the bound instead
of just the variable with that bound.

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

Change-Id: Ic0ce9e6b53ecee7d9d1dcb4e76b9214310f63631
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336884
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-27 11:06:52 +00:00
Martin Kustermann 31130b14e7 CLs that change VM/CFE packages should get approval from the corresponding team
TEST=none
Change-Id: Iee3d8921f0ee28dc384490d1e235108a50ade415
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337980
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-11-23 11:09:50 +00:00
Chloe Stefantsova c6b0e218c7 [cfe] Make extension type non-nullable only if it implements Object
Part of https://github.com/dart-lang/sdk/issues/49731

TEST=existing

Change-Id: I397bbd5ca7868a9fb344286c910536c6ac341222
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333500
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-15 14:02:35 +00:00
Srujan Gaddam 2c5cd7820f [CFE] Add support for indexing extension types
Adds an index for extension types and their members. Refactors
some members in this file to better reflect what's being indexed.

Change-Id: Ic397a5bfe1a8f9671a92f82c94f023faeeb5acac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332861
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-11-10 19:28:00 +00:00
Johnni Winther 519b342cc6 [cfe] Erasure extension types in constants
Closes #53936

TEST=added testcases

Change-Id: I0457bed4c9ed3d242549bba328eabb2b03825227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334463
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-10 10:42:51 +00:00
Johnni Winther 446881d53f [cfe] Update ast-to-text
Adds marker for InstanceAccessKind.Object and renames
'inline-class-member' to 'extension-type-member'.

TEST=existing

Change-Id: I087b48445e2794686c2f3db3d56dfbf7045f19fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334225
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-09 10:13:13 +00:00
Jens Johansen cd26ceeab1 [CFE] Micro-optimizations shaves off 1.42%
With a aot snapshot generated before this CL like this:

```
out/ReleaseX64/dart-sdk/bin/dart compile aot-snapshot \
  pkg/front_end/tool/_fasta/compile.dart
```

and then moved to `pkg/front_end/tool/_fasta/compile.org`,
then benchmarks run like

```
rm /path/to/other/checkout/pkg/front_end/tool/_fasta/compile.dart.dill ; \
  rm pkg/front_end/tool/_fasta/compile.aot ; \
  out/ReleaseX64/dart-sdk/bin/dart compile aot-snapshot \
  pkg/front_end/tool/_fasta/compile.dart && \
  out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart \
  --iterations=50 \
  --snapshot=pkg/front_end/tool/_fasta/compile.org \
  --snapshot=pkg/front_end/tool/_fasta/compile.aot \
  --arguments=/path/to/other/checkout/pkg/front_end/tool/_fasta/compile.dart \
  --filesize=/path/to/other/checkout/pkg/front_end/tool/_fasta/compile.dart.dill
```

(The other checkout is at 8b01baab71)

I get this:

```
Generated: [...]/pkg/front_end/tool/_fasta/compile.aot
Will now run 50 iterations with 2 snapshots.
......................................................................................................

Comparing snapshot 1 with snapshot 2
msec task-clock:u: -1.9077% +/- 0.5801% (-74.85 +/- 22.76)
page-faults:u: -2.6477% +/- 0.0391% (-2579.42 +/- 38.12)
cycles:u: -2.0459% +/- 0.6018% (-324680453.54 +/- 95498561.25)
instructions:u: -1.4202% +/- 0.0003% (-286466291.62 +/- 55229.41)
branch-misses:u: -3.0746% +/- 2.3469% (-1904933.80 +/- 1454106.83)
seconds time elapsed: -1.9144% +/- 0.5791% (-0.08 +/- 0.02)
seconds user: -1.8955% +/- 0.6479% (-0.07 +/- 0.02)
Scavenge(   new space) goes from 56 to 55
Notice combined GC time goes from 948 ms to 925 ms (notice only 1 run each).
```

So `instructions:u` being the most stable says a reduction of 1.42%,
time is in that range too (-1.9077% +/- 0.5801%), although in both
cases some of it is likely the number of new space GCs going from
56 to 55.

Change-Id: I0422af966f1902c50caa366cc2ad2cd7553c06d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333501
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-08 11:03:54 +00:00
Johnni Winther 0bdda5ca06 [cfe] Fix issue 53963
Closes #53963

Change-Id: Ibf1b58154347c4382046ba658553131717a9e23d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334540
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-08 09:05:19 +00:00
Chloe Stefantsova ad298bf8e1 [cfe] Adjust the nullability of UP w.r.t. undetermined RHS
Closes https://github.com/dart-lang/sdk/issues/52726

Change-Id: I80c3c219738bb999a1a5939d95d3119d8b63332c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334441
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-11-07 15:21:37 +00:00
Johnni Winther 3082602bf7 [cfe] Handle member access on extension type receivers
This updates the handling of member access on extension type receivers
to use the added `nonTypeVariableBound` and the `hasNonObjectMemberAccess`
properties.

The `nonTypeVariableBound` replaces the `resolveTypeParameterType`,
updated to taking the nullablity into account when going through
type variable bounds.

Change-Id: Ia2eb115c208350cdf011948177b15ebbc984fcac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333540
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-06 13:51:05 +00:00
Jens Johansen ed64348f68 [kernel] Calculate scopes for expression evaluation differently
This CL introduces an alternative way to calculate scopes for
expression evaluations. Currently the previous method is kept as well.

What this does is that it:

* Finds all nodes that match the offset and uri. (Ideally there's only
  one, but that's not always the case --- it's the case for less than
  60% of cases in the test added actually).
* Calculate the scope along the way.
* Return the scopes of all the found nodes that offset.

A test that asks for ~all file offsets in the dill files in the sdk and
compares the result with the scope the binary serialization computes is
added.
A single point can't always be found (for all dills in the sdk
only ~58.93% returns a single result), but for each query the wanted
scope is among the results returned.
For the non-outline dills in the sdk, between ~87.93% and ~94.52% of
the results are either a single result or multiple results with the
same actual scope in all of them.

Note that the test asks for ~all offsets, not just "debuggable" or
"stopable" offsets (which will likely vary depending on the vm/web
backend etc) --- likely the percentage will be higher for those points
though.

When this returns multiple results one can likely be picked by the
client based on information it has about names of variables in scope
etc.

Note that the test is rather slow, on my machine with the platforms
available there it makes 3,908,181 queries in ~3.5 minutes.
(Which corresponds to roughly 18,610 per second or under 0.06 ms per
query on average though, so it doesn't seem like a concert for actually
using it.)

Change-Id: I40b5360fcd935c70629543737e89a787de36ca16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332204
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-06 09:38:40 +00:00
Jens Johansen dc68ce5c68 [ddc/kernel] Move DDCs dart scope calculation for expression evaluation to kernel
Change-Id: I40602560d0a4d88db43f514bcfa46d9959299fc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332240
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-06 08:16:20 +00:00
Johnni Winther 12c4e22a4d [cfe] Handle various cases ExtensionType
Handles ExtensionType in inference of MapLiteral, inference of
ObjectPattern, and exhaustiveness.

TEST=tests/extension_type/*

Change-Id: I3284da2c69d875e192cf3f004ee1156e1aedd98b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333160
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-02 10:42:48 +00:00
Johnni Winther 72f1591f29 [cfe] Use getTypeAsInstanceOf instead of getInterfaceTypeAsInstanceOfClass
The changes calls to getInterfaceTypeAsInstanceOfClass (et al.) to
getTypeAsInstanceOf to ensure that we take extension types into account.

Change-Id: I7d732cdae8494002b44561cb02c49d58dd0ba67b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332920
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-31 22:30:50 +00:00
Nate Biggs 991f1aa248 [cfe] Add offset serialization to remaining Expression nodes without them.
Expressions missing offsets were:
- LogicalExpression
- ConditionalExpression
- Not
- BlockExpression
- Instantiation
- TypedefTearOff*

* I'm not sure how TypedefTearOff is actually being used, I don't see reference to it in the VM runtime. Unless the CFE lowers it before the VM gets it.

I also added a test on `binary.md` that ensures all expressions include a file offset in their serialized format. This can be expanded to statements if offsets are added to the remaining statement nodes without offsets.

TEST=Added binary_md_git_test.dart to ensure all expressions contain offset data going forward.


Change-Id: Ieaf80545f388b209f76be44db86ef07e80c8ad66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331540
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-10-30 16:05:27 +00:00
Johnni Winther 4b2cf0744d [cfe] Add TypeDeclarationType and asInstanceOf
This add a common sealed superclass TypeDeclarationType for
ExtensionType and InterfaceType and uses it to add a common
asInstanceOf method to ClassHierarchy.

Change-Id: I7294e41069b063305c3bd4e384ff90614a3936a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331981
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-10-26 08:46:48 +00:00
Paul Berry bbfe9b1ec9 Kernel: Remove Procedure.isLoweredLateField flag.
This flag used to be used for field promotion (to ensure that lowered
late fields are promotable, provided that they are private and final
and don't have a name that conflicts with something else
non-promotable). However, as of
https://dart-review.googlesource.com/c/sdk/+/330168, the logic for
determining when a Procedure is promotable now operates solely by
checking for all the conditions that prevent promotability. Lowered
late fields are now promotable because there is no reason for them not
to be.

Change-Id: I15982acef6fe8c46334fb859306bca1417a2ca64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331207
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-25 20:47:26 +00:00
Johnni Winther e06536af2e [cfe] Create combined member signature stub
This create a stub for combined member signatures from multiple
inherited non-extension type members and adds these to the
extension type declaration.

A sealed [TypeDeclaration] superclass is added to [Class] and
[ExtensionTypeDeclaration] to support accessing the enclosing type
declaration from a [Member].

TEST=existing

Change-Id: Ic01535d27a14187d37b00868e7e90fe73558b051
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331181
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-25 14:16:00 +00:00
Chloe Stefantsova b791861f75 [cfe] Make 'flatten' aware of extension types
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: Ic7175ebab22f7b9e956030616350e79d1837a1df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331942
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-25 07:41:38 +00:00
Chloe Stefantsova 67d45616c6 [cfe] Report error on bottom type used as representation type
Closes https://github.com/dart-lang/sdk/issues/53824
Part of https://github.com/dart-lang/sdk/issues/49731

Change-Id: I79776eb4f8b736f518898adff1078461895269f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-24 10:28:09 +00:00
Johnni Winther d252bb11a3 [cfe] Add representation field to ExtensionTypeDeclaration
This adds the representation field of an extension type declaration
as an abstract getter in the ExtensionTypeDeclaraiton marking it as
a ProcedureStubKind.RepresentationField

These are never used as interface targets and are therefore skipped
in the type flow analysis.

TEST=existing

Change-Id: Ie645e63e0995a31895e985a2025dccb1476d16bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330782
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-19 10:15:25 +00:00
Mayank Patke 5a0ff4ceb1 [dart2js] Lower JS_GET_FLAG in phase 0b kernel transformer
Also adds `JS_FALSE` to replace uses of `JS_GET_FLAG(false)`. See the
doc comment for details.

Change-Id: I33f89f158c1955a19fa299f22c50d51e36ede3d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330171
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2023-10-18 22:32:43 +00:00
Chloe Stefantsova 871d0b1b71 [cfe] Update UP for the case of extension and interface types
Change-Id: I968cc9c8ab38c944716c1a5f392e8cc4a732c1b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330801
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-18 10:37:32 +00:00
Alexander Thomas 48cc894e1c [cfe] Fix incorrect license header
Bug: b/286184681
Change-Id: I3eba25d9d18131da4cadac90d164f3f756c213eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330802
Auto-Submit: Alexander Thomas <athom@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-10-18 06:58:48 +00:00
Chloe Stefantsova e4bb5b608b [cfe] Use exhaustive switch in findTypeArgumentsIssues
This will allow to detect unhandled types statically.

The opportunity for the improvement was spotted while working on
https://dart-review.googlesource.com/c/sdk/+/312264

Change-Id: Ie39f48833be4d0f9f65a14e58f42843cc49c8fa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330424
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-17 10:28:23 +00:00
Chloe Stefantsova c658b463f4 [cfe] Update UP for the case of two extension types
Closes https://github.com/dart-lang/sdk/issues/53290
Closes https://github.com/dart-lang/sdk/issues/53730

Change-Id: Ic3b720898b5877e3ab122cb904f0e9dbb9c63caa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330422
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-10-17 09:38:26 +00:00
Chloe Stefantsova dfac967abf [cfe] Update comments on TypeParameterType
This CL removes the outdated comments hinting at the possibility of a
TypeParameterType object to represent an intersection type.

Change-Id: I5796f12bb22e9b21c3eb89c012abd6b6ebc75107
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330601
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
2023-10-16 15:42:17 +00:00
Johnni Winther f87142fdc2 [kernel] Add ExtensionTypeDeclaration.procedures
This adds a list of `Procedure`s to `ExtensionTypeDeclaration`. This is
meant to model representation fields and combined member signatures
computed from inherited non-extension type members.

These are not meant to be handled by the backends. The combined
member signature can be the interface target of an `InstanceInvocation`
expression but will always have a `.memberSignatureOrigin` value from
one of the original class members.

TEST=existing

Change-Id: I87768ed75a3c7126b0a30f8ccf06e46678c56db6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330301
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-13 07:42:29 +00:00