Commit graph

97105 commits

Author SHA1 Message Date
Srujan Gaddam
fedc687bd3 [dart:js_interop] Add toJSProxyOrRef
Adds a conversion function on List<JSAny?> so that users can
modify the original list and have those changes carry forward
to the array. Creates a proxy object for dart2wasm when the
list is not a JSArrayImpl. This proxy uses handler methods and
the fact that Array methods are generic to provide an Array
interface. Also fixes a small issue in the exporting so that
toJS'd function types have a valid return type.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I00f453aa82dd19f2913820579eb2675b799288d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323446
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-09-07 22:58:22 +00:00
Srujan Gaddam
54522db98f [dart2wasm] Fix nullable JS type and int parameters in JSFunction
When a callback is toJS'd with an int parameter, we should attempt
a conversion to int if possible, similar to return values on
external functions. Similarly, parameters where the expected type is
a JS type should check to make the value isn't nullish before boxing,
as JS null and undefined are converted to Dart null.

Tests are added for conversion semantics of JSFunctions.

Change-Id: I95566c2954d915b8cf31cdc55fed359c695404f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323445
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-09-07 22:58:22 +00:00
Srujan Gaddam
6f497776e6 Reland "[dart:js_interop] Remove unnecessary custom static interop check"
This is a reland of commit 8193e6a385

The CL is changed to handle the inconsistent patching we have for
extension methods. This CL either checks if the member is non-external
or has the @patch annotation. This accounts for all the members in
dart:js_interop.

Original change's description:
> [dart:js_interop] Remove unnecessary custom static interop check
>
> This was added to prevent accidentally lowering patched members,
> but these members are patched before we see them, so they aren't
> marked external.
>
> Change-Id: Ib8f7c52c38a3f1e28905798a40319f7aa2994328
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322502
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

Change-Id: I129e5a030df1fd55e7292b4b4bd0276cab7bee15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322564
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-09-07 22:58:22 +00:00
MarkZ
dacf4a8f46 [ddc] Cleaning up extraneous null checks in runtime.
Change-Id: Ia32b15ec9ac572332da7904e94ec9c9615bf3de1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324842
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-09-07 22:57:39 +00:00
Sam Rawlins
e6ac464ff0 Avoid passing a nullable value to Completer<nn-type>.completer.
This is cleanup work required to start enforcing this with static analysis, as
per https://github.com/dart-lang/sdk/issues/53253.

Real quick this issue is that this code is unsafe:

```dart
void f(Completer<int> c, int? i) {
  Future<int>.value(i); // Ouch!
  c.complete(i);        // Ouch!
}
```

Change-Id: Ia4d83719c425601b24e8ae6e305c88c95cba8b20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324640
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2023-09-07 21:48:26 +00:00
pq
7b8735eeb4 annotation validation for extension types
validation/tests for application of

* `@mustCallSuper`
* `@nonVirtual`
* `@reopen`
* `@sealed`

to extension types

See: https://github.com/dart-lang/sdk/issues/53434

Change-Id: I005523507044e7d5879a5589c132384e7bb8be56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324768
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-07 21:26:33 +00:00
Nicholas Shahan
c4d2f64dd8 [ddc] Avoid unnecessary cast as Object
Change-Id: I96ffb4e91bf1656818fd5a71077f034a1acd1b93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324641
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-09-07 21:20:44 +00:00
Kallen Tu
ac04a4e4e2 [analyzer] Remove generated constant evaluator and its tests.
The generated constant evaluator is not being used and is removed by
this CL. All imports of the deleted evaluator will import the more
direct dependency and tests are moved to `evaluation_test.dart`.

Change-Id: Ie435d289bd85256419f67407b36af0375661f335
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324342
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-09-07 21:08:49 +00:00
Danny Tuppeny
1a0472fdca [analysis_server] Migrate some more tests to use flattened client capabilities
Change-Id: I9e466d6eb3821f8f358d9f6c6c9d69c8f0ff9733
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-09-07 18:45:27 +00:00
Sam Rawlins
736d8bcd87 Move DEPRECATED_EXPORT_USE to be a WarningCode
After this move, there are 10 remaining HintCodes: 3 are deprecated
(only reported in pre Dart 3.0 code), 5 are to be moved; 2 are to be
re-implemented as LintCodes.

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

Change-Id: I230c1c6a4defcdf1a00c0a755eac71baa1d4c9bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324420
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-09-07 18:32:53 +00:00
Danny Tuppeny
fc44a53bd5 [analysis_server] Move signature help tests to TestCode + cleanup
No functional changes, just moving from the old `markers()` functions to `TestCode`, using the flat setXxxCapabilities() style and some other minor cleanup to be consistent with other tests.

Change-Id: I8ad04cd6b50df59004d07510f4fa2f57a8cd4463
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324721
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-09-07 18:28:53 +00:00
Danny Tuppeny
aee790b69e [analysis_server] Add a test for signature help of extension type method
Change-Id: I3e4d54e63f171dfd73b11e1997feb4dba7e4b76a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324684
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-09-07 18:24:50 +00:00
Konstantin Shcheglov
db212846ed Extension type. Create navigation regions for primary constructor and representation field.
Change-Id: I491780daa376941d031bba6dd7da60655ec3e76e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324765
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-09-07 18:20:50 +00:00
Sam Rawlins
48a8903efc Avoid passing a nullable value to Completer<nn-type>.complete
This is cleanup work required to start enforcing this with static
analysis, as per dart-lang/sdk#53253.

Real quick this issue is that this code is unsafe:

```dart
void f(Completer<int> c, int? i) {
  Future<int>.value(i); // Ouch!
  c.complete(i);        // Ouch!
}
```

Change-Id: I12c4f0a92a2071fb47759d9626689e00cfa42f8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324763
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-09-07 17:55:03 +00:00
pq
725de4ea23 validate @mustBeOverridden on extension type methods
See: https://github.com/dart-lang/sdk/issues/53434

Change-Id: Ibeab460fa8cc9d7e7fa0efdb062c839659243e45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324574
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-07 17:40:31 +00:00
Sam Rawlins
4176e16c59 linter: Move avoid_slow_async_io tests
Change-Id: Ic8a1e3ecd10b635b5f353ecbbabc942905fd2832
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324482
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-07 17:09:53 +00:00
Mayank Patke
1e2146b404 [dart2js] Bump pubspec SDK constraint to 3.0.0
This CL also cleans up any required mixin declarations/uses.

Change-Id: Ib51847f01aa6c10ebf1284600455a07091a109b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324484
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-09-07 17:07:24 +00:00
Derek Xu
06d644196a Reland "[analyzer] Make KernelCompilationService use AOT frontend_server snapshot"
This is a reland of commit 21743361b0

Original change's description:
> [analyzer] Make KernelCompilationService use AOT frontend_server snapshot
>
> TEST=pkg/analyzer/test/src/summary/macro_test
>
> Change-Id: I28a37c7648de3e9b3c98b93fea1244234854e439
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322424
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Change-Id: I4be432d7afbff60ef3ee4d0221c1275edd9ef65b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323881
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-09-07 16:08:49 +00:00
Ryan Macnak
fcda00866c [build] Export all symbols for the sanitizers.
This lets the sanitizers intercept any symbol. It's not worth trying to track which symbols the sanitizers are interested in. The sanitizer builds are not distributed so concerns about incompatibility, access to internals or size do not apply.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/53440
Change-Id: I59d137f4c15863cd27af857bfca4c53d847f2b90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324566
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-09-07 15:03:08 +00:00
Tess Strickland
3bbe27eadf [vm/compiler] Perform word-sized copies in MemoryMove when possible.
When copying elements that are smaller than words on non-X86
architectures, only copy element by element until the remaining elements
can be copied in word-sized chunks, and then do so.

TEST=vm/cc/IRTest_Memory, co19{,_2}/LibTest/typed_data,
     lib{,_2}/typed_data, corelib{,_2}/list_test

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

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv64-try,vm-linux-debug-simriscv64-try,vm-mac-debug-arm64-try,vm-aot-linux-release-simarm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-mac-release-arm64-try,vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-linux-release-simarm-try,vm-linux-release-simarm64-try,vm-mac-release-arm64-try,vm-aot-android-release-arm64c-try,vm-ffi-android-debug-arm64c-try
Change-Id: I61eab310b92a6bc5ebd88fa63d562103d887cb74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324280
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-09-07 14:11:19 +00:00
Johnni Winther
622f407f16 [cfe] Handle all type parameters in TypeBuilderComputer
Closes #53427

Change-Id: Ie4bf17b54db82416d77e3bbc063d0e628a4d6c24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324500
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-09-07 13:26:49 +00:00
Aske Simon Christensen
27d321e86c [wasm_builder] Fix --watch option to work with instructions
The `--watch` debug option to print the stack trace leading to a
particular byte in the output Wasm file didn't work for instructions
after the instruction encoder was changed to produce intermediate
instruction objects.

This is fixed by keeping a map from instruction objects to stack
traces in the instructions builder and registering those stack traces
when serializing the instructions.

Change-Id: I90d665753813452d07783c7f47e1e6bf63a3a18e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324681
Reviewed-by: Jess Lally <jessicalally@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-09-07 10:43:49 +00:00
Jess Lally
5a4b252252 [dart2wasm] Replace struct.new_default with struct.new for object
allocation.

When using the `struct.new_default` instruction for object allocation,
fields are always nullable and mutable. By using the `struct.new`
instruction instead, class fields can now have the same mutability and
nullability in Wasm as declared in Dart. In addition, the class ID and
type parameters (which are also stored in an object's struct), can now
be immutable and nonnullable as well.

To do this, object construction is now split into three functions:
(1) Initializer: evaluates initializers for instance fields and
constructor initializers (this constructor before super constructor).
(2) Constructor body: executes the constructor body (super constructor
before this constructor), with `this` pointed to the constructed object.
(3) Constructor allocator: which calls (1), allocates the object using
`struct.new`, then calls (2).

Because fields now have the correct mutability and nullability in Wasm,
this removes unnecessary null checks for nonnullable fields, and may
allow for better optimisations by Binaryen.

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

Change-Id: Ib26046686f772a70509a870301217e9b1c91b77e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315820
Commit-Queue: Jess Lally <jessicalally@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-09-07 09:52:57 +00:00
Jens Johansen
2bbf99351e [analyzer] Less duplicated line starts data with multiple contexts
When having multiple contexts we have duplicates of some things.
For instance line starts data.
This CL deduplicates some of it, and makes use of `Uint16List` and
`Uint32List` as appropriate (some where regular `List<int>`s before),
reducing the heap usage for analyzing `flutter/flutter` (80+ contexts)
when analyzing with an empty cache with about 165 MB.

Details:

```
_GrowableList (dart:core) (bytes):
Difference at 95.0% confidence
   -451040.00 +/- 0.00
   -0.79% +/- 0.00%

_Uint16List (dart:typed_data) (bytes):
Difference at 95.0% confidence
   6558032.00 +/- 0.00
   696.69% +/- 0.00%

_List (dart:core) (bytes):
Difference at 95.0% confidence
   -70840960.00 +/- 231371.19
   -9.58% +/- 0.03%

_Uint32List (dart:typed_data) (bytes):
Difference at 95.0% confidence
   -103560448.00 +/- 2829564.24
   -23.56% +/- 0.64%

heapUsage:
Difference at 95.0% confidence
   -173020528.00 +/- 7787712.50
   -4.78% +/- 0.21%
```
Change-Id: I49e23dde14a2faa7c8af94515b0ad1c669867c78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324501
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-09-07 07:11:42 +00:00
Aske Simon Christensen
36d6676833 [dart2wasm] Use Wasm array for type arguments in interface type
This avoids the overhead of Dart lists in subtype checks. It also
alleviates a potential source of infinite recursion by avoiding some
list operations with implicit type checks inside the type check code
(though there are still more of these).

With this change, we no longer have the const object cycle between
the empty list of `_Type` objects and the interface type object for
`_Type`. In combination with the the `struct.new` optimization, this
enables type argument fields to become non-nullable and immutable.

Change-Id: Ib46ea70a078a0c580713090163fecd63fe363bd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322900
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Jess Lally <jessicalally@google.com>
2023-09-07 05:29:30 +00:00
Aske Simon Christensen
3a72c7a56e [dart2wasm] Support initial value and literals for Wasm object arrays
Change-Id: I6de2c1f507623afac40dab0b1601582569ef1129
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322760
Reviewed-by: Jess Lally <jessicalally@google.com>
2023-09-07 05:29:30 +00:00
Stephen Adams
d7048e410b [dart2js] SSA Control flow instructions don't have types
This is a step towards making an [empty] `HInstruction.instructionType` more reliable as an indicator that following instructions are unreachable.

- Make accessing the `.instructionType` of a HControlFlow instruction
  an error.

- Remove `AbstractValueDomain` as a constructor argument for
  `HInstruction` nodes - either it is no longer necessary (for control
  flow) or pass in the AbstractValue.

Change-Id: I642915069015fc1a42bbe46d4aaedd919a9dbdc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324344
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-09-07 04:22:57 +00:00
Srujan Gaddam
826e970588 Reland "[ddc] Don't emit type args on interop invocations"
This is a reland of commit ebc96ecb83

Angular codegen emits members that are external so DDC's external
checks need to be more specific to only focus on JS interop. This
also modifies some code logic around whether a member is JS interop
to be less permissive. Before, it claimed that any member is JS
interop if it's external and the enclosing library has a @JS
annotation, but this is only true if there is no surrounding class.

Original change's description:
> [ddc] Don't emit type args on interop invocations
>
> DDC passes type args as the first args for a generic function
> invocation, but interop functions should be excluded from doing
> so, as this leads to passing type args to JS functions.
>
> Change-Id: Ia011beca8c7a0ebb3a7e6c81cd960096045c3a06
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323941
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

Change-Id: Id48337ac4980d9de5de03d895d93cad3ab3a1808
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324542
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-09-07 00:54:57 +00:00
Brian Wilkerson
7dd241361d Change the computation of the completion node
Sorry about the size of the change.

This started as a CL to move the computation of keywords with a record
pattern from the contributor to the pass. In the process of doing so I
realized that the previous computation of the completion node (the node
that's visited) was too aggressive about moving upward in the AST. I
believe the issue happens when we reach a node in a list of similar
nodes (such as a statement in a block).

I changed the computation of the completion node, which necessitated a
lot of changes to existing code. It also resulted in changing several
tests, most for the better I think, but please look carefully for
places where you think the changes aren't reasonable. I'm also
interested in feedback about the change to the computation of the
completion node.

Change-Id: I2c6ac76fe88f672a206c3692d9ff51d2e487ec0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324620
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-09-07 00:53:55 +00:00
pq
2221dc01dc extension type support for avoid_types_as_parameter_names
Fixes: https://github.com/dart-lang/linter/issues/4744

Change-Id: I7db548e484c719450f6608876fa2a325f0a3c784
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324621
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-07 00:09:30 +00:00
Nate Biggs
2d82eb76bb [dart2js] Fix regression in Dart2JS phase3 memory usage.
Due to a recent change to improve the dump info task, the `runSequentialPhases` method was reorganized. Part of this involved adding references to the closed world and global inference indices later on in the method (after the emitter task runs) to support serialization. Though this serialization only occurs if certain flags are passed to the compiler, the VM can no longer GC the results of those earlier phases as early since they might be used.

The fix is to reassign those locals earlier on based on the dump info flags. This way the VM will track the new locals separately and can free the original references while only adding a new reference if the relevant flags are passed.

Change-Id: I8f5dbc0f88c77ab43cb3f3bf12a42ecb37c9a803
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324660
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-09-07 00:01:47 +00:00
Elliott Brooks
058669769f Unpin webdev dep now that the breaking changes have been rolled into google3
Bug: https://github.com/dart-lang/webdev/issues/2201
Change-Id: Ib13c572c95676e5a12e835c0696f3721573da2fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324567
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
2023-09-06 22:08:26 +00:00
Ryan Macnak
bb464cab79 [vm] Avoid linker warnings for run_vm_tests.
```
ld64.lld: warning: cannot export hidden symbol Dart_ActivationFrameInfo
>>> defined in obj/runtime/vm/run_vm_tests.debugger_api_impl_test.o
```

Namespace the former API functions retained for testing so they don't match the export glob Dart_*.

TEST=build
Change-Id: I4b7ed4125ef25cc33b6d4073399b0824019a1e01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324568
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-09-06 21:46:00 +00:00
Sam Rawlins
14378ed39f Avoid passing a nullable value to Completer<nn-type>.completer.
This is cleanup work required to start enforcing this with static analysis, as
per https://github.com/dart-lang/sdk/issues/53253.

Real quick this issue is that this code is unsafe:

```dart
void f(Completer<int> c, int? i) {
  Future<int>.value(i); // Ouch!
  c.complete(i);        // Ouch!
}
```

Change-Id: I91d7be0a16e62e78b530a70f115117d379259b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324541
Reviewed-by: Liam Appelbe <liama@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-09-06 19:54:00 +00:00
Ryan Macnak
ec70ca424e [test] Update the dart_2 copy of flutter_regress_91370_il_test.
Cf. 72e8b555aa.

Bug: https://github.com/dart-lang/sdk/issues/53442
Change-Id: I1a8d09bc64dc51175bb96e92b6a5d17c36398333
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324563
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-09-06 19:22:47 +00:00
Sam Rawlins
dfe24f786e [analyzer] Tidy up doc comment code
No functional chages.

* Move doc comment-specific data classes out of ast.dart into their own
  library.
* Make many fields and methods in DocCommentBuilder private, and re-sort.
* Remove a text nit from doc comment warnings.

Change-Id: I2459115c2d688ef7ba4a0fa7d3ff986ace9d3f1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324565
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-09-06 18:55:37 +00:00
asiva
f7ef52616a [IO] - Use try/catch in lookupAddresses instead of Future error.
Applying patch from @aam for using try/catch in lookupAddresses instead
of Future error.

This will be cherry picked into the stable branch to ensure we
address the expedient issue in https://github.com/dart-lang/sdk/issues/53334

TEST=new test added.

Change-Id: Ia5375cbd118d8d6437cf6869383f173cab48aa3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323684
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-09-06 18:39:14 +00:00
Ryan Macnak
194951a41f [vm] Remove library lookup caches.
The library name cache is dead.

The library exported name cache is used indirectly through Dart_Invoke etc, and is practically only used for one-shot lookups like `main` or the embedder's startup hooks. The lookups that were worth caching now happen in the Dart frontend instead of the VM.

Cf. b9045af57b

TEST=ci
Change-Id: Ibd8bd30fbba3e9af32e3fbf3c5c4ced51a8d15d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324401
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-09-06 18:11:58 +00:00
Ryan Macnak
428dd41b8c [vm] Don't leak strings when given non-normalized, unrecognized, repeated flags.
TEST=lsan
Bug: https://github.com/dart-lang/sdk/issues/53441
Change-Id: I09630ed20c96b82f0fc908a9fea008b682121424
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324564
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-09-06 18:10:33 +00:00
Jackson Gardner
8001257ed0 [dart2wasm] Support for kernel_worker and unevaluated constants.
Change-Id: Icd92cb870ffd57635962e1e9831d7d777a7b00d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323000
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2023-09-06 18:02:58 +00:00
Alexander Aprelev
2df8b46b92 [gardening] Do not reset file_modified callback - it was never set.
Attempt to reset it results in diagnostic message returned, leak detected by asan.

BUG=https://github.com/dart-lang/sdk/issues/53443
TEST=ci

Change-Id: I52242d8b45e9891abfbfea27ff2bc97f833ad6dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324562
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-09-06 16:44:58 +00:00
Ryan Macnak
b2773528d0 [vm, reload] Mark call to _nativeSetRange as no-rebind.
This is a magical direct call, not a Dart language static call. Don't attempt to re-lookup.

TEST=reload
Bug: https://github.com/dart-lang/sdk/issues/53430
Change-Id: I4b0fd2491f7d41e5f6180970abbd43e871bd18b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324263
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-09-06 16:19:48 +00:00
Sam Rawlins
b4309860f9 [linter] Move null_closures tests
Change-Id: I071bb39750c08f05137ba244298b3d13309b5585
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324540
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-06 16:11:32 +00:00
Sam Rawlins
ee44a1b0f0 [linter] Move unsafe_html tests
Change-Id: I3da2f56e6f5c389e8389c954c1d565c2e1643e4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324561
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-06 16:10:28 +00:00
Sam Rawlins
531138a840 [analyzer] Add a few items in the new-language-feature process
Change-Id: I5347867f7c71feb2f4176552118440801cad0029
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-09-06 16:03:29 +00:00
Sam Rawlins
d2a47e9cce analyzer: Add YouTube doc directive support
Work towards https://github.com/dart-lang/sdk/issues/52705

Change-Id: I4887304a4029c0279ae67bd45e8ef391a3eae56e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-09-06 15:45:48 +00:00
Ilya Yanok
7b5954ce18 Revert "[ddc] Don't emit type args on interop invocations"
This reverts commit ebc96ecb83.

Reason for revert: breaks G3, b/299279625

Original change's description:
> [ddc] Don't emit type args on interop invocations
>
> DDC passes type args as the first args for a generic function
> invocation, but interop functions should be excluded from doing
> so, as this leads to passing type args to JS functions.
>
> Change-Id: Ia011beca8c7a0ebb3a7e6c81cd960096045c3a06
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323941
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

Change-Id: Id1af7f71e80b22b48343c1d918b9431afaf6aaf4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324521
Commit-Queue: Ilya Yanok <yanok@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-09-06 15:25:58 +00:00
Aske Simon Christensen
590c9cc08f [dart2wasm] Don't emit name section for benchmarks
Since the `compile_benchmark` script is used for compiling benchmarks
which will eventually be used for binary size tracking, the generated
Wasm file should have its names stripped.

Change-Id: I5db06537e29c0316eb5c15420448c64529bc763d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324520
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Jess Lally <jessicalally@google.com>
2023-09-06 14:58:11 +00:00
Vyacheslav Egorov
c121db286a [lib] Improve IndexedIterable performance on VM
* Check against raw `EfficientLengthIterable` instead of specifying
  its type parameter. Both checks are equivalent in this context as
  `EfficientLengthIterable` is an internal marker interface and an
  instance of `Iterable<T>` can never be an instance of
  `EfficientLengthIterable` but not an instance of
  `EfficientLengthIterable<T>`.
  VM compiler is currently not good enough to eliminate the
  `is` check if involves an uninstantiated type
  (see https://dartbug.com/53445).
* Force inlining of `IndexedIterable` factory,
  `IndexedIterable.get iterator` and `IterableExtensions.indexed`.

These changes significantly reduce overhead of for-in-indexed
when compared to baseline classical loop: before these changes
for-in-indexed is 13x slower than classical loop, after these
changes it is only 2.8x slower.

Performance comparison was using the following benchmark kernels:

```dart
final list = List<int>.generate(10000, (i) => i);

// For for-in-indexed
var result = 0;
for (var (i, e) in list.indexed) {
  result ^= (i & e);
}

// For classical loop
var result = 0;
for (var i = 0; i < list.length; i++) {
  result ^= (i & list[i]);
}
```

CoreLibraryReviewExempt: No API changes, VM specific optimisations.
Change-Id: Ic935a2aab2eda0837981184d872ee1eeef89ee7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324461
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-06 14:09:11 +00:00
Johnni Winther
952b7232c3 [cfe] Enable inline-class feature by default in testing
Change-Id: I4e0c22e0cb2f568dd2792a8f5a60c60605628d08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324440
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-09-06 12:33:44 +00:00