Commit graph

92755 commits

Author SHA1 Message Date
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
Ömer Sinan Ağacan
b45d62959f [dart2wasm] Update Binaryen
New version supports final encodings used in [1], `array.fill` used in
[2], and updates some other encodings to match V8, as noted in [3].

[1]: https://dart-review.googlesource.com/c/sdk/+/310163
[2]: https://dart-review.googlesource.com/c/sdk/+/315120
[3]: https://dart-review.googlesource.com/c/sdk/+/310560

Change-Id: Ib5627f02327a1301909fd7708856a6f726234293
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312800
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-07-21 08:42:49 +00:00
Sergey G. Grekhov
cc257d8f4f [co19] Roll co19 to 1530f9b2408f5754c1c114f4d6475d883301f0ca
2023-07-21 sgrekhov22@gmail.com Fixes dart-lang/co19#2141. Add covariant instance variable tests (dart-lang/co19#2144)
2023-07-18 sgrekhov22@gmail.com dart-lang/co19#2138. Fix assertions in some functions tests (dart-lang/co19#2140)
2023-07-17 sgrekhov22@gmail.com Fixes dart-lang/co19#2136. Add type variable conflict test (dart-lang/co19#2137)
2023-07-14 sgrekhov22@gmail.com Fixes dart-lang/co19#2127. Add tests for covariant-by-class parameters (dart-lang/co19#2133)

Change-Id: I0eb608e6bebaf9bcf1acced5e6db98e5ce622979
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315400
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-07-21 08:28:47 +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
Sam Rawlins
d982d1afd7 Bump linter to 9a4bc7910d1ea2660deadae4c212776e9cf6212e
Change-Id: I210fd8793e05db1e7f30f2aaf207057c151de14c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315241
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-20 21:28:40 +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
Paul Berry
fc387f0f7b Update SDK to prepare for enabling interface-update-2.
Several locations in the core SDK contain `!` or `?.` operations that
will become unnecessary once the language feature `inference-update-2`
(which provides field promotion) is enabled.  For example, in this
method from the class `_IOOverridesScope`, `_previous` refers to a
private final field, so after field promotion is enabled, the test `if
(_previous != null)` will promote it, and the `!` in
`_previous!.createDirectory` will become unnecessary:

    Directory createDirectory(String path) {
      if (_createDirectory != null) return _createDirectory!(path);
      if (_previous != null) return _previous!.createDirectory(path);
      return super.createDirectory(path);
    }

Since the SDK is built in a mode where warnings like this result in
build failures, we need to temporarily change the logic into a form
where the same promotion effect is achieved through local variable
type promotion:

    Directory createDirectory(String path) {
      if (_createDirectory != null) return _createDirectory!(path);
      var previous = _previous;
      if (previous != null) return previous.createDirectory(path);
      return super.createDirectory(path);
    }

(Note that `_createDirectory` doesn't need to change, because it is a
non-final field, so it won't undergo promotion).

After `interface-update-2` has been enabled, I will make a follow-up
CL that removes the local variables and simply takes advantage of
field promotion, e.g.:

    Directory createDirectory(String path) {
      if (_createDirectory != null) return _createDirectory!(path);
      if (_previous != null) return _previous.createDirectory(path);
      return super.createDirectory(path);
    }

Note: in theory it would be possible to do all this in a single step,
by atomically enabling field promotion and changing the SDK in the
same CL. However, I prefer breaking it up into stages like this,
because the act of flipping a langauge flag on tends to have
wide-ranging consequences, so I want the CL that does the flip to be
as small as possible.

Change-Id: I421c7661348bf407093ee64ef7f9dbfc0c04a353
Bug: https://github.com/dart-lang/language/issues/2020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314500
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-07-20 20:14:39 +00:00
Devon Carew
6fd249d379 [deps] rev dartdoc, ecosystem, leak_tracker, markdown, mime, native, string_scanner, test, test_descriptor, vector_math
Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (06d7288..a04ac3e):
  a04ac3e8  2023-07-19  Sam Rawlins  Format testing and fix static-type-parameter issue (#3465)
  a44ecebc  2023-07-19  Sam Rawlins  Move validation-related tasks to package:args (#3463)
  392812e4  2023-07-17  dependabot[bot]  Bump analyzer from 5.13.0 to 6.0.0 (#3458)
  642e8d8b  2023-07-17  Sam Rawlins  Convert 'p' prefixes to 'path' in test/ (#3462)

ecosystem (2052a4c..27ff3e9):
  27ff3e9  2023-07-19  Moritz  Add debug message (#142)
  02703ce  2023-07-18  Moritz  Split commenting into new workflow (#141)
  a52ac63  2023-07-18  Moritz  Finish renaming `coverage_web` (#140)
  ffa1ecb  2023-07-17  Moritz  Health workflow updates (#134)

leak_tracker (515612e..098bafc):
  098bafc  2023-07-20  fzyzcjy  Update pubspec.yaml (#75)
  7606fd1  2023-07-19  Polina Cherkasova  Improve performance. (#98)
  e6778b3  2023-07-18  Polina Cherkasova  Explain case when static object causes leaks. (#96)
  cca1d77  2023-07-18  dependabot[bot]  Bump actions/checkout from 3.5.2 to 3.5.3 (#86)

markdown (ee4e1b3..faabb1a):
  faabb1a  2023-07-17  Kevin Moore  Bump pkg:http (dev) dependency (#551)

mime (bdb66bd..799b398):
  799b398  2023-07-18  Kevin Moore  update lints, require Dart 3 (#101)
  d17e3ed  2023-07-18  Kevin Moore  blast_repo fixes (#100)

native (7c474e1..2598ac6):
  2598ac6  2023-07-20  Daco Harkes  Package name spacing (#101)
  3d73b4a  2023-07-19  Daco Harkes  [native_assets_builder] Builder `out/` folder (#99)
  6308330  2023-07-19  Daco Harkes  Remove compiled files (#92)

string_scanner (35657e2..413b57a):
  413b57a  2023-07-18  Kevin Moore  Require Dart 3, update lints (#61)
  53690da  2023-07-18  Kevin Moore  blast_repo fixes (#60)

test (a92b5bb..37e54e3):
  37e54e32  2023-07-19  Nate Bosch  Handle initial message entirely within conditional (#2067)
  e76bffe8  2023-07-19  Nate Bosch  Expand dom interop to cover more uses (#2066)
  8bc188f7  2023-07-18  Lukas Klingsbo  docs: Fix grammar and typos in Checks readme (#2058)

test_descriptor (54a4c59..36d8617):
  36d8617  2023-07-18  dependabot[bot]  Bump actions/checkout from 3.5.2 to 3.5.3 (#53)

vector_math (c147038..048777a):
  048777a  2023-07-19  moritzblume  Fix rotation around Y axis (#262)
  47a08ea  2023-07-17  dependabot[bot]  Bump actions/checkout from 3.3.0 to 3.5.2 (#293)

Change-Id: Id8010082c818c995aa7968327f98f347ff45761d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315221
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-07-20 18:51:49 +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
asiva
5d872a8737 [VM/Runtime] - Deprecate Dart_UpdateExternalSize and Dart_UpdateFinalizableExternalSize from the Dart C API
https://github.com/dart-lang/sdk/issues/52568

TEST=new test added.

Change-Id: I4f4b6b607fa2e0daa14fc25e3bdf99214f6ccb6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314900
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-07-20 17:06:44 +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
Lasse R.H. Nielsen
1861faef4a Make _IOOverridesScope have final fields.
Because it can, and therefore should.

Also update the methods to use `??` more, which should be
safe now that unsound null safety is no longer a thing.

Avoid chains of override-scopes by inlining the parts of the
outer scope which is not overridden.

Fix two bugs:
* `statSync` was checking whether `_stat` was non-`null`, then
  calling `_statSync`.
* `socketConncet` did not pass source port to function.

CoreLibraryReviewExempt: Affects only VM.
Change-Id: I9d4971271305c52948d334f69ae71d750587ed97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314880
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2023-07-20 10:11:58 +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
Alexander Aprelev
bd8cc7bc93 [gardening] Use correct ObjectPtr in DART_COMPRESSED_POINTERS mode.
This is the follow-up to https://dart.googlesource.com/sdk/+/a5936e404b39f4af7b4fbf51d06ad3a99ff9fa36.

TEST=ci

Change-Id: Id0a21952d9f8b044ca207d8f8286fd76c0630cb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314980
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-07-19 21:17:35 +00:00
Sam Rawlins
8c1b8e34b4 Bump linter to 6c1920198fc92af215297043609cecb4ac487a2a
Change-Id: Id04cade0791adb97970963574d40a3599bea2595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314860
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-07-19 21:17:28 +00:00
Brian Quinlan
e75cacf2b8 Clean up Platform.lineTerminator test.
Change-Id: I933956de806d9b4597385cf4afa4a98528c2165c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313542
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-07-19 20:23:51 +00:00
stuartmorgan
69f95fa2cd Add --downgrade to flutter/packages analysis
Closes https://github.com/dart-lang/sdk/pull/52989

GitOrigin-RevId: 0f3e9114c0afe23ebfda7d80e89e5cd46a4419fa
Change-Id: I7d0632c8efd34b414b47d1e8d80e7996a5d7726e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314920
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2023-07-19 20:10:38 +00:00
Alexander Aprelev
a5936e404b [vm] Include field and local names in isolate invalid object retaining path message.
Retrieval of local names only works in JIT as it relies on availability of LocalVarDescriptors.

For example, for this
```
import 'dart:isolate';

foo() {
  final x = RawReceivePort();
  RawReceivePort().sendPort.send(() => print("$x"));
}

main() {
   foo();
}
```

error message says
```
Unhandled exception:
Invalid argument(s): Illegal argument in isolate message: (object is a ReceivePort)
 <- field x in foo.<anonymous closure> (from file:///usr/local/google/home/aam/p/d/dart-sdk1/sdk/s1.dart)
```

Bug: https://github.com/dart-lang/sdk/issues/52957
TEST=ci
Change-Id: I684014fd19ea82829e7df17a8a67d386551a5a82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314501
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-07-19 19:58:18 +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
Alexander Aprelev
3284c68727 [gardening] Add 'previous-results' option to run_stress_test_shards.dart
Follow-up to https://dart-review.googlesource.com/c/sdk/+/314081
TEST=ci

Change-Id: Ib65a81738cb4b22531765a73becdc9cf7c836ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-07-19 17:34:53 +00:00
Paul Berry
e835ab692e Update language tests to prepare for enabling interface-update-2.
The tests `variable_property_not_promoted_test` and
`this_property_not_promoted_test` verify that fields are _not_
promoted. To prevent them from failing when we enable the language
feature `inference-update-2` (which provides field promotion), they
need `@dart=3.0` directives. This ensures that we will continue to
have coverage of the old (non-promoting) behavior after field
promotion is switched on.

Bug: https://github.com/dart-lang/language/issues/2020
Change-Id: I376da01dfe4223f17ae4863e4460b4f1a0708dc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314760
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-19 17:31:18 +00:00
Ryan Macnak
e50470568b [vm] Remove ValidateConstants.
This is already skipped for AOT and is unfixable after the DropTransitiveUserDefinedConstants optimizations.
This is already skipped for reload and is unfixable for issues related to 40442.
The non-reload JIT case isn't very interesting since each kernel constant will be loaded only once anyway.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/27003
Bug: https://github.com/dart-lang/sdk/issues/44862
Change-Id: I0676a96426142600f4ed9ec638b344a858aab7dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314480
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-19 17:26:50 +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
Ryan Macnak
7d48bd0e2f [vm] Reset canonical tables together instead of classwise.
TEST=ci
Change-Id: I8867f7981bb15fcf42eec7364394fcca556dca24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314540
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-19 16:53:46 +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
Ben Konyi
9ca0d413c5 [ Status ] Skip regress_45684_test on AOT configurations
regress_45684_test.dart makes use of the debugger, which isn't supported
in AOT.

TEST=N/A

Change-Id: I454aa92d1ce33638380e6fd02654dc5f925c2bf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314820
Reviewed-by: Dan Chevalier <danchevalier@google.com>
2023-07-19 14:55:48 +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