Commit Graph

697 Commits

Author SHA1 Message Date
Chloe Stefantsova 00acecdfbe [model] Upate bench maker and parser for recent type system changes
This CL includes changes to BenchMaker and test type parser that
include recent developments in the DartType system, such as extension
types and record types, outstanding existing features, such as
typedefs, and recent changes in the CFE type model, such as structural
parameters.

Change-Id: I16ca13273e83de7942abad67b8a2b67146fb24bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-23 01:57:10 -07:00
Chloe Stefantsova e535e812be [model] Update instructions for generating benchmark data in CFE
Change-Id: I505390321f8ca26391503dd4645b56a208108fc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-21 01:45:11 -07:00
Johnni Winther 2f27b68130 [cfe] Cleanup NameSpace
This remove part of the NameSpace to avoid an overreliance on its implementation. This is done in preparation for hold the name space content in a single map instead of a separate map for getables and setables.

The NamedBuilder interfaces is added to use for Builders that can be mapped in name spaces. This avoids the need for the NameIterator and all the associated methods.

Change-Id: Ia547bdc8ddcb83f47473b51a2059428b352f8916
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428001
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-13 01:15:33 -07:00
Jens Johansen ce4612dddb [CFE] Add mean absolute numbers to TTestResult; print mean from -> to in benchmarker
Change-Id: If935f5d9668cc1bd12ba3e2af7ae55f3bdea141f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421182
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-04-09 06:02:02 -07:00
Sigmund Cherem 44f8e21c82 [kernel] Adds helper to trim dill files for modular dependencies.
Introduce a helper library to trim components based on what we believe
it is needed for modular bytecode compilation. The script is configured
to accept a set of entry points, so unreachable libraries can be removed
entirely. The contents of the retained libraries is trimmed to remove
method bodies, constructor bodies, and initializers, except for where
they may be needed.


In the near future, this should be expanded to:
* include proper unit testing in the CFE
* review whether additional trimming operations can be made
* consider an explicit representation of trimmed content, to help the
  CFE recover when assumptions are not met (e.g. sentinel markers
  to establish whether a value has been trimmed)
* CFE produces trimmed data directly if needed, without having to first
  produce the full dill.

Tests that specifically stress that we don't over-trim include:
apply_mixin (requires preserving method bodies), const_body (requires
preserving initializers).

TEST=existing and new e2e dynamic module aot tests.

b/394936876

Change-Id: I26db8385bdfe1664b2aea234ec8bb896c7c21230
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418702
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-04-01 08:49:11 -07:00
Johnni Winther 06d938046f [kernel] Remove NonNullableByDefaultCompiledMode
and TargetFlags.soundNullSafety

TEST=existing

Change-Id: I5e28d3d187b0f84fa23130c042fd3c55b89c687c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413460
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-19 01:37:07 -07:00
Johnni Winther 1ebf3df920 [kernel] Add tool for checking AST equivalence
Change-Id: Ie06776203080e91346582534af2d56c24581bd54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413200
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-03-04 03:54:48 -08:00
Johnni Winther 0060b0f665 [cfe] Remove nnbd mode
TEST=existing

Change-Id: I30bbadb74e81c7f4aaa444d1e2f6f5ffc2005d4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412881
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-03-04 01:46:51 -08:00
Johnni Winther 7b34ecdb9d [cfe] Remove LibraryBuilder.scope and DeclarationBuilder.scope
Scopes are now handled through fragments

Change-Id: I9d73ef2ba48222962ae28fd9787b83536126c88d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412600
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-02-27 06:09:21 -08:00
Johnni Winther 060e154eed [cfe] Remove weak suite
Change-Id: Ic2598e408c0ca0d0f8cd1e07a0354f9e7fefd321
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411242
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-02-26 03:46:32 -08:00
FMorschel 2eec09dcd4 [DAS] Makes EXTENSION_DECLARES_INSTANCE_FIELD trigger on all field names
R=jensj@google.com, paulberry@google.com

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

Change-Id: Ic4b41973d0d74d809d813ba57b85f50fab4c9a47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407080
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-02-11 03:15:31 -08:00
Johnni Winther c27cec63aa [cfe] Remove macro support
This removes the support running macros in the CFE.

The scanner and package:kernel still have support for the macro modifier. This will be removed in a follow-up.

The metadata expression parser is deliberately left in, since it might serve as the basis for a parser AST.

Change-Id: I06d91eb0fac2e7a71e6afde647b03be3814dbd5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406963
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
2025-02-03 07:13:51 -08:00
Jens Johansen 08c802c7fc [CFE] Additions to benchmarker.dart et al
## Added --cache to benchmarker.dart

This doubles the amount of runs by running an additional round of `perf
stat` runs outputting low level cache information: L1-icache-load-misses
(instruction load misses), LLC-loads (last level cache loads, i.e.
probably how many loads goes to L3 cache) and LLC-load-misses (last
level cache load misses, i.e. how many loads goes to ram). I don't know
if these are generally available, only that they are available on my
machine.

## Added --silent to benchmarker.dart

Some benchmarks output information to stdout which is great when running
it by hand, but when running it via the benchmarker script it just
pollutes the output: The benchmarker script et al measures what is
supposed to be measured. This CL adds the `--silent` option to the
benchmarker script which then won't print the stdout output from the
benchmarkee.

## Output filename in benchmarker.dart

This CL adds the filenames of the benchmarked snapshots in an attempt to
avoid confusion. Example output before:

```
Comparing snapshot #1 with snapshot #2
```

```
Example output now:
Comparing snapshot #1 (optimization_attempt_41.aot) with snapshot #2 (optimization_attempt_42.aot)
```

## Utility to summarize --verbose-gc output

Takes input from --verbose-gc from stdin and summarizes the time taken
on GC and reports it back. Example:

```
$ out/ReleaseX64/dart --verbose-gc hello.dart 2> /dev/stdout 1> /dev/null | out/ReleaseX64/dart pkg/front_end/tool/verbose_gc_helper.dart
6.1
```

Change-Id: I206f21cd8b42f844e60358aed711e676e453c77c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406845
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-01-31 00:58:00 -08:00
Jens Johansen 9a8d4362df [CFE] Fix instrumenter
The `enter` and `exit` methods in the instrumenter library were also
instrumented and called themselves recursively.

I believe this has been broken since
https://dart-review.googlesource.com/c/sdk/+/387704

Change-Id: Iac3f91a23a25e0122be6bde00a132e4bf530f5db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406020
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-01-28 03:03:00 -08:00
Mohamed Abdelaal 9b7bb9df90 Fix "the the" typo
Closes https://github.com/dart-lang/sdk/pull/59926

GitOrigin-RevId: cb37bca473b0c177b876a0f4e75858cd1862e699
Change-Id: I6827241b22e99db455945afcdfbaee0450999ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404923
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-01-21 14:08:20 -08:00
Jens Johansen c075d939e0 [parser/scanner] Remove ScannerConfig enableNonNullable
Change-Id: If6bfbb65a02ac1a4f5708ab9e8c4d66c19ecff86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403984
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-13 00:32:35 -08:00
Jens Johansen 5dfce919cd [parser/scanner] Remove ScannerConfig enableExtensionMethods
Extension methods can no longer be disabled. This CL removes the option
from the scanner config and the parser related specific recovery.
It also removes any specific (triggered) test of the functionality.
A follow-up CL will do the same for NNBD.

Change-Id: Ia385008e5ed1333fb37697b8fe424b8759bce198
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403581
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-13 00:32:25 -08:00
Jens Johansen c95568aede [CFE] Fuzzer using Dart.G
This is the first commit of this effort. It's not polished and mostly
generates nonsense output that, though, should not crash the compiler.
Further work might add options to create less-nonsense output).

Change-Id: Ic7f140ea6f248bfa9a0e62ca37326def1d0a5086
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-01-09 23:13:33 -08:00
Jens Johansen bce3dd4fe7 [CFE/shared] Make formatting more consistent by specifying DartFormatter.latestShortStyleLanguageVersion
Autogenerated files was formatted with the new style, so if one for
instance formatted the file via the IDE or by saying
`out/ReleaseX64/dart-sdk/bin/dart format pkg/front_end/lib/` we'd get
*a lot* of changes which isn't great.
This CL sets the formatter version for the auto-generated files,
hopefully avoiding such things.

Change-Id: I4f92aafde7c77e7c78179f78bf821979a25ec12c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398884
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-12-05 08:50:30 +00:00
Jens Johansen 8a9a129d20 [CFE] Make pkg/front_end/tool/cfe executable
Change-Id: I4ba32d2c954c4dc0b28c2bface33e44dd1baca01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397860
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-11-27 12:15:51 +00:00
Johnni Winther eb8156415c [cfe] Remove use of 'fasta' in (file)names
Change-Id: Iac3850696fb5e48dff847d17f7110644e8b8bd03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395920
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-11-20 14:22:56 +00:00
Johnni Winther 808fa4ca8b [cfe] Move tool/_fasta/ to tool/
Change-Id: I5b7348fb4adb4e7f4039c91d54d712c1eb131ecf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395002
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-11-18 07:49:01 +00:00
Johnni Winther 72534f18fa [cfe] Remove library fasta.* names
Change-Id: I0a678e971395f70d09a3faf004e6476a9b5a48cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395000
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-11-14 07:32:21 +00:00
Jens Johansen a9469269d7 [kernel] BinaryReader takes Uint8List, not List<int>
In AOT this makes reading faster:

Output from `out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --iterations=10 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.1 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.2 --arguments="--warmups=10" --arguments="--iterations=5" --arguments="AstFromBinaryEager" --arguments="out/ReleaseX64/vm_platform_strong.dill"`:

```
msec task-clock:u: -8.6925% +/- 0.5737% (-167.09 +/- 11.03)
page-faults:u: 0.1410% +/- 0.0051% (243.00 +/- 8.71)
cycles:u: -10.2918% +/- 0.6161% (-732576747.50 +/- 43853449.16)
instructions:u: -14.4988% +/- 0.0004% (-1636799813.90 +/- 39902.18)
branch-misses:u: -3.4891% +/- 2.1142% (-1166085.00 +/- 706582.35)
seconds time elapsed: -8.7005% +/- 0.5634% (-0.17 +/- 0.01)
seconds user: -9.9752% +/- 1.5104% (-0.17 +/- 0.03)
```

Stats running manually (run as e.g. `out/ReleaseX64/dart-sdk/bin/dartaotruntime pkg/front_end/test/kernel_binary_bench.aot.1 --warmups=10 --iterations=5 AstFromBinaryEager out/ReleaseX64/vm_platform_strong.dill`):

```
AstFromBinaryEagerCold: -12.5174% +/- 3.10688%
AstFromBinaryEagerWarmup: -8.33675% +/- 2.62433%
AstFromBinaryEager: -10.3432% +/- 3.68375%
```

I don't expect there to be much of a change (if any) in JIT as the actual type was in practise always Uint8List anyway.

TEST=Existing tests.

Change-Id: I86b16ed207343848dee2e376f42598c223bbc48f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393740
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-11-08 08:23:42 +00:00
Danny Tuppeny 27b52a3f82 Add languageVersion to CompilationUnit and make non-null
Change-Id: Ice6f866929f1f028d9b4e64685c2e815a08279f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-31 18:49:03 +00:00
Jens Johansen 329760d5cf [cfe/parser] Parser doesn't set wrong endToken on handleThrowExpression; fix cfe coverage related to that
Change-Id: Ie1f936d1b914f38a819b3761770742c60d9be1e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392121
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-10-28 12:08:50 +00:00
Johnni Winther 307e5a62ce [cfe] Include offended version number and package name in too high/low version message
Closes #48819

Change-Id: I8700ed909c916b9c656cc8bc0e34eb1dd6ef0c09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390200
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-10-16 06:36:21 +00:00
Lasse R.H. Nielsen f8086c81ae Collect all test-related files in package:expect.
Collects files from `package:async_helper` and `tests/language`
that are generally useful, so that all test-related helpers are
in `package:expect`.

Moves the two libraries from `package:async_helper` into `package:expect`,
and the `tests/language/static_type_helper.dart` file too.

Deprecates `async_minitest.dart`, to follow `minitest.dart`,
expecting the Flutter use of it to have been fixed to not break
on deprecation (I believe Flutter no longer breaks builds on deprecations at all).

Patch 1 is the actual change.
Patch 2+4+8 is changing all existing references to the files.
Patch 6 ignores deprecation in files still using `async_minitest.dart`.

3+5+7+9 are updating this text to make the numbers match.
Then it's just test-expectations and small tweaks from there.

Change-Id: I1b665135b5fef9b9a0c3b340ffe9daf874d0174c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373120
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-10-11 16:53:52 +00:00
Johnni Winther d4b78e9c60 [cfe] Add subtype_measure
Add instrumenter to measure subtype checks

Change-Id: Ida25671e3e4d572a1eaa2114cb384c6e8c5c769a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387704
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-10-02 09:46:26 +00:00
Johnni Winther 63dff0db52 [cfe] Create SourceLibraryBuilder for libraries only
Change-Id: I1da8b463c7314566abfb573039316807546cb49d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386803
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-09-26 07:29:12 +00:00
Jens Johansen 3dce89fbe0 [scanner] Don't give the Utf8 scanner a 0-terminated byte sequence
Not having to do the read-allocate-copy dance for files to add a 0-byte
at the end results in these changes when using the CFE to compile
(a fixed version of) the CFE:

```
msec task-clock:u: -1.7356% +/- 0.2164% (-73.16 +/- 9.12)
page-faults:u: -2.6957% +/- 0.0111% (-2914.83 +/- 12.00)
cycles:u: -1.7128% +/- 0.2223% (-297927979.70 +/- 38660477.01)
instructions:u: -1.6814% +/- 0.0002% (-361315766.86 +/- 36853.71)
branch-misses:u: -3.3289% +/- 0.9669% (-2153126.00 +/- 625370.97)
seconds time elapsed: -1.7372% +/- 0.2154% (-0.07 +/- 0.01)
seconds user: -1.5998% +/- 0.2740% (-0.06 +/- 0.01)
seconds sys: -4.1451% +/- 2.9801% (-0.01 +/- 0.01)
Scavenge(   new space) goes from 62 to 61
```

TEST=Existing test coverage.

Change-Id: I8e182bcee39839f6ed1e658c30c85c40ecf0b259
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385722
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-25 08:33:48 +00:00
Sam Rawlins 7d4994fa4a linter: Report when single statement if-statement body is not on the same line as if-keyword
Fixes https://github.com/dart-lang/linter/issues/4870

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try
Change-Id: Ibd8969afe35f719a020e5aa37efdc1792addac7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353140
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-24 01:59:23 +00:00
Robert Nystrom 13323eeac6 Migrate internal CFE tools to the new DartFormatter API.
As far as I can tell, these scripts are all only used internally for
formatting generated code, so it should be safe to just parse the code
at the latest language version.

I didn't migrate:

  pkg/front_end/test/fasta/textual_outline_suite.dart

I believe that one may need to pass in a specific language version if it
needs to support formatting code from before Dart 3.0. (In particular
if it needs to handle code using old switch constant expressions that
are not supported in Dart 3.0 and later like `case 1 + 2:`.)

Bug: https://github.com/dart-lang/sdk/issues/56687
Change-Id: Ib5cef82c22fc749223095215d3b692e6c27decc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385341
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2024-09-17 10:59:41 +00:00
Jens Johansen 10622639f8 [CFE] Coverage auto-ignores assert message
Change-Id: Ia07503b7e66f4014366906b7697abed3df266a1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385163
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-09-17 06:35:10 +00:00
Johnni Winther 0f2897a419 [cfe] Build library name space late
This moves the building of the library name space until after the
library and its parts have been resolved.

Change-Id: I9d999cd779b07402fc247f10a58118d08ff0a2c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384521
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-09-12 07:34:38 +00:00
Johnni Winther cd236ece98 [parser] Add enclosingDeclarationName to beginMethod
This adds the enclosingDeclarationName to the beginMethod of the
parser listener.

This enables the removal BuilderFactory.currentTypeParameterScopeBuilder.

Change-Id: Ie2bec9432c20b8bdbd62a14e8a65c272179d4698
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383182
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-09-05 07:40:09 +00:00
Jens Johansen 0329ebfd99 [CFE et al] Lint for fields with StackTrace.current
This CL primarily adds a lint for fields with `StackTrace.current`
which is often useful for debugging, but shouldn't be left in.

* Add an ast visitor after the "explicit creation test",
  finding - for now - `StackTrace.current` calls in fields.
  This should have caught the left-in debug such in
  https://dart-review.googlesource.com/c/sdk/+/379281.
* Renamed explicit_creation to compile_and_lint
* Remove (for some time) unused "smoke_test_quick" files.
* Add kernel to the compile_and_lint suite, but ignore it for explicit
  creation (i.e. kernel will also be checked for fields
  with `StackTrace.current`).

Change-Id: Ib886d23a8945e7063dc673a7f99cbb3a6adc1139
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382361
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-08-28 09:46:08 +00:00
Jens Johansen 05ede5d564 [CFE] DartDoc tests prints test compile time errors better
Previously it wouldn't map back to which test, now we'll get something
like

```
Compilation error:
Test from file://path/to/pkg/front_end/lib/src/kernel/body_builder.dart:10094:7 has errors when compiling:

dartdoctest:tester:13:29: Error: Too many positional arguments: 2 allowed, but 3 found.
Try removing the extra positional arguments.
  dartDocTest.test(debugName(
                            ^
pkg/front_end/lib/src/kernel/body_builder.dart:10104:8: Context: Found this candidate, but the arguments don't match.
String debugName(String className, String name) {
       ^^^^^^^^^
```
Change-Id: I423e0329d37d7c2c27f158385a7514dca5645e92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379601
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-08-08 10:36:21 +00:00
Jens Johansen da48538b10 [CFE] DartDoc tests prints errors on crash better
Before:
```
Bang or other message!
Processed 4 test(s) in 205 ms.
3 OK; 0 bad; 1 crashed; 0 parse errors.
```

Now:
```
Failure:
Test from file://path/to/pkg/front_end/lib/src/kernel/body_builder.dart:10086:7 crashed with this message:
Bang or other message!

Stacktrace:
#0      debugName (package:front_end/src/kernel/body_builder.dart:10102:23)

Processed 4 test(s) in 90 ms.
3 OK; 0 bad; 1 crashed; 0 parse errors.
```

Change-Id: I49e8543dea5dc5285091fb57e8b92c45684fb5d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379060
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-08-08 08:15:18 +00:00
Jens Johansen a16f1adc2a [CFE] DartDoc tests support expecting throws
With this CL one could do a test like
```
DartDocTestThrows(LocalStack<int>([]).current)
```

which would then expect the call to throw and fail if it doesn't throw
in which case you might get something like

```
Failure:
Test from [...]/pkg/front_end/lib/src/util/local_stack.dart:19:25 failed with this message:
Expected a crash, but didn't get one.

Processed 19 test(s) in 33 ms.
18 OK; 1 bad; 0 crashed; 0 parse errors.
```

Change-Id: I52deb657cb95b9b1f866a58f7433f0c57162b5c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378480
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-08-05 11:22:58 +00:00
Jens Johansen 12c3fa8335 [CFE] DartDoc tests prints errors better
E.g. we might get something like this:

```
UNEXPECTED: dartdoctest/front_end/lib/src/util/local_stack
[...]
Failure:
Test from [...]/pkg/front_end/lib/src/util/local_stack.dart:11:19 failed with this message:
Expected 'false'; got 'true'.

Failure:
Test from[...]/pkg/front_end/lib/src/util/local_stack.dart:27:19 failed with this message:
Expected 'true'; got 'false'.

Processed 15 test(s) in 34 ms.
13 OK; 2 bad; 0 crashed; 0 parse errors.
```

Change-Id: I8e6072bc8484da06b035a5b951381938ac11e1fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378460
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-08-02 08:40:09 +00:00
Jens Johansen eb827b7f3f [CFE] Allow coverage tool up update comments and expectation file in one go
Previously to update comments "correctly" one had to
1) Do a coverage run with debug enabled to save the coverage files.
2) Pass the coverage files into the comment removal tool.
3) Do another coverage run with debug enabled to save the coverage files
   (for the now changed sources).
4) Pass the coverage files into the comment adding tool.
5) Do a third coverage run, updating the expectation (hopefully, saying
   0 missis in all files).
6) Format the changed files.

Now instead one can run

```
out/ReleaseX64/dart-sdk/bin/dart pkg/front_end/test/coverage_suite.dart --add-and-remove-comments --update-expectations
```

and it will all be done with only 1 run.

This CL also adds support for adding coverage igonre comments to `a?[b]`
where `a` is null and the lookup (and `b`) is thus not performed.
This should let the misses go to 0 (in a followup CL).

Change-Id: Ib96f3568f201586efe6f2d178133485d56a28be0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378440
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-08-02 08:39:17 +00:00
Jens Johansen 6995dc4447 [CFE] format_cl helper til also formats uncomitted changes
Compiling like so:

```
$ out/ReleaseX64/dart-sdk/bin/dart compile exe pkg/front_end/tool/format_cl.dart -o ~/bin/format_cl
```

I can format my CL with

```
$ format_cl
```

This isn't new. What's changed is that it now also includes the
not-yet-committed changes.
Previously my workflow has turned out to be format, committing,
then formatting again, then committing again because the files
that I hadn't yet committed wasn't formated. They will be now.

Change-Id: I30c30d7cfa6b885cf9f80bb1a6aa3022e898fd58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378420
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-08-01 09:53:18 +00:00
Johnni Winther 1917754f99 [cfe] Remove Scope
This changes the LibraryBuilder to use LookupScope+NameSpace instead
of Scope.

Change-Id: Ie969d5385cf83a19cfceb4aede9ff7c6821c9143
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377661
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-07-26 07:26:29 +00:00
Johnni Winther 218a0c63f5 [cfe] Simplify SourceLibraryBuilder constructors
This changes the SourceLibraryBuilder from a chain of 3 generative
constructors to a factory constructor calling an internal generative
constructor, making it much clearer when computations are performed
during creation.

Change-Id: I8251a874831e25aae59775410b8748111cb05f9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377441
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-07-24 16:37:14 +00:00
Johnni Winther 59e9a1a7a4 [cfe] Remove uses of SourceCompilationUnit.library outside _includePart
This is a step towards creating SourceLibraryBuilder during
SourceLoader.resolveParts.

Change-Id: I3000ad217957297034891ef2681ca6cd72f84242
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375524
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-07-16 07:45:19 +00:00
Johnni Winther 79003d77a7 [cfe] Pass originImportUri along origin
This is a step towards removing the reliance on SourceLibraryBuilder
for supporting augmentation/patch libraries.

Change-Id: I4a2f2ed28d7dda2796a7e6985a5f0c3fb0480b52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375520
Reviewed-by: Jens Johansen <jensj@google.com>
2024-07-12 12:53:19 +00:00
Jens Johansen 8767626437 [CFE] Remove rest of CompilerContext.current
Change-Id: Id81f06d80d43ac471b6278ef42a0270761b9d78c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374004
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-07-08 11:55:25 +00:00
Johnni Winther c17e9c116e [cfe] Clean up backend imports
This updates backend imports to use reexports from api_prototype
or api_unstable.

TEST=existing

Change-Id: I8d9d1c76ef72c709c578acac5497064710ee5579
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373462
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-07-08 11:32:30 +00:00
Jens Johansen 265197a85d [CFE] Split up some messages giving to either required CompilerContext or not
Steps towards getting rid of CompilerContext.current;

Change-Id: I5d02ea94860b938e065534748a08d2bed3fb9140
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374002
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-07-08 11:19:41 +00:00