Commit Graph

48781 Commits

Author SHA1 Message Date
Nicholas Shahan 39bcea7e76 [ddc] Cleanup use of dart library name
Avoid hard coded uses of the name for the SDK runtime library. This
unblocks a more consistent name/rename logic for all dart libraries
when they are imported.

Change-Id: I4599006569ecae81a0526686467e06da9b335fc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385188
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-09-25 21:49:39 +00:00
Graciliano Monteiro Passos c2b99d21c1 _IndexAssembler.assemble: optimize using toList(growable: false)
Closes https://github.com/dart-lang/sdk/pull/56544

GitOrigin-RevId: 7b342c4b8c90465b4c858ccfb2ef6ed99d8d9830
Change-Id: Id2d58f23344e525b80dd87112bc3d04a4cfc3c43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381780
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2024-09-25 21:43:16 +00:00
pq a6714ffdff a few new formatter migrations
See: https://github.com/dart-lang/sdk/issues/56685


Change-Id: Ifa7fbbc7aff7c5fd96b02cafe0da76b22a33b1e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386824
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-25 21:12:17 +00:00
FMorschel dbf87d8644 Improving string conversion
Closes https://github.com/dart-lang/sdk/pull/56723

GitOrigin-RevId: 802fda7efeace66f33a82fa939a3efac11064390
Change-Id: I6d4d3931e62b89265eb1d324856bed5b9febfe8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384962
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-25 21:11:17 +00:00
Konstantin Shcheglov 5e5cf385ee Parts. Report AMBIGUOUS_EXPORT in parts.
Change-Id: If900bd4b254c5c89719af61368c9160c2e6ac7ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386684
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-25 21:04:09 +00:00
FMorschel a0374dd70c Fix create method/function inside conditional operator
Closes https://github.com/dart-lang/sdk/pull/56722

GitOrigin-RevId: 9a861d4078b326754b8855e833c52ede03f0e28d
Change-Id: Ia7535ff48c16836b0e7d3a32005051c7defc3766
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384941
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-25 20:51:54 +00:00
Martin Kustermann 5ede6d466c [deps] Roll dart-lang/native to new version
We rename the Dart CI specific environment variables we use for testing
dart-lang/native code on Dart CI to make it clear they are for testing
only.

Change-Id: Idb7c016df5b6fd3aee7a2952be06752a8343f02e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386804
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-09-25 20:45:11 +00:00
Derek Xu 6121c396ee [VM/Service] Expose Service ID zone APIs in service.md and package:vm_service
TEST=pkg/vm_service/test/id_zones_test.dart, CI

Issue: https://github.com/dart-lang/sdk/issues/55869
CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes in
sdk/lib/vmservice/running_isolates.dart.
Change-Id: Id63180fd08a88865064435b056fa3269835cd476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381400
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-09-25 17:28:44 +00:00
Konstantin Shcheglov edccc388f5 Elements. Use 'formalParameters' and 'typeParameters' names.
Change-Id: I4540f3f23c7b317e54a59037eab6041794c745bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386606
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-25 16:49:31 +00:00
Danny Tuppeny c8adf3da3f [analysis_server] Update color handling for recent Flutter Color class changes
In https://github.com/flutter/engine/pull/54714 the "int value" that was used for storing the color values for a Flutter color was removed and replaced with `double red, double green` etc.

The color computer used the `value` field so this stopped it from computing any colors for previews in LSP clients. No tests broke because the tests here use a mock version of the Color class that still had `value`.

This change updates the mock Color class to match the new Flutter implementation, and updates the computer to use the red/green/blue doubles instead of parsing from an int.

It also adds support for the new `Color.from()` constructor that was also recently added.

Fixes https://github.com/Dart-Code/Dart-Code/issues/5289

Change-Id: I3ff20bda0cc848e028822cfcb5a14e6a8f6934d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386802
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-25 16:27:51 +00:00
Jessy Yameogo ef5295d050 [dtd] Use secure random number generator to generate URI auth code (path) and secret
Change-Id: Ibde6afaaf5d3f83f8f8aea1bca38bffc75a20e36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386280
Reviewed-by: Jessy Yameogo <yjessy@google.com>
Commit-Queue: Jessy Yameogo <yjessy@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-09-25 15:41:52 +00:00
Paul Berry 13d4eaf99a Implement matchInferableParameter in MiniAstOperations.
Previously the implementation of this method was a stub.

It turns out that all the necessary infrastructure was in place
already, however the type arguments supplied by MiniAstOperations to
TypeAnalyzerOperationsMixin and TypeAnalyzerOperations needed to be
changed: in the "mini_ast" representation of types, an
InferableParameter is represented by a String, not a
PromotedTypeVariableType. This is because InferableParameter is meant
to represent the declaration of the type parameter
(StructuralParameter for the CFE, TypeParameterElement for the
analyzer), not the type itself. The types used for unit testing in
_fe_analyzer_shared don't have a separate notion of the declaration of
a type parameter, so we just use its name.

Implementing this logic required adding a method
`TypeSystem.matchTypeParameterType`, which checks if a Type is a type
parameter type, and returns the name of the type parameter if so. I
based this on the previously existing `TypeSystem._isTypeVar` method
(which performed the same job but did not return the type parameter
name).

I also took the liberty of fixing a flow analysis test that treated
`T` as a type variable but failed to mark it as a type variable by
calling `addTypeVariable`.

This should help pave the way for unit testing more of the shared
infrastructure for types.

Change-Id: Ia7a9777ec3d90a5886567dcb9f831e388e372f32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386607
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-09-25 12:23:01 +00:00
Chloe Stefantsova f6fe5615c4 [analyzer][cfe] Generate constraints based on type variable bounds
In response to https://github.com/dart-lang/language/issues/3009

Change-Id: I918d392e422f1997736bf2543c8107cb44d3d6f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364721
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-09-25 10:59:51 +00:00
Johnni Winther 1bf0bc349a [cfe] Add LibraryProblemReporting
This adds an implementation of ProblemReporting that registers
the reported errors with a Library node.

Change-Id: I5d3f60f9691fe34b54322f9ed788025ff29cca29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386202
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-09-25 10:52:11 +00:00
Jens Johansen a086649e42 [scanner] Support 0-byte in input
Fixes https://github.com/dart-lang/sdk/issues/18090

Change-Id: I9bcd49c9ade7923eb087c5dd617a2f33cc84ee96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386161
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-09-25 09:15:19 +00:00
Johnni Winther a31c6dfc31 [cfe] Remove Builder.parent setter
This also moves some uses from .parent to .declarationBuilder to reduce
the reliance on the Builder.parent getter.

Change-Id: Ie99a7237a0f2bb68016cd1e0643f4e9045600a1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386140
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-09-25 08:34:14 +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
Johnni Winther 6d150d21b3 [cfe] Create PrefixBuilder through fragments
This creates a PrefixFragment during outline building and creates
a PrefixBuilder for each unique prefix during computation of import
scopes.

Change-Id: I0ac7ba22ec7db1aee288f088c60994c36c38f43a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385723
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-09-25 07:44:07 +00:00
Jens Johansen c242d3a756 [scanner] Use 'vm:unsafe:no-bounds-checks' and add explicit bounds checks
The (utf8) scanner currently has this thing where you give it a
0-terminated byte-array (i.e. you read the file, then allocate
something that's 1 bigger, copy the data, then give it to the scanner)
to 'avoid bounds checks'.
Dart still has bounds checks though - they're just implicit.

As for the string scanner ut gets a string, then creates a new string
like `string + '\x00'` - so basically the same thing.

This CL uses the 'vm:unsafe:no-bounds-checks' pragma, removing the
implicit bounds checks, adding explicit bounds checks,
saving ~73.6 mio instructions when compiling the CFE in the process:

```
Comparing snapshot #1 with snapshot #2
cycles:u: -0.9983% +/- 0.6563% (-174026333.30 +/- 114410028.98)
instructions:u: -0.3416% +/- 0.0005% (-73659267.00 +/- 108567.20)
branch-misses:u: -4.8952% +/- 2.2612% (-3172939.50 +/- 1465641.18)
```

With the scanner-benchmark with `--bytes` I get this:

```
msec task-clock:u: -1.2251% +/- 0.6355% (-50.64 +/- 26.27)
cycles:u: -1.2376% +/- 0.6385% (-223642830.80 +/- 115393789.68)
instructions:u: -2.8155% +/- 0.0000% (-1153243856.00 +/- 428.11)
seconds time elapsed: -1.2165% +/- 0.6408% (-0.05 +/- 0.03)
seconds user: -1.1539% +/- 0.6495% (-0.05 +/- 0.03)
```

With the scanner-benchmark with `--string` I get this:

```
msec task-clock:u: -7.6439% +/- 0.6628% (-366.08 +/- 31.74)
page-faults:u: -95.0034% +/- 0.0014% (-228023.50 +/- 3.41)
instructions:u: 2.1041% +/- 0.0000% (897941907.60 +/- 2082.79)
branch-misses:u: 3.2994% +/- 1.4675% (3239735.30 +/- 1440940.88)
seconds time elapsed: -7.6595% +/- 0.6610% (-0.37 +/- 0.03)
seconds user: -0.8801% +/- 0.7676% (-0.04 +/- 0.03)
seconds sys: -92.0140% +/- 2.8075% (-0.33 +/- 0.01)
MarkSweep(   old space) goes from 6 to 0
Notice combined GC time goes from 112 ms to 41 ms (notice only 1 run each).
```

Where I'll note that the 'vm:unsafe:no-bounds-checks' pragma doesn't
(yet?) work for `String.codeUnitAt`.
See https://dart-review.googlesource.com/c/sdk/+/384540
(and https://dart-review.googlesource.com/c/sdk/+/385201) for details.
I assume the relatively  big change here is caused by not allocating
a new string with a 0-byte in the end each time.

Note that the read-allocate-copy dance is still performed for the utf8
scanner in this CL as it requires changing all call-sites instead.
It will be done in a follow-up CL where the "end-of-file" int will
likely also be changed to `-1` to (I assume) allow for having the
0-byte in the middle of a file (see also the 10+ year old bug at
https://github.com/dart-lang/sdk/issues/18090)

Note: The pragma (currently?) only has effect in AOT and this change
will (for the utf8 scanner) make the JIT version slower
(probably by the same ~73.6 mio instructions as - at least in AOT -
the implicit check is 6 instructions and the explicit one is 3
instructions). As the pragma doesn't work in the StringScanner anyway
I expect the change to be somewhat equivalent there. Once the
read-allocate-copy dance is also removed from the utf8 scanner I expect
the combined result to be positive all around.

Update: With https://dart-review.googlesource.com/c/sdk/+/385201 landed
I get these changes:

Compiling the CFE:
```
instructions:u: -0.4520% +/- 0.0002% (-98470955.29 +/- 42253.40)
```

Scanner benchmark with `--bytes`:

```
msec task-clock:u: -2.1758% +/- 0.2316% (-92.07 +/- 9.80)
cycles:u: -2.1941% +/- 0.2283% (-405224983.11 +/- 42160655.88)
instructions:u: -3.1049% +/- 0.0000% (-1272360052.95 +/- 706.54)
branch-misses:u: 2.4718% +/- 0.5142% (2371345.23 +/- 493257.76)
seconds time elapsed: -2.1761% +/- 0.2317% (-0.09 +/- 0.01)
seconds user: -2.2071% +/- 0.2308% (-0.09 +/- 0.01)
```

Scanner benchmark with `--string`:

```
msec task-clock:u: -15.0073% +/- 0.2175% (-745.93 +/- 10.81)
page-faults:u: -95.0035% +/- 0.0003% (-228024.25 +/- 0.81)
cycles:u: -7.7986% +/- 0.2329% (-1558985588.99 +/- 46560962.79)
instructions:u: -3.7054% +/- 0.0000% (-1581977447.66 +/- 481.68)
branch-misses:u: -0.6880% +/- 0.5818% (-689453.22 +/- 583101.50)
seconds time elapsed: -15.0198% +/- 0.2170% (-0.75 +/- 0.01)
seconds user: -8.8149% +/- 0.2648% (-0.41 +/- 0.01)
seconds sys: -94.1247% +/- 1.6444% (-0.34 +/- 0.01)
MarkSweep(   old space) goes from 6 to 0
```

Change-Id: I524a21f488da7df5dc9d2cdf40112b84896ad3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383324
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-09-25 07:33:40 +00:00
Jens Johansen 23f0c0b27b [scanner/paser] Don't use identical on ints
Short explanation: For whatever reason, when using `identical` on `int`s
the ints are first boxed (`BoxInt64`) before being compared
(`StrictCompare`) whereas just doing `==` just does a compare
(`EqualityCompare`).

Results:

With the CFE compiling (a fixed version of) itself I get these results:

```
instructions:u: -0.5756% +/- 0.0003% (-124825401.80 +/- 64013.17)
```

i.e. almost 125 mio instructions saved.

Another run - with 100 iterations each - I get

```
msec task-clock:u: -0.4927% +/- 0.2585% (-20.85 +/- 10.94)
page-faults:u: 0.0174% +/- 0.0139% (18.80 +/- 15.00)
cycles:u: -0.5233% +/- 0.2683% (-91305451.82 +/- 46815747.30)
instructions:u: -0.5754% +/- 0.0002% (-124793061.49 +/- 37426.30)
branch-misses:u: -1.6903% +/- 1.1207% (-1091410.69 +/- 723627.04)
seconds time elapsed: -0.4863% +/- 0.2581% (-0.02 +/- 0.01)
seconds user: -0.4547% +/- 0.3253% (-0.02 +/- 0.01)
```

In the scanner benchmark with `--string` (i.e. using string scanner) I
get these results:

```
msec task-clock:u: -3.7992% +/- 0.3316% (-190.54 +/- 16.63)
cycles:u: -4.1423% +/- 0.3566% (-836808313.28 +/- 72033424.19)
instructions:u: -3.3524% +/- 0.0000% (-1480262370.08 +/- 828.58)
branch-misses:u: -1.7591% +/- 0.9582% (-1781144.28 +/- 970258.82)
seconds time elapsed: -3.7988% +/- 0.3303% (-0.19 +/- 0.02)
seconds user: -4.0211% +/- 0.4161% (-0.19 +/- 0.02)
```

(Just running the benchmark also sees the characters/µs go from ~93 to
~97).

In the scanner benchmark with `--bytes` (i.e. using the utf8 scanner) I
get these results:

```
msec task-clock:u: -4.2872% +/- 0.4467% (-185.64 +/- 19.34)
cycles:u: -4.2972% +/- 0.4382% (-812955454.92 +/- 82892232.23)
instructions:u: -3.4867% +/- 0.0000% (-1479744935.28 +/- 297.12)
seconds time elapsed: -4.2872% +/- 0.4470% (-0.19 +/- 0.02)
seconds user: -4.2204% +/- 0.4730% (-0.18 +/- 0.02)
```

(Just running the benchmark also sees the bytes/µs go from ~108 to ~113).

In both cases we notice how the actual time, cycles and instructions
agree pretty well.

Combining the data for the compile and the benchmark I assume this CL
actually reduces the runtime of the CFE compiling itself by a about
half a percent.

Change-Id: I67d056837240aef61b6707d02507ab4121b31715
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385940
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-25 07:08:56 +00:00
Jens Johansen 3f24e57422 [scanner] Add scanner benchmark
E.g. we might do this

```
$ out/ReleaseX64/dart-sdk/bin/dart compile aot-snapshot pkg/_fe_analyzer_shared/test/scanner_benchmark.dart
Generated: /usr/local/google/home/jensj/code/dart-sdk/sdk/pkg/_fe_analyzer_shared/test/scanner_benchmark.aot

$ for type in --bytes --bytes0 --string --stringtobytes --count ; do out/ReleaseX64/dart-sdk/bin/dartaotruntime pkg/_fe_analyzer_shared/test/scanner_benchmark.aot pkg/kernel/lib/ast.dart $type; done
Scanned 466534 bytes 1000 times in 0:00:04.413011
Found errors 0 times
That's 105.71784208106438 bytes per microsecond

Scanned 466534 bytes 1000 times in 0:00:04.911947
Found errors 0 times
That's 94.97944501437007 bytes per microsecond

Scanned 466532 string characters 1000 times in 0:00:05.413169
Found errors 0 times
That's 86.18463602374136 string characters per microsecond

Scanned 466532 string characters as bytes 1000 times in 0:00:06.722731
Found errors 0 times
That's 69.39620222793386 string characters as bytes per microsecond

Scanned 466534 bytes 1000 times in 0:00:00.641854
Found errors 0 times
That's 726.8537704836302 bytes per microsecond
```

to see that scanning pre-0-at-the-end'ed bytes scan at ~105 bytes/µs,
doing a copy to add the 0 at then end, then parse bytes scan at ~95,
scanning strings runs at ~86, converting strings to bytes, then scanning
the bytes at ~69 and - for comparision - just running through the bytes
counting linebreaks runs at ~726.

The benchmark is also useful for comparing optimizations.

Change-Id: I67c12850505e7f712660fd353575e8c7a455f112
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-09-25 06:47:14 +00:00
Konstantin Shcheglov d4b9bd6c38 Elements. Make 'firstFragment' nullable.
Change-Id: I696f5ede22cdd2ca60e9a057d035cfee7e4b93a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386604
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-24 23:14:38 +00:00
Parker Lougheed 59413a24f8 [analyzer/linter] Mark latest diagnostic docs as published
Change-Id: I60af7f164cc0a92e73e9a05605d11d8b2962b2d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386543
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-24 23:06:39 +00:00
Parker Lougheed 46cd8b627c [linter] Move old lint details out of source
- Makes way for slowly replacing them with new "why" docs.
- Slightly reduces snapshot size of analysis server
- Colocates docs in the new linter/messages.yaml file.

Change-Id: I8708b8b55455a183ccfa5c9d8c21098ae0655b51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385304
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
2024-09-24 23:06:34 +00:00
Mayank Patke 8fda05e2fd [dart2js] Remove redundant clone method from EnumSet.
Change-Id: I5ee35d9d66072a3838113e5686b40b5f7bc1dd02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386605
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-09-24 22:21:38 +00:00
MarkZ bbdf1952b4 [reload_test] Enabling all DDC hot reload tests.
Change-Id: I8a6a102f87ff162b1624da0917f3ee8db8f2144c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385120
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-09-24 22:03:24 +00:00
Konstantin Shcheglov b07eb3b325 Parts. Report PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER in parts.
This also moves the target to be the import prefix, not the declaration.
This is how the specification describes it, and scope lookup works.

Change-Id: Ic0f60a6b57bd8760589b1a91be8885fafb5c90c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386602
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-09-24 21:45:12 +00:00
Konstantin Shcheglov e9a7079ee3 Elements. Remove _writeCodeRange(), only fragments have offsets.
Change-Id: Ie0d1467feda42046620e5c24bbed924906696e0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386523
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-24 20:09:59 +00:00
Brian Wilkerson 037f313959 Migrate add_missing_enum_case_clauses
Change-Id: Idef9c7cb952ed11d39082f160713daf9c75c67e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-09-24 19:25:22 +00:00
Brian Wilkerson a3c6d05697 Migrate one_member_abstracts
Change-Id: I82504402beed3c9ab55099672236f82841d293e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386541
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-09-24 18:57:49 +00:00
Konstantin Shcheglov 26362db2bc Elements. Make ScopeLookupResultImpl constructor use named formal parameters.
Change-Id: Ib408b88e3adc0917a9af66f6f1c839dbaca135bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386600
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-24 17:37:22 +00:00
Sam Rawlins fb1cb0a0d4 lint rules: migrate tests for several rules:
* avoid_dynamic_calls
* combinators_ordering
* package_api_docs
* unnecessary_statements

Change-Id: Ie2e47029b8e81fd40e8abb5ce55d6f0f4bf7ddcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386120
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-24 16:40:04 +00:00
Konstantin Shcheglov d063ceb520 Elements. Store 'element2' in NamedTypeImpl, extract 'element' from it.
This is a step toward the state where we eventually want to be.

Change-Id: I8d3062478c08a5aac0992ccccd7848d2c74589de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-24 15:55:01 +00:00
Ömer Sinan Ağacan f80214eb86 [dart2wasm] Fix Uri.base in d8
Currently when the .wasm file path passed to run_wasm.js is a relative
path, `Uri.base` becomes something like `file://test.wasm`, which is not
a valid file URI, so it causes crashes in `Uri.toFilePath`.

When the file path is relative add a omit `file://` prefix.

`Uri.base` values before and after:

- Before, relative .wasm path: `file://test.wasm` (invalid)
- Before, absolute .wasm path: `file:///home/user/test.wasm`

- After, relative .wasm path: `test.wasm` (fixed)
- After, absolute .wasm path: `file:///home/user/test.wasm` (same as before)

Change-Id: I0d1c43716e07a9ee926e7feeeab514c2c66bac16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-09-24 10:21:52 +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
Sam Rawlins 24e28539c1 Lint rules: Migrate tests for four rules:
* avoid_setters_without_getters
* prefer_if_empty
* prefer_if_null_operators
* unrelated_type_equality_checks

Change-Id: I47e402c5a7f349ec56d620d198b7204b162d0be3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385801
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-24 00:41:16 +00:00
Konstantin Shcheglov 2fbdc85da0 Elements. Write InterfaceType.element3 where we write elements.
Change-Id: I2a46321d59c83f04f27f67b8335b7f31cddedbe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386264
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-23 22:14:49 +00:00
Konstantin Shcheglov 8393a6c895 Parts. Simplify MemberDuplicateDefinitionVerifier.
Change-Id: Ife514dcad7d248b39fa6a82c955b9df9facb469f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386263
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-23 21:18:10 +00:00
Nate Biggs 25706745bc [dart2wasm] Fix handling of user-defined _typeArguments members.
The dart2wasm transformer injects a `_typeArguments` into each class.
https://github.com/dart-lang/sdk/blob/main/pkg/dart2wasm/lib/transformers.dart#L201

This is a synthetic private member that gets handled specially. However, users can have their own private members with the same name so we have to ensure the intrinsic handler is only operating on synthesized members by looking at the library attached to the private name.

Bug: https://github.com/flutter/flutter/issues/154383
Change-Id: I04062bec1f2bcf9ce6420e749c417a65f676505d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386040
Auto-Submit: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-23 21:15:06 +00:00
Konstantin Shcheglov ca996da11e Parts. Support for exports from library fragments in ExportLocation.
Change-Id: I1f489dbbfe96b0d17e6b8bdb1df262d057f8a4b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386362
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-23 21:08:18 +00:00
Konstantin Shcheglov b058a3a080 Elements. Don't write LibraryImport reference, it does not exist.
Change-Id: I420946f08e04248a4f962a218f95c705b7d7ddfb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386340
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-23 19:55:08 +00:00
Nate Biggs 755db057ff [dart2js] Fix record FieldGet receiver type update.
We should be updating the receiver record's type regardless of whether or not we have a specific record type.

Bug: https://github.com/dart-lang/sdk/issues/56741
Change-Id: I16ce9f1db96c295566be802211c7280917416924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386262
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-09-23 19:48:07 +00:00
Nate Biggs 1d392255ef [dart2wasm] Add wasm module test mode.
Adds a mode that puts every library (outside of the SDK) into its own wasm module. Each module is then loaded before the program executes.

This allows us to get better coverage on multi-module logic.

I chose to augment the SDK `_invokeMain` entry point because it allows us to push the user-defined main into a second module ensuring we always have at least 2 modules. The SDK alone is then the main module and all user-code is in deferred modules.

The next step is to make a test configuration for this and decide what frequency to execute it with.

Change-Id: I01bf3a5fee4604a890ef376ebd35113281a36a5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384404
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-23 18:56:24 +00:00
Nate Biggs b79a06d99b [dart2wasm] Add last few fixes to translator to allow module test mode.
- Declare dummy value globals as needed per module. We cannot share these across modules as they can be used in a const context which limits  how we can reference them. The other option is to declare the dummy values for all heap types in the main module. However, declaring as needed per-module is more in line with our approach elsewhere and will work better for dynamic modules.

Change-Id: Ib2cd0a9300610ff8aa86d904902815d4fe9042d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385401
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-23 18:56:24 +00:00
Nate Biggs 9cd9071a7b [dart2wasm] Add support for module name in wasm NameSection.
This annotates each code location in wasm stacktraces with the name of the referenced module. By default v8 only includes an opaque hash to name each module.

For tests and debugging where we want to analyze stacktraces the opaque hash alone makes it impossible to associate each code location back to a file. With multiple modules we will need this additional information.

Change-Id: I464780d9234e0685d08f4f1925f65ce073b3f322
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385400
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-23 18:56:24 +00:00
Nate Biggs 1d3142d34b [dart2wasm] Fix closure representation in multimodule scenarios.
This pushes the module branching to the specific functions used for closures. Rather than have separate ClosureRepresentation objects for each module, we have the representation create the functions it needs within each module on demand.

This duplicates some of the closure logic but it means each module (including main) only needs the representations relevant to it and we don't have to worry about module import ordering.

If there are no deferred imports (i.e. the program is 1 module) then this has no effect on the generated program. If there are deferred imports (i.e. multiple modules) they may contain duplicate closure representations which will increase total code size.

Change-Id: Ib9506e1f94866a4ae6de4472362bd5cd4260b1e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385182
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-09-23 18:56:24 +00:00
Fedor Shcheglov 9f4bb0d654 Issue 56559. Remove @override from private field, add to getter/setter.
Bug: https://github.com/dart-lang/sdk/issues/56559
Change-Id: I57e9c5e286af520499ddddeee5818f1c22a94ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-09-23 18:13:45 +00:00
Konstantin Shcheglov 4684ef56dd Element. Don't cache setter name.
Follow up for https://dart-review.googlesource.com/c/sdk/+/381704
I think we  don't need to canonicalize it at all, and pay for map lookup.
If stop doing this, we actually save memory.
My suspicion is that we use setter names transiently.

And removing a field itself save some memory.

Before:
flutter_elements
  reachableObjects
    count: 11865740
      change: -0.01% -1335
    size: 993783127 = 970491 KB = 947.7 MB
      change: -0.01% -72336 = -70 KB


After:
flutter_elements
  reachableObjects
    count: 11861762
      change: -0.04% -5313
    size: 987428847 = 964285 KB = 941.7 MB
      change: -0.65% -6426616 = -6275 KB = -6.1 MB
Change-Id: Iaab513e545862df53ae1f144a7a8b1e695768d06
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386261
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-23 17:26:42 +00:00
Sam Rawlins 201f27a5d3 lint rules: Remove redundant test for eol_at_end_of_file
This test is fully redundant with the test in test/rules.

Change-Id: I414948dcd09ed3ea6a15329d85596b97cccc682f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386121
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-09-23 17:18:39 +00:00
Sam Rawlins 4531a30b56 Linter rules: Add some comments to unnecessary_statements
Change-Id: Ie08718de68ee2bdf0f3acf24bf5adfbeebdf5128
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386101
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2024-09-23 17:12:36 +00:00