Commit graph

44133 commits

Author SHA1 Message Date
Johnni Winther bf9ea56ff7 [kernel] Remove nodes used for the old 'extension-types' experiment
This removes ExtensionType, ExtensionTypeShowHideClause and
CallSiteAccessKind from package:kernel which where only used by the now
removed 'extension-types' experiment.

A follow-up CL will rename InlineClass/InlineType to
ExtensionTypeDeclaration/ExtensionType to match the names of the
Extension Type feature currently being implemented.

TEST=existing

Change-Id: I58d2e8b0a92ac61329ee161cc6884a2c0e6f87ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-07-27 10:47:08 +00:00
Johnni Winther 74fa24d4c0 [cfe,analyzer] Remove 'extension-types' experimental flag
This is not the flag you're looking for.

The 'extension-types' flag was used for an early experiment that is
not directly related to the Extension Types feature currently being
developed. The current feature uses the 'inline-class' flag.

Change-Id: Icbb6c3828c41e743e726161b17da4c7784a2c677
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316380
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-27 09:30:36 +00:00
Konstantin Shcheglov b42c27f2a2 Issue 53029. Include constant dependencies of map patterns.
Bug: https://github.com/dart-lang/sdk/issues/53029
Change-Id: I8d604a153452acee581f291f5806f88b4478fee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316081
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-27 03:22:23 +00:00
Sam Rawlins cb93ac73fd Re-add applyToAnalysisOptions, needed by internal customer
b/293297223

Change-Id: I852bbc5df9c5918b31a37eaebd4bf1d2895f6fb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316529
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-27 02:44:08 +00:00
Sam Rawlins ab8736cf7c [analyzer] Remove all checks for ui-as-code enablement
Dart 3's minimum language version is 2.12. google3's is 2.9.

Change-Id: I8303b14de17b695e835cf9f8018f08731b51ec35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316526
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-27 02:43:38 +00:00
Konstantin Shcheglov 88d84eb6f2 Remove ElementImpl.typeParameterContext, unused.
Change-Id: Idac59ddb6fa013ea1a01ff4cf16cd3df4b2cf672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316489
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-27 02:21:30 +00:00
William Hesse 7d802ca199 Increase maximum sdk version constraint on dart_internal to 3.3.0
The dart_internal has a maximum sdk version constraint so it
can be deprecated and removed once it is no longer used.
Increasing it from <3.2.0 to <3.3.0.
The package is still used internally, and downloaded by Flutter
from pub.

Change-Id: I210ac7453950388544d03d768ad9261d51a7f060
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2023-07-27 00:29:42 +00:00
Liam Appelbe edeac698c2 [vm/ffi] Closure callbacks for async callbacks
This change is almost trivial. The closure is stored on the callback's
RawReceivePort, not in the VM. So we can basically just remove the CFE
check and it pretty much works. The only problem is that we can't set
function.FfiCallbackTarget anymore, so most of the CL is dealing with
that.

A few places were deciding whether an FFI trampoline was a call or a
callback based on whether function.FfiCallbackTarget() was null. But
now the target will be null for async callbacks. So instead I've added
a new value to the FfiCallbackKind enum (and renamed it), and changed
those checks.

Sync callback closures will be a separate CL, because they're more
complicated.

Bug: https://github.com/dart-lang/sdk/issues/52689
Change-Id: I8e5dfb557362e679f66195b735c3c382e6792840
TEST=async_void_function_callbacks_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316160
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-07-26 23:23:26 +00:00
Kallen Tu 946175cbd0 [analyzer] Add tests for the removal of 'A value of type 'Null' can't be assigned to a parameter' overreporting in the const evaluator.
The constant evaluator now handles invalid types better and won't overreport this nonsensical error.

Bug: https://github.com/dart-lang/sdk/issues/47603, https://github.com/dart-lang/sdk/issues/47351, https://github.com/dart-lang/sdk/issues/49389
Change-Id: I63c253d2177c2b8c259c364e83753653eac1cae0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312707
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-26 20:36:28 +00:00
Sam Rawlins 05f2b3222a [analyzer] Add extension-naming to our style doc
Change-Id: I454df164b2cede7c4ae7d6fdf541e67fdf7090da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316525
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-26 20:32:59 +00:00
Konstantin Shcheglov 4787a99ba0 Don't print 'shouldUseTypeForInitializerInference' when no initializer expression.
Change-Id: I73c7bc973d8cdfbcc6d63232a5c8eec0ac43fe76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316524
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-26 19:46:18 +00:00
Konstantin Shcheglov d02097bd1e Test for extension types with type parameters.
Change-Id: Ib0d406cd98116deea20eb402d113f3cd2b97504c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316482
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 18:45:41 +00:00
Konstantin Shcheglov c36ff43382 Parse and use 'const' keyword for extension types.
Change-Id: I331d57f46507981f8532d504211267316770f86b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316521
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-26 18:45:12 +00:00
Sam Rawlins 411cfeef13 Address feedback from cr/316340
Change-Id: I5fecdab01b9a2af385ecae72b00b076821b3a605
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316480
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 17:27:38 +00:00
Derek Xu 0ba8d4ef77 [VM/Debugger] Fix the behaviour of setting inline breakpoints in uncompiled functions
TEST=pkg/vm_service/test/column_breakpoint_test.dart, other debugger
tests in tryjobs

Fixes: https://github.com/dart-lang/sdk/issues/51563
Change-Id: I87ef7e52cfc7e922904b267b7eb74fc783214b44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316440
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-26 17:15:36 +00:00
Sam Rawlins a07f57c7a1 Split out 'analysis-options-application' code from verification code
Change-Id: Id3aab1ef4c91c2f4c59ca253acbc51b80d6409ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316340
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-26 16:24:37 +00:00
Kallen Tu 66df28dcc6 [analyzer] Remove unused ConstantEvaluationValidator.
ConstantEvaluationValidator and it's implementation is not used
anywhere in g3 nor in the sdk.

Change-Id: I7490501e2e55ac567a996af658bb09dd7c37c8df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316020
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 15:21:04 +00:00
Konstantin Shcheglov e6f9e58371 Basic building of ExtensionTypeElement(s).
Change-Id: I0489a5dde5afe244d8c4b58351b3ecac6315a790
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316080
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 15:10:09 +00:00
Ömer Sinan Ağacan dd712accf4 [dart2wasm] Test with d8 --wasm-final-types --wasm-disable-deprecated
Change-Id: Iba192eb02bb6163e95e55deb4c3912315b8b77ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316201
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-07-26 10:58:09 +00:00
Johnni Winther 53deaf0522 [parser] Support 'extension type const'
This adds parser support for the optional 'const' keyword in extension
type declaration. The token is passed on through the endPrimaryConstructor
listener call since it is used to make the primary constructor constant.

Change-Id: I518a8e397fb62272002c424e7b69affe6123f4af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316221
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-26 08:17:49 +00:00
Nate Biggs 4f03bd0c30 [dart2js] Defer loading of codegen results.
This was landed a while ago as https://dart-review.googlesource.com/c/sdk/+/254600. However, this had to be rolled back because at the time this increased memory usage for the emitter phase. This change prevented GC from cleaning up the byte arrays of the codegen serialized files which resulted in an increased max heap.

However, now that we map (rather than copy) files into memory, there is no overhead to keeping a reference to the codegen serialization files.

Thanks to recent improvements in the efficiency of deferred serialization this change seems to improve max memory usage by up to 1.2GB for the emitter phase. Avoiding caching results also helps in this regard, usage of the results is fairly localized.

Change-Id: I4d401a877cb74cbb36b511eb598a759fe300fd5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316180
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-07-26 02:23:40 +00:00
Kallen Tu ba005169c5 [analyzer] Initial refactor of _InstanceCreationEvaluator to return Constant value.
evaluateConstructorCall now returns a Constant, which means evaluation may be cut early in some places if there's an error. However, some code generators rely on _InstanceCreationEvaluator to complete, and so there's no _major_ changes to the design right now (and some small additions to avoid breaking many tests).

This CL is just the framework for the "return Constant" design and will be the base for reporting better errors in constructor invocations.

These changes already show that we cut some amount of over-reporting in our existing language and unit tests, which is a step in the right direction.

Bug: https://github.com/dart-lang/sdk/issues/47603, https://github.com/dart-lang/sdk/issues/47351, https://github.com/dart-lang/sdk/issues/49389

Change-Id: I5ba7f1282658884c18a32d5e98c7804bbfeac0f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312347
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-25 19:23:02 +00:00
Sam Rawlins 005f7e84c2 Add fix for unreachable_from_main
We have a fix to remove private declarations (classes, other elements, local variables, etc). No reason to not allow this for public elements in entry-point libraries.

Change-Id: Id4c0ef1b14658d701229ea71d25669982e98d6c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313291
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-25 17:59:02 +00:00
Konstantin Shcheglov 8b6074617a Tests for metadata in ExtensionTypeDeclaration.
Change-Id: Ie474674bfba980ad085620d731540f0018534ae6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-25 17:43:08 +00:00
Paul Berry 5a79f8a9f3 Unify "mini-ast" constructs for rest pattern elements.
Previously, in the "mini-ast" pseudo-language for shared flow analysis
and type analysis unit testing, there were two separate functions to
create a rest pattern (`...`):

- `listPatternRestElement` for creating a rest pattern for use in a
  list pattern

- `mapPatternRestElement` for creating a rest pattern for use in a map
  pattern

The latter is not allowed in Dart, but it's supported to allow for
better error recovery.

But having two functions wasn't necessary--the two functions did
exactly the same thing.

This CL simplifies things so that there is just a single function,
`restPattern`. It also renames the underlying representation class
from `RestPatternElement` to `RestPattern`, to match the nomenclature
in the patterns spec document.

Change-Id: Iecfe8c86f49161e0657cdab44f000f47c0e3c212
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315520
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 16:36:28 +00:00
Alexander Thomas a3d48885e7 [release] Bump version on main to 3.2
Tested: CQ
Change-Id: I16210697b47dd85aec8743b457e773b044cab81f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316200
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-07-25 15:12:49 +00:00
Joshua Litt d1660236f1 [wasm_builder] Defer encoding instructions until Module.encode.
This CL lays the foundation for allowing us to emit instructions without finalizing imports, which will in turn enable more flexibility in code generation. For example, we will no longer need to do a pre-code generation pass to collect imports. In addition, it will pave the way for other optimizations as suggested in the `TODO` at the top of `instructions.dart`.

Perhaps counter-intuitively, even without any optimizations, this doesn't seem to be a measurable regression:

Before:
  Completed compilation of dart2wasm-html-engine in 52652ms.
  Completed compilation of dart2wasm-html-html in 51827ms.
  Completed compilation of dart2wasm-html-ui in 20399ms.
  Completed compilation of dart2wasm-canvaskit-canvaskit in 32899ms.
  Completed compilation of dart2wasm-canvaskit-ui in 20695ms.
  Completed compilation of dart2wasm-skwasm-ui in 20319ms.

After:
  Completed compilation of dart2wasm-html-engine in 51476ms.
  Completed compilation of dart2wasm-html-html in 48845ms.
  Completed compilation of dart2wasm-html-ui in 19676ms.
  Completed compilation of dart2wasm-canvaskit-canvaskit in 31933ms.
  Completed compilation of dart2wasm-canvaskit-ui in 19733ms.
  Completed compilation of dart2wasm-skwasm-ui in 19962ms.

Change-Id: Ib3740f88db56070fc3ccdde484675267e4bf40c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315580
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-07-25 13:55:10 +00:00
Paul Berry 39e1357288 Add shared analysis testing infrastructure for map literals.
This change adds the functions `mapLiteral` and `mapEntry` to the
"mini-ast" representation used for unit testing shared flow analysis
and type analysis logic. These can be used to model map literals with
explicit type arguments. Set/map literals without explicit type
arguments are not supported yet.

These functions replace the old `inContextMapEntry` method, which was
an alternative way of testing the type analysis behavior of map
literal entries (and was not yet being used). The new approach is
better in that it allows the test cases to follow the structure of
actual Dart code (map entries inside map literals) rather than just
testing map entries in isolation.

Change-Id: I4bfd31b8fb2865f3d0892da0a47ee0bdacaf9250
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315225
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-25 13:49:06 +00:00
Johnni Winther 5833837622 [cfe] Add test for issue 43400
Closes #43400

Change-Id: Icdd968f1265d2cf0969027752b2cdb3d2f04050b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316220
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 13:42:59 +00:00
Johnni Winther 4d78361e8f [cfe] Handle absolute part/part-of uri with packages
Closes #52964

Change-Id: I787af659744be45df4221fcaefe2b524beb20776
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315403
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 11:42:58 +00:00
Chloe Stefantsova 2c86500e36 [cfe] Adjust nullability of UP of intersection type and another type
Closes https://github.com/dart-lang/sdk/issues/52993

Change-Id: Id7c18f98d2422264ca69e275505d4977b8b59a99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315900
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 10:12:58 +00:00
Johnni Winther 29ff51a008 [cfe] Add ExtensionTypeHierarchyNode(Builder)
This adds checks for conflicting supertypes and prepares for computation
of extension type members.

Change-Id: If997fe84bac929274a6014b315ecea4f3856eedd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315441
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 09:15:47 +00:00
Nicholas Shahan f4e949609c [ddc] Add new build targets for DDC assets
- Introduces a new output subdirectory `gen/utils/ddc` where the
  new build targets output files. This is intended to make the
  migration to the new assets easier since landing this change
  shouldn't immediately break any dependencies.
- Enables building the canary and stable assets at the same time.
- Changes more names in our workflow from "dartdevc" to "ddc".
- Updates the ddc-canary-linux-chrome and
  ddc-canary-linux-chrome-unsound configurations to use the
  new assets.

The new outputs appear in directories that are more consistently
named, (no more sound vs kernel confusion). They are named in
preparation for the eventual deletion of the unsound targets
without any lingering cruft to be cleaned up in the sound
directories.

The new structure is:

```
gen/utils/ddc/
           |- canary
           |  |- pkg
           |  |- sdk
           |- canary_unsound
           |  |- pkg
           |  |- sdk
           |- stable
           |  |- pkg
           |  |- sdk
           |- stable-unsound
              |- pkg
              |- sdk
```

The 'pkg' and 'sdk' directories all contain outputs with the same
files names, each compiled in the respective build modes
(sound/unsound and stable/canary).

Change-Id: I66822ebf03bba487b6d359a8e0aa818b9e7b6bef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313081
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-25 00:19:52 +00:00
Sam Rawlins 8e66248765 Refactor doc comment-parsing tests
I suspect we ought to just remove many/all of the remaining simpler parser tests. I glanced at a few, and they do not seem specific to analyzer, so their covered features should be covered by parser tests in _fe_analyzer_shared.

https://github.com/dart-lang/sdk/issues/50702

Change-Id: I0e524562f6584145db5e80a154e72ea66090d924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316042
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-25 00:15:41 +00:00
MarkZ afefee3018 [ddc] Trust nullability of parameters in dart:_rti.
Improves performance of legacy mode apps in the new type system.

Change-Id: Ia884ea244741df5385271f43baa4125678b995ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315983
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-07-25 00:00:48 +00:00
Jake Macdonald e12698594c Move more macro apis to has* instead of is* nomenclature.
These are intended to be syntactic and not semantic in meaning, so I think has* is a better name.

Change-Id: Ia2a8a276c1057bde913eb755cc1a7a559d953774
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315960
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-07-24 20:51:38 +00:00
MarkZ 5831ed204f [ddc] Avoiding emitting legacy or mixed mode null checks for dart:_runtime and dart:_rti operations.
A side effect of DDC's new shared runtime ('dart:_rti') is that previously @notNull-annotated code paths were being extraneously null-checked. This is partly responsible for the slowdowns in some internal mixed-mode apps found in testing.

Change-Id: I3f619cfd23688f3eb4ada0079ad1664d39a7e010
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315640
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-07-24 20:06:43 +00:00
Kallen Tu 1740829f34 [analyzer] Remove unused methods in the constant evaluator.
Found some methods that weren't being referenced anywhere, or they
weren't cleaned up. Removing because it's just dead code.

Change-Id: Id344d2d7cedd87468255a33fea75bfda97d10cac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-24 19:44:19 +00:00
Ömer Sinan Ağacan 7fec037b6b [dart2wasm] Split more patch files into patch + implementation files
Following the refactoring we started in previous CLs, this splits string
and int patch files into (1) patch files that only patch and don't add
implementation classes (2) files for implementation classes (3) helpers.

Changes:

- `string_patch` is split into `string.dart` and `string_patch.dart`.

- VM's `integers_patch.dart` copied as `int_patch.dart` and updated.
  This was needed as `integers_patch` requires VM's library paths in
  imports.

  We needed to copy this file to be able to optimize based on
  dart2wasm's implementation classes. However in this CL we copy the
  file as-is and update import paths.

- VM's `string_buffer_patch.dart` copied to be able to use the string
  implementation classes from the new library.
  `string_buffer_create.dart` is merged ino `string_buffer_patch.dart`.

- `getHash` and `setHash` to set object identity moved to
  `object_helper.dart`, to be able to use in string implementations.

- Redundant `new` keywords in copied files removed.

One TODO added in `string_buffer_patch.dart` when allocating a new
string to the buffer:

    // _parts = _GrowableList.withCapacity(10)..add(str);
    // TODO(omersa): Uncomment the line above after moving list
    // implementations to a library.
    _parts = [str];

We can enable the old code again after moving list implementations to a
library.

Change-Id: Ice5dba40b3ba894797028987d4b42cb0c0f0c230
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315821
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-07-24 16:58:52 +00:00
Samuel Rawlins 008cb0bbc1 Revert "Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT"
This reverts commit a458bab09a.

Reason for revert: broke flutter snippet tests, and maybe customer tests

Work towards https://github.com/flutter/flutter/issues/131096

Original change's description:
> Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT
>
> Fixes https://github.com/dart-lang/sdk/issues/49025
>
> Change-Id: I401093e5b76bcf707060ce022c346e26c6807aa0
> Tested: try-bots
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303261
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Change-Id: Ib0c9afc4911efd620013896fb895ab7825c50aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315940
Commit-Queue: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-24 16:25:07 +00:00
Jake Macdonald 5220b9e5f7 Add Extension declaration introspection and extension macros
Bug: https://github.com/dart-lang/language/issues/3223
Change-Id: I43e0ea17ea1bf8dbb41ad899675ac25d26ca568f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315300
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-07-24 15:24:10 +00:00
Paul Berry 03a91b5d2a Simplify handling of variable expressions in shared analysis tests.
When using the "mini-ast" pseudo-language to write unit tests for the
flow analysis and type analysis logic in the `_fe_analyzer_shared`
package, it is no longer necessary to use `.expr` to turn a `Var` into
an `Expression`; this now happens automatically. The way this works
under the hood is that the `Var` and `Expression` classes implement
the `ProtoExpression` interface; constructs that expect expressions
are declared with input parameters of type `ProtoExpression`, and they
automatically convert to `Expression`s when necessary.

Change-Id: I85c493145c3fc41a5296c1807cd63fe1401672db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315247
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-24 15:03:19 +00:00
Konstantin Shcheglov 2d5dd229fe Add ExtensionTypeDeclaration, parse into it.
Change-Id: I5f7e8b074a137f6be86965509a47ce10c11e05e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315620
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-24 15:02:38 +00:00
Johnni Winther d9a1bd7762 [cfe] Refactor HierarchyBuilder
This removes the substitutions from ClassHierarchyBuilder and moves
the checking of inheritance conflict to the ClassHierarchyNodeBuilder.

Change-Id: I87a943102ab644c3b50acb07defb156e686225d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315102
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-24 14:55:14 +00:00
Chloe Stefantsova cc5ba81491 [cfe] Use term equality in place of identity in UP and DOWN
Closes https://github.com/dart-lang/sdk/issues/52997

Change-Id: I8b15ca1c4d2e3efbc8d7cdebeed1b16fe92d542b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315443
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-24 14:54:34 +00:00
Danny Tuppeny f191f235df [dds/dap] Fix some races in termination of test runs in DAP tests
It's not guaranteed that a "terminate" request will get a response so this changes the helper to accept a "terminated" event as acknowledgement of termination too.

It also fixes some issues running individual tests that didn't set a CWD (by setting a default for tests, since we can't "dart run test:test" without a cwd), and also updates a breakpoint test to not send breakpoints on invalid lines (something that had been fixed in the CLI test, but not the Test test).

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

Change-Id: I19dd60eb2b6d56035bb4d5b02d8e90713a8ce42d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315823
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-07-24 14:41:40 +00:00
Ilya Yanok 3911ef982d Try to fix _SubstitutedTypeParameters
It really looks like `_SubstitutedTypeParameters` factory
constructor assumes its `substitution` argument doesn't
include any of `elements` neither as a key, nor anywhere
it the result types. Since if it does contains a key from
`elements` that part of `substitution` will be lost, overriden by
`...substitution2.map` part of `Substitution.fromMap` call.
And if it has `elements` mentioned anywhere in values of the
`substitution` map, those won't be renamed.

But sometimes `_SubstitutedTypeParameters._SubstitutedTypeParameters`
is called with a `subtitution` that includes some of `elements`.
For example, that's what happens in both added tests.

I assume it never breaks, because the part of `substitution`
that acts on `elements` is trivial: just renaming a type
variable to a fresh name. And since `_SubstitutedTypeParameters`
just gets yet another fresh name for it, that works.

One small problem arises though if a type variable renamed by
`substitution` has a bound that references the type variable itself
(like `T extends Foo<T>`). In that case bound gets substituted with the
`substitution` first, so `substitution2` doesn't work on it anymore.
So we end up with an element `T0 extends Foo<T1>`, where `T0` and
`T1` and two different fresh names for `T`.

This commit changes the order of substitutions when handling bounds,
such that the part of `substitution` that substitutes `elements` is
effectively ignored. That agrees with the existing behavior of
rewriting this part of `substitution` in the result, so it shouldn't
make things worse.

Change-Id: I8f68c4342aad0c8f59f7c01a6cfac074946529ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2023-07-24 12:23:27 +00:00
Daco Harkes 72dd200f8a [pkg][dartdev] Error on native assets but not enabled
And only print logs if `-v` is passed.

TEST=pkg/dartdev/test/native_assets/

Bug: https://github.com/dart-lang/sdk/issues/50565
Change-Id: Iccf879c80ea01cb39f9dd0d13c2f515a885d11d2
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/+/314721
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Hossein Yousefi <yousefi@google.com>
2023-07-24 11:25:06 +00:00
Martin Kustermann 11d820890e Use utf8.encode() instead of longer const Utf8Encoder.convert()
The change in [0] has propagated now everywhere, so we can use
`utf8.encode()` instead of the longer `const Utf8Encoder.convert()`.

As the checked-in SDK has been rolled to include [0] we can now rely on
the better return type.

[0] https://github.com/dart-lang/sdk/issues/52801

TEST=ci

CoreLibraryReviewExempt: Minor cleanup.
Change-Id: I2c0144023e03b2c265582d83a7fb9469b02f1570
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313563
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-24 09:28:38 +00:00
Konstantin Shcheglov 4bb8312b4a Revert "Move API declarations of elements into src/, re-export."
This reverts commit 43db92d9ed.


Revert "Tweaks for comments of classes around augmentations."

This reverts commit 6d0fb5094f.

Change-Id: I9508169158d536302579346defebf696edfe4bec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-23 16:43:30 +00:00
Jia Hao Goh 11d0f060ef [dart2wasm] Fix location RangeError when using part
Here's a minimal repro that this CL fixes:

`ui.dart`

```dart
library dart.ui;

import 'dart:ffi';

part 'foo.dart';
```

`foo.dart`

```dart
part of dart.ui;

@Native<Void Function()>(symbol: 'foo_func', isLeaf: true)
external void foo_func();
```

When compiling with `compile_platform.dart` with `--target=dart2wasm`, the following error appears:


```
Unhandled exception:
Verification error: Target=wasm, VerificationStage.afterModularTransformations: Invalid location with target 'wasm' on FunctionNode() (FunctionNode): RangeError (offset): Invalid value: Not in inclusive range 0..56: 91
Context: 'foo_func_$import'.
Node: 'FunctionNode()'.
#0      VerificationErrorListener.reportError (package:kernel/verifier.dart:81:5)
#1      VerifyingVisitor.problem (package:kernel/verifier.dart:222:14)
#2      VerifyingVisitor._getLocation (package:kernel/verifier.dart:1361:7)
#3      VerifyingVisitor._hasLocation (package:kernel/verifier.dart:1370:26)
#4      VerifyingVisitor.getSameLibraryLastSeenTreeNode (package:kernel/verifier.dart:1342:28)
#5      VerifyingVisitor.localContext (package:kernel/verifier.dart:1382:24)
#6      VerifyingVisitor.defaultDartType (package:kernel/verifier.dart:1491:41)
#7      Visitor.visitVoidType (package:kernel/visitor.dart:1309:37)
#8      VoidType.accept (package:kernel/ast.dart:11190:42)
#9      FunctionNode.visitChildren (package:kernel/ast.dart:3919:16)
#10     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#11     VerifyingVisitor.visitWithLocalScope (package:kernel/verifier.dart:266:5)
#12     VerifyingVisitor.visitFunctionNode (package:kernel/verifier.dart:721:5)
#13     FunctionNode.accept (package:kernel/ast.dart:3908:38)
#14     VerifyingVisitor.visitProcedure (package:kernel/verifier.dart:620:19)
#15     Procedure.accept (package:kernel/ast.dart:3311:40)
#16     visitList (package:kernel/ast.dart:14488:14)
#17     Library.visitChildren (package:kernel/ast.dart:591:5)
#18     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#19     VerifyingVisitor.defaultTreeNode (package:kernel/verifier.dart:196:5)
#20     TreeVisitor.visitLibrary (package:kernel/visitor.dart:503:35)
#21     VerifyingVisitor.visitLibrary (package:kernel/verifier.dart:367:11)
#22     Library.accept (package:kernel/ast.dart:577:38)
#23     visitList (package:kernel/ast.dart:14488:14)
#24     Component.visitChildren (package:kernel/ast.dart:14320:5)
#25     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#26     VerifyingVisitor.visitComponent (package:kernel/verifier.dart:342:7)
#27     Component.accept (package:kernel/ast.dart:14313:38)
#28     VerifyingVisitor.check (package:kernel/verifier.dart:171:15)
#29     verifyComponent (package:kernel/verifier.dart:69:20)
...
```

The issue seems to be that after doing this native transformation, the node's `fileUri` references the enclosing library (`ui.dart` above), but the `node.location` references the actual source file (`foo.dart` above) indirectly through `node.fileOffset`.

This ends up being an issue when compiling the platform dill in Google3,   but I didn't look into why `flutter build web --wasm` isn't broken.

Internal bug: b/292172146

Change-Id: I2b8d7d215b2c36354860257ce651d50168e9523d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315360
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jia Hao Goh <jiahaog@google.com>
2023-07-21 23:08:28 +00:00
Anna Gringauze a322a97fac [ddc] Add debugger runtime API
Define debugger runtime API so the debugger can display objects without knowing DDC implementation details.

- Add new DDC debugger runtime API in `debugger.dart`
- Add helpers for getting some type information in new and old type systems
- Add tests


Closes: https://github.com/dart-lang/sdk/issues/52773
Change-Id: I8efa4cacebb0d73ef58b5360979089cba2039379
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311154
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2023-07-21 20:10:15 +00:00
Konstantin Shcheglov 4854aabac9 Stop expecting 'inlineKeyword' during class parsing.
Inline classes will be replaced with extension types.

Change-Id: I9472dfbb92f7f50a4649e6f1953481a9ac237fe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313284
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 19:12:48 +00:00
Ömer Sinan Ağacan 37581cb79e [dart2wasm] Fix names of dynamic call entry functions
Currently all closure dynamic call entries have the same name. This
makes it difficult to find locations of crashes. Example:

    wasm-function[677]:0x1de1d: RuntimeError: illegal cast
    RuntimeError: illegal cast
        at dynamic call entry (wasm://wasm/000909b2:wasm-function[677]:0x1de1d)
        at method forwarder for 'call' (wasm://wasm/000909b2:wasm-function[583]:0x1b474)
        ...

With this we now add the function name before "dynamic call entry":

  wasm-function[677]:0x1de1d: RuntimeError: illegal cast
  RuntimeError: illegal cast
      at C.m1 tear-off dynamic call entry (wasm://wasm/000921c6:wasm-function[677]:0x1de1d)
      at method forwarder for 'call' (wasm://wasm/000921c6:wasm-function[583]:0x1b474)
      ...

Which makes it easy to find the function in .wat output as there is only
one function with the name "C.m1 tear-off dyamic call entry".

Change-Id: Iea726b695fc29b361a347b64194d5c09601a0999
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315440
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 17:48:38 +00:00
Konstantin Shcheglov 6d0fb5094f Tweaks for comments of classes around augmentations.
Change-Id: If380225009237ca260cfb11b0f1861b50d34cae4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315223
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 17:42:32 +00:00
Ömer Sinan Ağacan 8b709ded96 [dart2wasm] Generate type names in names section
Change-Id: I35879dba0e5e4ecee279bdd8bf725798cd806595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315402
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 17:36:47 +00:00
Johnni Winther 65ce98f6de [cfe] Report error on cyclic extension types
Change-Id: I556a7fb63818879ac4adf94e070f68bf3b732036
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314440
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 17:34:28 +00:00
Konstantin Shcheglov 43db92d9ed Move API declarations of elements into src/, re-export.
In following CLs I plan to add `final` and `sealed` modifiers.

Change-Id: Ia6b9091034ed9f8f6f8576dbe6029d7e72a9d6b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315249
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-21 16:05:21 +00:00
Konstantin Shcheglov deb5fc8fa7 Don't report DUPLICATE_DEFINITION for augmentations of class / mixin / method.
Change-Id: I7c8e14216df650fbd6876a8087005a3bd3e82595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315248
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 15:59:08 +00:00
Aske Simon Christensen bac7e9b8c0 [dart2wasm] Emit encoding for final types.
This marks all types without subtypes as final and all types with
subtypes as non-final. This makes the emitted types maximally final
and is appropriate for a closed-world module.

V8 currently ignores the finality of types for the temporary WasmGC
encoding, which make our current encoding work even though it
implicitly marks some types as final that shouldn't be. For the final
WasmGC instruction encoding, V8 is likely to reject modules containing
final types with subtypes.

Change-Id: If3030c49e8fe60fec8099b731b6fcf618d6a7e64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310163
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 15:52:38 +00:00
Sam Rawlins 892fdd9ab0 Move all comment-parsing code into pkg/analyzer
I did not change the content of the functions, except the following:

* modernized some variable declarations with `var`.
* added periods to the end of comments.
* privatized most methods.

Work towards https://github.com/dart-lang/sdk/issues/50702

Change-Id: I4d63d3ee847316b58fa76c12558767c0825027a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315243
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-21 15:19:38 +00:00
Jake Macdonald 9803ffef27 Add support for macros adding mixins and interfaces to existing types in
the types phase.

Also seales the Code types hierarchy to block users from attempting to
create their own subclasses.

Bug: https://github.com/dart-lang/language/issues/3211
Change-Id: I51ebdfdad6e1fba3c19ef91f25e238730e98e740
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314821
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-07-21 15:18:33 +00:00
Paul Berry 82a196387d Allow .pattern only on const expressions.
Previously, when using the "mini-ast" pseudo-language to write unit
tests for the flow analysis and type analysis logic in the
`_fe_analyzer_shared` package, it was possible to call `.pattern` on
any arbitrary expression, creating a constant pattern containing the
expression. This didn't make sense--only constant expressions can be
used as the basis for constant patterns.

With this change, `.pattern` is only available on the various forms of
constant expressions supported by the "mini-ast" pseudo-language
(currently: integer literals, the `null` literal, and placeholder
expressions created using the `expr` function).

Change-Id: I0d87c66bdb8e636615b20bbb6207c38d78d0d2dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315245
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 14:52:26 +00:00
Paul Berry 64ecabdf16 Add function second to flow analysis tests.
In several flow analysis tests we need to model an expression with two
subexpressions, where the type of the overall expression is the same
as the type of the second subexpression.

Previously we did this using `ProtoStatement.thenExpr`, which created
a magic compound expression consisting of an expression (or statement)
followed by a second expression. This was too general, since it
allowed modelling code that would not be possible in Dart.

This CL replaces uses of `ProtoStatement.thenExpr` with a function
`second`, which models a Dart function defined this way:

    T second(dynamic x, T y) => y;

This has two advantages:

- The tests are now modelling code that could actually exist in the
  real world, rather than modelling pseudo-expressions that are not
  actually possible to write in Dart.

- It prepares for a follow-up CL in which I'll be unifying the
  representation of patterns and expressions in the flow analysis
  tests; eliminating `ProtoStatement.thenExpr` will prevent a conflict
  between it and `PossiblyGuardedPattern.thenExpr`.

With this change, two tests had to be deleted, because the conditions
they were testing could no longer be expressed:

- `for_conditionBegin() handles not-yet-seen variables`

- `whileStatement_conditionBegin() handles not-yet-seen variables`

This is ok, because these tests were designed to verify correct
behavior in the circumstance where the client forgets to declare a
variable. This circumstance no longer arises, because the
`_FlowAnalysisImpl` constructor detects undeclared variables and
generates synthetic declarations for them.

Change-Id: I19275ba0b7fa143ce7051bf14d0d4c6f57a4ab8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315244
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 14:43:08 +00:00
Johnni Winther 9cbb27ae8a [cfe] Create builders for extension type declarations
Change-Id: I12251865e0657a6241e9e3ce905df83bda24e260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313566
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 14:39:41 +00:00
Paul Berry bcaab7e985 Make more "mini-ast" constructs into expressions.
The following functions, which are used to create constructs in the
"mini-ast" pseudo-language to write unit tests for shared flow
analysis and type analysis logic, now have a return type of
`Expression` rather than `Statement`:

- checkAssigned
- checkUnassigned
- getSsaNodes
- implicitThis_whyNotPromoted an expression

This allows them to be used either where an expression is exprected or
where a statement is expected, which should give us the ability to
write some tests that are not possible (or very difficult) to write
today.

Change-Id: Ie50e82ad05dc88182b59c99c11ffaac41515ebb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315460
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 13:24:37 +00:00
Jonas Finnemann Jensen c77b7a6eda Add diagnostics for platforms key in pubspec.yaml.
**Context:**
The `platforms` field is used to indicate what platforms are supported
by a given package. It's only relevant when publishing to pub.dev, or
similar package repository. If no `platforms` fields is supplied the
platforms will be detected based on `import` statements, also accounting
for conditional imports. See [pubspec reference][1] for details.

These diagnostics aim to help developers discover a misconfigured
`platforms` fields, which they would otherwise only discover when
publishing to [pub.dev][2].

[1]: https://dart.dev/tools/pub/pubspec#platforms
[2]: https://pub.dev

Change-Id: I7b9ea5e371bb1cce6410d32fe6f38c49bc2ff69e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309661
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-07-21 12:04:19 +00:00
Johnni Winther 5fae2e484b [parser] Add parser support for extension type syntax
Change-Id: I6bf6c118b4daa2bed438f8f406b9aef6aacf439e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313501
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 12:01:10 +00:00
Chloe Stefantsova d3b2b764a1 [cfe] Remove 'value-class' experimental flag
Change-Id: I9bcb9e30732503c9da4e723ded863949f5f0f1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315200
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-21 11:16:24 +00:00
Johnni Winther 46086e908c [cfe] Disallow script tag in part file
In response to https://github.com/dart-lang/sdk/issues/52575

Change-Id: I452575517c378dda3000b8fcbf4f66274b1583a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 11:08:48 +00:00
Ömer Sinan Ağacan 463e251334 [dart2wasm] Optimize some list operations
- Use `array.copy` and `array.fill` when possible.

- Use the Wasm array directly (instead of `[]` and `[]=`) when possible
  to avoid redundant bounds checks.

- `_GrowableList.insert` is rewritten to avoid a redundant write when
  the element is not added to the end.

- Remove redundant bounds checks when calling `Lists.copy`.

Change-Id: I08d96b56201cbb4ff24ca969b7fde8bcc1315e4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315120
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 10:29:46 +00:00
Danny Tuppeny d53070ac75 [analysis_server] Add tests for Windows drive letter encoded colon issue
See https://github.com/dart-lang/sdk/issues/53000

Committing separately to the revert of pathContext.fromUri() so if in future that CL is reverted (to re-land the change), it doesn't remove these tests.

Change-Id: I922e5e770a0c8dfcfc6a1cd41f6734d88c2edf7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 01:53:12 +00:00
Danny Tuppeny be4189f047 [analysis_server] Revert use of pathContext.removeUri from LSP server
pathContext.removeUri does not handle escaped colons in drive letters (`Uri.toFilePath()` does), which VS Code currently sends.

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

Change-Id: Ic500404827a51afe3ffb14985df30fc98ba612f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-20 21:36:43 +00:00
Konstantin Shcheglov d90d50ae84 Use shared mixins _HasAugmentation / _HasAugmentationTarget.
WDYT?

Change-Id: I95f517f3645fce5fc434f8dcf451d6807d3635f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314864
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-20 21:34:21 +00:00
Joshua Litt 63786015f3 [dart2wasm|jscm] Move typed data to JS.
Change-Id: Ic4381818be9fdf3725a7eef8455451447a210b8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313281
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-07-20 20:31:38 +00:00
Sam Rawlins a458bab09a Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT
Fixes https://github.com/dart-lang/sdk/issues/49025

Change-Id: I401093e5b76bcf707060ce022c346e26c6807aa0
Tested: try-bots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303261
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-20 18:33:58 +00:00
pq 15acd7f16a make @useResult checking interpolation expression aware
Fixes: https://github.com/dart-lang/sdk/issues/51543

Change-Id: I10c02e278b303bc177985ff833eb79b6fc714a1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314865
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-07-20 16:01:08 +00:00
Paul Berry 7dc587d344 Simplify handling of switch heads in shared analysis tests.
When using the "mini-ast" pseudo-language to write unit tests for the
flow analysis and type analysis logic in the `_fe_analyzer_shared`
package, it is no longer necessary to use `.switchCase` to turn a
`Pattern` (or a `GuardedPattern`) into a `SwitchHead`; this now
happens automatically. The way this works under the hood is that the
`PossiblyGuardedPattern`, and `SwitchHead` classes implement the
`ProtoSwitchHead` interface; constructs that expect switch heads are
declared with input parameters of type `ProtoSwitchHead`, and they
automatically convert to switch heads when necessary.

Change-Id: Ic16264fc52ffff08bf0e0cc72db064a6da63eda5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315180
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-20 15:20:57 +00:00
Paul Berry ecf71eb63b Simplify handling of collection elements in shared analysis tests.
When using the "mini-ast" pseudo-language to write unit tests for the
flow analysis and type analysis logic in the `_fe_analyzer_shared`
package, it is no longer necessary to use `.asCollectionElement` to
turn an expression into a collection element; this now happens
automatically. The way this works under the hood is that both the
`CollectionElement` and `Expression` classes mix in the
`ProtoCollectionElement` mixin; constructs that expect collection
elements are declared with input parameters of type
`ProtoCollectionElement`, and they automatically convert expressions
to collection elements when necessary.

Also, instead of using `.inContextElementType` to establish the
appropriate context when testing a collection element, the tests not
simply create a `listLiteral` of the appropriate type, containing the
appropriate collection elements. This makes the unit tests much more
similar to the way actual Dart code is written in the wild, and makes
the test infrastructure more closely mirror the way types are analyzed
by the analyzer and CFE.

Change-Id: Ib628ff12caa84254df069308ae3a25061377db29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314141
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-20 13:14:24 +00:00
Johnni Winther 2172993731 [cfe] Add test for issue 52941
Change-Id: I5f40ab64923e6b1612e41fd96e3b92d52e2f79b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314720
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-20 12:08:31 +00:00
Ömer Sinan Ağacan 0f54180b51 [dart2wasm] New typed data implementation
New typed data implementation that optimizes the common cases.

This uses the best possible representation for the fast case with a
representation like:

    class _I32List implements Int32List {
      final WasmIntArray<WasmI32> _data;

      int operator [](int index) {
        // range check
        return _data.read(index);
      }

      void operator []=(int index, int value) {
        // range check
        _data.writeSigned(index, value);
      }

      ...
    }

This gives us the best possible runtime performance in the common cases
of:

- The list is used directly.
- The list is used via a view of the same Wasm element type (e.g. a
  `Uint32List` view of a `Int32List`) and with aligned byte offset.

All other classes (`ByteBuffer`, `ByteData`, and view classes)
implemented to be able to support this representation.

Summary of classes:

- One list class per Dart typed data list, with the matching Wasm array
  as the buffer (as shown in the example above): `_I8List`, `_U8List`,
  `_U8ClampedList`, `_I16List`, `_U16List`, ...

- One list class per Dart typed data list, with mismatching Wasm array
  as the buffer. These classes are used when a view is created from a
  list, and the original list has a Wasm array with different element
  type than the view needs. `_SlowI8List`, `_SlowU8List`, ...

  These classes use `ByteData` interface to update the buffer.

- One list class for each of the classes listed above, for immutable
  views. `_UnmodifiableI32List`, `_UnmodifiableSlowU64List`, ...

  These classes inherit from their modifiable list classes and override
  update methods using a mixin.

- One `ByteData` class for each Wasm array type: `_I8ByteData`,
  `_I16ByteData`,
  ...

- One immutable `ByteData` view for each `ByteData` class.

- One `ByteBuffer` class for each Wasm array type: `_I8ByteBuffer`,
  `_I16ByteBuffer`, ...

- A single `ByteBuffer` class for the immutable view of a byte buffer.

  We don't need one immutable `ByteBuffer` view class per Wasm array
  type as `ByteBuffer` API does not provide direct access to the buffer.

Other optimizations:

- `setRange` now uses `array.copy` when possible, which causes a huge
  performance win in some benchmarks.

- The new implementation is pure Dart and needs no support or special
  cases from the compiler other than the Wasm array type support and
  intrinsics like `array.copy`. As a result this removes a bunch of
  `entry-point` pragmas and significantly reduces code size in some
  cases.

Other changes:

- Patch and implementation files for typed data and SIMD types are split
  into separate files. `typed_data_patch.dart` and `simd_patch.dart` now
  only contains patched factories. Implementation classes are moved to
  `typed_data.dart` and `simd.dart` as libraries `dart:_typed_data` and
  `dart:_simd`.

Benchmark results:

This CL significantly improves common cases. New implementation is only
slower than the current implementation when a view uses a Wasm array
type with incompatible element type (for example, `Uint32List` created
from a `Uint64List`).

These cases can still be improved by overriding the relevant `ByteData`
methods. For example, in the example of `Uint32List` view of a
`Uint64List`, by overriding `_I64ByteData.getUint32` to do a single read
then requested bytes don't cross element boundaries in the Wasm array.
These optimizations are left as future work.

Some sample benchmarks:

vector_math matrix_bench before:

    Binary size: 133,104 bytes.
    MatrixMultiply(RunTime): 201 us.
    SIMDMatrixMultiply(RunTime): 3,608 us.
    VectorTransform(RunTime): 94 us.
    SIMDVectorTransform(RunTime): 833 us.
    setViewMatrix(RunTime): 506 us.
    aabb2Transform(RunTime): 987 us.
    aabb2Rotate(RunTime): 721 us.
    aabb3Transform(RunTime): 1,710 us.
    aabb3Rotate(RunTime): 1,156 us.
    Matrix3.determinant(RunTime): 171 us.
    Matrix3.transform(Vector3)(RunTime): 8,550 us.
    Matrix3.transform(Vector2)(RunTime): 3924 us.
    Matrix3.transposeMultiply(RunTime): 201 us.

vector_math matrix_bench after:

    Binary size: 135,198 bytes.
    MatrixMultiply(RunTime): 42 us.
    SIMDMatrixMultiply(RunTime): 2,068 us.
    VectorTransform(RunTime): 12 us.
    SIMDVectorTransform(RunTime): 272 us.
    setViewMatrix(RunTime): 82 us.
    aabb2Transform(RunTime): 167 us.
    aabb2Rotate(RunTime): 147 us.
    aabb3Transform(RunTime): 194 us.
    aabb3Rotate(RunTime): 199 us.
    Matrix3.determinant(RunTime): 70 us.
    Matrix3.transform(Vector3)(RunTime): 726 us.
    Matrix3.transform(Vector2)(RunTime): 504 us.
    Matrix3.transposeMultiply(RunTime): 53 us.

FluidMotion before:

    Binary size: 121,130 bytes.
    FluidMotion(RunTime): 270,625 us.

FluidMotion after:

    Binary size: 110,674 bytes.
    FluidMotion(RunTime): 71,357 us.

With bound checks omitted (not in this CL), FluidMotion becomes
competitive with `dart2js -O4`:

FluidMotion dart2js -O4:

    FluidMotion(RunTime): 47,813 us.

FluidMotion this CL + boud checks omitted:

    FluidMotion(RunTime): 51,289 us.

Fixes #52710.

Tested: With existing tests.
Change-Id: I33bf5585c3be5d3919a99af857659cf7d9393df0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312907
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-20 09:47:39 +00:00
William Hesse 9692a9dfef Revert "Balance tests equally across shards."
This reverts commit f827eb3a78.

Reason for revert: The tests being run, and the results being compared to, are changing dramatically, causing all sorts of test results going from [status] -> Skipped and from New Test -> [status].

Something is really going wrong.

Original change's description:
> Balance tests equally across shards.
>
> The sharded test runner invocations are now passed the previous results
> which contains the test timing, which are used to simulate how long each
> shard would take to run. The shards are now balanced as evenly as
> possible on a test level, taking multiple cores into account.
>
> Sharded tests are now run starting with the slowest test first, such
> that extremely long running tests finish as early as possible. This
> behavior ensures the cores are saturated and can be padded with fast
> tests near the end, rather than waiting for a few slow tests to complete
> while the rest of the system is idle.
>
> The algorithm works very well whenever it's able to accurately predict
> the time to run shards. In a number of cases, the model doesn't quite
> reflect reality and the data, which makes it fairly imperfect but still
> reasonably good. I think a second order feedback loop might kick in once
> it reorders the tests across shards and the test timing data reflects
> the new test timings.
>
> Multitests are no longer always sent to the same shard, since the data
> isn't available at the moment, and the change as-is speeds up the test
> running considerably.
>
> The front end unit test suites currently ignore the feature as there are
> no benefits yet to improving those quick shards.
>
> Upgrade the language version to 3.0.0 so patterns can be used and fix
> a mixin not being a mixin.
>
> Fixes: b/291585137
> Change-Id: I3cc1b1d96038d5b46e836b091e299097717c226c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314081
> Reviewed-by: William Hesse <whesse@google.com>
> Commit-Queue: Jonas Termansen <sortie@google.com>

Change-Id: I233e4bfa6d6ecf0cea4f97c1e47f1635f7b9040c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315060
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: William Hesse <whesse@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-07-19 23:56:06 +00:00
Mayank Patke b336f3900b [dart2js] Bailout tracing of record fields when record is bailed out
Fixes: #52968
Change-Id: Ie59d4c0f903089622bc260d471bc136fa91eacde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315020
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2023-07-19 23:34:46 +00:00
Konstantin Shcheglov 5494c1ce66 Resolve method invocations, both kinds of property access, to augmentations.
Change-Id: Idc776003154037bcdcba5ba24afd7326e4b7f527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-19 22:20:28 +00:00
pq c4e3e95db2 fix deletion range in remove_non_null_assertion
Fixes: https://github.com/dart-lang/sdk/issues/52913


Change-Id: Ide13776ec15ff706c532b495e8203204afb1c667
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314862
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-19 22:15:12 +00:00
Konstantin Shcheglov 2cac4abcc6 Don't add augmentations of class / mixin to export scope.
Change-Id: I4c75ea3347bbbeee4bed17f0530dd75b72aace2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314940
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-19 19:53:34 +00:00
Konstantin Shcheglov 688fdb086d Support for property accessors in augmentations.
Change-Id: I06e68030f3f1c0b9cb86df2abd7ba9b90d93f5e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314585
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-19 19:49:51 +00:00
Joshua Litt 5016361ccd [dart2wasm] Refactor core.dart to make it easier to patch.
Now that we no longer need to put boxes in `core.dart`, it makes sense to move them out of `core.dart` so that we can patch these classes and their helper functions. This CL moves `BoxedInt` and `BoxedDouble` out of core patch, and moves some of their intrinsics / helpers to side libraries.

Tested: Dart2Wasm internal refactor of patch files.
Change-Id: I1dac95089a8bd9e2c8ee4f467a0d6f2792f9d665
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313900
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-07-19 17:05:36 +00:00
pq 04aa5727be update make_class_abstract correction to handle class modifiers
Fixes: https://github.com/dart-lang/sdk/issues/52948

Change-Id: I3ceae27555b6b1904c01753a432a89314a183c21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314583
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-07-19 16:36:19 +00:00
Konstantin Shcheglov 81b64fc273 Resolve 'this' in class / mixin augmentations. Resolve method invocations to augmentations.
Note, that resolving against implicit 'this' is not implemented yet.
The instance scope is not correct yet.

Change-Id: I71ea51f82c5fa0a19ea77593df19be29189782fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-19 15:42:46 +00:00
eliasyishak d662bf77aa Bumping revision + adding method to analytics mock
Change-Id: Iec426ca68089893aca4f59fe29bef7d28074627c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314560
Commit-Queue: Elias Yishak <eliasyishak@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-19 15:36:49 +00:00
Jake Macdonald 1b99100e2e Add API for resolving any identifier in the final macro phase.
- Rename declarationOf to typeDeclarationOf.
- Add declarationOf api for general declarations.
- Tighten the type of typeDeclarationOf in the final phase to avoid unnecessary
  casts in user code.
- Refactor message handling a bit to unify the error handling.

Bug: https://github.com/dart-lang/language/issues/3216
Change-Id: Ia61da19374abec77853d37e110a08f7dfe0d3b10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314280
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-07-19 13:56:08 +00:00
Johnni Winther 4893acd579 [_fe_analyzer_shared] Add test for issue 52908
Change-Id: I6e1559832107a5d422731664ab309da5575e37be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314400
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-19 13:54:10 +00:00
Jonas Termansen f827eb3a78 Balance tests equally across shards.
The sharded test runner invocations are now passed the previous results
which contains the test timing, which are used to simulate how long each
shard would take to run. The shards are now balanced as evenly as
possible on a test level, taking multiple cores into account.

Sharded tests are now run starting with the slowest test first, such
that extremely long running tests finish as early as possible. This
behavior ensures the cores are saturated and can be padded with fast
tests near the end, rather than waiting for a few slow tests to complete
while the rest of the system is idle.

The algorithm works very well whenever it's able to accurately predict
the time to run shards. In a number of cases, the model doesn't quite
reflect reality and the data, which makes it fairly imperfect but still
reasonably good. I think a second order feedback loop might kick in once
it reorders the tests across shards and the test timing data reflects
the new test timings.

Multitests are no longer always sent to the same shard, since the data
isn't available at the moment, and the change as-is speeds up the test
running considerably.

The front end unit test suites currently ignore the feature as there are
no benefits yet to improving those quick shards.

Upgrade the language version to 3.0.0 so patterns can be used and fix
a mixin not being a mixin.

Fixes: b/291585137
Change-Id: I3cc1b1d96038d5b46e836b091e299097717c226c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314081
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
2023-07-19 12:24:38 +00:00
Paul Berry a746b64aa7 Front end: remove unnecessary call to FlowAnalysis.propertyGet.
It is not necessary for `InferenceVisitorImpl.visitPropertyGet` to
call `FlowAnalysis.propertyGet` directly, because it already calls
`_computePropertyGet`, which calls `FlowAnalysis.propertyGet`.

Change-Id: I806337ff24bc237ef0e2a42af7357a70d6df7f4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313901
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-19 12:15:08 +00:00
Paul Berry 8dec57b546 Use shared logic for computing which fields are promotable.
This change replaces the CFE logic for deciding which fields are
promotable, so that it now makes use of the shared infrastructure in
`pkg/_fe_analyzer_shared`.

Since the shared logic doesn't depend on the CFE having already
computed `noSuchMethod` forwarders, it can be placed earlier in the
compilation pipeline, before top level type inference. As a result,
field promotion during top level type inference now works properly.

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

Change-Id: I451aa112a0af114a9c88dd64ebb8f199f6f6589e
Bug: https://github.com/dart-lang/sdk/issues/50522
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313860
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-19 12:14:47 +00:00
Anna Gringauze ab933fe9e5 [ddc tests] Fix expression compilation tests timeouts on JS exceptions
Fix timeout in expression compiler tests

Closes: https://github.com/dart-lang/sdk/issues/51740
Change-Id: I8fd2a321450b4a10235c97af640714a93c805f85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314620
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-07-18 23:35:07 +00:00
Marya Belanger eae32a7e92 Fix link and missing new line in generate.dart
Added a new line to _writeGlossary before the contents, because otherwise it was generating in the line directly below the contents of _writeHeader, and therefore not rendering properly. I also updated the link to [Customizing static analysis] as that changed recently and I've had to manually update it in the site-www doc version a couple times now.

Change-Id: I8c5d3d9adcc0004fc8d84d11935860617e7c2bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314520
Commit-Queue: Marya Belanger <mbelanger@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-18 22:47:01 +00:00
Joshua Litt 9e37c2b480 [dart2wasm] Add JS compatibility mode.
The purpose of the wasm_js_compatibility target is to facilitate experiments with a JS compatibility mode for Dart2Wasm. Initially, we're just going to focus on typed data, but this will give us a place to experiment with moving List and String to JS as well.

In addition, someday down the road we hope to experiment with two additional compatibility changes:
1) Exclusively using double for all Dart numbers
2) Allowing undefined to flow as null.

The two major benefits of this approach are:
1) Much faster JS interop
2) To make it easier to bring up Dart2JS applications on Dart2Wasm

The only downside will be access overhead on the Wasm side, but the JS builtins proposal could potentially bring us close to parity with Wasm builtins someday.

Tested: Wasm specific trivial refactor.
Change-Id: I2c09426b6999507c1de6e584e9bc7072a088bda9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313240
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2023-07-18 19:34:38 +00:00
Paul Berry 130d6199c3 Field promotion: make the core promotability algorithm sharable; fix bugs
In the following code, it's not safe for the field `C._f` to undergo
type promotion, because a variable with static type `C` might have
type `D` at runtime, in which case `C._f` will get dispatched to
`noSuchMethod`, which is not guaranteed to return a stable result.

    class C {
      final int? _f;
    }
    class D implements C {
      noSuchMethod(_) => ...;
    }
    foo(C c) {
      if (c._f != null) {
        print(c._f + 1); // UNSAFE!
      }
    }

Therefore, in order to determine which fields are promotable, the
implementations need to analyze enough of the class hierarchy to
figure out which field accesses might get dispatched to
`noSuchMethod`.

Currently, the CFE does this by following its usual algorithm for
generating `noSuchMethod` forwarders before trying to determine which
fields are promotable. The analyzer, on the other hand, doesn't have
an algorithm for generating `noSuchMethod` forwarders (since it
doesn't implement execution semantics); so instead it has its own
logic to figure out when a `noSuchMethod` forwarder is needed for a
field, and disable promotion for that field.

But there's a chicken-and-egg problem in the CFE: the CFE needs to
determine which fields are promotable before doing top-level inference
(since the initializers of top-level fields might make use of field
promotion, affecting their inferred types--see #50522). But it doesn't
decide where `noSuchMethod` forwarders are needed until after
top-level inference (because the same phase that generates
`noSuchMethod` forwarders also generates forwarders that do runtime
covariant type-checking, and so it has to run after all top level
types have been inferred).

To fix the chicken-and-egg problem, I plan to rework the CFE so that
it uses the same algorithm as the analyzer to determine which fields
are promotable. This CL makes a first step towards that goal, by
reworking the analyzer's field promotability algorithm into a form
where it can be shared with the CFE, and moving it to
`package:_fe_analyzer_shared`.  Since this required a fairly
substantial rewrite, I went ahead and fixed #52938 in the process.

Fixes #52938.

Change-Id: I9e68f51b3ea9a967f55f15bdc445cc1c0efdabdd
Bug: https://github.com/dart-lang/sdk/issues/52938
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313293
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-18 18:54:26 +00:00
Konstantin Shcheglov 6b4337ab69 Inheritance inference for methods in augmentations, and using combined interfaces for classes and mixins.
Change-Id: I27af575219ab1e3bfba3f894ebc83e0806f7f968
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-18 18:51:27 +00:00
Konstantin Shcheglov f06a1d58d8 Inference of mixin type arguments in augmentations.
Change-Id: I3f3cb93a3df23fca6e2c764e387f910290bb9eda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314301
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-18 15:30:47 +00:00
Johnni Winther 33fcaec0f1 [cfe] Handle exhaustiveness checking in expression evaluation
The expression evaluator called directly into the constant evaluator,
skipping the setting up of the exhaustiveness cache used for
exhaustiveness checking.

Closes #52905

Change-Id: I367ff73d8e23127811f99dfbf451e66eef452443
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314060
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-18 10:17:49 +00:00
Brian Wilkerson 06be97c607 Capture the agreed on style for import prefix names
Change-Id: I6eba4a7e37a72677c58d219892cd2e4c74560356
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314220
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-18 04:09:58 +00:00
Marya Belanger 6b1c969ac5 Update glossary links and remove content from generated page.
I added the entries to dart.dev/resources/glossary in site-www/#5066.
I was only able to test whether the links worked by putting them in the same place in the diagnostics markdown on site-www, which worked. So, I think the way I did it in generate.dart should work but if anyone knows otherwise please let me know!

There were also a couple small changes from my last CL on the diagnostic messages that I didn't get in before merging, so those are in here too (https://dart-review.googlesource.com/c/sdk/+/309780).

Change-Id: Ie5561fa72c7f99f5c86d2112294edccee41d4544
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Marya Belanger <mbelanger@google.com>
2023-07-17 21:22:42 +00:00
Srujan Gaddam 18b7dd771b Reland "[dart:js_interop] Remove Object.toJS and JSNumber.toDart"
This is a reland of commit 16fcfe7eae

Original change's description:
> [dart:js_interop] Remove Object.toJS and JSNumber.toDart
>
> Modifies JSBoxedDartObject reified type on JS backends and also
> modifies JSBoxedDartObject.toDart now that a proper box is introduced.
> Also uses a JS symbol in JSBoxedDartObject.toDart for a property
> check so that different Dart apps don't accidentally share Dart
> objects. It's now an error to call this function on non-boxed objects.
>
> Fixes a type issue where creating a new object literal with the JS
> foreign function was resulting in dart2js thinking toJSBox would
> always throw. Changing the typeDescription to PlainJavaScriptObject
> instead of =Object fixes that issue.
>
> CoreLibraryReviewExempt: Backend-specific library.
> Change-Id: I5cfb1f32ff4328fafdf9831b0d8da806c39391d9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309082
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

CoreLibraryReviewExempt: Reland.
Change-Id: If6b190f12bdf840b0259c5739f50d9bdcd27fd47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313600
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-07-17 21:16:07 +00:00
Konstantin Shcheglov 87c49d9848 Use 'augmented' for ClassHierarchy.
Change-Id: Id4b9fb27990dd02f4c1d94faf11c6e25f056a5a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313221
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-17 21:12:49 +00:00
William Hesse 416b43faaa [infra] Fix handling of deflaking a list of tests
An error was introduced by
https://dart-review.googlesource.com/c/sdk/+/313567
when the --default-suites flag is used along with a
list of tests to deflake. The suites in the list of tests
should be the only suites used as selectors, and should
replace any other input selectors.

Bug: b/290617138
Change-Id: Ic43c1409df621bbaf852276fbaa16ce4961a9549
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314061
Auto-Submit: William Hesse <whesse@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-07-17 19:11:00 +00:00
Jake Macdonald c5bd32bac2 Major refactor to simplify the macro introspection interfaces.
Each phase now only has a single interface, instead of several of them. This
reduces the number of classes dramatically and also reduces the number of
objects actually sent over the wire.

It also means fewer things to name and a less polluted namespace.

Change-Id: Ib84b76ac4c0a04abfac5fd5650a228046b1bf1d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313721
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-07-17 17:28:35 +00:00
Konstantin Shcheglov 57ac271bf1 Verify that 'utf8.encode()' is not used in the analyzer.
To be removed after Dart SDK 3.1 is published, and the analyzer
SDK constraints updated.

See
https://dart-review.googlesource.com/c/sdk/+/254903

Change-Id: I2c3321d991cd3e123f08c5a360487362be16f258
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-17 17:28:31 +00:00
Konstantin Shcheglov ed776ebbc6 Simplify class and element hierarchy around augmentations.
Change-Id: If03fdad6891581a75cedaab8171c4626c9211ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314001
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-17 16:56:41 +00:00
Ömer Sinan Ağacan 1d8dde36e1 [dart2wasm] Add array.copy instruction and intrinsics
`array.copy` is used in [1] in `setRange` when source and destinations
are both typed arrays with the same Wasm array type.

[1]: https://dart-review.googlesource.com/c/sdk/+/312907

Change-Id: Iaeecea43c22805eca64b7d98751a52e607210a70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314080
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-17 16:51:25 +00:00
Danny Tuppeny ea790e901c [analysis_server]/[analyzer] Change package_path alias -> path
Change-Id: Ia4848e6b87433401be95a4e74c7681a1c983c12f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313568
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-17 16:48:36 +00:00
Ben Konyi d3e5252c01 [ DDS ] Update changelog
Change-Id: I079ee42634988d15b6e042fc67df26602fae8761
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314120
Reviewed-by: Derek Xu <derekx@google.com>
2023-07-17 15:33:50 +00:00
Derek Xu 4083853fd0 [package:vm_service] Prepare to publish v11.8.0
Change-Id: I1f3eb5ff1177ff020a053e76637e58a1c48dbbe6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313643
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-17 15:01:21 +00:00
Derek Xu 24e65bee37 [VM/Service] Add isGetter and isSetter properties to @Function and Function
TEST=pkg/vm_service/test/get_object_rpc_test.dart and
vm/cc/PrintJSONPrimitives

Fixes: https://github.com/dart-lang/sdk/issues/52920
Change-Id: Id3786e48c8827911e7c49af6ab2f0bf0cd97279f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313642
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-17 15:01:21 +00:00
Derek Xu ce5210bac9 [package:vm_service] Make generator generate abstract classes for enums in service.md
Change-Id: Idd7542daadcecdd8f71eebafdae3a8e7eecb7e9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313641
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-17 15:01:21 +00:00
Danny Tuppeny 98b63e1dcf [dds/dap] Fix ConcurrentModificationError when sending breakpoints
See https://github.com/dart-lang/sdk/issues/52932.

Change-Id: Iebfc335a44e3a8767341f678cf8af1627c21e50a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313782
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-07-17 14:35:57 +00:00
Paul Berry 53ead360bb Flow analysis: Test that functionExpression_begin() preserves promotions of initialized vars.
While working on some other changes to flow analysis, I discovered
that this particular behaviour wasn't unit tested.

Change-Id: Ia9b27672c62177ffed80d4143f33c5b764ac7bbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313242
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-16 13:11:17 +00:00
Danny Tuppeny 760c719b97 [analysis_server] Fix missing-drive-letter test on Windows
My previous CL changed too much... This test specifically didn't want a valid absolute path on Windows, it wanted one without the drive letter.

Change-Id: If0812517e506f9960bca7ac99dd713be087b9ad9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314020
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-16 02:45:00 +00:00
Nate Biggs acd2ad41b6 [dart2js] Union old and new type when refining in type inference.
This change doesn't seem to have a significant impact on most compilation results:
- Golem results show no significant difference in microbenchmarks.
- For a medium and large app tested, while we see a small change in the actual inference results, the generated code is identical before/after this change.
- Timing and memory usage on internal compilations seem comparable before/after this change.

Note: This replaces the need for any notion of "invalid" refines so I will clean up that code in a follow up change.

Change-Id: I2a293eacd944fc17ee2dab97d3d947c042b4038f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313720
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-07-14 20:46:17 +00:00
eliasyishak 34f0e26d45 Swapping NoopAnalytics for noop from package:unified_analytics
Change-Id: I3419a128830ae434fa37bd10a1fc8a3da146fd89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Elias Yishak <eliasyishak@google.com>
2023-07-14 19:15:20 +00:00
Paul Berry 6233cede64 Simplify the "mini-ast" for shared flow analysis and type analysis tests.
When using the "mini-ast" pseudo-language to write unit tests for the
flow analysis and type analysis logic in the `_fe_analyzer_shared`, it
is no longer necessary to use `.stmt` to turn an expression into an
expression statement; this now happens automatically. The way this
works under the hood is that both the `Statement` and `Expression`
classes mix in the `ProtoStatement` mixin; constructs that expect
statements are declared with input parameters of type
`ProtoStatement`, and they automatically convert expressions to
statements when necessary.

Also, the functions `checkNotPromoted`, `checkPromoted`,
`checkReachable`, `localFunction` now have a return type of
`Expression` rather than `Statement`. This allows them to be used
either where an expression is exprected or where a statement is
expected, which should give us the ability to write some tests that
are not possible (or very difficult) to write today.

Change-Id: I9f7ad5b15bcf8ccfccafc6985e0163b550c5ad1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313680
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-14 19:03:47 +00:00
Konstantin Shcheglov d4a70c8423 Support for always-false IfStatement(s) in RemoveComparison.
Change-Id: I14a8dedd6770081fc7fe9ee5c4e53c28e029ac3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-14 18:39:33 +00:00
Konstantin Shcheglov d1a75901c4 Link augmented methods and augmentations, fill 'augmented.methods'
Change-Id: Ic7e979c46fc646e436bafa18b5c5b01622ab209b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313544
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-14 18:32:10 +00:00
Marya Belanger 7918525a6b Writing review 3.0 diagnostics
Minor changes to last few 3.0 diagnostic message changes (late follow up). Mostly just a practice CL for me, after setting my sdk environment up for the first time.

Fixes https://github.com/dart-lang/site-www/issues/4740

Change-Id: I8f6871a270089627538928dd95bcbf38a29b74e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Marya Belanger <mbelanger@google.com>
2023-07-14 18:31:31 +00:00
Danny Tuppeny 77799f6d6c [analysis_server] Use current path context for path<->uri conversions
This allows changing the in-process tests to use Windows-style paths on macOS for convenience.

Change-Id: I0e85a4f8e831471925b8308ad348f75b6867a53b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313385
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-14 17:30:30 +00:00
Jonas Termansen f9b8917e30 Balance VM JIT and AOT shards.
Add test.py --default-suites that includes all the default suites in
addition to the ones explicitly requested, so the test matrix can run
co19 together with the default suites in one sharded test step.

Bug: b/290617138
Change-Id: I5dd5d1aaf3b1ee38adf88c6e9ee6ec13d97fe1ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313567
Reviewed-by: William Hesse <whesse@google.com>
2023-07-14 16:01:09 +00:00
Jake Macdonald 4f8061da63 Add MetadataAnnotation class and metadata fields to relevant objects
Bug: https://github.com/dart-lang/language/issues/1930
Change-Id: I3ba6facd4c0487b0af18108c8d1db21ee6d5a498
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313640
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-07-14 15:55:20 +00:00
Jonas Termansen 26a94439c6 Balance dart2js-unit-linux-x64-release shards.
The non-sharded tests takes 10 minutes and each of the sharded tests
takes 14 minutes. It's faster to shard immediately (costing one bot
more) and concurrently run the local tests.

Fix end to end dart2js test that times out when sharded and run outside
a directory called sdk.

Bug: b/290617138
Change-Id: If71f0d301edf565c9f15847098320106ca383635
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312983
Reviewed-by: William Hesse <whesse@google.com>
2023-07-14 15:38:29 +00:00
Chloe Stefantsova 7a232bb3e2 [cfe] Preserve the required flag in synthesized mixin constructors
Closes https://github.com/dart-lang/sdk/issues/52872

Change-Id: I9089683f4fb2027211c96ad2065044c8181a282f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313781
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-07-14 11:33:45 +00:00
Martin Kustermann 8d802dd78a [vm] Avoid embedding sources in CFE compilations if we AppJit
Creation of AppJit snapshot will not include the source of [Script]
objects (see `UntaggedScript::snapshot_to`). As a result there's no
point in letting the CFE embed the sources into the kernel if we
only use it to create an AppJit snapshot.

This is also in line with build rules for our dart-sdk, where we do the
kernel compilation separately, see utils/application_snapshot.gni:

```
  template("application_snapshot") {
    ...
    # Build the kernel file using the prebuilt VM to speed up the
    # debug and simulator builds.
    prebuilt_dart_action(target_name + "_dill") {
      ...

      args = [
        ...
        "--no-embed-sources",
        ...
      ]
      [[[
    }
    ...
  }
```

TEST=ci

Change-Id: I4e17e49dc21af6102d62c2278dbd6ebbe387f7e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313560
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-14 09:47:38 +00:00
Nate Biggs 25a1d01084 [dart2js] Remove need for individual closures in Deferrable serialized data.
This new approach uses static tear-offs where possible to avoid allocating a new Closure for each Deferrable.

Note: This doesn't scale to every case but as of today the one case not covered is a singleton and so only 1 closure should be allocated there regardless.

Data from a fairly large app:
Before:
Total => 3.8GB
Closures => 85.6MB
Closure Context => 71.0MB

After:
Total => 3.7GB
Closures => 28.9MB
Closure Context => 49.8MB

Diff:
Closures => 56.7MB
Closure Context => 21.2MB

Change-Id: If233f958df2822708b51c0d14c7439b5d3a5a07b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313340
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-07-14 01:29:36 +00:00
Sigmund Cherem 72f1c288bc [dart2js] Bailout tracing when hitting return values of async members.
When tracing closures, we accidentally ignored the fact that returning from a non-async
function allows the value to flow in other ways (e.g. through the completion of a future).

This changes the node tracer to always consider the async marker when looking at values
that flow into 'MemberInformation' information nodes, which are the nodes we use
to represent the returned value of a method.

Fixes #52825

Change-Id: I3322e105dc9612f47a516a17f9465bf1002a9f87
Fixed: 52825
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312708
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2023-07-14 00:24:07 +00:00
Sam Rawlins d3233115c8 Bump linter to aed089e45c35221ce2b82f3757132031f0344b8b
Sync compare URI implementation with linter

Change-Id: I23e14459ac55fef4cec1c0c41341fe6f51b781b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313285
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Oleh Prypin <oprypin@google.com>
2023-07-13 23:43:40 +00:00
Srujan Gaddam 2767fca6fe Revert "[dart:js_interop] Remove Object.toJS and JSNumber.toDart"
This reverts commit 16fcfe7eae.

Reason for revert: Flutter changes haven't landed to google3 yet.

Original change's description:
> [dart:js_interop] Remove Object.toJS and JSNumber.toDart
>
> Modifies JSBoxedDartObject reified type on JS backends and also
> modifies JSBoxedDartObject.toDart now that a proper box is introduced.
> Also uses a JS symbol in JSBoxedDartObject.toDart for a property
> check so that different Dart apps don't accidentally share Dart
> objects. It's now an error to call this function on non-boxed objects.
>
> Fixes a type issue where creating a new object literal with the JS
> foreign function was resulting in dart2js thinking toJSBox would
> always throw. Changing the typeDescription to PlainJavaScriptObject
> instead of =Object fixes that issue.
>
> CoreLibraryReviewExempt: Backend-specific library.
> Change-Id: I5cfb1f32ff4328fafdf9831b0d8da806c39391d9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309082
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

Change-Id: I469ad04db7b49ffef47a46ccac97e909e4865719
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313580
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-07-13 21:06:05 +00:00
Srujan Gaddam 16fcfe7eae [dart:js_interop] Remove Object.toJS and JSNumber.toDart
Modifies JSBoxedDartObject reified type on JS backends and also
modifies JSBoxedDartObject.toDart now that a proper box is introduced.
Also uses a JS symbol in JSBoxedDartObject.toDart for a property
check so that different Dart apps don't accidentally share Dart
objects. It's now an error to call this function on non-boxed objects.

Fixes a type issue where creating a new object literal with the JS
foreign function was resulting in dart2js thinking toJSBox would
always throw. Changing the typeDescription to PlainJavaScriptObject
instead of =Object fixes that issue.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I5cfb1f32ff4328fafdf9831b0d8da806c39391d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309082
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-07-13 20:38:11 +00:00
Konstantin Shcheglov 1cf1cf3215 Issue 52918. Report -TYPE_PARAMETER_REFERENCED_BY_STATIC for extension.
Bug: https://github.com/dart-lang/sdk/issues/52918
Change-Id: I2c21239c34bf852a1770296491f30d81dd5eb66c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313520
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-13 17:53:38 +00:00
Konstantin Shcheglov b4cdba66e2 Remove support for getters that are instances of macros.
https://github.com/dart-lang/language/issues/1890#issuecomment-1625587927
https://github.com/dart-lang/language/pull/3205

Change-Id: I20a181a01eab4fef9a8bf6e568745eb2b8e86d6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312881
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-13 17:32:49 +00:00
Sam Rawlins dea256c9fc Mark private classes which are annotated with @JS as used
Work towards https://github.com/dart-lang/sdk/issues/52835

Change-Id: I300928dbfcfd819e4a9f20030cb46e2048f504e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313287
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-13 16:06:12 +00:00
Danny Tuppeny 4d34d7aa24 [analysis_server] Remove unused parameters and related TODOs
Change-Id: I5b3fac0efa23c9e535635651a8e8b09398770a40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313504
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-13 15:57:47 +00:00
Joshua Litt 465d35fac9 [dart2wasm|js] Add support for JS backed subtypes of 64 bit typed data.
Change-Id: I534e946ffdfa6708af0c0ffdecb345adbc9561aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313286
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-07-13 15:29:37 +00:00
Daco Harkes a08e829ff2 [tool] Bisection tool
A basic bisection script.

Currently only supports substring matching for detecting the error.
This was enough for three use cases today:

* https://github.com/dart-lang/sdk/issues/52910
* https://github.com/dart-lang/sdk/issues/52911
* https://github.com/dart-lang/sdk/issues/52912

Produces a concise output on standard out, and a very detailed log
with all process invocation results in `.dart_tool/bisect_dart`.

Usage: tools/bisect.dart -Dstart=23f41452 -Dend=2c97bd78 -Dtest_command="tools/test.py --build -n dartk-linux-debug-x64 lib_2/isolate/package_resolve_test" -Dfailure_string="Error: The argument type 'String' can't be assigned to the parameter type 'Uri'." -Dsdk_path=/usr/local/google/home/dacoharkes/dart-sdk/sdk/ -Dname=20230712_package_resolve_test

This script starts a bisection in the provided SDK path.

It will write logs to .dart_tool/bisect_dart/.

start          : The commit has at the start of the commit range.
end            : The commit has at the end of the commit range.
test_command   : The invocation of test.py.
                 This should include `--build`.
                 This should be within quotes when passed in terminal because of spaces.
failure_string : A string from the failing output.
                 Regexes are not yet supported.
                 This should be within quotes when passed in terminal when containing spaces.
sdk_path       : The SDK path is optional.
                 The SDK path defaults to the current working directory.
name           : The name is optional.
                 The name defaults to the current date and the recognized test name.
                 The name is used for distinguishing logs.

Change-Id: Ib071a5305d4992cf189e35eb3dcc50c83101503e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313384
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-07-13 13:22:26 +00:00
Johnni Winther 6d56a75dca [cfe] Ensure default value on super parameter tear-off
Closes #52763

Change-Id: I765c80d9889315a32832e0f881dba1fc41400fad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313124
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-13 08:05:50 +00:00
Konstantin Shcheglov 150587d2b5 Merge MethodElement(s) into augmented.
Change-Id: I4965554d33f4345053c2b5abc05ba463a362b641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313301
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-13 05:11:57 +00:00
Samuel Rawlins e718a97882 Revert "Tweaks for mixin inference."
This reverts commit fb9d0e6dc3.

Reason for revert: Performance regression https://github.com/dart-lang/sdk/issues/52922

Original change's description:
> 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>

Change-Id: I33098d8509319e9d6e62d7f5174cae2c05977436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313440
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-12 22:20:27 +00:00
Kallen Tu c7187d3150 [analyzer] Consolidate more helpers in evaluation_test.
Added helpers `_field` and `_localVar` to allow tests to test their final fields and local const variables in the const tests.

The rest of the CL moves away from `_evaluateConstant` helpers (to avoid recomputing constants), to `_topLevelVar` or equivalent helpers which grabs the existing evaluation result.

This CL adds to the goal making all constant tests consistent and to avoid unnecessary const computations in the tests.

Change-Id: I508483714a51e5d060286256657ae460b65787c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312889
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-12 20:02:11 +00:00
Ryan Macnak 3daa47b54e [test_runner] Don't assign all vm/cc tests to the first shard.
Before:
./tools/test.py --shards=10 --shard=1 --list | wc -l  # 3664
./tools/test.py --shards=10 --shard=2 --list | wc -l  # 1047
./tools/test.py --shards=10 --shard=3 --list | wc -l  # 1146

After:
./tools/test.py --shards=10 --shard=1 --list | wc -l  # 1408
./tools/test.py --shards=10 --shard=2 --list | wc -l  # 1306
./tools/test.py --shards=10 --shard=3 --list | wc -l  # 1381

Change-Id: I2107779e79d85976c04db7c01c11581a8d9895b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313280
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-12 17:56:59 +00:00
Daco Harkes 70c186dc37 [gardening][pkg] Fix test expects
The Memory column is right aligned, and we can have large memory values.

`'|  Memory |    CPU | Elapsed time | ...`

Closes: https://github.com/dart-lang/sdk/issues/52915
Change-Id: I47c836ca85109bfa99e293c5c955c416c0f4067d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313382
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-07-12 16:04:38 +00:00
Nate Biggs 64fe77f8db [dart2js] Revert invalid refinement change.
A user found another case where this fails (b/290868787).

In this case a ForwardingTypeMask is delegating the subtyping checks to its `forwardTo` mask which ends up saying the masks are equal even though the wrapper around the forwarded masks means they are not equal.

Change-Id: I015f2faf57557ff4189acb6c7144d09cf1ae6bb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313341
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-07-12 15:56:09 +00:00
Danny Tuppeny d718ab5f08 [analysis_server] Extract LSP request helpers to allow reuse in LSP-over-Legacy tests
The mixin `LspAnalysisServerTestMixin` contains a lot of helpers for interacting with the LSP server in tests and is used by both the in-process tests and the out-of-process integration tests.

We now have a third category of LSP tests that would benefit from many of these helpers (such as "getHover()") but are not talking to a native LSP server.

This change splits those helpers out into `LspRequestHelpersMixin` which contains only the request helpers without any code assuming a native LSP server, so they can be used by LSP-over-Legacy tests.

All code in `request_helpers_mixin.dart` was lifted directly from `server_abstract.dart` with no changes.

It also adds a test that error responses in LSP-over-Legacy are handled appropriately.

Change-Id: I847855a5314b5b04d700c6400b67e76e5f0d3402
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313362
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-12 15:30:15 +00:00
Danny Tuppeny c4105d35db [dds/dap] Support translating VM Instance IDs -> DAP variablesReferences and back for DAP-over-DDS
This adds two custom requests to the DAP-over-DDS handler to translate between VM/DAP instance IDs:

- $/createVariableForInstance (String isolateId, String instanceId)
- $/getVariablesInstanceId (int variablesReference)

Because DAP's variables request only fetches _child_ variables (eg. fields) but we'd likely want to align the top-level string display of a variable, the wrapped variable will first be returned as a single variable named "value", which contains both the string display value and also a variablesReference to then get the child variables (usually invoked when expanded).

These methods currently live directly in the DDS DAP adapter since I figure they're only useful for clients using the VM Service, but we can move them to the base adapter if in future this turns out to not be the case.

Change-Id: I60f28edd86c3468cc592175cb665557a1fc85056
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312987
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-12 15:04:20 +00:00
Paul Berry 3ae6793469 Flow analysis: remove redundant assertion from constructor.
The assertion in the `_FlowAnalysisImpl` constructor was unnecessary
because it was checking that all variables that are reported to
`AssignedVariables` as read or written must also be reported as
declared. This is already checked by assertions in
`AssignedVariables.finish`, which is called by the `_FlowAnalysisImpl`
constructor.

I've added tests to `assigned_variables_test.dart` to confirm that
these assertions work, and I've also cleaned up the assertions a bit,
eliminating some redundancy and ensuring that in the event of a
failure the assertion failure message will be comprehensible.

Change-Id: Ife827c91d944707f093f4cb8421385f5355d11fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313140
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-11 21:03:29 +00:00
Daco Harkes b64ef27dec [pkg/ffi] Roll dart-lang/native
Rolling https://github.com/dart-lang/native/pull/87 manually because
of the c_compiler -> native_toolchain_c rename.

Change-Id: I2592882a7137a40703f96a487a66d31eac7c990d
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/+/313200
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2023-07-11 19:14:48 +00:00
Konstantin Shcheglov c54b4bc5d3 Push class modifiers up to ClassOrAugmentationElement.
Change-Id: If99d9e29ec8ca87677a58cd90a68a5dda5c5af9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313183
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-11 18:45:20 +00:00
Derek Xu f5080bedb3 [VM/Debugger] Fix behaviour of ActivationFrame::EvaluateCompiledExpression when paused inside a closure
TEST=pkg/vm_service/test/evaluate_inside_closures_test.dart, pkg tryjob

Fixes: https://github.com/dart-lang/sdk/issues/52430
Change-Id: I72b755d31614c7c56c504130656c3668d8b7e72b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313001
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-11 18:41:04 +00:00
Konstantin Shcheglov 3e80d29fd6 Use AugmentationExecutableElement, AugmentationMethodElement.
These become a single property of ExecutableElement, MethodElement.
No new visitors, no new nodes and elements.

Change-Id: Ic523e9d51356e5a8d2a6cd62cd508344f561ffb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312960
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-11 16:19:09 +00:00
Danny Tuppeny 80a6670d5d [dds/dap] Add some basic global evaluation support
This provides support for basic global evaluation matching the legacy DAPs. The first available thread is used (because there's currently no way for the user to select a thread) and we look up a library from a file URI provided in the `context` field.

In future I hope there's a standard DAP way of getting a file from the client (see https://github.com/microsoft/vscode/issues/134452).

See https://github.com/dart-lang/sdk/issues/52574
See https://github.com/Dart-Code/Dart-Code/issues/4636

Change-Id: I7bfa466001142e7e39ebb270ce65f4746a9affcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312980
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-11 15:12:41 +00:00
Johnni Winther 0d47ba6890 [_fe_analyzer_shared] Remove RecordStaticType.isSubtypeOfInternal
This method caused invalid exhaustiveness checking by seeing
record types as related based solely on the structure.

The original purpose of the methods has been removed in the mean time
by the change to restrict the created spaces by the matched value
type.

Closes #52800

Change-Id: I8fb581374a4813dc63261d9e1354c4eea94f212c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312982
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-07-11 12:19:39 +00:00
Martin Kustermann 81df36216f Make utf8.encode() have Uint8List return type
Right now `utf8.encode()` has a static return type of `List<int>`
due to extending `Encoding` (which extends `Codec<String, List<int>>`).

We cannot easily change `Encoding` to extend `Codec<String, Uint8List>`
because that would also change `utf8.decode()` to require `Uint8List`
which would be a breaking change.

So instead we override `utf8.encode()` to have more precise return type.

Some parts of our SDK are run using the checked-in SDK, so it cannot
rely on the changed return type yet (until checked-in SDK is rolled).

So we use `const Utf8Encoder().convert()` as a temporary change, as
that already has `Uint8List` return type.

Issue https://github.com/dart-lang/sdk/issues/52801

TEST=ci

CoreLibraryReviewExempt: More precise return type for existing API
Change-Id: I2861d1f0eb3d292d8e3ec8437c0d441a2d2bd193
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254903
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-07-11 08:54:33 +00:00
Daco Harkes e1c12b3ab2 [cfe/ffi] Fix Finalizable non-nullable variables
TEST=pkg/vm/test/transformations/ffi_test.dart
TEST=pkg/vm/testcases/transformations/ffi/regress_52596.dart
Contains
`throw "Attempt to execute code removed by Dart AOT compiler (TFA)";`
without the fix.

Closes:https://github.com/dart-lang/sdk/issues/52596
Change-Id: I5de819afcf6f70be037b60432ea016bc281b742e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312909
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2023-07-11 07:53:47 +00:00
Konstantin Shcheglov 2c97bd7801 Remove duplicate getters from ClassDeclaration and MixinDeclaration.
Change-Id: I69440dd7b1911db6616dc500d82b7b9c3e996529
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313083
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-11 05:47:30 +00:00
Konstantin Shcheglov 7a258fa43b Add NotAugmentedXyzElementImpl implements AugmentedXyzElement.
So, that we don't have to copy all class members for 99% cases when
there are no augmentaitons.

Change-Id: I5c225905a0460ce5162543553e207a2d4412ecb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313082
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-11 02:22:35 +00:00
Kallen Tu 8be3439ce3 [analyzer] Make InstanceCreationEvaluatorTest consistent with other const tests.
Print type in `dart_object_printer.dart`.
Use `assertDartObjectText` instead of whatever was being used before.

Change-Id: Ifdfb6343013bb5fe654bcff870a9ff83b155402f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312885
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-10 22:20:22 +00:00
Helin Shiah 2094a733aa Add URI converter method that can be overridden
This is for an internal debug adapter to extend the test debug adapter and provide a custom URI converter to provide internal local paths during breakpoints.

Change-Id: I3b61b70fe07e14f08ff37443ef87facc523bf7fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313000
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
2023-07-10 21:30:51 +00:00
Konstantin Shcheglov 3bb4d7d0d4 Parse mixin augmentations, build element model.
Change-Id: Ie1bdb6d47b31c527546f62abf65d19a4a4e50ee7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312924
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-10 20:48:32 +00:00
Danny Tuppeny 95e6f1e110 [dds/dap] Use Isolate numbers as DAP thread IDs
We used to generate our own thread ID starting at 1 and counting up. There was always a 1:1 mapping from a DAP thread to a VM Isolate. With this change, we always use the Isolate number as the thread ID which makes it easier for tools using both VM Service and DAP at the same time.

Change-Id: Id8d82f6fd5134987f2ecfeaa761765d55999405d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312906
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-07-10 20:14:58 +00:00
Brian Wilkerson edb8d33c8e Start converting portions of the KeywordContributor
Change-Id: I9423ae6e50eec95ba3e5212529f4f3635d2f76d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312940
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-10 19:51:33 +00:00
Joshua Litt 50c810e12c [js|dart2wasm] Add JS backed subtypes of Dart typed array classes.
Change-Id: I19a6d47bf857969abe2205e6b505b3a1dead5e3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310480
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-07-10 18:11:02 +00:00
Ryan Macnak 99ef36064f [infra] Make the sanitizer a first-class status variable.
Makes the TSAN skips apply to
 `test.py -mrelease --sanitizer=tsan`
and not just
 `test.py -n vm-tsan-linux-release-x64`.

Also makes the timeouts agree.

Change-Id: I10315e754a4ebb3020f3c2f6cecfac6b77e77a9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311828
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-10 17:46:31 +00:00
Sam Rawlins fab30a7a73 Bump linter to e8c878360595c1d268d93f54c09bc843815a42d7
Change-Id: I8ab5b3de76d2e498185135660aae1875326f8a8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312961
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-10 16:20:18 +00:00
Kyle Turney e826300560 add fix for removing the leading underscore from local function names
Closes https://github.com/dart-lang/sdk/pull/52822

GitOrigin-RevId: 1e97f3fde70079ea47a4bb8f8f58db341ae26fdc
Change-Id: Iec46cca3532789b4fb338d73cdbb946a0d383845
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-07-10 14:18:08 +00:00
Martin Kustermann daa35fd4fd [gardening] Restore timout multiplier in test runner for linux-arm64
The timeout multipiler for linux-arm64 was originally 4, then lowered to
1 (see [0]), then increased again to 2 (see [1]).

Though it seems that service tests are still flakily timing out, so
let's try restoring the original multilier.

[0] https://dart-review.googlesource.com/c/sdk/+/306662
[1] https://dart-review.googlesource.com/c/sdk/+/307972

Also special case `ia32` in timeout calculations due to not using
an AppJIT trained `kernel-isolate` snapshot and therefore being
very slow, especially in ia32-debug mode.

Issue https://github.com/dart-lang/sdk/issues/52589
TEST=ci

Change-Id: Iab8c768866aec9e77bb83c7a3242cc5de8fb4e2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312905
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-10 12:02:16 +00:00
Jake Macdonald 1a13ea6c05 Add a disposeMacro api, with TODOs in the implementations to call it.
Change-Id: I38049ca8b851c2203ddaaa729ef651e7802a1d2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312860
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-10 12:01:49 +00:00
Johnni Winther 911b376f7e [cfe] Handle inline class representation field in object pattern
Closes #52667

Change-Id: I9c6d51597ff27ae3a7cdeed29d75755c18a2d530
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311742
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-10 11:02:50 +00:00
Chloe Stefantsova b36fbaef2c [cfe] Update both sides of intersection types in GUB
In computation of GUB both the left-hand and the right-hand sides of
the intersection should be updated as nullable when the other operator
to GUB is Null.

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

Change-Id: I4b616a94a3e7bf149205ba1b90732453c19ace47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311845
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-07-10 09:51:56 +00:00
Konstantin Shcheglov 4d4eefa956 Compute 'mixins' and 'interfaces' for ClassElement.augmented
Change-Id: I7514576ada4a5dcd048a2c399d5bfe11169f3394
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312887
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-07 21:39:41 +00:00
Konstantin Shcheglov 884116a83b Move 'constructors' getter into NamedInstanceOrAugmentationElementMixin.
Remove extra looping detection.

Change-Id: Ifdd7f4729930b3022a8b04f8143d714298acf8dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312884
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-07 20:34:39 +00:00
Konstantin Shcheglov aad361b31e Link augmentations and targets during building.
We walk augmentations in the right order, so can update update
necessary data structures as we go.

Change-Id: Ibf3409658009b82a960caaacd538fcd6c779b007
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312883
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-07 19:14:25 +00:00
Konstantin Shcheglov 553c804eb5 Don't use LinkedData type parameter.
Change-Id: I2afa126856f05072cb5e796b4f47d64e61284b96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312882
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-07 18:29:37 +00:00
Konstantin Shcheglov ac0fc3c11c Print augmentation libraries after the defining unit.
So, we can read it more naturally, first the declaration, then its
augmentations.

Change-Id: I21805969bff6874660500d4477b39ce5aba7484a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312880
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-07 17:08:54 +00:00
pq ff8963d1be fix make_final to properly update for loop patterns
Fixes: https://github.com/dart-lang/sdk/issues/52820

Change-Id: If94b56f034bc8c28087251aada59433578ed7a2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312702
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-07 16:23:59 +00:00
Danny Tuppeny 201fb68e64 [analysis_server] Update remaining CodeActions tests to use new expectation format
This is a continuation of a previous change that stops tests from verifying only individual files modified via a `WorkspaceEdit`. All verifications of these edits are done via a single string that includes all changes, with annotations for creates/deletes/renames.

Additionally, it migrates some additional tests to use TestCode instead of the old markers, and removes some extra indenting these tests had.

It also starts changing how capabilities are set for tests from having to nest function calls in `initialize()` calls to instead calling simple helpers prior to initialization.

Change-Id: I35d16a296c2125ab830685437e14eb3b29ea4704
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312841
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-07 16:15:24 +00:00
pq b05282a1e9 @useResult support for pattern variable declarations
Fixes: https://github.com/dart-lang/sdk/issues/52841

Change-Id: I0ce4e8bc7771808fcaacfbfc2b591ab805c74ff4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312711
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-07-07 15:56:28 +00:00
Konstantin Shcheglov fc0e656868 Build ClassAugmentationElementImpl, basic linking.
Change-Id: I18bd3d97ad9fe661d14e3d3d006219ffceedcfc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312349
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-07 14:55:38 +00:00
Tess Strickland 1bdbafff49 [pkg/vm_snapshot_analysis] Allow old 'patched_class_' field.
While in more recent SDK versions the 'patched_class_' field has
been replaced with 'wrapped_class_', this package can still be
used with the earlier SDK versions if we fall back to checking it.

Issue: https://github.com/flutter/flutter/issues/130009
Change-Id: Ifb1250393b72e58bbdc0764c7e2ce96269e659ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312802
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-07-07 11:36:59 +00:00
Tess Strickland 1133598168 [pkg/vm_snapshot_analysis] Don't assume Code objects have an owner.
For regular stubs, the owner will be null.

Issue: https://github.com/flutter/flutter/issues/130009
Change-Id: I8c85e3130128af79c596f381869d61631221cf9e
Cq-Include-Trybots: luci.dart.try:pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-linux-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312660
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-07 09:52:50 +00:00
Nicholas Shahan 5ca83258ef [ddc] Fix default type args signature on native classes
- They should match the calling convention and use the "dartx" symbol.
- Skip adding signatures for static methods since they can't be
  called dynamically anyway.

Issue: https://github.com/dart-lang/sdk/issues/48585
Issue: https://github.com/dart-lang/sdk/issues/52867
Change-Id: If5a76f52163b2267129880dbfe8d145a3fd93408
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312204
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-06 23:34:20 +00:00
Alexander Aprelev e62748f3e1 [gardening] Make info_macos_test resilient to snapshots running.
Align info_macos_test with info_linux_test in this regard: fix is similar to how https://github.com/dart-lang/sdk/issues/50583 was addressed.

BUG=https://github.com/dart-lang/sdk/issues/52658
BUG=https://github.com/dart-lang/sdk/issues/52402

TEST=ci

Change-Id: If7ab54990069c86eb5c0348e20086254818da839
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312705
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-07-06 22:57:13 +00:00
Kallen Tu a2cdf8e96d [analyzer] Refactor const evaluator visitBinaryExpression and tests.
Made more of the tests consistent in `evaluation_test` (slowly, but surely).

Change-Id: I515c4d6d81cedcc1d8d20080e231ac1e0afb5ec7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-06 21:48:07 +00:00
Konstantin Shcheglov 98e6322086 Fix another TODO in elements printer, use 'name'.
Change-Id: I6696a4b559072b064ee16d22b8aad528b52eb6a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312704
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-06 21:47:21 +00:00
Jake Macdonald 658de58b4f move the majority of the client bootstrap code into a real library to make it more maintainable
Change-Id: Id84981b236176c7831cece61692ec895ba2ac1e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312723
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-07-06 21:12:58 +00:00
Brian Wilkerson a510e60dbf Simplify the keyword contributor to make it easier to port to the new framework
Change-Id: I29d0bdc2d798adc3b39718fabba893456495dce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312703
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-06 21:03:37 +00:00
Nicholas Shahan 420b551d54 [ddc] Fix missing type tags in new type system
The types implemented transitively through mixins were missing from
the tags we manually attach. 

Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I7fa00fd79963914cd25c2f87f52d8acc76c9c359
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312202
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-06 20:27:24 +00:00
Nicholas Shahan 1199dc09b7 [ddc] Support extractTypeArguments in new types
Inline calls to the extract function directly with the type arguments
inserted as extractions from the instance.

Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I6b791c59478c2e609df30163835e3fd0863a2d94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307514
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-06 19:24:54 +00:00
Konstantin Shcheglov 4169196834 Use NodeTextExpectationsCollector to collect and update element expectations.
This code was older, and was a prototype of NodeTextExpectationsCollector,
but we have it now, it is better, and we can de-duplicate.

Change-Id: I428abb04687f2e3ff5142907a71fcf80e460b830
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312700
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-06 17:50:59 +00:00
Nicholas Shahan be6a560ca1 [kernel] Fix record type equivalence
- Increment index to avoid infinite loop when the first named elements
  in the two record types are equivalent.
- Add some test cases for record types.

Fixes: https://github.com/dart-lang/sdk/issues/52817
Change-Id: Ifbf3505c74a1f130c9c90ddbb6b1d96d9641e51e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311929
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-06 16:37:49 +00:00
Konstantin Shcheglov eaed1fbaff Fix a couple TODOs in the element model printer.
We can use ElementPrinter now for printing elements as references.

Change-Id: Ie75dc96940cf3a1e60f87e34801494f55145901f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312350
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-07-06 15:45:57 +00:00
Ben Konyi ea1a6a66b8 [ DDS ] Set minimum SDK bound to 3.0.0
Allows for use of new language features.

Change-Id: Ic66cb6d2e8bfbf5ff505cc72c0a23deb32026bbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312601
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2023-07-06 15:39:35 +00:00
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