Commit graph

10996 commits

Author SHA1 Message Date
Alex Li fae49c0514 Improve comments of Directory methods
Closes https://github.com/dart-lang/sdk/pull/52194

GitOrigin-RevId: d6684f771db36b917b30d789785f3f883a76fad3
Change-Id: Ie6a172e7bf818368fe5557fec8b7b9eb1e7de8b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298841
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
2023-04-27 09:40:30 +00:00
Oleh Prypin 7bbf7ff43e Revert "[cfe] Enable verification in platform compilation"
This reverts commit 20e0ddf130.

Reason for revert: breakages in google3

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

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

Change-Id: I5a44e211a4b203e4879dbc8f6bf4bbec5abf51f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-04-27 07:34:39 +00:00
Devon Carew 7a5061e71a [docs] fix a grammar issue in the sdk readme
Change-Id: I566740cc36cbc85b16ece550b31481755b86524a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298720
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
2023-04-26 18:25:55 +00:00
Srujan Gaddam 1d28f8e821 [dart:js_interop/ddc/dart2js] Implement JS types using @staticInterop
Currently, dart:_js_types types are all typedefs in the web backends.
This leads to inconsistent semantics, since you can statically pass
Strings to JSString, for example. You cannot do this in dart2wasm.
In order to ensure consistent semantics, we reify these types using
a custom @staticInterop lowering. They all get erased to their
respective Dart type. When we have inline classes, these types
should be implemented using inline classes.

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

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

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

CoreLibraryReviewExempt: Backend-specific internal library changes.
Change-Id: I5942be628102919ec167f094cfe10fced606363c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295105
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-04-26 15:55:54 +00:00
Stephen Adams 70615d5970 [dart2js] Update TODO with issue number
Change-Id: I0191298058f8ceb68eaec91c0c00c8576799a634
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298180
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2023-04-25 18:19:06 +00:00
Lasse R.H. Nielsen d440905d5a Reestablish abstract on HttpProfiler.
Class used to be abstract, but lost it when made `final`.
There is no reason to allow instantiation, it's all static members.
Restablishing the `abstract` before we release 3.0, so we don't have to go through any extra steps.

The class is public, exported by `dart:io`. (Should probably also be documented.)

Change-Id: Ic1a3e1a777ecbdcf535b92dbcdd88f55a65e9cbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297463
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-04-25 14:41:19 +00:00
Stephen Adams 45efccb5e0 Remove left-over patch declarations for List constructor.
This CL replaces https://dart-review.googlesource.com/c/sdk/+/296900

The `List` constructor is removed in Dart 3.0.
Some of the `@patch` implementations were not removed.

This is *high priority*. It seems the left-over `@patch factory List` constructor did not cause any errors, instead it *added* a constructor  to `List` that can be used in web compiled code. Even if `List` doesn't have such a constructor in the SDK code proper.
The VM and analyzer will say the invocation is an error, but dart2js happily compiles it and runs.

(It used to be that patches couldn't add public members, that security seems to have been removed.)

Also removes code which tries to detect "the unnamed List constructor",
which is no longer a thing, and a number of invocations of the constructor, where it's not clear that the test is aware that the constructor no longer exists, and is not marked as `@dart=2.x` with x < 12.

TEST=ci

Change-Id: I4ffaf3ae2c4e75ca06e7ba0bf19187b6376f3888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297100
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-22 00:38:28 +00:00
Brian Quinlan 69f71e90ea Remove 'abstract' from 'class Platform'
Bug: https://github.com/dart-lang/sdk/issues/52138
Change-Id: Ibef54f5369d4b9374e9d58939ee26c853021bf74
CoreLibraryReviewExempt: Partial revert of 9c702bc72e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297160
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-04-21 23:44:29 +00:00
Stephen Adams 2a66f966f3 [dart2js] Rename dart:_async_await_error_codes -> dart:_async_status_codes
Change-Id: I6b47f08791544eabc09bb05a81bbd0154bc39cb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296704
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-04-21 00:01:51 +00:00
Ben Konyi aef551ac35 Reland "[ Observatory ] Disable serving Observatory by default"
This reverts commit fa0c81efe1.

Requires https://github.com/flutter/flutter/pull/123556/ to have landed.

TEST=Existing tests

Change-Id: I40b9e11a89fd66ec511d31a385192e577899fca3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296640
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-04-20 18:16:09 +00:00
Derek Xu afa3594ca1 [VM/Timeline] Support flow events in the Perfetto file recorder
This supports flow events reported through dart:developer, but does not
support ones reported with Dart_TimelineEvent in dart_tools_api.h. That
will have to be supported in a future CL.

TEST=CI, manually verifying that flow arrows appeared on flow events in
the trace viewer for traces recorded with our Perfetto recorder

Change-Id: Ic75a8ce277b436a609c027c2c0d4e94b51031aa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280740
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-04-20 16:42:23 +00:00
Nicholas Shahan 2a56d8ba84 [ddc] Fix RecordImpl instanceof test
The `instanceof` operator needs a reference to the JavaScript class
instead of the Dart Type. This avoids an issue when changing the
type representation in the new runtime type system where the two
are no longer interchangeable.

Update the parameter name for `_jsInstanceof()` which which was
probably the remnants of a copy paste.

Change-Id: I1d3fcf1915fb3e189ad7f3e130e101009ee50381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296341
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-04-19 21:32:33 +00:00
Lasse R.H. Nielsen b0260187e7 Remove base from StreamView.
It's not *needed* for safety or soundness, and it forces
subclasses to be `base` whether they want to or not.

Bug: https://github.com/dart-lang/async/issues/238
CoreLibraryReviewExempt: Removes a modifier, no implementation effect.
Change-Id: I72ec1ddb3b05b746c08437b0b8173c9e71673fc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296280
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-04-19 17:41:29 +00:00
Alexander Markov 9cf26fc3cd [vm] Fix handling of exceptions thrown from Iterable.iterator during yield*
TEST=language/sync_star/sync_star_exception_iterator_test
Fixes https://github.com/dart-lang/sdk/issues/52083

Change-Id: I6f26189b5d5df1c1804cd6cd7a64f72bdbe55f94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295922
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-04-19 13:50:19 +00:00
Stephen Adams 4c0de8ed89 [dart2js] sync* fixes
Change the calling convention of the sync* body to fix bugs and avoid allocations.

- Body takes the controlling _SyncStarIterator as a parameter.

- `yield` assigns directly to the `_current` field and returns.

- `yield*` calls a method on the controlling iterator (rather than returning the iterable). This avoids an allocation to wrap the iterable, a type test to distinguish `yield` from `yield*`, and allows the `get:iterator` call to happen in the dynamic scope of try-catch surrounding the `yield*` to that it will catch any exceptions.

- Avoid using IIFE to bind constants just to call the body.

- Use a dummy body to avoid the need to testing termination of the body.


Tests now passing:

co19_2/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_sync_t05
language_2/sync_star/move_past_end_test
language_2/sync_star/sync_star_exception_current_test
language_2/sync_star/sync_star_exception_iterator_test
language_2/sync_star/sync_star_exception_nested_test
language_2/sync_star/sync_star_exception_test


Bug: #51992


Change-Id: I397b470e121b8d71242ac28b3130637b78a1d0dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294685
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-18 22:24:24 +00:00
Stephen Adams 62a67ba5bc [dart2js][js_runtime] Use Array.isArray more consistently
The main reason is to do this change is to avoid inconsistencies in what is considered to be a `JSArray`. Using `Array.isArray` allows js-interop where the JavaScript code subclasses `Array`.

dart2js-production results:

ArrayLoop.pseudopoly.hoisted1-indexing  -50.20%
ArrayLoop.pseudopoly.indexing           -35.18%
Iteration.concat.manual                  11.69%
ListCopy.List.int.unmodifiable.2         12.03%
ListCopy.for.int.2                       12.58%
ListCopy.spread.int.2                    13.57%
ListCopy.toList.fixed.100                16.06%
ListCopy.List.of.fixed.100               16.96%
ListCopy.toList.100                      17.28%
ListCopy.spread.int.cast.2               18.45%
ObjectHash.hash.5                        19.62%
TypedDataPoly.A_UVx5.view.2              21.12%
ObjectHash.manual.5                      21.70%
ListCopy.spread.int.map.2                21.96%
ListCopy.spread.int.cast.100             22.12%
TypedDataPoly.A_UVx5.view.100            23.04%
ListCopy.spread.int.map.100              25.26%
ListCopy.List.of.100                     27.88%
ImagingGaussianBlurOnce                  29.67%
MegaEquality                             37.90%

An investigation of the two regressions shows that they benefit from a micro-benchmarking effect. The previous code was monomorphic at the property access in `receiver.constructor == Array`. If this is forced to be polymorphic, the baseline is quite a bit worse, leading to an improvement in line with some of the other benchmarks.


Change-Id: I5c265b1d7408fbd41da9c6fa17472bf648000c8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287140
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-18 20:39:39 +00:00
Aske Simon Christensen d8b53d97ff [dart2wasm] Implement identityHashCode via br_table.
This saves the space for the `_identityHashCode` method in the
dispatch table and allows customizing `identityHashCode` for classes
not in `dart:core`.

Change-Id: I829fb0f53dea1f3baf92e12079b9772ce2ff8c2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292820
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Auto-Submit: Aske Simon Christensen <askesc@google.com>
2023-04-13 16:45:14 +00:00
Lasse R.H. Nielsen 3e0ca136b6 Update documentation on Record and identical.
Smaller clean-ups.

CoreLibraryReviewExempt: Documentation only.
Change-Id: Idfe543f18927043ae8ec73e81dc7d9d333bb88df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294542
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-13 12:35:44 +00:00
Srujan Gaddam 568469b896 Reland "[dart:js_interop] Export some package:js annotations and check them"
This reverts commit df761ba9e7.

This also rebases the original CL onto HEAD so it can be landed first.

CoreLibraryReviewExempt: Reland of backend-specific library changes.
Change-Id: I4f9a017be3ec1924c021f941291d79d7aee06663
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294131
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-12 18:15:00 +00:00
Ahmed Ashour 3e0d976d4b Remove unneeded null check after promotion
Fixes #51171

CoreLibraryReviewExempt: Removes no-longer-needed non-null promotion.
Change-Id: I46215a274c3042619578bf25bff045b15d4e087f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283682
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-12 15:56:08 +00:00
Mark Zhou 887505e3ab [ddc] Creating dart_library API for deferred loading
This is part of a series of CLs to enable real deferred loading in DDC.

- Creates a new top-level object in dart_library.js for holding the state/API
  for deferred loading.
- Only supported in the DDC module system

This also contains a bunch of cleanup/comments for our internal JS Linter. Notably, 'var' is not allowed, so we're attaching our top level namespace objects to `self`.

Change-Id: I230d63f044e85e7d16644525ff79fa9522398c87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289400
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-04-10 23:00:41 +00:00
Lasse R.H. Nielsen 2a38b22aed Add a few more class modifiers.
Mostly interface on classes that can't be extended anyway.
A few `final` implementation classes.

Tested: No new functionality, only restrictions.
CoreLibraryReviewExempt: Just modifiers.
Change-Id: I1f298fe43836892c94c0b23326fda37b1904ec6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293683
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-07 21:54:44 +00:00
Zach Anderson 4919729f00 Revert "Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations""
This reverts commit 9e1997971e.

Reason for revert: Breaks Dart -> Engine roll?

See:
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/1821/overview
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20Engine%20Drone/666824/overview

Original change's description:
> Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
>
> This is a reland of commit fbe9c21972
>
> This fixes the issue with the duplicate allowPlatformPrivateLibraryAccess.
>
> Original change's description:
> > [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
> >
> > This moves package:js annotations to the internal library that
> > Flutter has been using already. This gives us a single location
> > for all package:js annotations. We also introduce a @JS annotation
> > in dart:js_interop since we can no longer use dart:_js_annotations
> > to avoid the breaking change in semantics.
> >
> > CoreLibraryReviewExempt: Backend-specific internal library.
> > Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
> > Commit-Queue: Srujan Gaddam <srujzs@google.com>
> > Reviewed-by: Samuel Rawlins <srawlins@google.com>
> > Reviewed-by: Johnni Winther <johnniwinther@google.com>
> > Reviewed-by: Joshua Litt <joshualitt@google.com>
>
> CoreLibraryReviewExempt: Relanding.
> Change-Id: I40ff2a00682fccbd7dd44a364b5046aaac0f3bac
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293203
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>

Change-Id: Ide8609575c73d714f3ae4f9ea9ffc74e228fa189
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293962
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2023-04-06 14:43:18 +00:00
Zach Anderson df761ba9e7 Revert "[dart:js_interop] Export some package:js annotations and check them"
This reverts commit ef7d8d3f9a.

Reason for revert: Breaks Dart -> Engine roll?

See:
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/1821/overview
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20Engine%20Drone/666824/overview

Original change's description:
> [dart:js_interop] Export some package:js annotations and check them
>
> To disallow package:js on dart2wasm, we need to export @staticInterop
> and @anonymous through dart:js_interop. However, users should not mix
> the two @JS annotations, so we add some static checks for that. We also
> export @JSExport to support export classes with dart:js_interop.
>
> CoreLibraryReviewExempt: Reexporting annotations through backend-specific library.
> Change-Id: I54610965da332320170d991d785192341049607e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293500
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

Change-Id: I2af0755e054a1b0452a5fc617a93257209703793
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293961
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-04-06 14:42:36 +00:00
Srujan Gaddam ef7d8d3f9a [dart:js_interop] Export some package:js annotations and check them
To disallow package:js on dart2wasm, we need to export @staticInterop
and @anonymous through dart:js_interop. However, users should not mix
the two @JS annotations, so we add some static checks for that. We also
export @JSExport to support export classes with dart:js_interop.

CoreLibraryReviewExempt: Reexporting annotations through backend-specific library.
Change-Id: I54610965da332320170d991d785192341049607e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293500
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-04-06 00:29:12 +00:00
Srujan Gaddam 9e1997971e Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
This is a reland of commit fbe9c21972

This fixes the issue with the duplicate allowPlatformPrivateLibraryAccess.

Original change's description:
> [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
>
> This moves package:js annotations to the internal library that
> Flutter has been using already. This gives us a single location
> for all package:js annotations. We also introduce a @JS annotation
> in dart:js_interop since we can no longer use dart:_js_annotations
> to avoid the breaking change in semantics.
>
> CoreLibraryReviewExempt: Backend-specific internal library.
> Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Joshua Litt <joshualitt@google.com>

CoreLibraryReviewExempt: Relanding.
Change-Id: I40ff2a00682fccbd7dd44a364b5046aaac0f3bac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293203
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-05 23:20:15 +00:00
Lasse R.H. Nielsen 87ccb4012c Use padLeft in Duration.toString.
Optimizing to avoid allocations probably not worth the cost in code size
and start-up time required by the constant list.

CoreLibraryReviewExempt: Minor change to internal implementation.
Change-Id: Ib54bf75f15aa096ac8e07577a47590f3cd9d55dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292780
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-05 06:24:20 +00:00
Lasse R.H. Nielsen 511bf8a80f Add nonNulls, indexed and other extensions on iterables.
Also adds `firstOrNull`, `lastOrNull`, `singleOrNull`, and `elementAtOrNull`.

I chose `nonNulls` instead of `whereNotNull()`.
The latter should have been a getter, but isn't.
Making it a getter in the platform libraries would be confusing,
and make migrating from `package:collection`'s function harder,
so instead I gave it a completely new name.
The alternative would be to retain the non-idiomatic `whereNotNull()`
for familiarity. But then it would be tool late to fix.



Fixes #49928

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

CoreLibraryReviewExempt: Everybody's on vacation, everybody everywhere.
Change-Id: If464e3bd6bc97cbeefc3e5084b4cbaadac3f1e95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290760
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-04 23:05:54 +00:00
Lasse R.H. Nielsen 5573ce7b84 Make Iterable be the default implementation of itself.
Makes `Iterable` a mixin class with a `const` constructor,
and `IterableBase` and `IterableMixin` (to-be-deprecated) aliases
for it.

Combining everything in one place avoids (some) code
duplication.

Also gave the methods a quick overhaul for formatting,
removing uses of `late` and unnecessary element accesses,
and some general tweaks.

CoreLibraryReviewExempt: Refactoring of redundant types.
Tested: Refactoring. If existing tests work, it works.
Change-Id: Ie49a88f713d386d2d118c53606a71bdd50e1eb11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287600
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-04-04 21:45:19 +00:00
Brian Quinlan 31095d70c6 Additional dart:io class modifier changes.
Change-Id: Ic6990835088e1c5052f2e556c73c04bb3ee98b8f
Tested: class type changes
CoreLibraryReviewExempt: Aske is on holiday
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292160
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-04-04 21:08:07 +00:00
Lasse R.H. Nielsen f51e9d1dda Make RegExpMatch.pattern have type RegExp.
It's always a RegExp, so it's a safe change.
It's also a very, very rarely used property,
since nobody ever noticed that it wasn't typed optimally.

Tested: Type change of getter to actual type of value. No new test.
CoreLibraryReviewExempt: Aske is out.
Change-Id: Ifb560a80c3cdb05be0164c593383539dc10ec0dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267961
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-04-04 20:34:36 +00:00
Ivan Inozemtsev ebd3243b2b Revert "Reland "Fix bug in Completer.complete.""
This reverts commit 51cbaed621.

Bug: b/276792935
Change-Id: I5b0ded0154a36a917ba099440d94b65764b29829
CoreLibraryReviewExempt: revert
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292889
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2023-04-04 20:06:41 +00:00
Brian Quinlan 9c702bc72e Add Dart 3 class modifiers to dart:io.
Change-Id: Ia6eda18bb4ad6ae9f2705846e262f793f73d1e4f
Tested: class type changes
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291343
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-04-04 19:06:21 +00:00
Srujan Gaddam 55e60cb982 Revert "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
This reverts commit fbe9c21972.

Reason for revert: Rebase leads to additional definitions of allowPlatformPrivateLibraryAccess in dart2wasm.

Original change's description:
> [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
>
> This moves package:js annotations to the internal library that
> Flutter has been using already. This gives us a single location
> for all package:js annotations. We also introduce a @JS annotation
> in dart:js_interop since we can no longer use dart:_js_annotations
> to avoid the breaking change in semantics.
>
> CoreLibraryReviewExempt: Backend-specific internal library.
> Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Joshua Litt <joshualitt@google.com>

Change-Id: I87c5510f7ec9bc059d4c17a354188222ac7e8cba
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293201
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-04-04 16:41:28 +00:00
Srujan Gaddam fbe9c21972 [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
This moves package:js annotations to the internal library that
Flutter has been using already. This gives us a single location
for all package:js annotations. We also introduce a @JS annotation
in dart:js_interop since we can no longer use dart:_js_annotations
to avoid the breaking change in semantics.

CoreLibraryReviewExempt: Backend-specific internal library.
Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-04 15:55:29 +00:00
Aske Simon Christensen d1d232776a [dart2wasm] Rename the dart:wasm library to dart:_wasm.
This is an internal library not meant to be used in application code.

CoreLibraryReviewExempt: Changes only Wasm specific libraries.
Change-Id: I2f5b463382d35a442e782067ef7d9063183fe5e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292021
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-04-04 11:52:18 +00:00
Lasse R.H. Nielsen 2f7213342b Add record-related wait extensions on Future tuples.
With the addition of records, it now makes sense to create an API
for parallelizing of futures of different types, like `Future.wait`
does for collections of same-typed futures.

The `wait` getters here apply to tuples of 2-9 futures of distinct types, which should be enough for most reasonable uses.

Planned addition for Dart 3.0.



CoreLibraryReviewExempt: Everybody's on vacation, everybody everywhere.
Change-Id: Iaa814e02e2274082bb8a29b9a18b4930bcc953bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288903
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-04 11:39:49 +00:00
Lasse R.H. Nielsen 67797ef46f Add more class modifiers to dart:collection.
Pure interfaces made `interface`s
implementation classes which cannot/should not be extended made `final`.

A class like `HasHMap` which provides the `Map` interface,
and no implementation except factory constructors
for internal implementations, is made `final`.

Unified {List,Set,Map}{Base,Mixin} into their `Base` class.
Deprecations are retained in comments for now, to be landed
separately. Search for '// TODO: @Deprecated'.

Tested: No new test, only adding restrictions on use.
CoreLibraryReviewExempt: Everybody's on vacation, everybody everywhere.
Change-Id: Ia83b8a3bb20b5b214546b328d4492de6658253db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288240
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-04-04 10:39:48 +00:00
Devon Carew 93f7e368f7 [SDK docs] update the SDK's API doc readme file
Closes https://github.com/dart-lang/sdk/pull/51934

GitOrigin-RevId: 7b1fa57387341cdd3a50592cda0cfe5df1608259
Change-Id: Ib5abf6faef205e02b7a1d42fd6cc11ec4488040b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293001
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-04-04 00:25:44 +00:00
Brian Quinlan 6f1d0e5afa Explain that Complete.future must be handled if it is an error.
Change-Id: I31d2e97d7df875607e30023f20c649680d9feaba
CoreLibraryReviewExempt: documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292286
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-04-03 23:55:02 +00:00
Brian Quinlan 17ea08c10c Document that IPv4 are preferred in socket.connect.
Bug: https://github.com/dart-lang/sdk/issues/50868
Change-Id: I8186d95d1a24c77c4cfade533af26695c7a13b24
CoreLibraryReviewExempt: documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293020
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-04-03 23:48:13 +00:00
Brian Quinlan 592c486b58 [doc/io] Clarify why not to modify data after IOSink.add
Bug:https://github.com/dart-lang/sdk/issues/31710
Change-Id: Ibd5903aa6c2ed268729ee860973195113596ca6e
CoreLibraryReviewExempt: documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279263
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-04-03 19:15:51 +00:00
Srujan Gaddam e95b84ed41 [dart2js] Fix native null assertions for Dart 3
Allows the following semantics:
- If the disable flag is passed, never check
- If we're in non-sound mode, never check to avoid a breaking
change (this was the behavior before)
- If the enable flag was passed and we're in sound mode,
always check
- If we're in sound mode and with >= -03, don't check

Discussion in https://github.com/dart-lang/sdk/issues/50710

Change-Id: If83aaebb2745e4c8bcaa3f5a38ff41d79a869b8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289451
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-04-03 18:05:28 +00:00
Brian Quinlan 69bddeeca1 Make FileSystemEvent and its subclasses final with public constructors.
Bug: https://github.com/dart-lang/sdk/issues/51912
Change-Id: I05f7884e619e3014339f7642c1eeacc8b617155a
Tested: existing unit tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292220
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-04-03 17:03:16 +00:00
Lasse R.H. Nielsen 51cbaed621 Reland "Fix bug in Completer.complete."
This is a reland of commit 3688a4723c

Original change's description:
> Fix bug in Completer.complete.
>
> When given a completed `_Future`, it would complete its own future synchronously.
>
> Fixes #48493.
>
> Bug: https://github.com/dart-lang/sdk/issues/48493
> Change-Id: Ic4a68389b5a009ef52b3875bf03a3bafb493f79a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234981
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

CoreLibraryReviewExempt: Bugfix.
Bug: https://github.com/dart-lang/sdk/issues/48493
Change-Id: If3a240b5b6eb016e8abe9a2c7551bfcaeea0da4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278920
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-03 14:22:26 +00:00
Martin Kustermann e1c2192110 [vm] Make writeHeapSnapshotToFile() API public in dart:developer
This API can be used by app developers that want to diagnose high
memory consumption by dumping state of Dart VM heap at specific
points in their apps code and later analyzing those dumps offline
(e.g. using the tool in `<sdk>/runtime/tools/heapsnapshot`).

TEST=Existing test suite.

Change-Id: I04de6ba564f7b9eaf8b59d41fc4b3ec35ce8d2e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279972
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Jacob Richman <jacobr@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-04-03 12:25:55 +00:00
Lasse R.H. Nielsen f0e099ec5b Add DateTime.timestamp() constructor for "now as UTC".
Change-Id: I497f335b1f1eb0f691c2d44557c50f0f55358426
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292003
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-31 20:52:31 +00:00
Srujan Gaddam 8ebed3d806 [dart:html] Add webkitSpeechRecognition to SpeechRecognition class
In Safari, the prototype of a SpeechRecognition object returns a
webkitSpeechRecognition prototype. This name is different than the
one in the @Native annotation, so dart2js fails to recognize it. We
should it to the annotation so we properly intercept it.

CoreLibraryReviewExempt: Changing bindings of dart:html, no change to API.
Change-Id: Ic533e1208dd28e521403998e43009e0f651e2dfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291961
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-03-31 17:32:54 +00:00
Daco Harkes 3de5d25429 [vm] Class modifiers for NativeFieldWrapper subtypes
Split off https://dart-review.googlesource.com/c/sdk/+/291761.
Landing separately, so that the breaking change itself is a smaller
CL.

TEST=ci build (see touched _test files)

bug: https://github.com/dart-lang/sdk/issues/51896
Change-Id: Ic8d218845ccb6a277689e911b2c34c44639e13cf
Cq-Include-Trybots: luci.dart.try:flutter-linux-try,vm-aot-linux-debug-x64c-try,vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-03-31 13:20:19 +00:00