Commit graph

43125 commits

Author SHA1 Message Date
Konstantin Shcheglov a0218e916c Issue 52176. Support for ojbect pattern in 'Create Getter' and 'CCreate Field'.
Bug: https://github.com/dart-lang/sdk/issues/52176
Change-Id: Ic9c97bec1981c5613b23206e872f6f708d53792d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-27 20:52:39 +00:00
Nate Biggs b9c73fdf23 [dart2js] Update switch block local handling to correctly propagate types that fall through the block.
Fixes #52170

Change-Id: I7c473c3101d446eb17433d583bfe266bf6f193d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298760
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-04-27 19:35:45 +00:00
Joshua Litt 47b7c1f31d [js] Add js_interop_unsafe library.
CoreLibraryReviewExempt: Web only library.
Change-Id: I4d6007e0731ecae81fcc614168baee7d5e662fd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293743
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-04-27 18:51:49 +00:00
Nate Biggs a6f543e50a [dart2js] Repro for issue 52170.
Type inference is not tracking the type of 'local' correctly through the switch statement into the inner return. The same code without the for loop does work correctly though.

Change-Id: I0b1b4741e4ff17c22dec3383defb412f5fff0836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298980
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-04-27 18:15:48 +00:00
Konstantin Shcheglov 58e48de282 Issue 52175. Support for ConstructorDeclaration in 'Remove unused element' quick fix.
Bug: https://github.com/dart-lang/sdk/issues/52175
Change-Id: I7c5a237fc9a358488e4431d4785ec51b0322f66a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-27 16:00:12 +00:00
Danny Tuppeny 0588afe783 [analysis_server] Add a script to print tests marked @FailingTest() referencing closed GitHub issues
Change-Id: I8e68b70c4f271d1610f955cf22dfe9523d7f7ca2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-27 14:46:48 +00:00
Johnni Winther bfda964ab8 [cfe] Add BodyBuilderContext
This adds a BodyBuilderContext to separate the BodyBuilder from its
[member], [declarationBuilder] and [sourceClassBuilder] fields. The
latter two are fully removes and trivial uses of [member] have been
removed.

This is a step towards a more clean implementation of inline class
members. The plan is to have the members create their own
BodyBuilderContext to use in the BodyBuilder which should the be
agnostic about the builders of its context.

Change-Id: Ic3b29693dd26aa8c57a9ac175b4a07ce4b0a15d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298860
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-04-27 09:40:39 +00:00
Oleh Prypin 7bbf7ff43e Revert "[cfe] Enable verification in platform compilation"
This reverts commit 20e0ddf130.

Reason for revert: breakages in google3

Original change's description:
> [cfe] Enable verification in platform compilation
>
> Closes #32530
>
> Change-Id: I5a44e211a4b203e4879dbc8f6bf4bbec5abf51f3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298820
> Reviewed-by: Jens Johansen <jensj@google.com>
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>

Change-Id: Idb2c30d93ad385431734c4a4e884d3d53be76b2b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299040
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Oleh Prypin <oprypin@google.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-04-27 08:43:00 +00:00
Johnni Winther 20e0ddf130 [cfe] Enable verification in platform compilation
Closes #32530

Change-Id: I5a44e211a4b203e4879dbc8f6bf4bbec5abf51f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-04-27 07:34:39 +00:00
Jens Johansen 255d755975 [CFE] Cache calls in type inference that almost always creates a FunctionType
InstanceAccessTarget calls "base.getGetterTypeForMemberTarget" a lot;
this CL caches the result which is almost always a new FunctionType,
thus creating fewer FunctionTypes.
When compiling compile.dart ~29% fewer:
Before this CL, compiling compile.dart created a little over 217k
FunctionTypes (down in a previous CL from almost 263k); with this CL
"only" ~153.5k FunctionTypes are created.

Change-Id: Ib110ed5e0d152a3b86044f20dc50f0924a083f46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-04-27 07:30:41 +00:00
Jens Johansen f72b7ae86f [CFE] Don't create new 'unknown' FunctionTypes for each TypeInferrerImpl
When compiling "compile.dart" this creates ~17% fewer FunctionTypes
(from almost 263k to a little over 217k).

Change-Id: I0090c287ce427b298897846de03679f562223e63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298581
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-27 07:14:51 +00:00
Konstantin Shcheglov ea2d6a7659 Issue 52177. Fix rename refactoring for type parameter of a class.
It does not work for function / method type parameters though.

Bug: https://github.com/dart-lang/sdk/issues/52177
Change-Id: I51ae5379425e156640ae32d0cea6fd59cdc62b15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298960
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-27 04:51:26 +00:00
Helin Shiah 5ef021b116 Add debug adapter to DAP
Change-Id: I5bacd460175a5b2e86326f7501d7f250bbe3ab0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292060
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
2023-04-27 01:19:57 +00:00
Konstantin Shcheglov 97a762b083 Remove debug output from analysis_server/ tests.
Change-Id: Ia358d4f51c605ca66e5111769d1f716559251f63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298780
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-26 19:58:48 +00:00
Brian Wilkerson 03270f748b Convert the tests for the combinator contributor
Change-Id: Ic165bf7fed1f045f489998ecf9dec9edbd516274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298480
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-26 18:42:37 +00:00
Konstantin Shcheglov 8d2bafa624 Use OpenUriNotificationSender to replace separate flag and sending method.
If the sender is not `null`, then we can send.
No need for a flag, and assert() in the sending method.
If the sender is `null`, then the sending code will not able to invoke it.
Types FTW :-)

Change-Id: I7d153ba014c578a73dce2eab28aceedbb8814711
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298440
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-26 18:17:37 +00:00
Nate Biggs 4bbdc97d1c [dart2js] Ensure Dart2JS only reports relevant metrics.
Prior to this change the metrics modified here are all printed during every run of the compiler, even when the compiler is running in phase mode on a phase that cannot modify these metrics.

This will make collection of these metrics easier and ensure the collected data is cleaner.

Change-Id: I62a081d9dbae71256882f24156faf246f4076e61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297440
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-04-26 17:36:51 +00:00
Konstantin Shcheglov c13acbf1dd Issue 52136. Report USE_OF_VOID_RESULT for SwitchExpression.
Bug: https://github.com/dart-lang/sdk/issues/52136
Change-Id: I3a3b8f45419c57deec77deae37cd5f98481debeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-26 16:12:48 +00:00
Srujan Gaddam 1d28f8e821 [dart:js_interop/ddc/dart2js] Implement JS types using @staticInterop
Currently, dart:_js_types types are all typedefs in the web backends.
This leads to inconsistent semantics, since you can statically pass
Strings to JSString, for example. You cannot do this in dart2wasm.
In order to ensure consistent semantics, we reify these types using
a custom @staticInterop lowering. They all get erased to their
respective Dart type. When we have inline classes, these types
should be implemented using inline classes.

Note that Interceptor will not work for this use case. The reified
type of JS primitives are Dart types e.g. String, bool, and therefore
can not be casted to Interceptor.

In order to do this, the eraser is refactored and the JS backends use
shared erasure code to either erase/emit types.

Tests are added to make sure you need to go through a conversion or
cast to pass Dart objects to JS types.

CoreLibraryReviewExempt: Backend-specific internal library changes.
Change-Id: I5942be628102919ec167f094cfe10fced606363c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295105
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-04-26 15:55:54 +00:00
Tess Strickland e506581534 [pkg] Don't run native_stack_traces test on non-VM runtimes.
Fixed: https://github.com/dart-lang/sdk/issues/52174

Change-Id: I64b8b389ed5e80484367fe9475bb898dd493a319
Cq-Include-Trybots: luci.dart.try:dart2js-minified-linux-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298620
Commit-Queue: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2023-04-26 14:43:08 +00:00
Johnni Winther 009cbfbeac [kernel] Merge front_end and kernel verifiers
This merges the front_end and kernel verifiers into one Target based
kernel verifier. The RedirectingFactoryBody work-around is moved to
package:kernel to support its verification.

TEST=existing

Change-Id: I0adf4d2c22c4009cf439b3b23fa14192253a2846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280161
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-26 14:14:36 +00:00
Johnni Winther 498dcc02ee [cfe] Promote matched expression in relational pattern
Closes #52123

Change-Id: I702524479d1abe83eb67e801454f03a88febe434
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298600
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-04-26 13:27:49 +00:00
Jens Johansen ad87701920 [CFE] Check 'instrumentation != null' before doing other calls
Change-Id: I81f562824b8011d5a99e334daeeede36e6650b03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298560
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-26 12:19:47 +00:00
Jens Johansen 43b499cf9a [kernel] Optimize computeThisFunctionType
When compiling compile.dart:
148,192 FunctionType are created via `computeThisFunctionType`.
133,085 of them have no named parameters; 141,507 of them have no type
parameters; 128,357 of them have neither.

This CL makes it not create new lists when not needed
(or create empty iterators and sort empty lists), and makes the lists
it do create not growable.

Change-Id: Ibd5fef458b8a1254aa2f1fab80d0449a2f0bfd94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298541
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-26 11:29:28 +00:00
Jens Johansen 6f1b754a2f [CFE] Instrumenter can also count constructors; first run uses less ram because of trimming
For instance running like this:

    out/ReleaseX64/dart pkg/front_end/tool/flame/instrumenter.dart pkg/front_end/tool/_fasta/compile.dart --count
    out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart.dill.instrumented.dill --omit-platform pkg/front_end/tool/_fasta/compile.dart

will now also print how often Constructors are executed, e.g. it contains
stuff like thid:

    529,397: ast.dart|DartType.constructor:
    715,197: ast.dart|Expression.constructor:
  1,177,700: ast.dart|TreeNode.constructor:
  2,001,460: ast.dart|Node.constructor:

Change-Id: I26ff69f8ad8a1453d6004e97952ce3b39bfff687
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298540
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-04-26 10:50:09 +00:00
Johnni Winther 2a82ba0f48 [cfe] Report error on indirect implementation of base class
Closes #52161

Change-Id: I9e2f441036cfeeb904a3e3ec5aeff2e5c45cb8a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298160
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-04-26 08:16:34 +00:00
Stephen Adams 8ee2b8b36b [dart2js] Convert recordTypes after closureData
Fixed #51899
Change-Id: Id9108e6cf13aee409b127fe6cd007bef8f0fe609
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298460
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-26 03:57:07 +00:00
Nate Biggs 0028815f16 [dart2js] Remove experimental inferrer.
We have merged the experimental inferrer back into the main inferrer branch and therefore can clean this up.

Change-Id: I66481c51276b0ffbf79b4b41b21a3ee5c2ca9cf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298360
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-04-25 21:50:02 +00:00
Konstantin Shcheglov 80d26df2fd Issue 52160. Report BASE_CLASS_IMPLEMENTED_OUTSIDE_OF_LIBRARY for implementing 'base' via 'extends'.
Bug: https://github.com/dart-lang/sdk/issues/52160
Change-Id: I47a72021a002663d04fd8ea14c11a012917e8a8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-25 20:19:38 +00:00
Konstantin Shcheglov 79bf3eedd6 Run UseOfVoidResultTest with null safety enabled.
Bug: https://github.com/dart-lang/sdk/issues/52136
Change-Id: I0a77a81d0a558e8b2450e91e6156d5fab03579a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298300
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 20:14:08 +00:00
Konstantin Shcheglov 00d841ee99 Issue 52060. Fix reporting CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE for Null vs. nullable FunctionType.
Bug: https://github.com/dart-lang/sdk/issues/52060
Change-Id: I5373a9a73396fbf49562131f5f801d1bceeb65f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298280
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 20:09:28 +00:00
Konstantin Shcheglov b81fd66ed5 Issue 52164. Include enums and mixins into types of a sealed class.
Bug: https://github.com/dart-lang/sdk/issues/52164
Change-Id: Icd6ac232d6356b7e05995b79e5f7d8b33b88a719
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298260
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 20:01:52 +00:00
Konstantin Shcheglov 018dadcf5b Resolve the whole unit in resolveForCompletion() when the node is a directive.
There is a quite complicated logic in resolving directives and walking
augmentations and parts. And we don't expect users write a lot of code
in directives, so there is less need for optimizations than when typing
in method bodies.

Change-Id: Id38e90f09eb5c1e84be8fc28ed4211d03762d2e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-25 20:01:25 +00:00
Stephen Adams e8832a643e [dart2js] Fix value_range_test
The fix is to enable type inference.

The old `List(n)` constructor was replaced by `List.filled`. `List(n)`
could be recognized as fixed-length purely by syntax. The test failed
after the replacement because `List.filled` is not recognized to be
fixed-length purely syntactically in the SSA builder, but rather by
type inference.

With type inference enabled, `List.filled` is recognized, but other
parts of the test need to be more realistic, as type inference also
detects the element type and length.

Bug: #52139
Change-Id: Icfaeb3e341b448bbc263efe43f48a2b76d05bf5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298020
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-25 17:58:29 +00:00
Danny Tuppeny a0d6b2daed [analysis_server] Switch some code from package:collection to Dart 3 APIs
- change forEachIndexed to `.indexed`
- remove `package:collection` imports for files only using `.firstOrNull`, `.singleOrNull`, `.lastOrNull` that is now available in `dart:core`
- switch from `Pair` to records
- use switch expressions

Change-Id: Id1ae22db427b4cd955f26e0d6c852944a540a05f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 14:28:26 +00:00
Danny Tuppeny 528c75acd2 [analysis_server] Support folding switch statements/expressions/cases
Fixes https://github.com/Dart-Code/Dart-Code/issues/4506.

Change-Id: Idd5924d04e9ffffc49f088ca6884393ea72e9bea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 14:18:04 +00:00
Danny Tuppeny c4d2d2d7c2 Reland "[analysis_server] Use fixDataYamlFolder constant instead of string literals"
This is a reland of commit ccb02fa8fc

Original change's description:
> [analysis_server] Use fixDataYamlFolder constant instead of string literals
>
> Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.
>
> Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I202392de3444556dc2baa9ed9e1b82c3a1ede4aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 14:17:00 +00:00
Paul Berry 96a346fc5e Front end: move anonymous mixin sealed/final inference to checkSupertypes phase.
Previously this step happened during `buildOutlineNodes`, but since
`buildOutlineNodes` happens in source order, this means that anonymous
mixins would only get their sealed and final attributes properly
inferred if they appeared *after* their immediate supertypes in source
order.  By moving this step to `checkSupertypes`, we ensure that the
computation is correct regardless of source order, because
`checkSupertypes` happens in class hierarchy order.

Fixes #52048.

Bug: https://github.com/dart-lang/sdk/issues/52048
Change-Id: Ib9f1f3dafded88681a26f09e4d21dfd44e70dfd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297901
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-25 12:26:38 +00:00
Jens Johansen dc77baa5a8 [kernel] Call Reference.node less; make it inlinable
This CL splits up `Reference.node` in to the most-often fast-case and the
has-to-load case, making the procedure smaller which makes the VM inline
it. This was "verified" by looking at the VMs optimized flow graph for
`Reference.asClass`.

This CL furthermore reduces the number of "calls" to `Reference.node`
by almost half (a reduction of over 3 mio calls when compiling
`compile.dart`) by "caching" the `.node` call in the `as*` methods.

Change-Id: I7b5497397a11f05fdeaf05d6cc420072d98dc030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298101
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-04-25 10:21:46 +00:00
Jens Johansen e5c2dd28c7 [CFE] Allow counting method calls when instrumenting
When instrumenting one can use "--count" to instrument counting method
calls instead of instrumenting to create a flame graph.

From that I can for instance see that `Reference.node` is called 6+ mio
times when compiling compile.dart.

Example run:
out/ReleaseX64/dart pkg/front_end/tool/flame/instrumenter.dart pkg/front_end/tool/_fasta/compile.dart --count
out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart.dill.instrumented.dill pkg/front_end/tool/_fasta/compile.dart

Change-Id: I583f4b53a474c3777bb059ea89d932607b7c23ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-04-25 10:11:30 +00:00
Jens Johansen 1574e860c8 [CFE] Add instrumenter that can produce flame graph output
Could for instance be run like this:

out/ReleaseX64/dart pkg/front_end/tool/flame/instrumenter.dart pkg/front_end/tool/_fasta/compile.dart
out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart.dill.instrumented.dill --omit-platform pkg/front_end/tool/_fasta/compile.dart
out/ReleaseX64/dart pkg/front_end/tool/flame/instrumenter.dart pkg/front_end/tool/_fasta/compile.dart --candidates=cfe_compile_trace_candidates.txt
out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart.dill.instrumented.dill --omit-platform pkg/front_end/tool/_fasta/compile.dart
out/ReleaseX64/dart pkg/front_end/tool/flame/instrumenter.dart pkg/front_end/tool/_fasta/compile.dart --candidates=cfe_compile_trace_candidates_subsequent.txt
out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart.dill.instrumented.dill --omit-platform pkg/front_end/tool/_fasta/compile.dart

 * The first command compiles and instruments "compile.dart" to record
   all procedure calls.
 * The second command runs the instrumented compiler on "compile.dart"
   (but it could have compiled anything). Because every procedure is
   instrumented this will take a lot longer than a usual run.
   This produces a trace "cfe_compile_trace.txt" with every call taking
   at least 1000 microseconds. This can be displayed via Chromes
   about://tracing tool.
   It also produces a file "cfe_compile_trace_candidates.txt" with a map
   of the procedures that on average took at least 500 microseconds.
 * The third command compiles and instruments "compile.dart", this time
   only instrumenting the procedures mentioned in the map
   "cfe_compile_trace_candidates.txt".
 * The forth command runs the instrumented compiler on "compile.dart".
   This run shouldn't take significantly longer than a non-instrumented
   run. It produces a new "cfe_compile_trace.txt" which this time is
   not filtered. It also produces a file
   "cfe_compile_trace_candidates_subsequent.txt" of recorded procedures
   that on average took at least 50 microseconds.
 * The fifth and sixth commands repeats the third and forth but
   instrumenting only the procedures mention in
   "cfe_compile_trace_candidates_subsequent.txt".

The third iteration might not be needed, but if the first run was on a
smaller input (which it isn't in this example) there might be some calls
that on average took long enough to be included in the candidate list
because the first call was slow and there were only very few of them,
making the second trace very big because there are now a lot of - as it
turns out - very quick calls recorded. Adding the third iteration will
filter (at least some of) those out.

Change-Id: I702c5c9142e525502b02f37744fcdc9d2b0f9b20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296902
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-04-25 08:34:01 +00:00
Chloe Stefantsova b9b1fdff76 [cfe] Infer type and finality of joint variables in or-patterns
Closes https://github.com/dart-lang/sdk/issues/52099

Change-Id: I019e0a9e38cee35883c197ebae855b0854a0b2ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297640
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-04-25 06:31:28 +00:00
Konstantin Shcheglov 34c18da5eb Prepare to publish analyzer 5.11.1 and _fe_analyzer_shared 59.0.0
Bug: https://github.com/dart-lang/sdk/issues/52159
Change-Id: Ia603e77694d11af1045a94bdf00468d02eb5f6af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-25 01:15:05 +00:00
Danny Tuppeny 86e3305538 Reland "[analysis_server] Analyze fix data in fix_data folder"
This is a reland of commit bbacf39e9c

Original change's description:
> [analysis_server] Analyze fix data in fix_data folder
>
> Fixes part of https://github.com/dart-lang/sdk/issues/52126.
>
> Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I571c1e4f87fdf0095d003d496f3c5d88e5cf0ff8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297940
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 00:08:54 +00:00
Nate Biggs b508533666 [dart2js] Add 'CONTEXT' diagnostic level option.
Metrics are using 'INFO' level diagnostics but these do not match the stated usage for INFO. This level was originally supposed to be used for contextual info about a previous warning/hint:
https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/compiler_api.dart#L44

These is logic that is preventing these metrics from being printed when they are logged following a hint and hints are turned off:
https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/src/source_file_provider.dart#L259.

Instead we introduce a 'CONTEXT' for those contextual info messages and use 'INFO' as its own level of logging.

Change-Id: Ie845f30dfd7d04fa9fe1d0a866e07c834dc64b32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297280
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-04-24 23:17:09 +00:00
Konstantin Shcheglov 82cffbb38b Prepare to publish analyzer 5.11.0 and _fe_analyzer_shared 59.0.0
Change-Id: I1d841f7c12698e56bd99ed109e58795172499ed1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297842
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 22:08:12 +00:00
Konstantin Shcheglov 39cb6acb88 Issue 52149. Fix to support rename refactoring for declared identifier with LSP.
Bug: https://github.com/dart-lang/sdk/issues/52149
Change-Id: Ia4c5c564cc44583741722c658389ea674a5643c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-24 22:04:39 +00:00
Konstantin Shcheglov 887e6da4a5 Issue 52150. Support for unused variable patterns in logical-and patterns.
Bug: https://github.com/dart-lang/sdk/issues/52150
Change-Id: I9efb2f8ece0ccb3d3c2e276ff708a671dea80fa3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297841
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 21:53:38 +00:00
Konstantin Shcheglov a868a5bfa6 Issue 52148. Disable invert 'if' when 'case'.
Disable a few assists that require 'patterns', when it is not enabled.

Bug: https://github.com/dart-lang/sdk/issues/52148
Change-Id: I3c3816f4a944c59698543e37f15e024249545952
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297880
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-24 21:16:48 +00:00
Sigmund Cherem 8026975546 [dart2js] better help message.
Makes more prominent that you can use '-v' to show
extra details about all options.

The message after this change will look as follows:
```
Compile Dart to JavaScript.

Usage: dart compile js [arguments] <dart entry point>
(use -h -v for detailed information about all options)
  -h, --help      Print this usage information
  -o, --output    Write the output to <file name>.
  -O<0,1,2,3,4>   Set the compiler optimization level (defaults to -O1).
```

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

Change-Id: I76fe5478b4a1d4b2ae2170eca72d764bc4d120b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294164
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2023-04-24 20:48:14 +00:00