Commit graph

43884 commits

Author SHA1 Message Date
Danny Tuppeny 7c2ee2222f [dds/dap] Improve stack frame rendering + fix bad paths in tests
This fixes a bug where we'd produce the wrong absolute path for stack frames that had absolute paths (because `package:stack_trace` uses `path.absolute()` on them).

It also adds support for making stack frames in printed stack traces faded if they are not part of the users own code. This is something the legacy DAPs did. I've also made it possible to perform this stack parsing on non-error events because I'd like to use it on Flutter structured errors (again, something we supported in legacy adapters and was missing here).

Fixes https://github.com/Dart-Code/Dart-Code/issues/4573,

Change-Id: I6c1c3ab69915eca9a1eeef5dcba7f1eb558086de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311842
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-07-06 15:01:21 +00:00
Danny Tuppeny c81b2bac1b [analysis_server] Enable calling LSP handlers over the legacy protocol
This currently only allows "textDocument/hover". Handlers may need some tweaks to remove any dependencies on LspAnalysisServer before they can be enabled.

Capabilities and config are hard-coded to a very basic set (which I suspect will expand as new handlers are added). Reverse requests and notifications are not currently supported (I suspect these will be added when there are more concrete use cases for them because they may need to be conditional based on real client capabilities/needs).

Change-Id: I8a096f9530ad1518ac5ee876aea2560d269a27ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312303
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-06 14:15:16 +00:00
Danny Tuppeny 0d3e76c8e6 [analysis_server] Modify code action/refactor tests to verify whole set of edits
The goal here is to ensure tests can't accidentally check only a subset of edits made during the command execution.

Not all tests have been migrated (only refactorings and a few that happened to use some of the same methods for verification).

Change-Id: I5589e8e667e957aee3ea55f741b1b49a3859d6bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312304
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-06 14:05:09 +00:00
Nate Biggs 924a33c0f5 [dart2js] Fix valid/invalid refinement logic.
The issue here was that isInMask does not hold inversely. The key is that we want to verify which refinements to skip, therefore we want to calculate *in*valid refinements. We want to skip refines where the new type is a Union AND the old tpye is a supertype of the new type. after.isInMask(before) gives us that but !before.isInMask(after) does not.

I've renamed isValidRefinement to isInvalidRefinement to more accurately capture this distinction.

Change-Id: I0d99479357a140095a5d0dfb7e2f987556097891
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312160
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-07-05 20:56:28 +00:00
Konstantin Shcheglov ec893a4d8f Rework ElementImpl and AugmentationElementImpl hierarchies to use XyzOrAugmentationElementMixin(s).
Add ClassAugmentationElementImpl, no any tests yet because it
required parsing, AST, etc. And it is also not ready yet.

Change-Id: I601141545e9bf0638771f28bb9498be9de664659
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312345
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-05 20:03:47 +00:00
Konstantin Shcheglov c4cbc7042f Add ClassAugmentationDeclarationImpl, parse into it.
Change-Id: I2461cffa76f31079e52f9877b9fe35668811191b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312346
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-05 20:03:37 +00:00
Jake Macdonald f254c8a4ba Add library macro definitions and support for executing them.
These are intended to be applied by annotating a library directive.

Note that some parameter types had to be widened since `Library` is not a subtype of `Declaration`. Ultimately I think that is fine though.

Bug:https://github.com/dart-lang/language/issues/2839
Change-Id: Ia1311c8aea729f2bd8b76173ce4c7595a6a37a42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312140
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-07-05 18:56:53 +00:00
Danny Tuppeny 1c4ad79985 [analyzer] Include trailing commas in display strings for single-positional-field records
See https://github.com/Dart-Code/Dart-Code/issues/4624

Change-Id: Iac2f061c11ffdb95917329465307abc8e92b6ba3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312421
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-05 18:56:36 +00:00
Danny Tuppeny 28ea45c05c [analysis_server] Handle hovers for identifiers declared in for loops
Fixes https://github.com/Dart-Code/Dart-Code/issues/4627

Change-Id: Idcff9a6e87929ef6ceb0cbed5b44a493bb6a8260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-05 18:12:21 +00:00
Konstantin Shcheglov fb9d0e6dc3 Tweaks for mixin inference.
I started initially with the idea to move 'mixinInferenceCallback'
to `ClassElementImpl`, but then realized that we do it for enums too.
So, it should stay in `InterfaceElementImpl`.

I left with code that I think slightly modernized, so decided to
send it for review.

Change-Id: Ib990392dc4985a71ffba1f4080237872d9a65ad2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312521
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-05 18:04:37 +00:00
Konstantin Shcheglov 2b36ef12e6 Remove a few ramaining references to TypeName, use NamedType.
Change-Id: I61b6499dd369c24726084d68f1f4abf374209986
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-05 17:48:09 +00:00
Kallen Tu 1da821f670 [analyzer] Refactor visitRecordLiteral and visitSetOrMapLiteral in the constant evaluator.
Change-Id: Iabab7f406a5f688c5070a26af12cabc3323ef765
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310970
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-05 17:43:55 +00:00
Konstantin Shcheglov 4f62032cf9 Fix a few TODOs in DartObjectPrinter, ElementPrinter.
Change-Id: I76aedfffad60095bdca5c09644c983439868f9bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312343
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-05 17:37:08 +00:00
Danny Tuppeny 08353751ea [analysis_server] Handle inlay hints for patterns + improve hints for record types
Fixes https://github.com/Dart-Code/Dart-Code/issues/4624

Change-Id: Ib1887803957c001907ac439fd9f380964f6177e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-05 16:41:49 +00:00
Danny Tuppeny 0daf23ee75 [analysis_server] Handle widget references inside functions when converting to StatelessWidget
Fixes https://github.com/Dart-Code/Dart-Code/issues/4621

Change-Id: I7dda2ff11e56bb227b476b38ba42e3222f2ceb59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312265
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-05 16:37:56 +00:00
Konstantin Shcheglov 2b8b3345aa Use XyzElementImpl in 'declaredElement' in AST impls.
Change-Id: Id1e59db0e706859e9e04132b3058e8885f8cb669
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312344
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-05 15:11:40 +00:00
Tess Strickland ac2533e705 [pkg/vm] Instantiate the ffi Pointer class to bounds when needed.
Previously, the FFI transformer could produce is checks where the
type to check against was Pointer<dynamic>. However, given that
the Pointer class is defined as:

abstract class Pointer<X extends NativeType> ...

the instantiated to bounds version of its type is Pointer<NativeType>.
Pointer<dynamic> is not a subtype of Pointer<NativeType>, and thus is an
invalid instantiation, but the only place this type could occur was as
the right hand side of an is check.

Before 7cc005ea1, Class::RareType() returned the class instantiated with
the null (all-dynamic) type arguments vector. Among other things, this
"rare" type was compared to the right-hand side of is checks and, if it
matched, performed a simple (cid-only) check of the instance type
arguments in unoptimized code.

Afterwards, Class::RareType() returns the class instantiated with a type
arguments vector where each type parameter is instantiated to bounds, so
now the "rare" type check fails and it falls back to the full check of
the instance type arguments, which causes a ~25% regression in some
unoptimized benchmarks.

This CL fixes the generation of those is checks in the FFI transformer
to use the instantiated to bounds version of the Pointer type instead.

TEST=pkg/front_end/test

Issue: https://github.com/dart-lang/sdk/issues/52843
Issue: https://github.com/dart-lang/sdk/issues/52848
Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-linux-debug-x64-try,vm-linux-debug-x64-try
Change-Id: Ic9ac6d75ba2743e233065444fad13ab098094349
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312400
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-05 14:24:56 +00:00
Konstantin Shcheglov 6a4ef6c93f Update DartObjectPrinter to TreeStringSink and ElementPrinter.
Change-Id: Ied8b54df21b19f144566546de0c0580ebb2078a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312340
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-05 03:04:09 +00:00
Konstantin Shcheglov 03e6d8d758 Test that augmentations are listed in the depth-first pre-order.
Change-Id: I7ade7b101c3c7895c1e8a68ca336ac83fa2b1348
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312341
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-05 03:01:40 +00:00
Konstantin Shcheglov 636abe3ab7 Extract TreeStringSink and ElementPrinter, reuse in a few tests.
Change-Id: I78cafbd198af113f11216d7c0322559dc5d20cd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312320
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-04 21:43:23 +00:00
Sam Rawlins e67a2193da Add jsonEncode for use in unreachable_from_main
Bug: https://github.com/dart-lang/linter/issues/4495
Change-Id: I74b0a6cb516d2850bb922005e463f58f58453b4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312280
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-04 03:02:47 +00:00
Konstantin Shcheglov 37003ee3be Add InterfaceElementImpl, move many methods into it.
Change-Id: I7f77e318586b2c05874b3a0d25d2d940869b6a0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312240
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-04 01:41:38 +00:00
Konstantin Shcheglov d4de535a3a Use identical() instead of == for elements in RuntimeTypeEqualityVisitor.
See https://github.com/dart-lang/mockito/issues/658#issuecomment-1615269018

Change-Id: I5b9e4b1d82ec935bcd2097ec76cf5a8e28c5e29e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312205
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-04 01:33:12 +00:00
Konstantin Shcheglov 44a94e8400 Remove 'Clients may not extend...', because all these classes are final.
Change-Id: If20d22b0407a67f630aa87debada6dab1d803c71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312201
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-04 00:17:10 +00:00
Nate Biggs 73160bc40d [dart2js] Temporarily undo valid refines change.
It's still unclear why this is causing an issue but this will unblock b/285636639 until the underlying cause is found and fixed.

Change-Id: I44db6059a13738d5781c0557810ee53556ecb9c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312100
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-06-30 20:40:45 +00:00
Kallen Tu c86af3c39b [analyzer] Refactor visitMethodInvocation in the const evaluator.
Change-Id: I9ae6c17967c98770ed06dead200c8bd87ae7f2a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309829
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-30 18:32:27 +00:00
Vyacheslav Egorov a52f2b9617 [vm] Rework awaiter stack unwinding.
The main contribution of this CL is unification of disparate
handling of various functions like `Future.timeout`,
`Future.wait`, `_SuspendState.createAsyncCallbacks` and
`_SuspendState._createAsyncStarCallback` into a single
`@pragma('vm:awaiter-link')` which allows Dart developers
to specify where awaiter unwinder should look for the next
awaiter.

For example this allows unwinding to succeed for the code like this:

    Future<int> outer(Future<int> inner) {
      @pragma('vm:awaiter-link')
      final completer = Completer<int>();

      inner.then((v) => completer.complete(v));

      return completer.future;
   }

This refactoring also ensures that we preserve information
(including Function & Code objects) required for awaiter
unwinding across all modes (JIT, AOT and AOT with DWARF stack
traces). This guarantees users will get the same information
no matter which mode they are running in. Previously
we have been disabling awaiter_stacks tests in some AOT
modes - which led to regressions in the quality of produced
stacks.

This CL also cleans up relationship between debugger and awaiter
stack returned by StackTrace.current - which makes stack trace
displayed by debugger (used for stepping out and determinining
whether exception is caught or not) and `StackTrace.current`
consistent.

Finally we make one user visible change to the stack trace:
awaiter stack will no always include intermediate listeners
created through `Future.then`. Previously we would sometimes
include these listeners at the tail of the stack trace,
which was inconsistent.

Ultimately this means that code like this:

    Future<int> inner() async {
      await null;  // asynchronous gap
      print(StackTrace.current); // (*)
      return 0;
    }

    Future<int> outer() async {
      int process(int v) {
        return v + 1;
      }

      return await inner().then(process);
    }

    void main() async {
      await outer();
    }

Produces stack trace like this:

    inner
    <asynchronous suspension>
    outer.process
    <asynchronous suspension>
    outer
    <asynchronous suspension>
    main
    <asynchronous suspension>

And when stepping out of `inner` execution will stop at `outer.process`
first and the next step out will bring execution to `outer` next.

Fixes https://github.com/dart-lang/sdk/issues/52797
Fixes https://github.com/dart-lang/sdk/issues/52203
Issue https://github.com/dart-lang/sdk/issues/47985

TEST=ci

Bug: b/279929839
CoreLibraryReviewExempt: CL just adds @pragma to facilitate unwinding
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-dwarf-linux-product-x64-try
Change-Id: If377d5329d6a11c86effb9369dc603a7ae616fe7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311680
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-30 14:03:03 +00:00
Konstantin Shcheglov 8828fee865 Deprecate ExecutableElement.returnType, use returnType2 instead.
Change-Id: Ibd29c3fbec0439236c2cf45c57f820c45427df9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311932
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-29 23:16:59 +00:00
Jake Macdonald 34f25c4a28 Add library introspection apis for macros.
Allows you to ask for the types in a library in the declarations phase, and all
the top level declarations in the definitions phase.

Bug: https://github.com/dart-lang/language/issues/2839
Change-Id: If0f8fb777fd8a006d686d457cf5d5ca11fcca9ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311900
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-06-29 22:05:58 +00:00
Kallen Tu 74adf1626e [analyzer] Refactor visitNamedType and other visitors in const evaluator.
Change-Id: Ia3c22fc87c96d719cfa3617c72f5586badfec183
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310972
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-06-29 21:26:14 +00:00
Konstantin Shcheglov fae9e418ea Deprecate Element.enclosingElement, use enclosingElement2 instead.
Change-Id: I78edb6d433949eb8bd86f397fb873a078edf9fc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311827
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-29 19:45:19 +00:00
Danny Tuppeny fc1188d55c [analysis_server] Refactor/rename server to simplify sharing handlers between LSP+Legacy protocols
In order to share LSP handlers between protocols, we need to be able to use a LegacyAnalysisServer in place of an LspAnalysisServer which means having a common interface (which they have via AnalysisServer) and to make the mapping of LSP method names to handlers reusable.

This changes makes the following non-functional changes (to reduce the size of a future change that will begin sharing handlers):

- Rename "clientCapabilities" to "lspClientCapabilities" to avoid conflicts with legacy servers clientCapabilities field when we add this to the base AnalysisServer interface
- Rename "clientConfiguration" to "lspClientConfiguration" for consistency
- Add an "LspMessageHandler" typedef over "MessageHandler" which now has a server type arg so that it can be used with either LspAnalysisServer (by handlers that really need LSP) and AnalysisServer (for handlers that can work in either server)
- Extract handler generators in `InitializedStateMessageHandler` to a static map and make constructors consistent taking only a server (in a future CL the legacy server will want access to some this mapping)

Change-Id: I23554a7ca318fbcd1113dcebff5601186b223618
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311982
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-29 19:20:20 +00:00
Ryan Macnak a4f59b8c20 [gardening] Update PatchClass::patched_class_ to wrapped_class_ in pkg/vm_snapshot_analsysis.
Cf. 99db606bab

Change-Id: I653ab3d8d4bb0ccee0bfeed7e8ab5d2c219b6924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311928
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-29 18:34:37 +00:00
Nate Bosch a4331b433a Fix dependency on package:meta
A usage of `@mustBeOverridden` was added in
https://dart-review.googlesource.com/c/sdk/+/309460. The API was added
in version `1.9.0` of `package:meta`.

R=jakemac@google.com

Bug: https://github.com/dart-lang/sdk/issues/52815
Change-Id: I6069b20d2ea6cfae6af4cb0af033ad9a07f48d0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311925
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-06-29 17:35:51 +00:00
Danny Tuppeny 70be63ce49 Fix CreateConstructorForFinalFieldsRequiredNamedTest.test_enum on Windows
Checking the offset can be wrong on Windows due to line endings. Other tests in this file are checking the message, so I've done the same here.

I noticed this locally, but I see the Windows bot was also failing on this.

Change-Id: I36de86c3b3eac6f379da894ea9e6fcfcb1a0aa4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311981
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-06-29 15:39:08 +00:00
Konstantin Shcheglov 8a037770f9 Tweaks for element model documentation comments.
As requested in https://dart-review.googlesource.com/c/sdk/+/311725

Change-Id: I76cd2322f9cca9845f3ec767adfd1e5dca9d7c47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311826
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 20:28:30 +00:00
Konstantin Shcheglov 6f01da06a2 Put aside invalid mixin constructors, quick fix for MIXIN_DECLARES_CONSTRUCTOR.
Change-Id: If1b808bf7746b4f2c2c856d7fb7e72499023759f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311823
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 19:49:08 +00:00
Keerti Parthasarathy aec08eabd9 Convert some more assists/fixes to using ParsedCorrectionProducer
Change-Id: Ie715868183e1b06023b538ec1bc550171cfa2f5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311825
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-06-28 19:46:47 +00:00
Konstantin Shcheglov 1fd7e2b670 Update a few documentation comments to the style guide.
Change-Id: If019e456de041081ed688cfce4c7f5063055ba39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311821
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 17:44:08 +00:00
Konstantin Shcheglov 892a7fbe4e Put aside invalid nodes during parsing, fix for EXTENSION_DECLARES_CONSTRUCTOR.
Change-Id: Ic01f4c1116ecb29087c8d1bff679906522b7562e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311726
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-28 15:17:23 +00:00
Konstantin Shcheglov a49dbe539f Extract NamedInstanceElement from InstanceElement, use for ExtensionElement.
Change-Id: Iee49f110afacc3f5c54fb15e70b3f18ac18c67a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311725
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 15:16:18 +00:00
Chloe Stefantsova 53c9cf1c46 [cfe] Remove spurious assignment error on late final loop variables
Closes https://github.com/dart-lang/sdk/issues/52704

Change-Id: I2bf7363be6def613fdd9389d5e080514a3f2e455
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311120
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-06-28 10:13:28 +00:00
Daco Harkes bd1bad7afc [deps/ffi] Unbundle package:native_assets_builder
The Dart SDK CL for https://github.com/dart-lang/native/pull/69.

Bug: https://github.com/dart-lang/native/issues/67
Change-Id: I45d7ac691a6aaa41bce5be0e36403021a948bb4f
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311740
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2023-06-28 09:09:09 +00:00
Johnni Winther 0c8ded72dc [cfe] Add FileUriConstantExpression
This adds FileUriConstantExpression, a subclass of ConstantExpression, to support correct file offset of annotations for augmentations and patches.
The FileUriExpression is used to carry the file uri of the expression
before constant evaluation.

TEST=general/patch_annotations

Change-Id: I0dc8a0cb97dd530fd1960785d38c2d5e4883c3dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311660
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-28 07:52:09 +00:00
Johnni Winther cfd4200c85 [cfe] Handle late lowered fields in addUnpromotablePrivateFieldNames
Closes #52452

Change-Id: I39b3045b5e8b95493ea954ffa678b9caede901c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311741
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-28 07:34:38 +00:00
Liam Appelbe 13ec07415b [vm] Async FFI callbacks
More details about the design:
https://docs.google.com/document/d/1QDjyY_6wOTOgURwpeYMKU9qEz0gKxx2MUrdruC6Kp6c/edit?usp=sharing

Change-Id: Ie3985d86dca7f5010044ca46c33ca177588c0f69
Bug: #37022
CoreLibraryReviewExempt: Reviewed by vm and api groups. web and wasm groups not affected because FFI isn't on those platforms.
TEST=async_void_function_callbacks_test.dart, ffi_callback_metadata_test.cc, other front end tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305900
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-28 01:00:18 +00:00
Konstantin Shcheglov d264ceeb05 Add InstanceElement as a super-interface for InterfaceElement and InlineClassElement.
Change-Id: Ie92168509cccb5b145bc5c9adea2945813725038
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311721
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 00:56:05 +00:00
Anna Gringauze 789b1d1fcd [frontend_server] Add --canary flag
Closes: https://github.com/dart-lang/sdk/issues/52774
Change-Id: Ie42a803c5b63a41c37984a790ab0406c8939872d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311149
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-06-27 22:21:04 +00:00
Nate Bosch db585cef2b Add a note about training run for JIT snapshot
Closes #50615

R=bkonyi@google.com

Change-Id: I488c9f232ab5b0138d25a66006b8f69a05ea9c05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311144
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-06-27 19:26:38 +00:00
Devon Carew 9216f830c6 [deps] rev package:lints to the latest; address lints
Change-Id: I64032a39c589c291297decade18f6a46c08f9c5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310966
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-06-27 17:03:37 +00:00
Jens Johansen b2756f3aae [CFE] Tool for benchmarking adjacent revisions
E.g. if asking the tool to figure out any performance changes to
revision 5222bfd90c it will checkout 5222bfd90c and 2037563b94
(the previous commit), make aot-snapshots for both and run both on
the same (specified) target.

Change-Id: Ief56843326343ebaa681df596162d1d08457a8f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311602
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-06-27 14:58:03 +00:00
Danny Tuppeny 4d1b418230 [dds/dap] Fix breakpoint resolution races when there are multiple isolates
When there are multiple isolates, we may get breakpoint responses/events like this:

- Request/Response to add breakpoint to Isolate 1
- Request/Response to add breakpoint to Isolate 2
- BreakpointAdded for Isolate 1
- BreakpointResolved for Isolate 1
- BreakpointAdded for Isolate 2

Because Isolate 2 did not load the script, the last breakpoint was never resolved. However because the breakpoint ID matched, we would forward this event to the client and un-resolve the previously resolved breakpoint. This would result in odd behaviour in VS Code.

Additionally, the VM may return the same BM breakpoint ID for what the client thinks are two breakpoints (they are on different lines, but resolve to the same location) so when we get a resolved breakpoint, we need to handle both:

- Client breakpoints that have already been transmitted
- Future client breakpoints that may resolve to this same VM breakpoint

The previous code assumed that a BreakpointResolved event could be handled just once. Either for an existing breakpoint, or a future one.

This change swaps from storing queued events to storing the resolution information for each breakpoint, and it does this even if there was an existing breakpoint (in case the breakpoint is reused in future).

Fixes at least some of https://github.com/Dart-Code/Dart-Code/issues/4598

Change-Id: I53b92debfaa0c8f538dc8d67966854bb89634708
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311480
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-06-27 14:54:10 +00:00
Ömer Sinan Ağacan f041dd4af4 [dart2wasm] Simplify a list intrinsic
Change-Id: I769d33ac838a09350427dcdc14e3c2a6daf37cc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311381
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-06-27 14:50:00 +00:00
Danny Tuppeny 06ade88478 [dds/dap] Update test to not set breakpoints on invalid lines
Fixes https://github.com/dart-lang/sdk/issues/51928.

Change-Id: Ifdffd1a90fa8d9a07f34742874064b2192d0005c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310880
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-27 14:46:05 +00:00
Brian Wilkerson 45572cf7dd Pull in a new version of unified_analytics and update server
Change-Id: I7f63b55fc6a74f2adfc97f00950ca0516bae68ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310965
Reviewed-by: Elias Yishak <eliasyishak@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-06-27 13:35:08 +00:00
Slava Egorov 758727dd12 [vm] Rename tests causal_stacks -> awaiter_stacks and improve harness.
The main difference from the previous harness is that it
allows auto updating the expectations instead of
maintaining them manually.

This relands 0c1b2722ed with
changes to harness which fix issues on Windows.

Note: some amount of AOT failures are expected and should just
be approved. They will be fixed with the last CL in the series.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-win-release-x64-try
Change-Id: I7ae84769ed54bc447ebf71acc68ba9d0b6717bac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311604
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-06-27 11:50:32 +00:00
Tess Strickland 516f238aa6 Revert "[vm] Rename tests causal_stacks -> awaiter_stacks and improve harness."
This reverts commit 0c1b2722ed.

Reason for revert: Failures on AOT (stack expectations unmet) and Windows (parse errors due to Windows paths) trybots.

Original change's description:
> [vm] Rename tests causal_stacks -> awaiter_stacks and improve harness.
>
> The main difference from the previous harness is that it
> allows auto updating the expectations instead of
> maintaining them manually.
>
> TEST=ci
>
> Change-Id: I80e303d3ecbcc834ac94fa089cabe4f8834cc661
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311400
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

Change-Id: I7311bf08403f4167f88f6204fde1a6fdee353f7d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311600
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-27 09:02:28 +00:00
Vyacheslav Egorov 0c1b2722ed [vm] Rename tests causal_stacks -> awaiter_stacks and improve harness.
The main difference from the previous harness is that it
allows auto updating the expectations instead of
maintaining them manually.

TEST=ci

Change-Id: I80e303d3ecbcc834ac94fa089cabe4f8834cc661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311400
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-27 07:47:39 +00:00
Vyacheslav Egorov 8d5dbbdf69 [vm/debugger] Rename "causal" to "awaiter" internally
The name is more accurately reflects what this stack trace
contains: despite what causal implies it does *not* actually
reflect the stack which initiated the async operation. Instead
it contains the chain of listeners which will run when
the async operation completes - its awaiters.

TEST=ci

Change-Id: Ie7309c9b1c39246e0fd4c14f7b9c515bcdfbbe10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311384
Reviewed-by: Derek Xu <derekx@google.com>
2023-06-27 07:47:39 +00:00
Ludi Zhan cdd1163b27 [analyzer] Address coding style comments for visibleOutsideTemplate change
Addressing additional comments got from:
https://dart-review.googlesource.com/c/sdk/+/304825?tab=comments

Change-Id: I973c2c33a9a850122542389fc65d66c6fb810deb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311300
Auto-Submit: Ludi Zhan <ludizhan@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-27 03:53:37 +00:00
Anna Gringauze d2f5b3bfab [ddc] Add --canary flag to expression compiler worker
Closes: https://github.com/dart-lang/sdk/issues/52776
Change-Id: I639fe7fbadf3e938cc686aa8dbd2320a4cc7af7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311151
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-06-26 22:55:07 +00:00
Vyacheslav Egorov 4a6f9328a2 [vm/debugger] Simplify async breakpoints implementation
We no longer rewrite suspendable function into closures nested
inside the original function, so the whole synthetic async breakpoint
machinery is not needed.

Refactor `Breakpoint` class to make one-shot and per-closure
separate properties of breakpoint, which allows creating
one-shot-per-closure breakpoints.

TEST=existing service tests

Change-Id: I208afe13f36efa40f5746e44867bd24684cf5f03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310601
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-26 22:45:10 +00:00
Jake Macdonald d1ecf01f71 Cache remote objects by ID, only send IDs for already sent objects
This is done through a synchronized cache between the server and client. When serializing a remote instance, if the server has already serialized that object then it will only send the ID in the future.

These caches currently only live as long as a single macro application in a given phase, but could live longer in the future. They do need to get reliably cleared out to avoid memory leaks though, and the shorter lifetime is easier to manage consistently.

This also allowed me to remove the specialized server/client modes (clients would always only send back IDs previously).

Change-Id: I4e8a102403153829d66b0ac379636f5a95a70cea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311420
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-06-26 22:36:37 +00:00
Nate Biggs fe73f0cf5d [dart2js] Reduce size of Dart2JS deferred loading event logs.
- Only include the script tag src if it differs from the previous log entry.
- Use single letters for each event field's key.
- Fix some typos.
- Remove 'uri' from download event as it can be inferred from script tag src and part file name.

Change-Id: Ib7916ea5e92720a10c7e1e1cab2e535fae2bbf49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311180
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-06-26 20:43:32 +00:00
Parker Lougheed 5200d086d1 [pkg/analyzer] Add class to diagnostic messages for special highlighting
Will be used on dart.dev for customizing the highlight syntax in code blocks to be red underlines rather than yellow highlighting.

Related: https://github.com/dart-lang/site-www/pull/5006
Change-Id: Ib33ee8f6f7307efb649b627dfd9a5d90187cca1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-06-26 19:58:56 +00:00
Joshua Litt 64290e1052 [js] Add JSStringImpl box for JSString.
Change-Id: I63a2ecdf3fd2331f91632ae5b2cc51813cd44c66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307961
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-06-26 17:15:24 +00:00
Konstantin Shcheglov 76eb70963c Use 'UnitResult' type parameter instead of 'T' in CorrectionProducerContext.
Change-Id: I24c7f9450f6ad84de6e67a2fb2f70d6dea7983e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311158
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-06-26 16:05:14 +00:00
Martin Kustermann bee46896d8 [cfe] Use Uint8List instead of List<int> for representing bytes
Seems to reduce instruction count by 4% (when using AOT-compiled
pkg/vm/bin/gen_kernel.dart to compile pkg/compiler/lib/src/dart2js.)

Change-Id: Ica88716bd9c06ea446258cd3eb4f26ca1890805b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311121
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-06-26 08:07:13 +00:00
Konstantin Shcheglov eeecd53fe2 De-duplicate refactoringContext in RefactoringProducer.
Change-Id: Ia1dcbaf301d37d977b22742bf8198c64f7d34159
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311159
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-24 17:00:20 +00:00
Konstantin Shcheglov 69c62b1a31 Remove shipped features, and deprecated experiments from tests.
Change-Id: I428906a1d75a0dacedc8a5d5fd805f84ca8e3ce0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311156
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-24 16:23:28 +00:00
Konstantin Shcheglov b013a40f39 Add isInline to ClassElement.
Change-Id: I80dafc9ef0dc03b8090032a7b7168302a8d6ad66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311150
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-23 22:49:09 +00:00
Alexander Markov 57863dc64b [vm/aot/tfa] Tree-shake unused libraries
On a large app (which apparently has too many unused dependencies),
size of the AOT kernel file:
before: 464 MB
after: 108 MB

TEST=pkg/vm/testcases/transformations/type_flow/transformer/libraries.dart
Bug: b/287638965
Change-Id: I79a26305c00741babb6a69a18919983b398109e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310772
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-23 20:14:08 +00:00
Konstantin Shcheglov 98d7e25027 [CMSR] Test that it works with FunctionTypedFormalParameter(s).
Change-Id: I86d483d379e7fe0be2dccf1659d2c6377dcc8eb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311140
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-23 19:30:12 +00:00
Konstantin Shcheglov ecc18c9600 [CMSR] Tests for TrailingComma, support for required positional formal parameters.
Change-Id: I1e477782895a053ff2060dada8fe834bd2c2c8db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310977
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-23 17:53:30 +00:00
Alexander Aprelev b892ccdb19 [gardening] Fix 'debugger()' line expectations in tests.
Follow-up to bbdf87d277.
TEST=ci

Change-Id: I3198698cd6df8a917fa676b6ff42b72cb645949e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311141
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-23 17:46:57 +00:00
Alexander Aprelev bbdf87d277 [vm/debugger] Have debug step check point after debugger() call.
Fixes https://github.com/dart-lang/sdk/issues/46006
TEST=ci

Change-Id: I89a7ad248b75204d1754668cfb23c8d98f554b28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310779
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-06-23 16:53:48 +00:00
Nate Biggs 43df18a0d2 [dart2js] Use existing J-model entities where possible when converting from kernel to JS entity maps.
Change-Id: I1bcfecb313fab1e7dc03bf1d8c14b8410226f431
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309140
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-06-23 16:02:50 +00:00
Nate Biggs dbd34a452e [dart2js] Remove nullability on type declaration for IR type variables.
The only nullable call to the JTypeVariable constructor was if the K-model had a Local as the typeDeclaration.

However, the K-model creates LocalTypeVariable entities for these instead of TypeVariable entities. The former is never added to the K- element map so they aren't copied over to the J-model up front:
https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/src/kernel/element_map_impl.dart#L1531

Instead the corresponding JTypeVariable entities are added later when the closures are created:
https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/src/js_model/element_map_impl.dart#L1871

Change-Id: If018fe8ca666695989b0f2075d837f8e6994f0fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311060
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-06-23 16:02:50 +00:00
Konstantin Shcheglov 9b3e36bbdc Refactorings run with multiple AnalysisContext(s) and sessions.
If we use just the session that produced the resolved unit, we will
not update other packages for example.

I tried to apply a refactoring to `LanguageVersionImpl` from `_fe_analyzer_shared`, and it did not update `analyzer`. With this change it does update :-)

Change-Id: I47fc28b4adba59c8e025e1bfe17490e4038d28ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310973
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-23 00:22:38 +00:00
Konstantin Shcheglov c50958a019 [CMSR] Add LSP command 'Move selected formal parameter(s) left'.
Change-Id: Ia30e9bad9643d80c183d8b17a0d3aae065c30dc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310969
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-22 23:13:27 +00:00
Helin Shiah 5b3f7990e8 Revert "Revert "Send DAP events through DDS"" - only check for event handler when DDS URI is also set.
Original change reverted due to test failure: https://github.com/dart-lang/sdk/issues/43743#issuecomment-1601278402

This reverts commit 02b10e1321.

Change-Id: Idb2cbffe18342c76d0cc062e5855c10a6df0e8f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310780
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
2023-06-22 21:43:22 +00:00
Marcin Wojnarowski e56ef707eb Fix grammar docs for type aliases in AST
Closes https://github.com/dart-lang/sdk/pull/52515

GitOrigin-RevId: aa7b3ddee2a5b90bbb671e15b9a777ae441f83b4
Change-Id: Ib201d5ef9193b50305138efc23e97b8c5be8336f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305840
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-22 21:17:52 +00:00
Kallen Tu 951d589c20 [analyzer] Refactor visitPrefixExpression, visitNamedExpression, and visitParenthesizedExpression.
Change-Id: I5a5fa0897d25aab3092fc526342c5af12a67e0a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310770
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-06-22 20:48:48 +00:00
Jake Macdonald b9bcfa7004 add Library and LanguageVersion classes, all declarations now have a library
Bug: https://github.com/dart-lang/language/issues/2839
Change-Id: Id09b2da070302b67f7c9921f1ad8a6d91a129f77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311000
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-06-22 20:37:14 +00:00
Kallen Tu 9ec1a84f29 [analyzer] Produce CONST_EVAL_EXTENSION_METHOD diagnostic when using extension methods in const contexts.
More specific error code.

Semi-related to work in https://dart-review.googlesource.com/c/sdk/+/301505.

Change-Id: I1233e9e31389d387a9c777fe83cdd30a224bd00e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-06-22 20:35:29 +00:00
Konstantin Shcheglov 09f6d8bb58 Use select() instead of NodeLocator in CorrectionProducerContext.
Includes https://dart-review.googlesource.com/c/sdk/+/310060,
as it is 2023-06-20 @ 1243

Change-Id: I8f9788bb3a7b669191e34a8ec42b81d2ebcd31b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310325
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-22 20:29:07 +00:00
Konstantin Shcheglov c2ffa07d7e [CMSR] Tests for removing first / last named / positional formal parameter.
Change-Id: I4028f17b9244835beb60d955f12763ff9184afc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310967
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-22 20:27:24 +00:00
Nicholas Shahan cc5b77a710 [ddc] Handle undefined as null in switch
Add a case for `undefined` whenever a case expression is a null
constant.

Issue: https://github.com/dart-lang/sdk/issues/51527
Change-Id: I6e9946b588e293bcf0b953d568495c8be95f3749
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310775
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-06-22 20:12:28 +00:00
Stephen Adams 5a595124b4 [dart2js] Handle null as a switch statement case value.
Bug: 51527
Change-Id: I6203c9aa668689bb44800082864174b9fb215289
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310500
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-06-22 19:55:22 +00:00
Konstantin Shcheglov 5940badbd3 Prepare to publish analyzer 6.0.0 and _fe_analyzer_shared 62.0.0
Change-Id: Ic816540e8b052fdd1fd59f030c334c3bf56e79f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310961
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-22 19:00:56 +00:00
Keerti Parthasarathy a023c3f00e Fix bug with change parameter type when there are no parameters in argument list
Change-Id: I5cabd16091cb66be45f107a3701128776e8129ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310820
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-22 18:45:27 +00:00
Srujan Gaddam 6fec16d482 [dart:js_interop] Require top-level externals to have @JS
To refuse confusion between dart:ffi and dart:js_interop,
top-level externals will need to be annotated when using
dart:js_interop.

Change-Id: I1e4887eb32f135df94426e43fc885346f1b9f1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310485
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-06-22 18:45:21 +00:00
Keerti Parthasarathy ab884b7d7f Refactors to allow for parse only mode for lints and fixes.
- Make CorrectionProducer as base class for {Parsed/Resolved}CorrectionProducer.
- Use ParsedCorrectionProducer for ConvertDocumentationIntoLine
- Move sort imports test to used ParsedUnitResult
- Add getter to LintRule to indicate that rule can be run using just parsed AST


Change-Id: Id11466c445e6e505ea752d097b57143f18c47060
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310484
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-06-22 18:20:15 +00:00
Konstantin Shcheglov fe35362602 [CMSR] Support for removing formal parameters.
Change-Id: Id04f6c7854dec3d5059009a0a579110690d3eb62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310963
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-22 18:09:23 +00:00
Danny Tuppeny 194767e452 [dds/dap] Add 'showGettersInDebugViews' which includes getters but lazily
The existing 'evaluateGettersInDebugViews' evaluates getters eagerly which can have side-effects. This adds a setting that allows showing getters in a way that can be shown lazily instead.

I added a new setting (instead of just making evaluateGettersInDebugViews=false be lazy) to preserve the ability to have getters not shown at all (since some users are using that today and might prefer this over lots of lazy getters showing up).

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

Change-Id: I56c2a7c8f85aa8c4cc85cfb3120a8cfec6b54c70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310164
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-06-22 16:42:52 +00:00
Danny Tuppeny c2a4f8e7eb [dds/dap] Ensure breakpoint modifications do not drop resolution events
When adding new breakpoints, DAP clients send a full new set of breakpoints which results in us removing and re-adding all breakpoints (for a file).

When we re-add a breakpoint that already existed, we would sometimes get the BreakpointAdded event _before_ the addBreakpointWithScriptUri request completed. We couldn't process the event because without the original request completing we could not map the VM breakpoint back to the clients breakpoint to generate the event.

This could result in resolution events being lost, and breakpoints becoming unresolved when you modified them (depending on timing).

This change collects queues and replays any BreakpointAdded/BreakpointResolved events that arrived when the breakpoint ID is unknown, and when `addBreakpointWithScriptUri` completes, it immediately processes any items in this queue.

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

Change-Id: I11daaf99b786ab94f1cc93f9fd38a4f1e241320f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310620
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-22 16:36:55 +00:00
Danny Tuppeny 0a691e3647 [dds/dap] Fix a bug that could result in test failures
This logic was inverted and could result in duplicate terminate requests being sent. Depending on timing, this request might be sent but not responded to (because the DA was already shutting down), causing a "Application terminated with pending terminate request" error.

Change-Id: If89f002792878f8a5ce12341536be70ee01cde11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310380
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-22 15:26:39 +00:00
Konstantin Shcheglov a8a3f3f77e [CMSR] Improve 'get invocation' implementation.
Change-Id: I871eddc1727ea6a51e169f4031d55ba3bc93527d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-22 14:38:38 +00:00
Brian Wilkerson 1c3011cbf0 Capture a failing case in code completion
Change-Id: I6a21172628462d0f3b569360849f8417e48cad1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310321
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-06-22 05:19:58 +00:00
Brian Wilkerson 5c84db453d Initial framework for completion refactoring
This is some prepration for starting the refactoring of the completion
support. The plan is for `InScopeCompletionPass` to implement the first
pass of the proposed algorithm. My intention is to convert one
contributor at a time (as much as possible), starting with the
`KeywordContributor`.

Change-Id: I206c704f5c2370f4c37b674be01ab7fb55afa65e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310200
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-06-22 05:18:07 +00:00
Konstantin Shcheglov dc01c56e94 [CMSR] Test when the agnostic refactoring updates multiple files.
Change-Id: Ia80d9e31db9d7ad17472aff0e5f5595bf43bc9ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310778
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-22 05:11:55 +00:00
Srujan Gaddam e985d991b1 [dart:js_interop] Fix JSNumber conversions/semantics and JSBoxedDartObject
- Adds toDartInt and toDartDouble to JSNumber
- Changes semantics of int on external functions from truncate to
assert integer value
- Adds tests for number semantics
- Renames JSExportedDartObject -> JSBoxedDartObject to avoid confusion
with @JSExport
- Adds Object.toJSBox

JSNumber.toDart and Object.toJS will be removed in a future CL once
migrations are complete.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I8ff26ee5624c52703e49dd8483f62e829cb6fff0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309081
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-06-22 02:51:13 +00:00
Konstantin Shcheglov 7ecc57ac9e [CMSR] Split into separate files.
Change-Id: I45f1b13a2a025887ee7eb05179934f219097f67c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310776
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-22 01:19:08 +00:00
Marcin Wojnarowski 330106212a Retain surrounding comments in remove comparison quickfix for if-statement
Closes https://github.com/dart-lang/sdk/pull/52544

GitOrigin-RevId: 267e6378cc9a3f64a1a177ec69279ed1baa61b4a
Change-Id: Idb51e14b46708d8b44bc703a4681deea7ec8b42e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306220
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-06-22 00:26:27 +00:00
Konstantin Shcheglov 6a65dd0efe [CMSR] Check the second file for ConvertFormalParametersToNamed.
Change-Id: I07a477701939cf2f40c8eeb77faf5a2d38290a5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310700
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-21 23:03:42 +00:00
Konstantin Shcheglov 1d9846b16f Remove ADD_NOT_NULL_ASSERT
We believe that it is not necessary anymore, with sound null safety.

Change-Id: I18741eafea1bd969139cdae3b94a294dde1b5abd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310769
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-21 22:54:12 +00:00
Danny Tuppeny eafa748a4b [dds/dap] Make hot reload test not flaky on Windows
On my Windows PC, this test often fails because the new content is never hot reloaded because the modification is made too soon after the app starts.

This change does what some Flutter tests do, which is to write a future modified stamp to ensure the file is considered updated when the reload is issued.

Change-Id: If52086fb279897d3e572162dc3a32436fbdb27c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310400
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-06-21 22:46:24 +00:00
Konstantin Shcheglov 55e7119183 [CMSR] Add new command to LSP, to convert selected formal parameter(s) to required named.
Change-Id: I7d86ccfe94cc960ea3a8204daf27f339c4ca767f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310764
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-21 22:06:44 +00:00
Konstantin Shcheglov 6a4f127831 [CMSR] Not available if external executable element.
Change-Id: Icf209c8cd844918a62195f8a024f0c0b8922f0d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310705
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-21 19:51:58 +00:00
Kallen Tu b8d8da0183 [analyzer] Refactor visitListLiteral to handle Constants.
Add CONST_FOR_LOOP error message to be clearer that for loops are not
allowed in const contexts.

visitListLiteral handles Constants.

Change-Id: I84465ecf4e1f044c256db45c723fac081b50a40c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306917
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-21 18:20:51 +00:00
Helin Shiah 02b10e1321 Revert "Send DAP events through DDS"
This reverts commit 5292ee8839.

Reason for revert: Causes failure on `sse_smoke_test` because it needs to set up an event handler.

Original change's description:
> Send DAP events through DDS
>
> Change-Id: Ib40306b8e47d74b02b6cbf348c2b5833cfb31a9d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309080
> Commit-Queue: Helin Shiah <helinx@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

Change-Id: I62b12de8e2478441d9a7a4177ed1090aa845467f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310740
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
2023-06-21 18:17:16 +00:00
Konstantin Shcheglov c3f3a00465 [CMSR] More checks for not allowed order of formal parameters.
Change-Id: Ida0380afb141873e75c27460b0804a8457c876e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310703
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-21 18:12:48 +00:00
Konstantin Shcheglov 67970cc613 Add failing tests for enum and 'if'.
Change-Id: I23187e0699df36c8a24d066a733382fe090e3b44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310701
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-21 17:57:29 +00:00
Brian Wilkerson bf62bc27bc Adjust the definition of coveringNode to favor identifiers
I would like to use `Selection` for code completion, but the current
definition of `coveringNode` too often favors the parent node over the
child node. This will effectively cause the cursor to bind more closely
to an identifier token than to other tokens, making it more useful for
code completion.

If we don't like this change for the general case, I can make these changes in a specialized `coveringNodeForCompletion`, but I'd rather not have two approaches.

Change-Id: I39e70f83ad44d50cec55a8bee1f7061dd83746fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-06-21 17:55:36 +00:00
Helin Shiah 5292ee8839 Send DAP events through DDS
Change-Id: Ib40306b8e47d74b02b6cbf348c2b5833cfb31a9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309080
Commit-Queue: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-21 15:51:24 +00:00
Paul Berry 2ca7380ab0 Flow analysis: fix first phase handling of pattern assignments.
Prior to this change, the first phase of flow analysis, in which flow
analysis "looks ahead" to see which variables are potentially assigned
in each code block, was failing to properly account for variables that
are assigned by pattern assignment expressions. This "look ahead"
information is used by flow analysis to determine the effects of
nonlinear control flow (e.g. to figure out which variables to demote
at the top of a loop, or to figure out which variables are potentially
assigned inside a closure). As a result, it was possible to construct
correct code that would be rejected by the analyzer and compiler, as
well as incorrect code that would (unsoundly) be accepted.

The fix is to call `AssignedVariables.write` from the analyzer's
`FlowAnalysisVisitor`, and from the CFE's `BodyBuilder`, to let flow
analysis know about variable assignments that occur inside pattern
assignment expressions.

Fixes #52745.

Change-Id: I0e6f426a5c5c36f214d5a206aaf5a2de0bfdaac1
Bug: https://github.com/dart-lang/sdk/issues/52745
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310502
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-21 14:33:42 +00:00
Kallen Tu 3deaeb84dd [analyzer] Refactor visitFunctionReference for the const evaluator.
Simple functions can be printed in dart_object_printer.dart.
Moving function reference tests around so they can be easily found together.


Change-Id: If022721f7dca4881d51cbebd65ed968cd89c33c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308261
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-06-21 14:29:48 +00:00
Aske Simon Christensen 5838562040 [dart2wasm] Add option and target for stringref.
This adds basic infrastructure for a stringref implementation in
dart2wasm:

- A `--[no-]stringref` option to the compiler
- An option in the `WasmTarget`, controlling the name of the target
- Separate sets of patch files for the two targets
- Separate platform dill files for the two targets

For now, the patch file contents are the same, and the compiler flag
is not used by the backend (only by the `dart2wasm` script to select
the appropriate platform dill file). Both of these will change as the
implementation progresses.

Tested: ci + manual check that the option selects the correct dill
Change-Id: I2c9bb95ba06fd3de3f7007703ef545e3f0c728ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310621
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-06-21 14:25:38 +00:00
Vyacheslav Egorov 8f6eaeb883 [infra] Pass TEST_COMPILATION_DIR to Android tests
The whole directory is already copied to the device. This makes
it consistent with tests running on the host and allows us to
access various artefacts (e.g. SO files containing DWARF
information).

Change-Id: I9fe20fdbb48ad5a3742286a84c87f87f580f2c09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310600
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-21 14:17:34 +00:00
Stephen Adams b64fc318e7 [dart2js] Update JavaScript global names list
The following would fail unminified because the variable shadowed the
global JavaScript constructor. The fix is to add more global names to
the avoid-list. This is not a problem for js-interop since those are
accessed via `self` or `globalThis`.

```
import 'dart:typed_data';

foo(int Float32Array) => Float32List(Float32Array);

main() => print((foo)(10));
```

Change-Id: I887ece4a888fdab5df437822f9f1f34b384ec24f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310482
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2023-06-21 01:49:57 +00:00
Robert Nystrom ce9e38fff1 Update package:dart_internal to work with SDK 3.2.0.
Fixes #52742.

Change-Id: I11cebf22f48788632e45cacc1e43c3be069a03dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310323
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-06-21 01:14:38 +00:00
Stephen Adams 5cbba84b91 [dart2js] Better const Maps and Sets
Constant Sets now have their own classes rather than being constructed as a wrapper over a const Map. The new scheme is similar to Maps - using a ConstantStringSet backed by a JavaScript Object 'dictionary' when the elements are all suitable String values, otherwise using a GeneralConstantSet backed by a list of elements that is converted to a lookup map on demand.

Constant Sets and Maps with suitable String keys are backed by a JavaScript Object literal 'dictionary'. The use of the Object literal has been changed so that the property values are no longer the values of the Dart Map, but the position of the key in the order of the entries. The values are provided as a List (Array), so there is an additional indexing operation to access the value on lookup. This does not seem to affect performance.

The advantage of the two-level lookup using the 'dictionary' is that Maps with the same keys (in the same order) can share a 'dictionary'. In order to achieve the advantage, the JavaScript Object is modeled as a first class ConstantValue - JavaScriptObjectConstantValue.

These changes achieve a code size benefit of -0.90% (~130K) on the main unit of a certain large app, and -0.35% for flute/benchmarks/lib/complex.dart

Change-Id: Icad2e6136218486a439e3c5ed0296462e3c3c4e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310020
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-06-20 23:44:08 +00:00
Elliott Brooks 70af4a9db0 Add constructor to RPCErrorKind enum
Follow up to https://dart-review.googlesource.com/c/sdk/+/307970

Learned from Kenzie this was possible :) https://github.com/flutter/devtools/pull/5917#discussion_r1231368050

Bug: https://github.com/dart-lang/sdk/issues/52636
Change-Id: Ic244765a6258c000c4171ece35273609c7ee5929
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309831
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-20 18:33:50 +00:00
Danny Tuppeny 421ac46702 [dds/dap] Implement missing "pause" request
Fixes https://github.com/Dart-Code/Dart-Code/issues/4597

Change-Id: Id21baa8428f80f5c9e80840caf836dc05c4f7209
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310343
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-06-20 18:29:26 +00:00
Devon Carew 78da16c5ae [dartdev] fix an issue with the macos process listing
Bug: https://github.com/dart-lang/sdk/issues/52402
Change-Id: I71a9d1112475347beae5a634d0275847a5c7685e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308962
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-20 18:08:44 +00:00
Danny Tuppeny 2d197e4c60 [dap] Regenerate DAP classes based on latest published version of spec
A lot of this change is just documentation comments, but it includes some minor updates such as supporting "lazy" on variables.

All changes are backwards compatible and this should not affect any tests or functionality of Dart's DAP implementation (but provides the ability for us to use the new features).

Change-Id: Ief81927f2f370b4bfb6b5a9acc8659c45c33ea18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310161
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-06-20 17:29:24 +00:00
Danny Tuppeny 01c02d6afd [dds/dap] Clear stored thread data on resume
When an isolate is paused, we store some data for things like variables, stack frames, etc. to round-trip an identifier to the client that it can ask about later.

Previously we never cleared these, so over time in a long debug session they could build up. The DAP spec says these references become invalid when execution is resumed:

> To simplify the management of object references in debug adapters, their lifetime is limited to the current suspended state. Once execution resumes, object references become invalid and DAP clients must not use them.

Because it's possible to resume one thread without another, I'm clearing up only the specific thread (isolate)s data when it resumes, rather than all of it.

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

Change-Id: I2ba7d9cd3f23b5a628d9e279e49edf2bee5afd29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310342
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-20 16:41:49 +00:00
William Hesse 98009cf7a7 [test] Report android infra failures correctly when running tests
Any adb failures when test_runner runs tests on android devices,
except an failure of the actual precompiled test when it is run,
should be reported as an infra failure and should shut down the
test runner.

After change https://dart-review.googlesource.com/c/sdk/+/291304
these types of failure were reported as test failures instead.

Fixes: b/281492587
Change-Id: Iea47ccffac81b0b92f3a3fb3780d2181d08fc1d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310260
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2023-06-20 15:49:38 +00:00
William Hesse 6a37857855 [test] Mark analyzer/test/verify_docs_test as slow
Fixes: https://github.com/dart-lang/sdk/issues/52738
Change-Id: Iaba3f3cab566073c8739f274e16d24e181e7209b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310280
Auto-Submit: William Hesse <whesse@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-06-20 12:06:50 +00:00
Johnni Winther 9059949ce9 [cfe] Initial check of macro annotations
This adds a check that all annotations of macro classes correspond
to applied macro applications. This should be improved in the future
to detect what the problem with the annotation was. For now it helps
avoid inadvertently using invalid/unrecognized annotations in the
macro feature development.

Change-Id: I9574e2e24150d2febfc5489ab4ebf0ae2627e3fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310101
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-20 07:36:21 +00:00
Jens Johansen a0f71d4f6b [analyzer] Make benchmark report memory usage in bytes to make golem happy
Initial commit at https://dart-review.googlesource.com/c/sdk/+/276100
used kb because that's what was reported by the system.
I wasn't allowed to add that to golem though, and then I forgot about
it.
This CL changes it to bytes so it can hopefully by allowed into golem.

Change-Id: Ia7fae9ed47e6d237648e266c26f4a644f13571d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-06-20 06:07:48 +00:00
Konstantin Shcheglov 62f66ecef4 [CMSR] Initial support for constructors.
Change-Id: I2349eaf5dd59596bab1137e297fdf08873d79c1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310201
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-20 00:33:28 +00:00
Ömer Sinan Ağacan 87a3de41b1 [dart2wasm] Implement micro-task scheduling
Use JS `setTimeout` for events and `queueMicrotask` for micro-tasks.

dart2js event loop implementation is copied in `run_wasm.js` to be able
to use `clearTimeout`, `setInterval`, `clearInterval`, and
`scheduleMicrotask`, which are not not available in d8, and `setTimeout`
in d8 does not wait before calling a callback.

New passing d8 tests:

- co19/LibTest/async/Future/Future.delayed_A01_t02
- co19/LibTest/async/Stream/Stream.periodic_A01_t01
- co19/LibTest/async/Stream/Stream.periodic_all_t01
- co19/LibTest/async/Stream/Stream.periodic_all_t02
- co19/LibTest/async/Stream/timeout_A04_t01
- co19/LibTest/async/StreamController/stream_all_A01_t01
- co19/LibTest/async/StreamController/stream_all_A01_t02
- co19/LibTest/async/StreamController/stream_all_A02_t01
- co19/LibTest/async/StreamController/stream_all_A02_t02
- co19/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A01_t01
- co19/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A01_t02
- co19/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A02_t01
- co19/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A02_t02
- co19/LibTest/async/Timer/Timer.periodic_A01_t01
- co19/LibTest/async/Timer/Timer_A01_t01
- co19/LibTest/core/Stopwatch/elapsedTicks_A01_t01
- language/async/call_test
- language/regress/regress21795_test
- lib/async/multiple_timer_test
- lib/async/periodic_timer2_test
- lib/async/periodic_timer3_test
- lib/async/periodic_timer4_test
- lib/async/schedule_microtask3_test
- lib/async/schedule_microtask_test
- lib/async/stream_timeout_test
- lib/async/timer_isActive_test
- lib/async/timer_repeat_test
- lib/async/timer_test

New passing Chrome tests:

- co19/LibTest/async/Stream/timeout_A04_t01
- language/async/call_test
- lib/async/schedule_microtask3_test

Tests below fail because of async* desugaring issues and will be fixed
separately:

- language/async_star/no_cancel2_test
- language/async_star/no_cancel_test

Tests below fail because of an existing issue (#29615):

- co19/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A01_t03
- co19/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A02_t03
- co19/LibTest/async/StreamController/stream_all_A02_t03

Fixes #51599.

Change-Id: Ib313e99bf3b3cb3bebeddc9e47dc77425ef94481
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305201
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-06-19 10:21:35 +00:00
Paul Berry 6dff4755e6 Rename Ir to IR, per dart style conventions
"IR" is a two-letter acronym (short for "intermediate
representation"), not a two-letter abbreviation, so both the "I" and
the "R" should be capitalized.

See
https://dart.dev/effective-dart/style#do-capitalize-acronyms-and-abbreviations-longer-than-two-letters-like-words.

Change-Id: I641b6d4ffc656ba9cd527e05df6e865527ec56d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310080
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-19 08:47:00 +00:00
Liam Appelbe 583da435e9 [analyzer] Support for RawVoidCallbacks
Pointer.fromFunction returns a native function pointer to a Dart
function, but has the restriction that the native code must invoke it
on the same thread as the isolate that created it. RawVoidCallbacks is
a new API that is similar to Pointer.fromFunction. It returns a native
function pointer that can be invoked on any thread, with the
restriction that the Dart function must return void. Under the hood we
forward the function args over a port to the target isolate.

We're not 100% settled on the name of the class, but the overall API
design won't change. I'll make sure to get the naming finalized before
submitting this CL. Doc with discussion of naming:
https://docs.google.com/document/d/1z9Rgahoid2AhC9JXwsDAEODvlJS6dvBHCbcGkOxv_ws/edit?resourcekey=0-TbdNiSL-fdwskla02QaPwg#heading=h.te70ikwelbw8

Bug: https://github.com/dart-lang/sdk/issues/37022
Change-Id: Iba98f6f803c52919b942fa054df1060991574c8c
TEST=ffi_async_callback_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-06-18 23:28:52 +00:00
Konstantin Shcheglov c24c41eeac Extract availability analysis from selection analysis.
Danny gave a good idea that checking for availability of a refactoring
should be cheap. Change method signature refactoring mostly satisfied
this, with one exception - we cannot compute formal parameters for
an ExecutableElement, because we need resolved AST to do this, and
the invoked method can be declared in a different file. We cannot
afford resolving other files while checking.

So, this CL separates availability checking, and preparing formal
parameters, postponing expensive opertions until the time when the
action is invoked.

Change-Id: Ic703d70717e41de304c9dbcef66cadb22c139ad8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310041
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-18 20:51:16 +00:00
Paul Berry 80bc65bb0b Flow analysis: add field promotion support for cascades.
This change updates the flow analysis support for field promotion
(which is not yet switched on by default) so that it supports field
accesses inside cascade expressions. The key moving parts are:

- The type hierarchy `PropertyTarget` (which is used by the client to
  tell flow analysis whether the target of a property access is
  `this`, `super`, or an ordinary expression) now has a new class,
  `CascadePropertyTarget`, to represent the situation where the target
  of the property access is an implicit reference to the target of the
  innermost enclosing cascade expression.

- Flow analysis has two new methods on its API:
  `cascadeExpression_afterTarget` and `cascadeExpression_end`, so that
  the client can inform flow analysis when a cascade expression is
  being analyzed.

- Flow analysis uses its `_makeTemporaryReference` method to track the
  implicit temporary variable that stores the target of cascade
  expressions. (This method was developed as part of flow analysis
  support for patterns, where it creates the data structures necessary
  to track the implicit variables that are created as part of pattern
  desugaring).

- The "mini-AST" pseudo-language used by flow analysis unit tests now
  has a way to represent cascade expressions and method invocations.

- In addition to unit tests for `_fe_analyzer_shared`, `analyzer`, and
  `front_end`, there are new language tests in
  `tests/language/inference_update_2` to test cascaded field
  promotions in end-to-end fashion.

Bug: https://github.com/dart-lang/language/issues/2020
Change-Id: I21353bbc884ed599cb1739cecfb68ad1d975d18b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309220
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-06-17 08:13:20 +00:00
Konstantin Shcheglov fda8556438 [CMSR] Write existing extra named formal parameters and arguments.
Change-Id: Ibbd69140c7e46bca95dd72f99739eccd1984b2d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309828
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-17 05:20:27 +00:00
Nicholas Shahan b5c42b8cc6 [ddc] Fix missing type rules
Type rules for classes appearing in the type hierarchy above types
in the current module were missing. Specifically types that appear
in instantiations of supertypes.

Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I11f2af1435f18ab7567766c865d9898d60b9272b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309827
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-06-16 23:24:52 +00:00
Nicholas Shahan 0ead4ff72b [ddc] Fix type environment in forwarding stubs
When mixin applications introduce forwarding stubs with covariant
checks they can contain uses of type parameters that belong to the
synthetic mixin application class. The type environment needs to
be updated to contain those type parameters.

Also cleanup some comments, variable names, and the code to avoid
an assertion failure. Methods can contain covariant checks on the
arguments, not just setters.

Issue: https://github.com/dart-lang/sdk/issues/52688
Change-Id: Ifd91f76de85cb2092b0a3a0c4a808f2660eb5c17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308460
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-06-16 22:31:26 +00:00
Nate Biggs d87219bd30 [dart2js] Add test that loads multiple Dart2JS apps with different runtimes.
I confirmed that this test would've failed before the fix was submitted: https://dart-review.googlesource.com/c/sdk/+/309761.

Change-Id: I9c823c3acfb094a58143140069d55e01e2631581
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309840
Auto-Submit: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2023-06-16 17:12:38 +00:00
Jake Macdonald 96dcb2a5ab add support for type annotations and code arguments
Change-Id: I14ad05e810494de94f7935b7ca11b1922f90ecda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309021
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-06-16 16:59:06 +00:00
Konstantin Shcheglov 21cfe2ce61 Breaking changes for analyzer version 6.0.0
Change-Id: I792c3d66fb10ab779e2a5011b2909efa5738aba7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265183
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-16 16:31:27 +00:00
Keerti Parthasarathy fd4af5f0ff Wire up changeParameterType when running dart fix cli
Change-Id: I41e96ca4722faf746e18b193319d84ade0e08138
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309800
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-16 15:58:38 +00:00
Jake Macdonald 4590fc83e7 Reland "Add wrappers for macro arguments to help with serialization."
The type arguments have to be explicitly given for collection types,
but this should be doable given they are all constants and only certain
types are allowed.

Change-Id: I2721f37d194d73de1df81302298101adeb87534c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309460
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-06-16 14:02:05 +00:00
Johnni Winther 9c68598133 [cfe] Assert verification errors
This adds assertions that no verification errors are found.
This enables the distinction between compile-time errors and
verification during trybot testing, leaving the latter as crashes
rather than (unexpected) compile-time errors, while retaining the
good diagnostics.

Change-Id: I097d875a75e8343c67cb96190b53320d4799663c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309662
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-06-16 12:41:14 +00:00
Johnni Winther dd4a95793d [cfe] Ensure abstract methods have sync marker
This ensures that abstract methods have sync markers even when they
are erroneously marked with a sync*, async or async* marker. This
ensures that these are verifiable.


Change-Id: I6d5bed9305129c47306ad9fd0e248683a6577800
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307804
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-06-16 12:31:22 +00:00
Martin Kustermann ddc236ba64 [vm] Add @pragma('vm:keep-name') annotation
This allows us to keep symbol names for classes/methods/fields - even if
obfuscation is enabled, but has no other effect on tree shaker / ...

For go/dart-ama

TEST=vm/dart/keep_name_pragma_test

Change-Id: I66c0fc32217d9180f821658bae463f2c1d7fb1af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309740
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>
2023-06-16 10:22:23 +00:00
Paul Berry 788a3a95c2 Flow analysis: clean up public method call to functionExpression_begin.
In a future CL, I plan to refactor some of the flow analysis API so
that the CFE can supply subexpressions to flow analysis before they
are lowered, rather than after. This should help reduce the risk of
bugs where lowering leads to type promotion being lost
(e.g. https://github.com/dart-lang/sdk/issues/52183).

The refactor I'm planning will be easier if there are no calls to the
flow analysis API within flow analysis itself, so to prepare for it,
this CL moves the body of `FlowAnalysisImpl.functionExpression_begin`
to a private method, and updates both `functionExpression_begin` and
`lateInitializer_begin` (which use the same underlying logic) to call
that private method.

Bug: https://github.com/dart-lang/sdk/issues/52189
Change-Id: I1185418225b8a402670e6eece6599c326fdc234a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309440
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-06-16 10:18:05 +00:00
Jens Johansen 5e08794bbf [analyzer] Plug "temporary leak" when starting new rebuilds before afterContextsCreated is called
If again and again editing, say, a `pubspec.yaml` with proper timing
there is a "temporary leak" that repairs itself once the analyzer
finishes (some time after the editing stops).

What happens is that old contexts are saved in the
`declarationsTracker` but eventually cleared in the
`afterContextsCreated` call.

In a test on Windows (on Linux I'd currently run into
https://dartbug.com/52703) I opened the entire "pkg" folder and edited
a `pubspec.yaml` file every 5 seconds.
The analyzer went from using something along the lines of 700MB of heap
to using around 2.5 GB of heap after 25 edits and 17GB (!) of heap
shortly before stopping at 250 `pubspec.yaml` edits.
After the editing stopped (and clicking the GC button in observatory)
the heap usage went down to ~650MB heap used.

This fixes the problem by clearing the `declarationsTracker` on the
`afterContextsDestroyed` call too. In the same test it stays at around
300-700MB of heap.

Possibly related to:
https://github.com/dart-lang/sdk/issues/48788
https://github.com/dart-lang/sdk/issues/52447

Change-Id: Ia38cc946a1f36fa8c5b6804f79cbc8dd96c21030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-06-16 06:42:41 +00:00