Commit graph

22103 commits

Author SHA1 Message Date
Alexander Markov 1d985a58cd [vm/compiler] Avoid adding the same ConstantInstr both to GraphEntry and FunctionEntry initial definitions
Each instruction should appear only once in the flow graph.
Before this change a ConstantInstr from initial definitions of
GraphEntry could be also added to initial definitions of FunctionEntry.

This is also a step towards https://github.com/dart-lang/sdk/issues/36894.

TEST=ci

Change-Id: I042258dced99cbf5a908028427da2cb5a8b0d329
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253840
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-08-09 13:58:52 +00:00
Joshua Litt b99140115b [dart2wasm] Fix some js interop related issues.
Change-Id: Id189c53c7a4c536c703b0b9e83265a81d0c14094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253609
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-08-08 17:29:40 +00:00
Nicholas Shahan 9939ff116c [ddc] Ensure status file entries are consistent
Compilers named "dartdevc" and "dartdevk" should be listed together
at all locations. These are now aliases for the same compiler
across different configurations.

In the future these names should converge on "dartdevc".

Some skipped tests for "dartdevc" no longer need to be skipped but
currently there are no configurations are running those tests with
that compiler name so removing the skips shows no change in test
results.

Change-Id: Ieca27fbe497c4768293de125b14c694666dc8a8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253821
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-08-08 17:23:50 +00:00
Daco Harkes e364fda064 Reland "[cfe/ffi] Improve FFI call mismatched types compile errors"
This is a reland of commit 206fdf148c

Original change's description:
> [cfe/ffi] Improve FFI call mismatched types compile errors
>
> This CL fixes two issues.
>
> 1. `FfiNative`s now check the Dart and native type for compatiblity.
> 2. Both `FfiNative`, `asFunction`, and `lookupFunction` check the type
>    correspondence between native and Dart type with a subtype check of
>    the expected Dart type and the provided Dart type. For functions,
>    any return type is a subtype of a void type. This is fine for Dart,
>    but not for native calls. This CL manually checks the return type
>    for void.
>
> This CL does not fix the inconsistency between `asFunction` and
> `FfiNative` with regard to allowing more strict return types than
> `Object` for `Handle`s
> Issue: https://github.com/dart-lang/sdk/issues/49518
>
> Analyzer fixes in follow up CL.
>
> TEST=tests/ffi/vmspecific_static_checks_ffinative_test.dart
>
> Closes: https://github.com/dart-lang/sdk/issues/49471
> Change-Id: Ibc7bd6a1a0db59cc5fa5d755d76999fd7e9a06a4
> Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252601
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TEST=tests/ffi/vmspecific_static_checks_ffinative_test.dart

Change-Id: Ic1efba45ae8ff2585fc67fdf63c653ce090d0337
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252663
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-08-01 16:09:03 +00:00
Daco Harkes 48693c6b3d [analyzer/ffi] Error on FfiNative mismatched types
This CL applies `_validateCompatibleFunctionTypes` to `FfiNative`s.
The validation is enhanced to include `Pointer<Void>` to native field
wrapper conversion.

Also, this CL explicitly checks for `void` return types to match the
previous CL CFE behavior.

Closes: https://github.com/dart-lang/sdk/issues/49412
Change-Id: I96243ac1038321febf32f5a03507c6431fdb03d6
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252602
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-08-01 15:44:53 +00:00
Stephen Adams dc5dbbae4c [dart2js] test for #49502
Change-Id: I2f33db918476271e77befcc3466271da80ad9504
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252868
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2022-07-28 04:18:40 +00:00
Joshua Litt fe78a23e9a [js_util] Generalize dartify, and make it more robust.
Change-Id: I3608bcbdf320f6d4da2a52119d48fb02df2ad0e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252565
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-07-26 21:49:27 +00:00
Daco Harkes f9722142ee Revert "[cfe/ffi] Improve FFI call mismatched types compile errors"
This reverts commit 206fdf148c.

Reason for revert: Flutter issues are caught by this CL, preventing
Flutter from building.
https://github.com/flutter/flutter/issues/108309

Original change's description:
> [cfe/ffi] Improve FFI call mismatched types compile errors
>
> This CL fixes two issues.
>
> 1. `FfiNative`s now check the Dart and native type for compatiblity.
> 2. Both `FfiNative`, `asFunction`, and `lookupFunction` check the type
>    correspondence between native and Dart type with a subtype check of
>    the expected Dart type and the provided Dart type. For functions,
>    any return type is a subtype of a void type. This is fine for Dart,
>    but not for native calls. This CL manually checks the return type
>    for void.
>
> This CL does not fix the inconsistency between `asFunction` and
> `FfiNative` with regard to allowing more strict return types than
> `Object` for `Handle`s
> Issue: https://github.com/dart-lang/sdk/issues/49518
>
> Analyzer fixes in follow up CL.
>
> TEST=tests/ffi/vmspecific_static_checks_ffinative_test.dart
>
> Closes: https://github.com/dart-lang/sdk/issues/49471
> Change-Id: Ibc7bd6a1a0db59cc5fa5d755d76999fd7e9a06a4
> Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252601
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TBR=kustermann@google.com,dacoharkes@google.com

Change-Id: Id82b129d491adcc94cdd685a0a0f6a43248c71f2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Issue: https://github.com/dart-lang/sdk/issues/49518
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252662
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-07-25 18:18:29 +00:00
Daco Harkes 206fdf148c [cfe/ffi] Improve FFI call mismatched types compile errors
This CL fixes two issues.

1. `FfiNative`s now check the Dart and native type for compatiblity.
2. Both `FfiNative`, `asFunction`, and `lookupFunction` check the type
   correspondence between native and Dart type with a subtype check of
   the expected Dart type and the provided Dart type. For functions,
   any return type is a subtype of a void type. This is fine for Dart,
   but not for native calls. This CL manually checks the return type
   for void.

This CL does not fix the inconsistency between `asFunction` and
`FfiNative` with regard to allowing more strict return types than
`Object` for `Handle`s
Issue: https://github.com/dart-lang/sdk/issues/49518

Analyzer fixes in follow up CL.

TEST=tests/ffi/vmspecific_static_checks_ffinative_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49471
Change-Id: Ibc7bd6a1a0db59cc5fa5d755d76999fd7e9a06a4
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252601
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-07-25 14:34:39 +00:00
Alexander Thomas 237ecdb607 [infra] Add missing parenthesis in co19 update scripts
Fixes: https://github.com/dart-lang/sdk/issues/49503
Change-Id: I3e6c0450fcb7c6ff55d2ff1b1607685bb05289e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252606
Reviewed-by: Erik Ernst <eernst@google.com>
2022-07-25 14:14:59 +00:00
Anis Alibegić 40e18905f2 Fixed various typos in a lot of files
Closes https://github.com/dart-lang/sdk/pull/49478

TEST=Manual

GitOrigin-RevId: f4c9c6869dfe73639295e86574a021523b3d374d
Change-Id: I134a97caed4eec59d70e9cbca16b7e9a472cf2c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251902
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Chisholm <kevinjchisholm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2022-07-25 12:21:59 +00:00
Martin Kustermann b6c8bd7a81 [gardening] Mark all tests as slow in debug-ia32 mode
On ia32 the CFE will run from a kernel file instead of an AppJit
snapshot. This is generally not that fast. In debug mode the JIT will
have various additional verifications turned on in the runtime (e.g.
flow graph checker runs, ...) - which will make it very slow.

So we should give all tests on debug-ia32 extra time.

TEST=ci

Change-Id: Ia2738a38c5cb50a4e830af23f663f205ab4c6593
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252360
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-07-21 10:22:45 +00:00
Stephen Adams d6e78f27af [dart2js] late annotations with context
Annotations

    @pragma('dart2js:late:trust')
    @pragma('dart2js:late:check')

are now scoped, so that an annotation on a library or class will take effect unless shadowed by a closer `dart2js:late` annotation.
Currently the annotations affect only `late` fields.

Change-Id: Ida5c2b9387449263e29e74925aac9172fb3dc40c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251503
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-07-20 06:04:34 +00:00
Aske Simon Christensen d8d9e06804 [dart2wasm] Support defining, exporting and accessing Wasm tables
Tested: Added tests/web/wasm/table_test.dart
Change-Id: I3971f4432a7a59bd6bc9874fc96202a7a9f2283d
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248586
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-07-19 13:06:54 +00:00
Michael Thomsen e15d639827 Remove deprecated APIs from dart:developer
Contributes to bug: https://github.com/dart-lang/sdk/issues/34233

Change-Id: I18f12b8c8da2ec444911128b96111e93df6c0496
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251767
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-07-19 07:10:03 +00:00
Brian Quinlan 981bcf61c9 Disallow invalid content-length.
Change-Id: I502c80f6d5914683622272cca37b5ba324f9262f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248840
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-07-19 00:44:33 +00:00
Srujan Gaddam f6a3d2d5c2 [pkg:js] Transform constants and supertypes in eraser
Types in constants and supertypes need to be visited in case
they include @staticInterop types.

Fixes a bug in caching in the constant replacer.

Change-Id: Icde8b7170a8806d6a1995cad57a9788893b7772f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249441
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-07-18 18:24:53 +00:00
Alexander Markov 025bfc858e [vm] Fix yield in async* to check if the stream was canceled while generator was suspended
Previously there was a window between the decision to resume generator
and actually running the micro-task. The stream could be canceled
during that window, making running the generator incorrect.

The solution is to check if the stream was canceled right before
resuming the generator in yield/yield*.

This change also unifies yield and yield* to check if the stream
was canceled even before suspending the generator.

TEST=language/async_star/cancel_while_paused_test,
language/async_star/cancel_while_paused_at_yield_test

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

Change-Id: Ib8ff3a2da9a6a7da8766a7dbf28e2c9d618728f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251562
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-07-15 14:09:20 +00:00
Alexander Thomas da31d6f667 [infra] Remove builder detection from co19 roll scripts
Change-Id: Idf018c2cd33be10ef62310230f90f891937d84ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251547
Reviewed-by: Erik Ernst <eernst@google.com>
2022-07-15 07:29:54 +00:00
Alexander Markov 94c120a6ea [vm] Cleanup old async/async*/sync* implementation from kernel
This change removes kernel transformation which was used to
desugar async/async*/sync* functions in the old implementation of
async/async*/sync*.

The useful part of the transformation is retained in
pkg/vm/lib/transformations/for_in_lowering.dart.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: Ic70c1fb35162a31bcc22eac3a8f6488b61e945b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249944
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-07-11 18:12:41 +00:00
Ben Konyi bf19cfc8fe [ dart:developer ] Expose the set of currently registered Metrics
Fixes https://github.com/dart-lang/sdk/issues/49062

Change-Id: I2e12dd51c7e43c3cd33d7ad6716849a010ec57d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251121
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-07-11 15:52:18 +00:00
Daco Harkes aa6abbf464 [cfe/ffi] Transform FfiNatives in a single pass
Before this CL, `FfiNative`s were first transformed to `asFunction`
calls, which were then immediately transformed to `_asFunctionInternal`
calls.

This caused the the static checks to be done in two steps, the second
step happening after the first transform. It is cleaner to first do all
checks.

This refactoring enables implementing `_asFunctionInternal` variants
for `FfiNative`s that don't use a `Pointer` for the address.

Besides the transform change, this CL
- moves shared logic over to pkg/vm/lib/transformations/ffi/common.dart,
- splits up the ffi-native tests in to positive and negative tests, and
- adds negative tests for mismatches between Dart and native types.

These new tests do _not yet_ pass on the analyzer. This is tracked in:
https://github.com/dart-lang/sdk/issues/49412

TEST=tests/ffi/ffi_native_test.dart
TEST=tests/ffi/vmspecific_static_checks_ffinative_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49413
Change-Id: I5baded43eab7ff1dc1ffb16550b2a638e4b7a34e
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250843
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-07-08 12:36:09 +00:00
Daco Harkes d3ea8bff5c [vm/ffi] Fix constant Finalizables
The kernel builder relied on only seeing expressions emitted by the
finalizable transform (variable get and this) as arguments to the fence.

However, other transforms can run later. In this case the expression
was turned into a constant.

This CL changes the implementation to accept any expression rather than
accepting a subset of expressions.

TEST=tests/ffi/regress_49402_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49402
Change-Id: I1a962a5b7a38099eb5c3bbf5a5a8145b16727d97
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250744
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-07-07 08:39:21 +00:00
Alexander Markov 64f3a240fd [tests] Address comments for language/async/await_user_defined_future_soundness_test
This change is a follow-up to https://dart-review.googlesource.com/c/sdk/+/250222.

TEST=language/async/await_user_defined_future_soundness_test

Issue: https://github.com/dart-lang/sdk/issues/49345
Change-Id: I9e486a0a90fbe6df74398bd11a2be805e6d1c0a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250404
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-07-02 10:11:42 +00:00
Alexander Markov abedfaf62a [vm] Fix soundness issue when awaiting a user-defined Future
TEST=language/async/await_user_defined_future_soundness_test

Issue: https://github.com/dart-lang/sdk/issues/49345
Change-Id: Ieaaa9baace13dad242c770a710d4d459e135af81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250222
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-30 22:53:24 +00:00
Alexander Aprelev f51149eba3 [embedder] Clean up deprecated secure connection enforcement mechanism.
Addresses https://github.com/flutter/flutter/issues/54448
TEST=ci, flutter

Change-Id: If1ea8044cdfa8d593e0cd5b5201c2fbe71dd08ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248220
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
2022-06-29 16:59:25 +00:00
Srujan Gaddam 911f3a8012 [pkg:js] Handle mutually recursive libraries
Related issue: #49301

We have an invariant to make sure stubs aren't created across other
libraries but really the invariant should test for other
components, as it's valid to have two libraries call each other's
factories. Similarly, stubs need to be added to the class before we
clone the body, as the body may mutually recurse. Tests are changed
to reflect this.

Change-Id: I529b682f107a55791a52fa79f082cc8ef5fce1f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249546
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-06-28 18:36:02 +00:00
Daco Harkes a37502c1b8 [misc] Cleanup stale todos
TEST=tests/ffi

Change-Id: Iae97f62b1adb8dbe99ad075dfe750604db0de62c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249301
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2022-06-28 16:02:53 +00:00
Ryan Macnak 93a4247af3 Reapply "Account for @pragma("vm:entry-point") creating additional "root" libraries when partitioning the program into loading units."
Weaken assertion in gen_snapshot requiring all libraries to have a loading unit as there can still be unreachable libraries:
  - Google3 and Fuchsia will compile all the sources in a package to a single dill file, then present multiple input dill files to the AOT compilation. Since the set of libraries was derived from package membership instead of imports, many can be unreachable.
  - When the root library's main comes from an export, the frontend's representation will incorrectly report the library containing main as the root library and the true root library may be unreachable from it.

Instead, assert only that surviving compiled code is assigned a loading unit.

TEST=gallery
Bug: https://github.com/flutter/gallery/issues/545
Bug: https://github.com/dart-lang/sdk/issues/49325
Bug: https://github.com/dart-lang/sdk/issues/41974
Bug: b/237016312
Change-Id: Ia52563a6f517308d041368be11dcc85270f19acc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249724
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-06-27 18:56:12 +00:00
Devon Carew f0811f8ef3 [tests/standalone] remove unused imports
Change-Id: I49b94e8793082064679e963952a6c6a3eee3131c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249663
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2022-06-24 20:28:00 +00:00
Emmanuel Pellereau fd590c54c2 Revert "Make nullFuture be per-zone."
This reverts commit c97f7b7fad.

Reason for revert: Still breaking google3 (b/236665701)

Original change's description:
> Make `nullFuture` be per-zone.
>
> We introduced a `nullFuture` during the null-safety migration where
> we changed some methods to no longer allow returning `null`,
> and they therefore had to return a `Future`.
> That affected timing, because returning `null` was processed
> synchronously, and that change in timing made some tests fail.
> Rather that fix the fragile tests, we made the function return
> a recognizable future, a canonical `Future<Null>.value(null)`,
> and then recognized it and took a synchronous path for it.
>
> That caused other issues, because the future was created in the
> root zone. (Well, originally, it was created in the first zone
> which needed one, that was worse. Now it's created in the root zone.)
> Some code tries to contain asynchrony inside a custom zone, and
> then the get a `nullFuture` and calls `then` on it, and that
> schedules a microtask in the root zone.
> (It should probably have used the listener's zone, and not store
> a zone in the future at all, but that's how it was first done,
> and now people rely on that behavior too.)
>
> This change creates a `null` future *per zone* (lazily initialized
> when asked for). That should be sufficient because the code recognizing
> a returned `null` future is generally running in the same zone,
> but if any other code gets the `nullFuture`, it will be in the
> expected zone for where it was requested.
>
> This is a reland of commit a247b158d6
>
> Change-Id: Ieec74d6f93c57175c357ec18889144635f5bdca6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249490
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Erik Ernst <eernst@google.com>

TBR=lrn@google.com,eernst@google.com,nbosch@google.com

Change-Id: I870285b03ec05803c5aaa6b66f9a6e6ea360d732
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249609
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
2022-06-24 14:13:39 +00:00
Martin Kustermann 0113970da0 [gardening] Mark some tests as Pass, Slow
The tests are generally slow and sometimes hit the limit to a timout
(e.g. recently on win-debug-ia32)

TEST=Should fix flaky timeouts.

Change-Id: I8879d0e6df94046e79e43957877877a3458deb3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249607
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-24 13:26:39 +00:00
Lasse R.H. Nielsen c97f7b7fad Make nullFuture be per-zone.
We introduced a `nullFuture` during the null-safety migration where
we changed some methods to no longer allow returning `null`,
and they therefore had to return a `Future`.
That affected timing, because returning `null` was processed
synchronously, and that change in timing made some tests fail.
Rather that fix the fragile tests, we made the function return
a recognizable future, a canonical `Future<Null>.value(null)`,
and then recognized it and took a synchronous path for it.

That caused other issues, because the future was created in the
root zone. (Well, originally, it was created in the first zone
which needed one, that was worse. Now it's created in the root zone.)
Some code tries to contain asynchrony inside a custom zone, and
then the get a `nullFuture` and calls `then` on it, and that
schedules a microtask in the root zone.
(It should probably have used the listener's zone, and not store
a zone in the future at all, but that's how it was first done,
and now people rely on that behavior too.)

This change creates a `null` future *per zone* (lazily initialized
when asked for). That should be sufficient because the code recognizing
a returned `null` future is generally running in the same zone,
but if any other code gets the `nullFuture`, it will be in the
expected zone for where it was requested.

This is a reland of commit a247b158d6

Change-Id: Ieec74d6f93c57175c357ec18889144635f5bdca6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249490
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2022-06-24 11:32:30 +00:00
Jens Johansen b4e2012f5b [CFE] Remove support for .packages file
This CL:
* Removed the redirect from .packages to .dart_tool/package_config.json
  (whenever such a file existed).
* Removes support for the old format entirely.
* Updates all tests etc that were found.

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

TEST=Existing tests updated.

Change-Id: Iccf711c455ac1885189aa773ca74dd8f55012964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248603
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-06-24 08:20:39 +00:00
Emmanuel Pellereau d9d7d30820 Revert "Make nullFuture be per-zone."
This reverts commit 4d750a862d.

Reason for revert: breaks google3 (b/236665701)

Original change's description:
> Make `nullFuture` be per-zone.
>
> We introduced a `nullFuture` during the null-safety migration where
> we changed some methods to no longer allow returning `null`,
> and they therefore had to return a `Future`.
> That affected timing, because returning `null` was processed
> synchronously, and that change in timing made some tests fail.
> Rather that fix the fragile tests, we made the function return
> a recognizable future, a canonical `Future<Null>.value(null)`,
> and then recognized it and took a synchronous path for it.
>
> That caused other issues, because the future was created in the
> root zone. (Well, originally, it was created in the first zone
> which needed one, that was worse. Now it's created in the root zone.)
> Some code tries to contain asynchrony inside a custom zone, and
> then the get a `nullFuture` and calls `then` on it, and that
> schedules a microtask in the root zone.
> (It should probably have used the listener's zone, and not store
> a zone in the future at all, but that's how it was first done,
> and now people rely on that behavior too.)
>
> This change creates a `null` future *per zone* (lazily initialized
> when asked for). That should be sufficient because the code recognizing
> a returned `null` future is generally running in the same zone,
> but if any other code gets the `nullFuture`, it will be in the
> expected zone for where it was requested.
>
> This is a reland of commit a247b158d6
>
> Change-Id: Ia113756de1f6d50af4b1abfec219d6b4dcd5d59b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249488
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

TBR=lrn@google.com,nbosch@google.com

Change-Id: I02d62d58bae33d6a606a80eb3eee2e8e721a8e20
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249620
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2022-06-24 06:48:49 +00:00
Lasse R.H. Nielsen 4d750a862d Make nullFuture be per-zone.
We introduced a `nullFuture` during the null-safety migration where
we changed some methods to no longer allow returning `null`,
and they therefore had to return a `Future`.
That affected timing, because returning `null` was processed
synchronously, and that change in timing made some tests fail.
Rather that fix the fragile tests, we made the function return
a recognizable future, a canonical `Future<Null>.value(null)`,
and then recognized it and took a synchronous path for it.

That caused other issues, because the future was created in the
root zone. (Well, originally, it was created in the first zone
which needed one, that was worse. Now it's created in the root zone.)
Some code tries to contain asynchrony inside a custom zone, and
then the get a `nullFuture` and calls `then` on it, and that
schedules a microtask in the root zone.
(It should probably have used the listener's zone, and not store
a zone in the future at all, but that's how it was first done,
and now people rely on that behavior too.)

This change creates a `null` future *per zone* (lazily initialized
when asked for). That should be sufficient because the code recognizing
a returned `null` future is generally running in the same zone,
but if any other code gets the `nullFuture`, it will be in the
expected zone for where it was requested.

This is a reland of commit a247b158d6

Change-Id: Ia113756de1f6d50af4b1abfec219d6b4dcd5d59b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249488
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-06-23 09:19:45 +00:00
Emmanuel Pellereau 707ade91c9 Revert "Make nullFuture be per-zone."
This reverts commit a247b158d6.

Reason for revert: breaks google3. See b/236665701.

Original change's description:
> Make `nullFuture` be per-zone.
>
> We introduced a `nullFuture` during the null-safety migration where
> we changed some methods to no longer allow returning `null`,
> and they therefore had to return a `Future`.
> That affected timing, because returning `null` was processed
> synchronously, and that change in timing made some tests fail.
> Rather that fix the fragile tests, we made the function return
> a recognizable future, a canonical `Future<Null>.value(null)`,
> and then recognized it and took a synchronous path for it.
>
> That caused other issues, because the future was created in the
> root zone. (Well, originally, it was created in the first zone
> which needed one, that was worse. Now it's created in the root zone.)
> Some code tries to contain asynchrony inside a custom zone, and
> then the get a `nullFuture` and calls `then` on it, and that
> schedules a microtask in the root zone.
> (It should probably have used the listener's zone, and not store
> a zone in the future at all, but that's how it was first done,
> and now people rely on that behavior too.)
>
> This change creates a `null` future *per zone* (lazily initialized
> when asked for). That should be sufficient because the code recognizing
> a returned `null` future is generally running in the same zone,
> but if any other code gets the `nullFuture`, it will be in the
> expected zone for where it was requested.
>
> Change-Id: Ibe204eaabe175cbcbcb7822ca1f2bcdda72a478c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248660
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

TBR=lrn@google.com,nbosch@google.com

Change-Id: Ic765eb1401dbff4dea6c08c007c0bf9aff186684
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249188
Reviewed-by: Oleh Prypin <oprypin@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
2022-06-21 07:33:23 +00:00
Lasse R.H. Nielsen a247b158d6 Make nullFuture be per-zone.
We introduced a `nullFuture` during the null-safety migration where
we changed some methods to no longer allow returning `null`,
and they therefore had to return a `Future`.
That affected timing, because returning `null` was processed
synchronously, and that change in timing made some tests fail.
Rather that fix the fragile tests, we made the function return
a recognizable future, a canonical `Future<Null>.value(null)`,
and then recognized it and took a synchronous path for it.

That caused other issues, because the future was created in the
root zone. (Well, originally, it was created in the first zone
which needed one, that was worse. Now it's created in the root zone.)
Some code tries to contain asynchrony inside a custom zone, and
then the get a `nullFuture` and calls `then` on it, and that
schedules a microtask in the root zone.
(It should probably have used the listener's zone, and not store
a zone in the future at all, but that's how it was first done,
and now people rely on that behavior too.)

This change creates a `null` future *per zone* (lazily initialized
when asked for). That should be sufficient because the code recognizing
a returned `null` future is generally running in the same zone,
but if any other code gets the `nullFuture`, it will be in the
expected zone for where it was requested.

Change-Id: Ibe204eaabe175cbcbcb7822ca1f2bcdda72a478c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248660
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-06-20 08:00:01 +00:00
Daco Harkes 1fdd242e4b [deps] Roll package:ffi to 2.0.1
Bug: https://github.com/dart-lang/ffi/issues/148
Change-Id: I406c6a0fbdb53c07507519f1237e09362e3475d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249160
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-06-19 18:29:11 +00:00
Stephen Adams 6dd17d6ec4 [runtime] Avoid SIGSEGV on String.*
Correctness changes:

Fix SEGV by checking for overflow in computing the length of the
repeated string.

Performance changes:

Use unnested loops to fill the string instead of nested loops.

Implement `operator *` for _TwoByteString in the same way.

(The default implementation using StringBuffer causes a lot of
allocations. For example, `"α" * 10000` repeatedly adds the small
string to the StringBuffer, which repeatedly compresses a sequence of
small strings to make a bigger string to stop the list of parts
becoming too large. This compression creates a lot of small strings
with the same contents.)

Bug: 49289
Change-Id: I06c3d91b531d7e4fffc8de9f3bada3eb62ad185f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249122
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-19 17:02:41 +00:00
Stephen Adams 5b76ad2de8 Test for issue 49287
Change-Id: Ia2216b4513e149b54813ffc783dd4c03a5fe1e33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249101
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-18 17:57:40 +00:00
Srujan Gaddam 459d57c8b8 [package:js] Add static interop stub for outlines
Fixes b/235393918

@staticInterop replaces factories with a new named node, a static
method. In order to persist this transformation in modular
compilation, this needs to be done to outlines that can then be
consumed by the source library. In order to allow erasure at the
time of 'performOutlineTransformations', coreTypes is added to that
API.

Change-Id: I90d17fff8bbe143982fcd12cfb06dc3e8d58781a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247928
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-17 19:58:49 +00:00
Alexander Aprelev 6d923dfd99 Revert "Deprecate outdated errors, drop CastError and NullThrownError."
This reverts commit 0f3dea33f9.

Reason for revert: breaks dart->engine roller as flutter still uses NullThrownError, fails analysis step

Original change's description:
> Deprecate outdated errors, drop `CastError` and `NullThrownError`.
>
> Both `CastError` and `NullThrownError` becomes just (deprecated) aliases for `TypeError`.
>
> `FallThroughError` becomes deprecated. Fall-through was made a compile-time error in Dart 2.0, the error should no longer be used.
>
> `CyclicInitializationError` is deprecated. Null safe Dart doesn't specify which error a late initialization error throws. We use internal errors now.
>
> These errors should not be needed in sound null-safe mode (if they are even needed now), and so should be removed in Dart 3.0.
>
> TEST= No new tests, should not change behavior in a significant way.
>
> Bug: https://github.com/dart-lang/sdk/issues/49141
> Change-Id: I636e9a0d0c32021d40bb819a88a1f57db6efc5a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247384
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Brian Quinlan <bquinlan@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/49141
Change-Id: I1b2802ec69fe654525e683527ff3554ff972f0c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248741
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-16 17:12:19 +00:00
Lasse R.H. Nielsen 330759efc0 Refactor to implement Stream.fromIterator more directly.
The current implementation uses a specialized version of the
pending-event queue used by stream subscriptions to remember
pending events.
That makes the queue polymorphic, and slightly more complicated than
necessary, and that again makes further refactorings of the
Stream implementation harder.

This change moves the logic from the specialized pending-queue
into a simple function instead, so you only pay for it if you
actually use `Stream.fromIterable`.

Also allows `Stream.fromIterable` to be listened to more than once.
(It uses `Stream.multi` for the general async+sync controller API,
and it would cost extra code to make it only work once.)

Change-Id: I44b2010225cd3d32c2bcdb8a315c94881331bdae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248146
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-06-16 11:39:30 +00:00
Lasse R.H. Nielsen 0f3dea33f9 Deprecate outdated errors, drop CastError and NullThrownError.
Both `CastError` and `NullThrownError` becomes just (deprecated) aliases for `TypeError`.

`FallThroughError` becomes deprecated. Fall-through was made a compile-time error in Dart 2.0, the error should no longer be used.

`CyclicInitializationError` is deprecated. Null safe Dart doesn't specify which error a late initialization error throws. We use internal errors now.

These errors should not be needed in sound null-safe mode (if they are even needed now), and so should be removed in Dart 3.0.

TEST= No new tests, should not change behavior in a significant way.

Bug: https://github.com/dart-lang/sdk/issues/49141
Change-Id: I636e9a0d0c32021d40bb819a88a1f57db6efc5a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247384
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-06-15 15:35:58 +00:00
Ahmed Ashour 85700570f6 Fix typos
Fixes #49241

TEST=ci

Change-Id: I6117bf816fc8c4613cce66927f952fef75632725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248120
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-06-15 11:08:28 +00:00
Joshua Litt 76ccc89a10 [dart2wasm] Fix a number of minor JS interop issues.
This CL fixes a number of minor JS interop issues.
* `dartify` was moved to Dart, so we can control implicit coercion from JS
* All JS types are 'correctly' handled in `dartify` though a few are boxed
  as opaque types that could be exposed.
* The logic to convert a JS array is now driven from the Dart side.
* Function, Number, and Boolean can now make the roundtrip through Dart.
* The wrapper for Dart functions in JS is now a regular JS function.

Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try

Change-Id: Ifcd7a447419bca2adf78070e07750c1b3c5c6a18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247925
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-06-14 17:32:39 +00:00
Johnni Winther 7900e9071a [cfe] Remove support for old super-mixins feature
This CL remove the support for mixing in classes that don't extend
Object. An error has been report by the analyzer for some time and
now also by the CFE.

This puts the breaking change https://github.com/dart-lang/sdk/issues/48167 into effect.

TEST=pkg/front_end/testcases/general/issue48167.dart

Change-Id: Ia7715a27dc1aa18a7c85b24ed86d19a91b6924d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247551
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-13 15:30:57 +00:00
Ahmed Ashour 8bb3a10e40 Fix typos
Fixes #49228

TEST=ci

Change-Id: Idcc625554bcf07807bae9791ea37b73ae9394b87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247960
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-06-10 15:48:54 +00:00
Alexander Markov de43a7c16a [vm] Cleanup --lazy-async-stacks VM option
This option was enabled by default in https://dart-review.googlesource.com/c/sdk/+/149288
This change removes old logic behind --no-lazy-async-stacks
and makes --lazy-async-stacks/--no-lazy-async-stacks options no-op.

TEST=ci

Change-Id: I5726690e90e78dd2ac37d8c5944e388042fc3acf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247780
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-10 13:41:24 +00:00
Daco Harkes a855030120 [vm/ffi] Allow struct nesting with looser packing
C compilers don't enforce nesting rules. `dart:ffi` was enforcing these
rules causing issues for binding to C libraries having looser packing
for nested structs than outer structs.

This CL completely removes the error from the analyzer and CFE.
(As an alternative we could have kept a hint/lint, but this might create
more noise than value.)

TEST=pkg/analyzer/test/src/diagnostics/packed_nesting_non_packed_test.dart

Closes: https://github.com/dart-lang/sdk/issues/46644
Change-Id: Iae2d5c885546f7799bc6dea2f8cd7dd508216a0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247382
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-06-09 19:08:43 +00:00
Siva Annamalai 5cb3b37c74 Revert "Refactor _Future."
This reverts commit 69f32d6ad7.

Reason for revert: We seem to have a number of tests failing with timeouts in CBUILD after this change, please see logs at
69f32d6ad7

Original change's description:
> Refactor `_Future`.
>
> This is a major rewrite of the `_Future` class,
> which is the default implementation of the `Future` interface.
>
> The main goal was to reduce the number of expensive type checks
> in the internal passing around of data.
> Expensive type checks are things like
> * `is _Future<T>` (more expensive than just `is _Future`, the latter
>   can be a single class-ID check.
> * Covariant generic parameter checks (using `T` covariantly in a
>   parameter forces a run-time type check).
>
> Also removed some plain unnecessary casts and turned some
> implicit casts from `dynamic` into `unsafeCast`s.
>
> This seems to be an success, at least on very primitive benchmarks, according to Golem:
> FutureCatchErrorTest    41.22% (1.9 noise)
> FutureValueTest         46.51% (2.8 noise)
> EmptyFutureTest         59.15% (3.1 noise)
> FutureWhenCompleteTest  51.10% (3.2 noise)
>
> A secondary goal was to clean up a very old and messy class,
> and make it clearer for other `dart:async` how to interact
> with the future.
>
> The change has a memory cost: The `_FutureListener<S,T>` class,
> which represents a `then`, `catchError` or `whenComplete`
> call on a `_Future`, now contains a reference to its source future,
> the one which provides the inputs to the callbacks,
> as well as the result future returned by the call.
> That's one extra memory slot per listener.
>
> In return, the `_FutureListener` now does not need to
> get its source future as an argument, which needs a covariant
> generic type check, and the methods of `_Future` can be written
> in a way which ignores the type parameters of both `_Future`
> and `_FutureListener`, which reduces complex type checks
> significantly.
>
> In general, typed code is in `_FutureListener`, which knows both
> the source and target types of the listener callbacks, and which
> contains the futures already at that type, so no extra type checking
> is needed.
> The `_Future` class is mostly untyped, except for its "public"
> API, called by other classes, which checks inputs,
> and code interacting with non-native futures.
> Invariants ensure that only correctly typed values
> are stored in the untyped shared `_resultOrListeners` field
> on `_Future`, as determined by its `_state` integer.
> (This was already partially true, and has simply been made
> more consistent.)
>
> Further, we now throw an error in a situation that was previously
> unhandled: When a `_Future` is completed with *itself*.
> That would ensure that the future would never complete
> (it waits for itself to complete before it can complete),
> and may potentially have caused weird loops in the representation.
> In practice, it probably never happens. Now it makes the error
> fail with an error.
> Currently a private `_FutureCyclicDependencyError` which presents
> as an `UnsupportedError`.
> That avoids code like
> ```dart
> import "dart:async";
> void main() {
>   var c = Completer();
>   c.complete(c.future); // bad.
>   print("well!");
>   var d = Completer();
>   d.complete(c.future);
>   print("shucks!");
> }
> ```
> from hanging the runtime by busily searching for the end of a cycle.
>
> See https://github.com/dart-lang/sdk/issues/48225
> Fixes #48225
>
> TEST= refactoring covered by existing tests, few new tests.
>
> Change-Id: Id9fc5af5fe011deb0af3e1e8a4ea3a91799f9da4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244241
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

TBR=lrn@google.com,kustermann@google.com,sra@google.com,sigmund@google.com,nshahan@google.com

Change-Id: I455be5a04b4c346df26d4ded0fa7388baccb0f8c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247762
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-09 16:51:55 +00:00
Lasse R.H. Nielsen 69f32d6ad7 Refactor _Future.
This is a major rewrite of the `_Future` class,
which is the default implementation of the `Future` interface.

The main goal was to reduce the number of expensive type checks
in the internal passing around of data.
Expensive type checks are things like
* `is _Future<T>` (more expensive than just `is _Future`, the latter
  can be a single class-ID check.
* Covariant generic parameter checks (using `T` covariantly in a
  parameter forces a run-time type check).

Also removed some plain unnecessary casts and turned some
implicit casts from `dynamic` into `unsafeCast`s.

This seems to be an success, at least on very primitive benchmarks, according to Golem:
FutureCatchErrorTest    41.22% (1.9 noise)
FutureValueTest         46.51% (2.8 noise)
EmptyFutureTest         59.15% (3.1 noise)
FutureWhenCompleteTest  51.10% (3.2 noise)

A secondary goal was to clean up a very old and messy class,
and make it clearer for other `dart:async` how to interact
with the future.

The change has a memory cost: The `_FutureListener<S,T>` class,
which represents a `then`, `catchError` or `whenComplete`
call on a `_Future`, now contains a reference to its source future,
the one which provides the inputs to the callbacks,
as well as the result future returned by the call.
That's one extra memory slot per listener.

In return, the `_FutureListener` now does not need to
get its source future as an argument, which needs a covariant
generic type check, and the methods of `_Future` can be written
in a way which ignores the type parameters of both `_Future`
and `_FutureListener`, which reduces complex type checks
significantly.

In general, typed code is in `_FutureListener`, which knows both
the source and target types of the listener callbacks, and which
contains the futures already at that type, so no extra type checking
is needed.
The `_Future` class is mostly untyped, except for its "public"
API, called by other classes, which checks inputs,
and code interacting with non-native futures.
Invariants ensure that only correctly typed values
are stored in the untyped shared `_resultOrListeners` field
on `_Future`, as determined by its `_state` integer.
(This was already partially true, and has simply been made
more consistent.)

Further, we now throw an error in a situation that was previously
unhandled: When a `_Future` is completed with *itself*.
That would ensure that the future would never complete
(it waits for itself to complete before it can complete),
and may potentially have caused weird loops in the representation.
In practice, it probably never happens. Now it makes the error
fail with an error.
Currently a private `_FutureCyclicDependencyError` which presents
as an `UnsupportedError`.
That avoids code like
```dart
import "dart:async";
void main() {
  var c = Completer();
  c.complete(c.future); // bad.
  print("well!");
  var d = Completer();
  d.complete(c.future);
  print("shucks!");
}
```
from hanging the runtime by busily searching for the end of a cycle.

See https://github.com/dart-lang/sdk/issues/48225
Fixes #48225

TEST= refactoring covered by existing tests, few new tests.

Change-Id: Id9fc5af5fe011deb0af3e1e8a4ea3a91799f9da4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244241
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-06-09 15:32:33 +00:00
Alexander Markov 3e0abdbb98 Reland "[vm] Enable new implementation of async/async* in JIT mode"
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I5b8720b8ef5b8d28773d26c7e94c2e78d876c9d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247603
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-09 15:24:13 +00:00
Brian Quinlan e5af733398 Handle the case where HttpClientRequest.maxRedirects==0
Bug: https://github.com/dart-lang/sdk/issues/49012
Change-Id: Iaec1073b0797564058e99e2dde0d138f1eccbb92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247020
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-06-09 01:02:24 +00:00
Joshua Litt 3fd96e2cb8 [dart2wasm] Wire up stubbed out dart:js on dart2wasm
Change-Id: Ia06db4b1b2f3d07278819936842a4185cc9a45f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247329
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-06-08 20:38:52 +00:00
Alexander Markov 3e10d8c833 Revert "[vm] Enable new implementation of async/async* in JIT mode"
This reverts commit b3544c44dc.

Reason for revert: avoid incompatibility between Dart->kernel compiler
and Dart VM during Dart and Flutter rolls (b/234850964).

TEST=ci

Original change's description:
> [vm] Enable new implementation of async/async* in JIT mode
>
> TEST=ci
>
> Issue: https://github.com/dart-lang/sdk/issues/48378
> Change-Id: I0fc069508cb1ce5648deb6604171dfdcd5bcb5c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246082
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

TBR=vegorov@google.com,kustermann@google.com,rmacnak@google.com,alexmarkov@google.com,johnniwinther@google.com

Change-Id: I6157623857dbfa9bb07eb1f620d100f5b24314d9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Issue: https://github.com/dart-lang/sdk/issues/48378
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247243
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-06-07 17:57:30 +00:00
Ömer Sinan Ağacan 1456af7b97 [dart2wasm] Implement backward jumps in switch statements
Change-Id: I1c39722edb72d7fb5128bb9fe7e4d03ce4041849
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246443
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-06-07 08:30:29 +00:00
Joshua Litt d872e74a6d [js] Support js_util on Dart2wasm.
This CL consists of:
1) Moving most of the contents of `js_util_wasm_patch` to
   `js_util_patch` and `js_helper`.
2) Addressing the inconsistencies between `js_util` and `js_util_wasm`.
3) Fixing a minor bug with nested `allowInterop` in
   `js_util_wasm_optimizer`.
4) Removing hardcoded eval.

Change-Id: Ie43cdc91d344745ef9b40e273192b34af2a84138
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246380
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-06-06 18:18:20 +00:00
Nate Bosch 75ed6c01fb Make path argument optional for Uri.http(s)
Closes #49165

The empty string argument can be confusing to read since it is not clear
what it means. Allow omitting the argument entirely to default to an
empty path.

R=lrn@google.com

Change-Id: I05ca432a679a0df751a16d1beb241b14f80d4681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246988
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2022-06-03 18:07:27 +00:00
Sigmund Cherem e808fa1751 [jsinterop] Add static check for JSName of static class members.
Static class members could technically be mapped to a name with dots,
but in the early days of JSInterop we thought this was not necessary
since it could also be modeled as a top-level member or by adding
additional classes and exposing the member as a simple name on a deeper
class.

This invariant was assumed by DDC (which crashed if this was not the
case) and ignored by dart2js.

This change adds a static check to ensure both compilers act
consistenlty.

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

Change-Id: I20e59fbb75f0378a58ca88dc3910e079b4eeb7a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247180
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2022-06-03 17:02:26 +00:00
Sigmund Cherem 0517e97250 [dart2js] Fix stub generator.
When generating the tear-off stub of a JSInterop method, dart2js
associated the full JSName as the target name, as opposed to a
target path. This meant that code like:

  @JS('console.log')
  external consoleLog(arg1, [arg2]);

  main() => (consoleLog)(1);

Generated a tear-off with code like:

  self[console.log](arg);

Instead of:

  self.console.log(arg);

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

Change-Id: I7abb320ce790e2ce533031fefd3abc15f8958b5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246340
Reviewed-by: Stephen Adams <sra@google.com>
2022-06-03 17:02:26 +00:00
Alexander Markov b3544c44dc [vm] Enable new implementation of async/async* in JIT mode
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I0fc069508cb1ce5648deb6604171dfdcd5bcb5c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246082
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-02 23:40:15 +00:00
Alexander Markov af4da780be [vm] New async/async* implementation in JIT mode
The new implementation is based on suspend/resume stubs and doesn't
use desugaring of async functions on kernel AST.

Previously, new implementation of async/async* was only supported in
AOT mode. This change adds all necessary bits for the JIT mode:

 * Suspending variable-length frames (for unoptimized code).
 * Handling of Code and pool pointers in Dart stack frames.
 * OSR.
 * Deoptimization.
 * Hot reload.
 * Debugger.

The new implementation is not enabled in JIT mode yet.

Design doc: go/compact-async-await.
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I477d6684bdce7cbc1edb179ae2271ff598b7dcc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246081
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-02 23:39:45 +00:00
Jonas Termansen 83850ac5fa [io] Don't restore terminal state on exit.
This is breaking change #45630.

The Dart VM has until now restored the terminal settings upon exit to
their initial values for stdin, stdout, and stderr. This change removes
that automatic behavior in favor of having the program do the
restoration. Previously the intention was that dart programs can
enable/disable echoing and line buffering and not worry about restoring
the original settings.

However, the VM doing so unconditionally leads to undesirable behavior
e.g. when the program does not care about terminal settings and is
sharing a process group with a program that does care. E.g. if dart's
output is piped into less(1), then there is a race condition where dart
might see the raw terminal settings set by less(1), and if the dart VM
exits after less(1) has exited, then it will restore the raw terminal
settings, leaving the user with a seemingly defective shell with echo
disabled. This race condition can be reproduced using:

    cat > yes.dart << EOF
    main() {
      for (int i = 0; i < 1000000; i++) {
        print("yes");
      }
    }
    EOF
    stty; (sleep 1 && dart yes.dart) | less; stty; stty sane

The user will end up with a shell with echo behavior disabled. The stty
command shows the current terminal settings, where the difference can be
seen, and 'stty sane' fixes the settings before returning to the shell
prompt. The 'stty sane' call can be omitted to see the defective shell
prompt.

This change removes the terminal restoring behavior (added in Dart
2.0.0) and instead asks applications to do the restoration themselves.
The new design matches how programs in other programming languages
implement interactive input that changes terminal settings.

Furthermore the `echoMode` setting now only controls the `echo` local
mode and no longer sets the `echonl` local mode on POSIX systems (which
controls whether newline are echoed even if the regular echo mode is
disabled). The `echonl` local mode is usually turned off in common shell
environments. Programs that wish to control the `echonl` local mode can
use the new `echoNewlineMode` setting. This change is required to
prevent the reoccurence of #30318 when programs manually restore
`echoMode`.

Windows has further considerations: It also saves the console code pages
and restore them if they were not UTF-8. This behavior is retained as it
is useful and needed for Dart's output to function properly. ANSI output
sequences are also turned on via ENABLE_VIRTUAL_TERMINAL_PROCESSING,
which is slightly changed in this change to only rsetore that setting if
it wasn't already on for consistency.

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

TEST=Reproduced with less as above

Change-Id: I2991f9c7f47b97fe475c1ad6edeb769024f8d0db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190484
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-05-31 15:36:33 +00:00
Konstantin Shcheglov 58ae856422 Issue 48004. Report when null-aware operator is used on type.
Bug: https://github.com/dart-lang/sdk/issues/48004
Change-Id: I61c658f9974fdb2023aa999bf34ee873e348058a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-05-29 19:03:15 +00:00
Ryan Macnak 38f9b339e3 [vm, compiler] Fix BigInt._rsh intrinsic when shifting out at least one word on RISC-V.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/49067
Change-Id: I3f7041243334da3a106534f7cf4903a7c34b272c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245780
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-26 22:54:29 +00:00
Paul Berry 0a92b0c3aa Turn on the experimental feature inference-update-1.
Fixes https://github.com/dart-lang/language/issues/731.

Change-Id: I5fee1470efe7b891b79dcfecd33bc3670590efb3
Tested: trybots, and global presubmit in the internal mono repo
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243530
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
2022-05-24 13:54:23 +00:00
Ahmed Ashour a6fcb56901 Fix typos
Fixes #49094

TEST=ci

Change-Id: I23cdcb5ad2fc83e5e91d80e34b66af186c0cb923
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-05-24 09:10:51 +00:00
Nicholas Shahan 444982f364 [web] Share more runtime code between ddc and dart2js
Creates a new 'dart:_js_shared_embedded_names' library for the names
accessed from the shared 'dart:_rti' library. Migrate all of the shared
symbols and uses to the new location.

Change-Id: Iaa72c4522888ad630782b921b0b70d7a2626d1b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241507
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-05-23 18:04:10 +00:00
Stephen Adams cbb15c3742 [corelib] Fix bug in VM implementation of BigInt.bitLength
Change-Id: I8664013e27c9c43cd71dd9a271c2e61404d37feb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244764
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2022-05-19 23:29:51 +00:00
Johnni Winther 5222bfd90c [cfe] Refactor bounds checking
This CL moves the bounds checking into the TypeBuilder instead of
performing it from the outside on the computed DartType node.
This solves several problems:

  1) Errors are now reported on the type in the code instead of the
     declaration which holds the type.
  2) Checking of type aliases (both function and nonfunction type
     aliases) is now handled correctly in all cases. This achieved by
     computed the aliased type (containing TypedefType nodes)
     internally and performing the checking on this type, and only
     convert the type into the unaliased version (without TypedefType
     nodes) after checks have been performed. Previously this handled
     through the FunctionType.typedefType property for function type
     aliases and through and incomplete work-around for nonfunction
     type aliases.
  3) With 2) FunctionType.typedefType is no longer needed and is
     removed.

TEST=general/bounds_*

Change-Id: I7653bca5ccb0ebf4b3553828a298d1ad918ef235
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243722
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-17 14:36:19 +00:00
Joshua Litt c6d5cd043b [js_util] Add dartify and some helpers.
Change-Id: I40822d87a7fef9e4de563ccb73046eee78f34b21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243846
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-05-16 21:31:47 +00:00
asiva e8290f7f5a [VM/io] - Reland : Set correct file type for files backing unix domain sockets
The file type of file backing unix domain sockets was being incorrectly
set as kDoesNotExist resulting in errors when operations like delete
on the file was done. File::Exists on the other hand returned true.
File rename and copyfile functionality have been fixed too.

TEST=new tests added

Please see https://github.com/dart-lang/sdk/issues/48569 for the original issue.

Change-Id: I28505236fbad2ea86ad65065e753b13fb7ff655a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240300
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-05-15 00:40:07 +00:00
Daco Harkes e418026d74 [vm/ffi] Support late Finalizable variables
This CL changes the IL building for reachability fences to their call
sites. This enables us to catch the field load and tell it to not emit
an initialization check for late fields.

The sentinel value will now flow into the ReachabilityFenceInstr, where
it will be discarded.

TEST=tests/language/vm/regress_49005_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49005
Change-Id: Ic21c9905290925eb83860d8394b13be7dd7592c1
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244628
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-05-13 16:44:26 +00:00
Alexander Aprelev 1e5d063b21 [vm/sim/simd] Fix vmin/vmax implementation on simulator.
minss/maxss used by simulator 0.0==-0.0, which is inconsistent with arm native instructions.

Fixes https://github.com/dart-lang/sdk/issues/48988
Addresses https://github.com/dart-lang/sdk/issues/40426
TEST=ci

Change-Id: I9d88d89e342bb543b1e90fdbe3c7aa8303353dab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244320
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-05-11 16:59:24 +00:00
Aske Simon Christensen de3cec3a47 Make hashcode override test throw instead of looping indefinitely.
This achieves the same thing (test that `hashCode` is not called), but
avoids a costly timeout on failure. This drastically cuts down the total
testing time for the language and corelib suites for dart2wasm (which
intends not to implement a special case here, since it is going to be
illegal in the future anyway).

Change-Id: I040925ebd8271a5816c81bc16484c0a96626857d
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244061
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2022-05-11 11:48:26 +00:00
Mayank Patke 34ebfc6594 [dart2js] Add regression test for https://dart-review.googlesource.com/c/sdk/+/225320
Change-Id: Iff348b9ce13ea249b8c63f8c0952cd446ad5cb7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243528
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-05-10 22:56:23 +00:00
Paul Berry 0d636e5543 Ensure that partial inference results aren't refined by later partial inference stages.
As part of the implementation of
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.), I expanded the front end's type inference logic so
that instead of just having a downward phase and an upward phase, it
could have 3 or more phases.  The function that previously did
downward inference became repurposed to do "partial inference" (which
could either be the first, downward stage, or a later, horizontal
stage).  However, I failed to generalize the logic that prevents types
assigned by one inference stage from being refined by later
stages--previously this logic was only needed for upward inference,
but now it's needed for horizontal inference stages as well.  (This
logic is needed because of Dart's "runtime checked covariance"
behavior--it means that we want to stick with the type from downward
inference, even if a later horizontal inference stage is able to find
a more precise type, because that more precise type may lead to
runtime failures).

As part of this change I've re-architected the inference methods so
that they are responsible for creating and returning the list of
inferred types.  This makes the inference logic more similar between
the front end and analyzer, and is easier to read IMHO.  The total
number of list allocations is the same as before.

Change-Id: I19bfcede9c2968e50f110b571164549f16495217
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243707
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-05-10 15:10:44 +00:00
Paul Berry 51d578cf91 Fix horizontal inference logic for extension method invocations.
The front end desugars extension methods by inserting a synthetic
`this` argument before all other arguments.  But this synthetic
argument isn't included in the `formalTypes` and `actualTypes` arrays.
So when recording a value into
`_DeferredParamInfo.evaluationOrderIndex` we may need to subtract 1 in
order to ensure that later logic will find the correct argument.

Fixes a corner case of https://github.com/dart-lang/language/issues/731.

Change-Id: Idbf136195e40555199f7c5b61a575a430f6ec6bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243854
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-05-10 14:54:53 +00:00
Alexander Aprelev 2a12dd3315 [vm/simd] Add Float64x2 clamp simd implementation
Fixes https://github.com/dart-lang/sdk/issues/40427

TEST=ci, float64x2_clamp_test

Change-Id: I12618c37135feecffb115ce4aca02af1ecb03167
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243848
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-05-10 04:56:25 +00:00
Joshua Litt 2783cca57d [dart2js] Fix bug in impact data serialization.
Change-Id: I1e4915624b609aafa9392fc651f5935bf658a71b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244184
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-05-10 03:34:13 +00:00
Paul Berry ce591d17c3 Resolve deferred function literals in stages.
This change allows function literals in invocations to be inferred in
dependency order.  For example, given the following code:

    U f<T, U>(T Function() g, U Function(T) h) => h(g());
    test() {
      var x = f(() => 0, (y) => [y]);
    }

The function literal `() => 0` is inferred first, causing the type
parameter `T` to be assigned the type `int`.  Then, `(y) => [x]` is
inferred with the benefit of this type assignment, so `y` gets the
type `int`, and consequently, `U` gets assigned the type `List<int>`.

This completes the support for
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.)

Change-Id: I48c22693720a1cc8bbf435643e863834e07f02b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243002
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-05-03 22:04:39 +00:00
Nicholas Shahan 651350bc3b [ddc] Avoid emitting dead branches in conditionals
Don't emit dead code branches that are guarded by boolean literals.

Add a single level of simplification for !true -> false, and
!false -> true.

While this might not be very common in code, it does allow for a
useful pattern in the runtime libraries. Branches can be included
into the compiled code or not based on a compile time flag.

Change-Id: Ib90e1e951cea3ef8c75b944635776b292759594a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243363
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
2022-05-03 20:17:44 +00:00
Liam Appelbe b6cfea8d8b Remove trailing null char from IOOverrides.fseGetType
This null char is inserted by _toNullTerminatedUtf8Array, and right
below that function is _toStringFromUtf8Array, which does the opposite.
But _toStringFromUtf8Array is currently dead code, so it looks like the
intent was always to use _toStringFromUtf8Array for this, and the fact
that utf8.decode was being used instead is just a mistake.

Bug: https://github.com/dart-lang/sdk/issues/34885
Change-Id: I1404c7783b055902b256176aa61971c0d6969f5e
Fixes: https://github.com/dart-lang/sdk/issues/34885
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243103
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-05-02 21:16:20 +00:00
Paul Berry 8566dbeb57 Fix spelling
Change-Id: I831388f23f907781b13c6026a8bcfae9fbcc7e18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243001
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-05-02 14:32:40 +00:00
Paul Berry 40632d7186 Ensure that parenthesized function literals are deferred too.
When a function literal is wrapped in parentheses, it shouldn't affect
how it interacts with type inference.  This change ensures that
parenthesized function literals are treated the same as
unparenthesized ones by the logic that supports
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.)

Change-Id: I672787a31addbfe3f3282b6e638e00b693eea46f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243000
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-04-29 20:35:51 +00:00
Alexander Markov bf4bb95308 [vm] New async/await implementation in the VM, part 2 - vm
The new implementation moves away from desugaring of async
functions on kernel AST, state machine generated in the flow graph and
capturing all local variables in the context.

Instead, async/await is implemented using a few stubs
(InitSuspendableFunction, Suspend, Resume, Return and
AsyncExceptionHandler). The stubs are implemented in a
platform-independent way using (macro-)assembler helpers.
When suspending a function, its frame is copied into a SuspendState
object, and when resuming a function it is copied back onto the stack.
No extra code is generated for accessing local variables.
Callback closures are created lazily on the first await.

Design doc: go/compact-async-await.

Part 1 (kernel): https://dart-review.googlesource.com/c/sdk/+/241842

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: Ibad757035b7cc438ebdff80b460728b1d3eff1f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242000
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-04-29 01:03:50 +00:00
Stephen Adams c50157e099 Support invoking JS operators through dart:js_util.
Some JS functionality is only exposed through operators, such as
implicit type conversions and BigInt arithmetic. Other than requiring
some minor additions for the exponentiation (`**`) operator, supporting
these through `dart:js_util` is trivial.

Change-Id: I010674303e4f99b42d43b73095de69b8ddcdeb47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242680
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-28 21:18:40 +00:00
Liam Appelbe 738b142e59 Test that renaming file doesn't change modified time.
Looks like #36030 is already fixed, so this is just a regression test.

Bug: https://github.com/dart-lang/sdk/issues/36030
Change-Id: Idbb8e7ea473ec40225653398acc7863f89570b48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242760
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-04-28 19:57:52 +00:00
Paul Berry 3199e6548f Fix logic error causing all unnamed parameters have index 0.
In the definition of `_computeExplicitlyTypedParameterSet`, I
accidentally nested the declaration of `unnamedParameterIndex` inside
the `for` loop, defeating the increment and causing all parameters to
be considered to have index 0.

I've included a test case that would have caught the mistake.

Bug: https://github.com/dart-lang/language/issues/731
Change-Id: I0cd0e1e5b481313150e495d370af2477253d6637
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242741
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-04-28 17:14:50 +00:00
Ahmed Ashour 1586ac81a0 Fix typos
TEST=comment only change

Fixes #48853

Change-Id: I1fd47b8f186514af95a49ef253170045c584f970
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241963
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-04-28 12:53:43 +00:00
Paul Berry 3203a0784a Additional tests for deferred function literals.
These tests exercise the "deferred type inference of function
literals" part of https://github.com/dart-lang/language/issues/731
(improved inference for fold etc.) for super-constructor invocations
and redirecting constructor invocations, both of which have their own
code paths in the analyzer.

Change-Id: I6877ac3c07a3cca31550ba74d941d250c8410cfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241987
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-04-27 20:30:35 +00:00
Martin Kustermann efdffab8b7 Reland "[vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)"
This fixes an issue where VM would run the async* generator after a
`yield` / `yield*` even though the subscription may be paused or
cancelled.

Furthermore this fixes an issue where `StackTrace.current` used
in async* generator crashes VM and/or produces truncated stack
trace.

This fixes the following existing tests that were failing before:

  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
  * language/async_star/async_star_cancel_test
  * language/async_star/pause_test

New in reland: Allow the generator to to cause cancelling it's own consumer.
This addresses the issue of original revert
  -> see https://github.com/flutter/flutter/issues/101514

Issue https://github.com/flutter/flutter/issues/100441
Issue https://github.com/dart-lang/sdk/issues/48695
Issue https://github.com/dart-lang/sdk/issues/34775

TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test

Change-Id: I091b7159d59ea15fc31162b4b6b17260d523d7cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242400
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-26 12:01:34 +00:00
Dan Field fe30c3f235 [vm] Expose whether extension stream has listeners, guard postEvent
This avoids json encoding that was otherwise happening even in product mode. JSON encoding shows up CPU profiling as taking significant time, particularly on low end devices.

TEST=runtime/observatory/tests/service/developer_extension_test.dart

Bug: https://github.com/dart-lang/sdk/issues/48860
Change-Id: I2cf4d949e85c0b23de01ec2033b04527d40c76fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242081
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Dan Field <dnfield@google.com>
2022-04-26 07:53:43 +00:00
Joshua Litt c242053202 [dart2js] Fix bug in constant impact visitor.
Currently we do not collect constants from UnevaluatedContants.

Change-Id: Ie9ff2cd09cdd654f2294f4eee42edbfdc652695f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242220
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-25 18:51:37 +00:00
Johnni Winther 6fdaed9eba [cfe] Handle tear-offs of patched constructors
Previously the tear-offs created for the origin constructors were not
replaced with the tear-offs created for the patch constructors - as is
normally done for the constructors themselves. This lead the tear-offs
to refer to unlowered code, breaking dart2js.

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

Change-Id: I1cb09c07bb2ac7fffb81acd31547ee96e7ecdc64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242284
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-25 15:50:47 +00:00
Lasse R.H. Nielsen 0f0f045128 Fix bug in Duration.toString.
The `toString` used the sign of `hours` to get a leading `-`
when the duration is negative. However, a negative duration of
less than one hour would therefore miss out on the sign,
because `-0` is not an integer.
Now handles sign explicitly.

Fixes #48841.

Change-Id: I0ab6d451faf1c76b838fc35a692f07c5b035d2a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241748
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-04-25 14:37:42 +00:00
Jackson Gardner 6466bac7cd Add support for importing shared memory as per wasm threading proposal.
Change-Id: I077b8d3a60f543c3e54cd3e6d024260adcb8ed83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241420
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2022-04-22 22:40:29 +00:00
Sigmund Cherem e5f4b85066 [dart2js] Fix deferred load URI when baseUrl has a single path segment
This fixes https://github.com/dart-lang/sdk/issues/48848

When the base URI is just a filename, then base was empty, and we accidentally
added a / in the first position.  This made the deferred URI absolute by
mistake.

Change-Id: I4d6a773f6ef8bfefbbf61417bfe7c005aa5e63ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241990
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-04-22 21:33:10 +00:00
Joshua Litt 8e6fa91711 [dart2wasm] Add support for calling Dart functions from JS.
Change-Id: I83cb295ce61b266b86e9efa194dcbc61fc2c8d31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239200
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-21 16:30:18 +00:00
Srujan Gaddam a5cd295831 [CFE] Add 'futureValueType' to visitors/transformers
Closes https://github.com/dart-lang/sdk/issues/48835

This fixes an issue in which erasure is incomplete for
static interop types.

Change-Id: Ia2aef8c009d83df30bbb63b9c4dbb5b96e9f8e34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241820
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-04-20 21:59:10 +00:00
Joshua Litt 43cfa8cea3 [dart2js] Support trimming modular analysis data.
Change-Id: I0e0902813fd71c0bda5de6171487fa0e941f6bad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241246
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-20 21:58:29 +00:00
Riley Porter 1c74986a2a [JSinterop] Skip csp build for new tests using eval
Change-Id: Id008ebd57d7f30e1a9a7dffb0e4b48105f63357e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241805
Auto-Submit: Riley Porter <rileyporter@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-04-20 18:38:38 +00:00
Joshua Litt 84497e41ca [package:js] Add @trustTypes annotation.
Adds an experimental `@trustTypes` annotation which can be used during
migration to static interop to preserve the older semantics for JS interop.

Change-Id: Ic00a6c968b15f8c8f5d0840b82db5a6670eaf0eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241362
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-20 15:24:18 +00:00
Aske Simon Christensen fec466e3fe [dart2wasm] Add Wasm function references and more Wasm ref conversions
Having first-class Wasm function references makes it possible to call
JS function objects directly from Dart, and to call some Dart functions
(static functions with no optional parameters and no type parameters)
from JS as function objects.

Change-Id: I1c788338d418c8857493ec76560d74fdd17d5dd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241001
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-04-19 09:40:17 +00:00
Mayank Patke 5ac78a501e [dart2js] Add failing tests for issue #48277.
Bug: #48277
Change-Id: If7916e86a21b975cd2ab7d7ccc5224d0b4dc8e41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241147
Reviewed-by: Stephen Adams <sra@google.com>
2022-04-16 00:07:25 +00:00
Joshua Litt bdbecf318e [dart2wasm] Add support for anonymous JS interop classes.
Change-Id: Ib0645b4e3b0bd410188be9e39755be5e4c02bb44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240323
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-12 22:51:02 +00:00
Joshua Litt fcba410c6c [dart2wasm] Add support for top level JS interop methods.
Change-Id: I2926306419f5694d180ce57d392b144a2e3177f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240144
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-12 21:34:02 +00:00
Paul Berry a34c454e30 Test horizontal inference for a variety of invocation types.
Bug: https://github.com/dart-lang/language/issues/731
Change-Id: I2f3db7b3d9ff6f4a8b374b78d0e3b3b921095a69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241040
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-04-12 21:06:02 +00:00
Joshua Litt d06fd8d081 [js_util] Add globalThis getter.
Change-Id: I325f3ea7f5aad84dff9e08c6a958b478d6926cb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240962
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-12 20:12:02 +00:00
Joshua Litt f6af76eaf8 [dart2wasm] Basic support for js interop annotations.
Change-Id: Ibb66415ec77a45e436d4058c5d9873c5918b68a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239009
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-12 18:26:02 +00:00
Paul Berry 30f0e0f4d5 Discard parens before deciding whether an invocation argument is a function literal.
This extends the fix for
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.) to cover situations where the function literal passed
to an invocation is enclosed in (unnecessary) parentheses.

Change-Id: I5eb40cf73336612e241a930122f8ae7b1c25bb2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241021
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-04-12 16:25:22 +00:00
Paul Berry b7257ef58e Skip horizontal inference when unncessary due to explicit closure parameter types.
The purpose of horizontal inference is to allow the types of closure
parameters to be inferred based on the static type of other arguments
in the same invocation.  When the closure parameter in question
already has an explicit type, there is no benefit, and there are
potential drawbacks (because horizontal inference could infer too
narrow a type).

This change includes the explicitness/implicitness of closure
parameter types in the dependency analysis for
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.) so that we won't do horizontal inference when it's not
needed.

Change-Id: I33781877685867a8fcb40de54fc055f6348c21b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240505
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-04-12 03:27:32 +00:00
Paul Berry cd005ecdd4 Rework ClosureDependencies to include all arguments in dependency analysis.
This change addresses a corner case discovered during internal testing
of the fix for https://github.com/dart-lang/language/issues/731
(improved inference for fold etc.): if there is no order dependency
forcing us to do a round of horizontal inference between visiting
non-closure arguments and closure arguments, then it's important that
we *don't* do a round of horizontal inference before visiting the
closure, because there is a risk of inferring too narrow a type.

The new algorithm includes all the invocation arguments in dependency
analysis, and the dependency rules are structured such that
non-closure arguments always wind up in stage 1.  If there is no
dependency between non-closure arguments and closure arguments, then
the closure arguments also wind up in stage 1, and no horizontal
inference occurs.  If there is a dependency, then closure arguments
wind up in stage 2 or later, and horizontal inference occurs between
stages.

Change-Id: Ida0b28da211f63191c9c9c39e6004893617507bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240442
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-04-11 16:51:01 +00:00
Sigmund Cherem d2d810a8e8 [modular_test] Remove uses of .packages altogether.
Embed in the modules.yaml any extra paths needed for package dependencies
instead.

This is one step to help towards https://github.com/dart-lang/sdk/issues/48275

Change-Id: I22ef02b2b2327a0c798f2fea73d59c758a8bb0bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240651
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-04-09 00:35:13 +00:00
Erik Ernst b71bd25a97 Add test about evaluation order
This CL adds a test of the evaluation order in the case where a function
invocation `g(a)` or `r.g(a)` involves the invocation of a getter `g` that
returns a function object, and that function object is invoked with an
actual argument `a`.

The expectation in the test is that evaluation occurs left-to-right in
every case, with one exception: when `g` is a class instance getter (this
does not apply to extension instance getters) the actual argument list
is evaluated before the getter. This is the actually implemented behavior,
and the specification is being updated to specify this behavior
(cf. https://github.com/dart-lang/language/pull/2182).

------- Old description:

A piece of technical debt which has been around for several years is the
fact that the specified left-to-right evaluation order isn't implemented
everywhere.

In particular, with an ordinary invocation like `r.m(a)` where `m` is a
getter that returns a function, the argument is evaluated before the
getter is called, which is not a left-to-right ordering.

This CL adds a test (with 2 libraries) where the evaluation order is
detected, such that we can decide how to proceed.

Change-Id: Ia2619fe6b4c4cf4cec63bac9c9f834306bdefe52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238903
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2022-04-08 17:44:18 +00:00
Siva Annamalai 94bc01240c Revert "[vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)"
This reverts commit 837ee17b43.

Reason for revert: Please see https://github.com/flutter/flutter/issues/101514

Original change's description:
> [vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)
>
> This fixes an issue where VM would run the async* generator after a
> `yield` / `yield*` even though the subscription may be paused or
> cancelled.
>
> Furthermore this fixes an issue where `StackTrace.current` used
> in async* generator crashes VM and/or produces truncated stack
> trace.
>
> This fixes the following existing tests that were failing before:
>
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
>   * language/async_star/async_star_cancel_test
>   * language/async_star/pause_test
>
> Issue https://github.com/flutter/flutter/issues/100441
> Issue https://github.com/dart-lang/sdk/issues/48695
> Issue https://github.com/dart-lang/sdk/issues/34775
>
> TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test
>
> Change-Id: I73f7d0b70937a3e3766b992740fa6fe6e6d57cec
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239421
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ic3d9c0508310a33a2aaee67860c0bb2ec83bab4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240506
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-07 21:46:38 +00:00
Chris Terefinko ecbf11b8d8 [dart2js] Add missing connectionState and onConnectionStateChange to RTCPeerConnection.
Closes https://github.com/dart-lang/sdk/issues/48735

Change-Id: I04f263afa4dee1b868ad254cb54ad7c398435e03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240240
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-04-06 22:34:07 +00:00
Sigmund Cherem bbf5dc1c59 [dart2js] add regression test for issue 48571
Global type inference incorrectly handles conditions nested within
subexpressions and accidentally carries information from those
in the context of outer conditions.

Change-Id: I99e0af3da65590acb9429771b318b7da8f3b7f14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240320
Reviewed-by: Stephen Adams <sra@google.com>
2022-04-06 16:42:34 +00:00
Martin Kustermann 837ee17b43 [vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)
This fixes an issue where VM would run the async* generator after a
`yield` / `yield*` even though the subscription may be paused or
cancelled.

Furthermore this fixes an issue where `StackTrace.current` used
in async* generator crashes VM and/or produces truncated stack
trace.

This fixes the following existing tests that were failing before:

  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
  * language/async_star/async_star_cancel_test
  * language/async_star/pause_test

Issue https://github.com/flutter/flutter/issues/100441
Issue https://github.com/dart-lang/sdk/issues/48695
Issue https://github.com/dart-lang/sdk/issues/34775

TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test

Change-Id: I73f7d0b70937a3e3766b992740fa6fe6e6d57cec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239421
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-06 10:44:34 +00:00
Erik Ernst 93379074ad Skip co19/LanguageFeatures/Enhanced-Enum/grammar_A07_t01 on the web
Change-Id: I6325497456357dfebe9864ec2d11207b39b3fdf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240046
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2022-04-05 19:54:13 +00:00
Siva Annamalai ac6f72205a Revert "[VM/io] - Set correct file type for files backing unix domain sockets"
This reverts commit dbe6d1d574.

Reason for revert: One of the new tests spawns a process and runs the script from source and so this test will fail on all AOT configurations, In addition it is failing on mac builds and needs investigation.

Original change's description:
> [VM/io] - Set correct file type for files backing unix domain sockets
>
> The file type of file backing unix domain sockets was being incorrectly
> set as kDoesNotExist resulting in errors when operations like delete
> on the file was done. File::Exists on the other hand returned true.
> File rename and copyfile functionality have been fixed too.
>
> TEST=new tests added
>
> Please see https://github.com/dart-lang/sdk/issues/48569 for the original issue.
> Change-Id: Ie9c716c84b1d818c906ecdb622ba930125f9ee30
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237745
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

TBR=rmacnak@google.com,asiva@google.com

Change-Id: I517896fb90b013af1ce9a6754442a922e2b7cda5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240149
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 23:30:02 +00:00
asiva dbe6d1d574 [VM/io] - Set correct file type for files backing unix domain sockets
The file type of file backing unix domain sockets was being incorrectly
set as kDoesNotExist resulting in errors when operations like delete
on the file was done. File::Exists on the other hand returned true.
File rename and copyfile functionality have been fixed too.

TEST=new tests added

Please see https://github.com/dart-lang/sdk/issues/48569 for the original issue.
Change-Id: Ie9c716c84b1d818c906ecdb622ba930125f9ee30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237745
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 22:17:42 +00:00
asiva 89f5b68ca1 [VM / IO] Fix cases where TlsExceptions were being created with an
OSError code of 0

One such example was _SecurityContext.setTrustedCertificatesBytes

TEST=new tests added

Change-Id: Ibc5d06b83bb1bb93e12f79100acc60546554c268
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239863
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 21:57:22 +00:00
Mark Zhou 471fcee079 [ddc] Adding support for static setters of const fields
Fixes #48717

Change-Id: I45145bc992bb129d54962b1ed9cfebbdbac41f92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239730
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-01 23:51:15 +00:00
Johnni Winther 7bfa7fcea5 [cfe] Improve experiment not enabled messages
The updates the messaging for when experimental features are not
enabled to take into account whether the feature has been released
and whether an explicit or implicit language version opt out the
feature.

Change-Id: I77c31e7e327d1beca2dd4a82dbaf648711894e7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239663
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-01 12:49:07 +00:00
Alexander Aprelev 67c6e2311a [io/win] Use filewin api which is coordinated with GetLastError, rather than errno.
Fixes https://github.com/dart-lang/sdk/issues/48718
TEST=file_test

Change-Id: Ie47fa7807b96832140e8b9d5df53b47ffa0ecc67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239725
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-31 20:51:25 +00:00
Paul Berry 5e79626eb4 Resolve deferred closures in stages.
This change enhances support for
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.) by allowing closures in invocations to be inferred in
dependency order.  For example, given the following code:

    U f<T, U>(T Function() g, U Function(T) h) => h(g());
    test() {
      var x = f(() => 0, (y) => [y]);
    }

The closure `() => 0` is inferred first, causing the type parameter
`T` to be assigned the type `int`.  Then, `(y) => [x]` is inferred
with the benefit of this type assignment, so `y` gets the type `int`,
and consequently, `U` gets assigned the type `List<int>`.

Change-Id: Ia0028a7f3fc8cdc78fbdf2c10c3b8d7b82a9006a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239461
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-31 12:43:44 +00:00
Lasse R.H. Nielsen d063ac3233 Revert Isolate.run.
The current VM closure serialization makes this function a foot-gun.
Revert until the supporting features are improved, so as to not give
users a bad experience.

Change-Id: I83b6b453ce5ab00d49ffbf36a5763119a6435352
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237940
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-03-31 09:42:34 +00:00
Brian Quinlan c286b76c2d Allow sockets to enable TLS renegotiation.
TESTED=unit + manually tested user issue.
Bug: https://github.com/dart-lang/sdk/issues/47841
Change-Id: Iad13899135fd34f15abba3a499132d88e7f597dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234821
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-03-31 06:40:51 +00:00
Joshua Litt 856fcb9c8c [dart2wasm] Add experimental JS interop API for dart2wasm.
This is a fork of `js_util` to support the needs of Wasm. It is very
much a WIP. We're landing this now to facilitate prototyping, and so we
can get a sense of what the right JS interop API might look like for
Wasm.

Change-Id: I8b2ddda07e906f1938d4cd5fe0e63203e9cdd6d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230120
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-30 17:00:20 +00:00
Johnni Winther 2b79d2b747 [cfe] Refactor TypeBuilders
Various cleanups to the TypeBuilder classes:

TypeBuilder:
* Remove `origin` parameter from TypeBuilder.build and instead make
  FunctionType.typedefType mutable and set if after creation.
* Remove `charOffset` and `fileUri` parameters from
  TypeBuilder.buildSupertype/buildMixedInType
* Remove `bind`, `resolveIn`, and `check` from TypeBuilder so that
  these are only present on NamedTypeBuilder
* Remove TypeBuilder.buildTypeLiteralType and instead pass an
  argument to NamedTypeBuilder that determines what type to create
  on `build`.

NamedTypeBuilder:
* Make NamedTypeBuilder.instanceTypeVariableAccess private
* Add NamedTypeBuilder.forDartType for prebuilt types
* Add NamedTypeBuilder.forInvalidType for types created for errors
* Make NamedTypeBuilder.declaration private and corresponding getter
* Check most type use errors on NamedTypeBuilder.bind
* Make NamedTypeBuilder helper methods private
* Add `TypeVariableBuilder.isClassParameter` to support checking for
  valid type variable use through the `NamedTypeBuilder.bind` method.
* Remove checking of type variable in static context from BodyBuilder
  since it is now checking on `NamedTypeBuilder.bind`.

FunctionTypeBuilder:
* Cache result of FunctionTypeBuilder.build

TypeBuilderComputer:
* Cache "constant" type declarations in TypeBuilderComputer
Change-Id: Ibaedcb255487eecc5efe70b84e5cbd5a118c1e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239023
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 18:22:50 +00:00
Jonas Termansen 9a862aab34 [infra] Stop manually creating co19 cipd packages.
The co19 cipd packages are now made automatically.

Bug: b/218296230
Change-Id: I3fe051517bb6e1307204b28ba9c4eb6de440252f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239063
Reviewed-by: Alexander Thomas <athom@google.com>
2022-03-28 14:01:37 +00:00
Daco Harkes 1f1f7dbe08 [test] Skip FFI native in invocation_fuzz_test
TEST=tests/lib/mirrors/invocation_fuzz_test.dart

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

Change-Id: Ib9d189a78c6bfe63378be04cfdcb80761fe0b52f
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-nnbd-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239021
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-03-28 10:00:32 +00:00
Daco Harkes 90f118484f [vm/ffi] Add Char C type
The diff from
https://dart-review.googlesource.com/c/sdk/+/229156/1..3

This was blocked by https://github.com/timsneath/win32/issues/349
earlier. Now that that has been resolved, we should be able to land
this.

We should land this to make package:ffigen be able to bind to `char` in
Dart 2.17.
https://github.com/dart-lang/ffigen/pull/287#discussion_r835734993

TEST=tests/ffi/c_types_test.dart

Change-Id: Ia3bc3785a3d5c0c9f7475106eb77f944f2d0a838
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239020
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-03-28 09:46:56 +00:00
Daco Harkes 532c116cd2 [vm] Implement NativeFinalizer
This CL implements `NativeFinalizer` in the GC.

`FinalizerEntry`s are extended to track `external_size` and in which
`Heap::Space` the finalizable value is.

On attaching a native finalizer, the external size is added to the
relevant heap. When the finalizable value is promoted from new to old
space, the external size is promoted as well. And when a native
finalizer is run or is detached, the external size is removed from the
relevant heap again.

In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate
shutdown.

When the `NativeFinalizer`s themselves are collected, the finalizers are
not run. Users should stick the native finalizer in a global variable to
ensure finalization. We will revisit this design when we add send and
exit support, because there is a design space to explore what to do in
that case. This current solution promises the least to users.

In this implementation native finalizers have a Dart entry to clean up
the entries from the `all_entries` field of the finalizer. We should
consider using another data structure that avoids the need for this Dart
entry. See the TODO left in the code.

Bug: https://github.com/dart-lang/sdk/issues/47777

TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*

Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
Paul Berry 83bea5cfbb Do an extra round of type inference before resolving deferred closures.
The order of operations for type inference of a generic invocation is
now:

1. Create some constraints on type parameters by trying to match the
   return type of the invocation target as a subtype of the incoming
   type context.  (For a constructor invocation, the return type of
   the invocation target is considered the raw uninstantiated type of
   the class enclosing the constructor declaration.)

2. Downwards inference: partially solve the set of type constraints
   accumulated in step 1, to produce a preliminary mapping of type
   parameters to type schemas.

3. Recursively infer all arguments to the invocation, except that if
   experimental feature `inference-update-1` is enabled, skip any
   arguments that are function literals (a.k.a. "closures").  Obtain
   the type contexts for the recursive inference by substituting the
   preliminary mapping (from step 2) into the corresponding parameter
   types of the invocation target.  For each argument that is
   recursively inferred, create additional constraints on type
   parameters using the resulting static type.

4. If no arguments were skipped during step 3, go to step 7 (this
   always happens if `inference-update-1` is disabled).

5. Horizontal inference: partially solve the set of type constraints
   accumulated so far, to produce an updated preliminary mapping of
   type parameters to type schemas.

6. Recursively infer all of the invocation arguments that were
   previously skipped.  As in step 3, obtain the type contexts for the
   recursive inference by substituting the preliminary mapping (this
   time from step 5) into the corresponding parameter types of the
   invocation target.  Again, for each argument that is recursively
   inferred, create additional constraints on type parameters using
   the resulting static type.

7. Upwards inference: solve the set of type constraints accumulated so
   far, to produce a final mapping of type parameters to types.  Check
   that each type is a subtype of the bound of its corresponding type
   parameter.

8. Check that the static type of each argument is assignable to the
   type obtained by substituting the final mapping (from step 7) into
   the corresponding parameter type of the invocation target.

9. Finally, obtain the static type of the invocation by substituting
   the final mapping (from step 7) into the return type of the
   invocation target.

This addresses simpler cases of
https://github.com/dart-lang/language/issues/731.  Note that if
experimental flag `inference-update-1` is disabled, the behavior is
unchanged.

Note that steps 2 and 5 use the same algorithm as each other (they
only differ in how many type constraints have been accumulated so
far), so I've renamed the function that performs it from
`downwardsInfer` to `partialInfer`.

Change-Id: I10d3288d4f4ba9e2b6bc18409186ddc67ca2ee9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238881
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-25 22:07:50 +00:00
Paul Berry 5c0e0922d0 Defer analysis of closure arguments when inference-update-1 is enabled.
In order to address https://github.com/dart-lang/language/issues/731
(improved type inference for `fold` etc.) we're going to need to
sometimes defer analysis of invocation arguments that are closures, so
that closure parameters can have their types inferred based on other
parameters.  To avoid annoying the user with inconsistent behaviors,
we defer analysis of closures in all circumstances, even if it's not
necessary to do so for type inference purposes.

This has a minor user-visible effect: if an invocation contains some
closures and some non-closures, any demotions that happen due to write
captures in the closures are postponed until the end of the
invocation; this means that the write-captured variables remain
promoted for other invocation arguments, even if those arguments
appear after the closure.  This is safe because there is no way for
the closure to be called until after all of the other invocation
arguments are evaluated.  See the language tests in this CL for
details.

Note that this change only has an effect when the experimental feature
`inference-update-1` is enabled.

Change-Id: I283fc5eb07af2aeca0a06d523011d8c4617fbad7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237720
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-25 16:40:10 +00:00
Joshua Litt 0ad7f27990 [dart2js] Apply mixin transform globally.
This cl applies the mixin transform only on the full dill. In addition,
this cl also adds a concatenate dills step to more closely match
modular builds in production.

Change-Id: Icb37c5e2180c9e8246334143a6f772a203f80bf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238320
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-23 18:38:51 +00:00
Srujan Gaddam 3f1c69dd1d [dart:html] Fix Performance.mark typing to work with Firefox
Closes https://github.com/dart-lang/sdk/issues/48630

'mark' can return undefined in Firefox, and therefore needs to
return a nullable. Similarly, the different syntaxes of 'measure'
don't work in Firefox or Safari, so the incompatible ones are
removed from tests.

Change-Id: Ia137fe0d72ddbaad03ae8cf58c43736b128b3f33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237930
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-03-22 19:37:00 +00:00
Srujan Gaddam 2444bcca59 Fix Performance.mark and measure
Closes https://github.com/dart-lang/sdk/issues/48430

Adds overloads for both methods to accept additional/different options.
Also changes return types:
- mark returns a PerformanceEntry
- measure returns a PerformanceMeasure, but this may be undefined, so it's
  marked as nullable

Change-Id: I189c4613b19e214a1f5bcc5bbd780d9dc447d9e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235286
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-03-21 18:58:38 +00:00
Clement Skau 2c0ba56ea1 [vm/ffi] Add error for FFI annotation with opt. args.
Optional arguments (positional and named) in @FfiNative
annotations are not meaningful, and should result in a
compile-time error.

TEST=tests/ffi/ffi_native_test.dart
Bug: https://github.com/dart-lang/sdk/issues/47169
Change-Id: I8896e6a43f9399b537e6ee7c7a0e2857a370203f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232622
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-03-18 20:58:51 +00:00
Aske Simon Christensen 58cad00468 [dart2wasm] Initialize the function class early.
Subclasses of the _Function class are generated on the fly as fields
with function types are encountered. Therefore, this class must be early
in the initialization order.

Change-Id: Ia0b998c443af9f6bdb4af512f6da99e6e3767c1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237681
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-03-18 17:44:57 +00:00
Martin Kustermann 873978ccff [gardening] Run subtests in parallel to avoid timeout for lib/isolate/spawn_uri__package_uri__test
Should make this test run within the normal timeout period.

TEST=ci

Change-Id: Ie8048a6cc7c31b193cf326bf9742fad279411b44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237688
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-03-18 13:27:50 +00:00
Stephen Adams bc1d9b0a2f [dart2js] Test for trusted script URLs
Change-Id: Ib4726fc522756f9a7cc860aaa09c6b0037a85c70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237638
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-18 01:09:47 +00:00
Jens Johansen fd4e41a7af [parser-ish] Better errors on invalid unicode escapes
https://github.com/dart-lang/sdk/issues/48542

Change-Id: Icbdcc939a93c737914091c00aaefa3c4efb2dde0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-03-17 13:57:45 +00:00
Mayank Patke 2cdceab575 [dart2js] Add failing tests for issue #48422.
Bug: #48422
Change-Id: If2bc60ea4d1fdd55a786ff2e1154c3091c73aada
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235982
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-14 20:49:48 +00:00
Alexander Aprelev 9feea727c6 [vm/field_guards] Ensure that field guard updates are done with stopped mutators.
Fixes https://github.com/dart-lang/sdk/issues/48473

TEST=language[_2]/vm/lazy_deopt_with_exception_concurrent_test

Change-Id: Ic54cbb1aa01dd367b42e559ebd70d3156fe54a45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235920
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-10 17:16:05 +00:00
Paul Berry 76bbd199a4 Fix analyzer implementation of the "variance" feature.
It had bit rotted slightly: we were not properly accounting for
variance when gathering type inference constraints from the comparison
of two interface types.

Also, some of the tests needed to be updated to account for follow-on
errors.

Change-Id: Ife9feae3e2180a179ebc8503751690789dc1483e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235941
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-10 15:56:35 +00:00
Mayank Patke 6005e923d8 [dart2js] Rename issue-specific tests.
The `regress` folder in tests/web and tests/web_2 has been renamed to
`issue`. All issue-numbered tests have been placed there; other tests
have been moved out of that folder.

Change-Id: I4534d34b2ef21f7accc45c3ce097d9be74845e4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235984
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-03-09 22:18:27 +00:00
Paul Berry 9872e9d4c4 Stop using deprecated "screaming caps" constants from dart:io
Bug: https://github.com/dart-lang/sdk/issues/34218
Change-Id: I4215c0a2212d5c15972d9ffe4075c89d27c9081e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235701
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-09 16:08:44 +00:00
Lasse R.H. Nielsen 33c38e914b Fix bug in Isolate.run.
Failed to close the receive-port if `Isolate.spawn` threw
asynchronously, which would keep the isolate alive forever.

Fixes #48516

BUG= http://dartbug.com/48516

Change-Id: If53a868bcc6a11aef9123e95a7dfe47d25932c4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235603
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-03-09 11:53:34 +00:00
Srujan Gaddam f8933dda8d [pkg:js] Disallow all operators in JS classes
Closes https://github.com/dart-lang/sdk/issues/48515

Expands existing checks for index operations to all operators. This
only affects instance members and not extension members.

Change-Id: I8cbb5b12a49539ea502e4396e1b469ffb0e17d5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235980
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-03-09 01:48:24 +00:00
Ryan Macnak d34e7b0500 [vm, compiler] RISC-V BigInt intrinsics.
Note that unlike x86 and ARM, RISC-V has no carry flag, so we must synthesize the carry in a GPR using sltu.

TEST=ci, RSA
Change-Id: I24898cb8b7166d5769ae98c535ec29b2206340d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235063
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-08 18:08:44 +00:00
Johnni Winther 5090974cf3 [cfe] Use effective target in redirecting factory tear off lowering
The tear-off lowering for a redirecting factory called the
immediate target (even when this was also a redirecting factory)
instead of the effective target. This caused problem in backends
that don't support redirecting factories directly.

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

Change-Id: Iafb11c42c1e99e70ed44b0835473a8c69e995b01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235780
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-08 13:11:53 +00:00
William Hesse 06763dd539 Roll dart_style 2.2.2 into the repo.
This adds formatting support for upcoming language features:

- Named arguments anywhere
- Enhanced enums
- "super." parameters

It doesn't change the formatting of any existing code, so it should be
safe to roll this in without coordinating a pre-built SDK roll.

I also went ahead and ran the formatter on the related language tests
since before now they couldn't be formatted. (And I incidentally ran
the formatter on the other enum tests sitting in the same directory.)

Edit: Actually there is one small change to existing formatting: enum
declarations will now get a blank line inserted before them. Most hand
authored enums already have this so will be unchanged but I see a few
diffs when formatting generated code.

Change-Id: Icefd9f10bedc589312396cf0ddb8eafc418f8dbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235284
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2022-03-04 13:06:42 +00:00
Leaf Petersen 35e66b5081 Enable by default the experiment flags for the 2.17 language features
TEST=Existing language tests
Change-Id: I6c2ecd73a1c7add1451d72adff94df6fdcfca9fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234704
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
2022-03-04 01:08:01 +00:00
Lasse R.H. Nielsen 05322f23dd Add Isolate.run.
Change-Id: I049f6b1bf684ed28b6f14d380adfadf9f4e97fcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217008
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-03-03 11:43:10 +00:00
Brian Quinlan cdcc221d60 Remove renegotiate.
TESTED=deprecation does not break unit tests.
Bug: https://github.com/dart-lang/sdk/issues/42771
Change-Id: I5c661ef91285a117c881cb15d26ab40cfd185a70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234880
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-03-02 19:50:50 +00:00
Johnni Winther 1f848492b7 [dart2js] Compute the correct selector for InstanceGetterInvocation
The Selector computed for InstanceGetterInvocation used the name of
the getter eventhough the invocation is actually a .call invocation.
This lead the computation of whether type arguments need to be parsed
to fail because it queried with the wrong selector.

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

Change-Id: Ia08fb91fa24b5b04eba850f75f9b66cb89494dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234288
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-01 08:55:17 +00:00
Konstantin Shcheglov b1af9288ea Evaluate enum constants and report errors.
Change-Id: Ie3e307ae667cf5e0679a9750047b81ca66c3323c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234141
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-23 22:15:22 +00:00
Stephen Adams b55de5554b [dart2js] Avoid eager initialization optimization for some Maps and Sets
Unfortunately we have to give up on eager initialization of many maps
and sets due to unknown dependencies and effects in the hashCode
implemenation. Eager initialization of some cases could be recovered
as they are eligible to be `const` maps and sets.

Fixed: https://github.com/dart-lang/sdk/issues/48442
Change-Id: I6500123ff9d1fe42bacb53718a4b9e4e969ebc3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233942
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-23 19:17:32 +00:00
Konstantin Shcheglov c4aaf8a710 Update language/enum/enhanced_ tests with analyzer error codes and locations.
Change-Id: I5928a7e6b20e24a6e9e3e11f525d8a9996eaa1f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-23 18:00:12 +00:00
Konstantin Shcheglov 0caead5485 Report ILLEGAL_CONCRETE_ENUM_MEMBER_DECLARATION/INHERITANCE
Change-Id: I6e0815ddbd3f161fc07c83d6a0c9b7c61b2f9fc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233702
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-22 18:12:31 +00:00
Paul Berry 19c7f85bfe Test an odd interaction of implicit .call tearoffs with promotion.
Currently, we decide whether to insert an implicit `.call` tearoff on
an expression based on the type the expression is being assigned to,
whereas the spec says that we decide it based on the context type.

In most cases, these are the same type, however when assigning to a
promoted variable, the context type is the promoted type, whereas the
"type being assigned to" is the unpromoted type.

Previously, we had no language tests of this behavior; it just emerged
naturally from the way it was implemented in the CFE.  This test locks
down the behavior so that we won't change it by mistake.

We may, at some future time, decide to change it on purpose though.
Discussion about this behavior is ongoing on the langauge team.

Change-Id: I82f54c8875fd3b5829c5f75a676fdaf5eea64703
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233650
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-02-22 11:49:41 +00:00
Lasse R.H. Nielsen a3e39fadd6 Make UriData more case-insensitive.
Add `isMimeType` method to `UriData` class, to allow case-insensitive
checking of the MIME type.
Add `isCharset` and `isEncoding` methods to `UriData` class,
to allow case-insensitive and alternative-encoding-name aware checking
of the MIME type "charset" parameter.
Make `UriData.fromString` and `UriData.fromBytes` recognize and omit
a "text/plain" `mimeType` even if it is not all lower-case.

Be case-insensitive in a few cases where we weren't before
(like the `charset` getter not recognizing `CHARSET=utf-8`.)

Fixes #28592
TEST=corelib/data_uri_test.dart updated

BUG= http://dartbug.com/28592

Change-Id: Ia885af69d271856af7fadfe93851e07eff6ddca2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217366
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-02-22 10:47:41 +00:00
Erik Ernst 46daf0fbd1 Fix various small issues
This CL makes a lot of small corrections in enhanced_enums_basic_test,
e.g., references to variables whose name is slightly different in the
declaration and at the use site.

[Edit: This CL no longer adds a new test, `enhanced_enums_error_test`
already covers all the situations tested by that new test.]

Change-Id: I9d2aabd5ab740b91463eff12a5c676136bf4ec04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233384
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2022-02-22 10:18:21 +00:00
Paul Berry 77a4d88c06 Properly handle implicit .call tearoff on RHS of assignments.
Previously, when inserting an implicit `.call` tearoff on the RHS of
an assignment, both the analyzer and the CFE failed to properly
propagate the type of the tearoff to the static type of the assignment
expression.  This resulted in a soundness bug for compiled programs.

Fixes #48409.
Fixes #48410.

Bug: https://github.com/dart-lang/sdk/issues/48409, https://github.com/dart-lang/sdk/issues/48410
Change-Id: I489f38bd7cac4ebadd3746ec32c1ef0f73e18169
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-02-21 16:38:51 +00:00
Lasse R.H. Nielsen db30a5f670 Add error tests for enhanced enums.
The tests check that expected errors actually happen.
There might be *too many* error markers in the tests,
since it's not clear *where* an error is reported.

Is a naming conflict reported for one or both conflicting declarations?
Is a conflict reported on the class declaration or on a conflicting
declaration?

The front-ends might need to remove themselves from some of the errors,
when the error reporting strategy is decided, but they should report
at least *one* error for each problem.

Also fixed bugs in the non-error `enhanced_enum_basic_test.dart` file.

Change-Id: I673244d1d5a8803e5b49d53150a2b3ab47522c89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231950
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-02-19 10:47:33 +00:00
Paul Berry 9ad6cc49af Additional language test for implicit .call in conditional expressions
Change-Id: Ibfff039ddbba1e805c07f6eeec75d959c607d196
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233162
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-02-18 14:23:01 +00:00
Martin Kustermann f50b3a52e4 [vm] Make async lowering no longer use optional parameters
This CL

  * Makes :async_op only have two parameters: We take advantage
    of the fact that errors not only have exception != null but
    also stacktrace != null.
  * Makes :async_op have no optional parameters. This reduces
    code size significantly.
  * Removes unused parameter in _awaitHelper calls
  * Wrap the then callback instead of the error callback. (needed
    to make optional parameters required)

This results in 2% code savings on a big g3 app.
The size of :async_op shrinks on average by 11%

TEST=ci

Change-Id: I38d5fba4ebebc780b48dac5aa6a250d2c7952bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233362
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 12:09:42 +00:00
Mayank Patke d539c43372 [dart2js] Create child LocalState for inference of labeled statements.
This is analogous to what we do for other control flow constructs.
Without this, a `break` to the label causes the outer scope to also
appear aborted.

Fixes: #48317
Bug: https://github.com/flutter/flutter/issues/96394
Change-Id: I575a5bf96b25b49df6f15d429881e310b3b34d15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233446
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-02-18 00:58:20 +00:00
Srujan Gaddam 30195a437b [dart:html] Fix decodeAudioData to use both syntaxes
Closes https://github.com/dart-lang/sdk/issues/47520

decodeAudioData has an older callback-based syntax and newer
Promise-based syntax. In order to be consistent with the method
signature as well as be able to use both syntaxes, this CL
provides an API that can handle both.

Change-Id: I875defcfec9e429496a1ac9866f1b53d204eff69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221744
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-02-17 23:44:51 +00:00
Brian Quinlan 917ae52f70 Add the ability to log TLS keys.
TEST=unit tests
Bug: https://github.com/dart-lang/sdk/issues/47838
Change-Id: I8a64e8623022215cae261eadb25b22deb9f3d910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231330
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-17 21:39:31 +00:00
Brian Quinlan f056a4515d Reland "Add the ability to customize socket creation."
Will only submit this after the cbuild is green.

Bug: https://github.com/dart-lang/sdk/issues/42716
Change-Id: I228050594ce9897e388b4d5e446d3e4b94d08f12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232320
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-16 19:23:50 +00:00
Aske Simon Christensen 6faa5f3bd0 [dart2wasm] Initial commit for the Dart-to-WasmGC compiler.
This is work in progress. Several language features are still
unimplemented or only partially implemented.

Instructions for running the compiler and its output can be found in
pkg/dart2wasm/dart2wasm.md. These procedures are preliminary and
expected to change.

The best version of d8 to use for this version of dart2wasm is 10.0.40,
as explained here: https://dart-review.googlesource.com/c/sdk/+/232097

This commit also adds a dart2wasm-hostasserts-linux-x64-d8 testing
configuration to run the compiler over the test suite.

The history of the prototype that this is based on can be seen here:

https://github.com/askeksa-google/sdk/tree/wasm_prototype

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

Change-Id: I910b6ff239ef9c5f66863e4ca97b39b8202cce85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175728
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-02-16 11:11:14 +00:00
Sergey G. Grekhov 5e4f36eda6 [co19] Test that use FFI turned off on not supported platforms
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-win-release-x64-try,vm-kernel-precomp-linux-release-simarm64-try
Change-Id: Iccd080591cc3dda60b5bd2ab9d8f2261445df610
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232880
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-02-16 09:41:09 +00:00
Stephen Adams 53b730791a Test for #48322
Change-Id: I878a288ac5932de8c83546df91038dcf54cd9039
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231845
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-16 01:32:14 +00:00
Paul Berry bf23af8375 Add a language test to check expressions for which implicit call tearoff should occur.
Currently, all the language tests that exercise implicit call tearoff
do so using expressions that are either instance creation expressions
(e.g. `new C()`, where `C` is a class containing a `.call` method) or
simple identifiers.

This test exercises all of the syntactic constructs which are capable
of undergoing implicit call tearoff.

This will help ensure that some upcoming analyzer changes don't break
implicit call tearoff support.

Change-Id: I3e6471a3ba22fb3e3be38f2721db549da631668a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232920
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-02-15 17:57:49 +00:00
Paul Berry 904d1af024 Add a language test to check situations where implicit call tearoff does not occur.
I'm not 100% sure we have a spec for precisely when we do implicit
call tearoffs and when we don't, but the CFE and analyzer agree on
this behavior, and I'm about to reorganize some of the analyzer code
that handles it, so I'd like to be sure the behavior is tested.

Change-Id: I1afee375181fde7b3a304aa8b71b23a45a337be0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232784
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-02-15 16:37:50 +00:00
Stephen Adams 75d4047276 [dart2js] Dead code eliminator should remove dead phis
The bad codegen reported in #48383 was due to an unused phi confusing
the expression-tree construction algorithm. It was trying to generate

    data = cond ? callWithSideEffects() : null;

but `data` is unused, so somehow we generated only

    cond;

We should not have unused phis at this point so I put a safety check
in the above code to not try to build an unused conditional, and
changed the dead-code eliminator to eliminate dead phis.

Now we get

    if (cond)
      callWithSideEffects();

I compared the output for some large apps and there were about a dozen
changes. All looked like improvements, e.g. not assigning to an unused
variable. There was some code missing that is now present, but luckily
for the large apps, it was all code that did not have real-world side
effects.


Fixed: 48383
Change-Id: Id7b32cfa0cbfb47a4d9eff174ad9ae52da99f6a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232781
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-14 20:15:30 +00:00
Martin Kustermann bbefb29ab2 [gardening] Skip standalone{,_2}/io/http_redirect_test
This test was modified (in [0]) to use `dart:mirrors` which doesn't
work in AOT mode. So we'll skip it (which fixes some unapproved dartkp
failures).

[0] https://dart-review.googlesource.com/c/sdk/+/230600

TEST=ci

Change-Id: I02f6efded23ae2fa16ee72b792632f252202adf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232900
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-14 18:14:33 +00:00
Martin Kustermann 31ac1d26f9 [vm] Make Isolate.spawnUri() work in AOT iff the uri is compatible AOT snapshot
Right now the implementation of `Isolate.spawnUri(<uri>, ...)` in
the standalone embedder is to ignore `<uri>` and make the spawnned
isolate from the same AOT snapshot as the main isolate.

This is very confusing and very incorrect.

Instead `Isolate.spawnUri()` should work if-and-only-if the given
`<uri>` points to a valid and compatible AOT snapshot. If not, it should
throw an appropriate exception.

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

TEST=vm/dart{,_2}/spawn_uri_aot_test

Change-Id: I279ace08ac1b9a9eed3ae03ebe5d9e2336c1e5c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232603
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-14 15:18:33 +00:00
Alexander Thomas 30beab0f43 [infra] Add OWNERS to the Dart SDK
* Add team "groups" in tools/OWNERS_<group name>.
* Add top-level OWNERS as a fallback.
* Add OWNERS for all top-level directories.
* Add OWNERS to all packages.

For additional background information see go/dart-sdk-owners.

TEST=No op until code-owners is enabled.
Bug: b/200915407
Change-Id: I7fe6116cc599c749cd50ca16151d6d6a801d99d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229147
Reviewed-by: Jonas Termansen <sortie@google.com>
2022-02-14 14:06:34 +00:00
Brian Quinlan 98634512f2 Surface errors returned by SSL_read.
TEST=repro in bug & unit test
Bug: https://github.com/dart-lang/sdk/issues/48311
Change-Id: Ib13d0e3c2b98be85533a65532119874ca504f196
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226607
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-11 02:07:43 +00:00
Nicholas Shahan 4c1143a048 [ddc] Reset static fields on first get or set
Fixes a memory leak issue where statics that are set but never
read before a hot restart are never reset and the functions to
set them are never garbage collected.

Update and add more tests for this specific scenario that inspect
the number of fields that will be reset during a hot restart.

Change-Id: Id5a56625279c84a37f53253a5ee667758bc22f87
Issue: https://github.com/dart-lang/sdk/issues/48349
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232230
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-02-11 01:18:01 +00:00
Brian Quinlan 20401b32ec Tests for _HttpClient.shouldCopyHeadersOnRedirect.
TESTED=test change
Change-Id: I3fb27e21eaab05fc812b2b888dfea3b29e0c5648
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230600
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-10 22:34:11 +00:00
Johnni Winther 2a1224f3b5 [cfe] Check primitive equals in legacy libraries
This enables the check for primitive equals in switch cases in
legacy libraries.

Change-Id: Iddc464f39525d5167a5c6e8c40c95acc3c245d76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231701
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-02-10 22:13:14 +00:00
Daco Harkes 828dcd00e8 [vm] Implement WeakReference in the VM
This CL implements `WeakReference` in the VM.

* This reduces the size of weak references from 2 objects using 8 words
  to 1 object using 4 words.
* This makes loads of weak reference targets a single load instead of
  two.
* This avoids the fix-point in the GC and message object copying for
  weak references. (N.b. Weak references need to be processed _after_
  the fix-point for weak properties.)

The semantics of weak references in messages is that their target gets
set to `null` if the target is not included in the message by a strong
reference.

The tests take particular care to exercise the case where a weak
reference's target is only kept alive because a weak property key is
alive and it refers to the target in its value. This exercises the fact
that weak references need to be processed last.

Does not add support for weak references in the app snapshot. It would
be dead code until we start using weak references in for example the
CFE.

This CL does not try to unify weak references and weak properties in
the GC or messaging (as proposed in go/dart-vm-weakreference), because
their semantics differ enough.

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

TEST=runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart
TEST=runtime/tests/vm/dart/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/lib/isolate/weak_reference_message_1_test.dart
TEST=tests/lib/isolate/weak_reference_message_2_test.dart

Change-Id: I3810e919a5866f3ae8a95bd9aa23a880a0b0921c
Cq-Include-Trybots: luci.dart.try:app-kernel-linux-debug-x64-try,dart-sdk-mac-arm64-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simriscv64-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-ia32-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232087
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-02-10 21:59:41 +00:00
Alexander Aprelev d6a4edaf04 Revert "Add the ability to customize socket creation."
This reverts commit a0aeed9faa.

Reason for revert: flutter and g3 buildbot regressions.

Original change's description:
> Add the ability to customize socket creation.
>
> Bug: https://github.com/dart-lang/sdk/issues/42716
> Change-Id: I9e854007f15ed54cc2d85a372bc145e1b90f5967
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231530
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Brian Quinlan <bquinlan@google.com>

TBR=aam@google.com,bquinlan@google.com

Change-Id: I55eede1b26e02b215c21339dacaf2a52857bdebd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/42716
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232280
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-02-09 21:48:34 +00:00
Brian Quinlan a0aeed9faa Add the ability to customize socket creation.
Bug: https://github.com/dart-lang/sdk/issues/42716
Change-Id: I9e854007f15ed54cc2d85a372bc145e1b90f5967
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231530
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-09 19:42:46 +00:00
Riley Porter 278a040e1d Add WeakReference and Finalizer patches for ddc and dart2js
Routes implementation to JavaScript WeakRef and
FinalizerRegistry APIs using JS foreign function calls. Uses
Wrapper names for the Dart library to avoid issues with DDC.

Bug: #47775, #47776
Change-Id: Iad82bd83ac10c666d08a2c042a8ed6109b8b58c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229180
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2022-02-08 22:01:36 +00:00
Nate Bosch 33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00
Stephen Adams 8d335e5e08 [lib/collection] Test for #48282
Change-Id: I62306feab09f8dcd0335daa296b6c744bc139e62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231336
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-08 19:36:38 +00:00
Brian Quinlan 085e978ce4 Fix on Windows, renaming a file using the Directory class generates an incorrect exception
TEST=unit
Bug: https://github.com/dart-lang/sdk/issues/47713
Change-Id: I603a452cece478ad5ddd85d47e9cfe02cee3f4d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231801
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-07 23:15:56 +00:00
Ryan Macnak b6ab7350be [test] Inform status files about the new simulated architectures.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/37299
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: I6f1a749690b894b14f465d608f37acf62568cdef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231521
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 20:32:16 +00:00
Alexander Markov 3d977bc191 [vm/test] Fix memory leak in ffi/regress_flutter97301_test
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/48283

Change-Id: I22d9ebac3240e9ca84fec833340d71b58d01119d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231335
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-02-03 00:28:55 +00:00
Alexander Markov e4942db83e [vm/compiler] Avoid speculative conversion in ffi Pointer.asTypedList
On 32-bit ARM in AOT mode Pointer.asTypedList is generated so that
there is a LoadField from Pointer.data_field which has kUnboxedFfiIntPtr
representation (uint32) and then the value is passed to a
StoreInstanceField for TypedDataBase.data_field which has kUnboxedIntPtr
representation (int32). As a result, a speculative uint32->int32
IntConverter instruction is inserted by SelectRepresentations pass.
AOT doesn't support deoptimization so code generation crashes after
retrying without speculative inlining.

This change fixes the type incompatibility by loading value with
LoadUntagged and then converting it with ConvertUntaggedToUnboxed(kUnboxedIntPtr).

TEST=ffi/regress_flutter97301_test
Fixes https://github.com/flutter/flutter/issues/97301

Change-Id: I4a00d4ac7978b4775add0ddae510841a2b4cbae0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230956
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-01 16:49:56 +00:00
Riley Porter 9fff4351cf [js_util] Fix lib status files
Change-Id: I946631781508a4364060edc6cab4e9d7e8f69ba6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230885
Auto-Submit: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-01-29 00:13:12 +00:00
Riley Porter 150b51e3dc [js_util] Add implicit downcasts to js_util methods
Add dynamic to JS foreign function calls to get implicit
downcast to T, which will cause more accurate type errors
for DDC and dart2js with -O2. Checks will be omitted
with dart2js and -O3.

Bug: #47832
Change-Id: Ie85faf47d58d748b068bc7e902a17a99292f02e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230823
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2022-01-28 22:28:52 +00:00
Chloe Stefantsova 999f267d0e [cfe] Add more compiler-time errors for incorrect enum constructors
Additionaly this CL moves the arguments checks for redirecting and
super initializer invocations from the early stage of their creation
to a later stage of their addition to the list of constructor
initializers, after the possible modifications to the arguments of the
invocation are performed.

Change-Id: I87a3710c885926a74c844288bdf266e7127a9c40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229967
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-01-28 15:07:02 +00:00
Brian Quinlan 57db739be0 Disable security-related headers on redirect.
TESTED=updated unit tests
Bug: https://github.com/dart-lang/sdk/issues/45410
Change-Id: I7c555a4818fd719d42748b6a18780e3d9b3ee147
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229947
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-01-27 20:49:42 +00:00
Daco Harkes 045b9c1715 Reland "[vm/ffi] Add common C types"
We're adding these types to `dart:ffi` rather than `package:ffi` so that
they can be used with `FfiNative`s.

Adds `NativeType`s for the following C types:

* unsigned char
* signed char
* short
* unsigned short
* int
* unsigned int
* long
* unsigned long
* long long
* unsigned long long
* uintptr_t
* size_t
* wchar_t

Because the C standard only defines minimum sizes for many of these
types, future platforms might diverge from the typical size even if all
platforms currently agree on a size. To avoid having to reification
later, we define all types as AbiSpecificIntegers rather than typedefs,
even if all current target platforms agree on the size.

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

TEST=tests/ffi/c_types_test.dart

Original patch in patchset 1.

* Removes `Char` for now until package:win32 has rolled to 2.3.8 in
  Flutter. https://pub.dev/packages/win32/versions/2.3.8/changelog
  https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064587445729/+/u/Android_Views_Integration_Tests/stdout
* Adds `c_type.dart` in `ffi_source.gni` which should fix `IntPtr`
  missing when analyzing `path_provider_linux`. (However, I was unable
  to reproduce the issue locally.)
  https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064571399025/+/u/run_test.dart_for_flutter_plugins_shard_and_subshard_analyze/test_stdout
  `/tmp/flutter_plugins.KZMNMC/packages/path_provider/path_provider_linux$ ~/flt/engine/src/out/host_debug/dart-sdk/bin/dart  analyze --fatal-infos`

Change-Id: I89130cccba285fc9c483bb53f5710a302f2b104f
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-release-x64-try,flutter-analyze-try,flutter-engine-linux-try,flutter-frontend-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229156
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-27 13:09:01 +00:00
Ryan Macnak 9bc03ece9a [vm, compiler] Fix BinarySmiOpInstr(USHR, reg, reg) on RV64.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: I29a532e8c8a1170dbd4f20e081c1a3f397ccc591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229700
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-25 22:54:47 +00:00
Srujan Gaddam 4c64181d73 [dart:html] Fix requestFullscreen bindings and type
Closes https://github.com/dart-lang/sdk/issues/25324

requestFullscreen returns a Promise and takes in an options parameter.
It also can be accessed either via `requestFullscreen` or
`webkitFullscreen` (only necessary for Safari). The bindings should be
updated to reflect this behavior.

Change-Id: I9401b6a1c8b3f9ac370aad8caac8295e0ee358b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229381
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-01-25 00:24:57 +00:00
Paul Berry 5106605af6 Fix context type for conditionals of conditional expressions.
Fixes #48199.

Bug: https://github.com/dart-lang/sdk/issues/48199
Change-Id: I8483e87e4680c1f3ab97f58818eeaa57dec78b07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229500
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-01-24 01:25:38 +00:00
Ryan Macnak 90542c2903 [vm] Alternate fix for mismatch between native and intrinsic versions of writeIntoOneByteString.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48194
Change-Id: I8baa500e220db43d894498c59211831d15af1b4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229322
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-21 19:32:40 +00:00
Daco Harkes 5183ba3ca4 Revert "[vm/ffi] Add common C types"
This reverts commit 85a87ca7ae.

Reason for revert: 

* Adding `Char` breaks `package:win32` which is used in Flutter so it
breaks the Flutter build:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064587445729/+/u/Android_Views_Integration_Tests/stdout

For reference: full list of Flutter failues:
https://github.com/flutter/flutter/runs/4890844911

Original change's description:
> [vm/ffi] Add common C types
>
> We're adding these types to `dart:ffi` rather than `package:ffi` so that
> they can be used with `FfiNative`s.
>
> Adds `NativeType`s for the following C types:
>
> * char
> * unsigned char
> * signed char
> * short
> * unsigned short
> * int
> * unsigned int
> * long
> * unsigned long
> * long long
> * unsigned long long
> * uintptr_t
> * size_t
> * wchar_t
>
> Because the C standard only defines minimum sizes for many of these
> types, future platforms might diverge from the typical size even if all
> platforms currently agree on a size. To avoid having to reification
> later, we define all types as AbiSpecificIntegers rather than typedefs,
> even if all current target platforms agree on the size.
>
> Closes: https://github.com/dart-lang/sdk/issues/36140
>
> TEST=tests/ffi/c_types_test.dart
>
> Change-Id: Ie97d253856d787386529231e8060f879069be886
> Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-release-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228541
> Reviewed-by: Martin Kustermann <kustermann@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ic56df88c653b1395ed5e5a71af5e571b1adc3671
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229152
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-21 17:05:42 +00:00
Srujan Gaddam d17205184a [dart2js] Handle Object members of dart:html types
`dart:html` types have changed to inherit `JavaScriptObject`. Therefore,
the dart2js runtime needs to be changed so that interceptors are still
created for those types, and they're properly handled in `toString`
calculations. Includes tests on `Object` members that are currently
inconsistent between both compilers.

This test passes on dart2js with and without making the types in `dart:html`
extend `JavaScriptObject`. This test fails in DDC for the following reasons:

- `toString` of native types calls the native `toString`
- `hashCode` for interop objects are random and not 0
- `runtimeType` of interop objects is `LegacyJavaScriptObject` not `JSObject`

Change-Id: Ibf80109174615120df9e64995fa13016f7a1677b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228741
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-01-21 01:04:10 +00:00
Srujan Gaddam 2da95997c3 Rename status files in tests/web
Renames `dart2js.status` files to their corresponding directory so they
are used. Moves the filters in `dart2js_native.status` files up to the
parent directory's status files.

Change-Id: Iced14c2d7d40034173768b2d15cf7558c13e7555
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229064
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-01-20 18:35:27 +00:00
Daco Harkes 85a87ca7ae [vm/ffi] Add common C types
We're adding these types to `dart:ffi` rather than `package:ffi` so that
they can be used with `FfiNative`s.

Adds `NativeType`s for the following C types:

* char
* unsigned char
* signed char
* short
* unsigned short
* int
* unsigned int
* long
* unsigned long
* long long
* unsigned long long
* uintptr_t
* size_t
* wchar_t

Because the C standard only defines minimum sizes for many of these
types, future platforms might diverge from the typical size even if all
platforms currently agree on a size. To avoid having to reification
later, we define all types as AbiSpecificIntegers rather than typedefs,
even if all current target platforms agree on the size.

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

TEST=tests/ffi/c_types_test.dart

Change-Id: Ie97d253856d787386529231e8060f879069be886
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228541
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-01-20 14:41:46 +00:00
Ryan Macnak 04ba20aa98 [vm] Support RISC-V.
Implements a backend targeting RV32GC and RV64GC, based on Linux standardizing around GC. The assembler is written to make it easy to disable usage of C, but because the sizes of some instruction sequences are compile-time constants, an additional build configuration would need to be defined to make use of it.

The assembler and disassembler cover every RV32/64GC instruction. The simulator covers all instructions except accessing CSRs and the floating point state accessible through such, include accrued exceptions and dynamic rounding mode.

Quirks:
  - RISC-V is a compare-and-branch architecture, but some existing "architecture-independent" parts of the Dart compiler assume a condition code architecture. To avoid rewriting these parts, we use a peephole in the assembler to map to compare-and-branch. See Assembler::BranchIf. Luckily nothing depended on taking multiple branches on the same condition code set.
  - There are no hardware overflow checks, so we must use Hacker's Delight style software checks. Often these are very cheap: if the sign of one operand is known, a single branch is needed.
  - The ranges of RISC-V branches and jumps are such that we use 3 levels of generation for forward branches, instead of the 2 levels of near and far branches used on ARM[64]. Nearly all code is handled by the first two levels with 20-bits of range, with enormous regex matchers triggering the third level that uses aupic+jalr to get 32-bits of range.
  - For PC-relative calls in AOT, we always generate auipc+jalr pairs with 32-bits of range, so we never generate trampolines.
  - Only a subset of registers are available in some compressed instructions, so we assign the most popular uses to these registers. In particular, THR, TMP[2], CODE and PP. This has the effect of assigning CODE and PP to volatile registers in the C calling convention, whereas they are assigned preserved registers on the other architectures. As on ARM64, PP is untagged; this is so short indices can be accessed with a compressed instruction.
  - There are no push or pop instructions, so combining pushes and pops is preferred so we can update SP once.
  - The C calling convention has a strongly aligned stack, but unlike on ARM64 we don't need to use an alternate stack pointer. The author ensured language was added to the RISC-V psABI making the OS responsible for realigning the stack pointer for signal handlers, allowing Dart to leave the stack pointer misaligned from the C calling convention's point of view until a foreign call.
  - We don't bother with the link register tracking done on ARM[64]. Instead we make use of an alternate link register to avoid inline spilling in the write barrier.

Unimplemented:
 - non-trivial FFI cases
 - Compressed pointers - No intention to implement.
 - Unboxed SIMD - We might make use of the V extension registers when the V extension is ratified.
 - BigInt intrinsics

TEST=existing tests for IL level, new tests for assembler/disassembler/simulator
Bug: https://github.com/dart-lang/sdk/issues/38587
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I991d1df4be5bf55efec5371b767b332d37dfa3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217289
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-20 00:57:57 +00:00
Chloe Stefantsova 7cb72e977a Change ":" to ";" at the end of a getter in a language test
Change-Id: I4702322fb98fec7549c2392a1ceb3c80bb5109fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228641
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-01-18 18:36:16 +00:00
Alexander Aprelev b453c6bcba [gardening] Fix env_test/has_mirror_support.
Fix the test so it reports that mirrors are not supported in aot configuration.

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

Change-Id: I07fceebf8cbee8048988c8bd5287c8aec1bb8f0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227582
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-14 23:33:11 +00:00
Stephen Adams 7504ce34b0 Add tests for String.replaceAll with general Pattern
Change-Id: Ic680dc229e014f3323945bd509184d501c381041
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226983
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-01-13 20:52:33 +00:00
Simon Binder 0a3d896274 [ffi] Add .ref= setter for pointers of structs or unions
Adds the `ref` setter to the `StructPointer` and `UnionPointer`
extensions, copying a compound structure into native memory.
The FFI use-site transformation transforms invocations of this setter
into an appropriate memcopy call.

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

TEST=tests/ffi(_2)/extension_methods_test.dart

Change-Id: I3ef06ad08b8e71e39b05d662e8082fc5d0ad876d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227542
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-12 20:48:28 +00:00
Paul Berry 4775fa3857 Flow analysis: ensure that not-yet-declared variables aren't marked as captured.
In certain error recovery situations, it's possible for code to refer
to a variable whose declaration has been lost by error recovery
mechanisms.  To prevent flow analysis from crashing when this
happened, it assumed that any reference to a variable whose
declaration had not yet been seen was valid, and implicitly added that
variable to the flow analysis state.

This created a subtle problem: if a function contained a closure that
declared (and assigned to) a local variable, at the time the closure
was entered, flow analysis would get confused and temporarily put the
variable in the "write captured" state (because it hadn't yet seen the
declaration of the variable, so it didn't realize it was local to the
closure).  Then, a boolean variable might capture that incorrect
state.  Later, upon seeing the declaration of the variable, it would
fix the incorrect state, however it was possible that a later
reference to the boolean variable would re-vivify the old incorrect
state.  This is precisely what happened in issue #47991.

This CL fixes the problem by giving flow analysis the ability to
detect, at the time the FlowAnalysis object is constructed, all
variables that are referred to but not explicitly declared, and add
them to the flow analysis state.  This allows it to safely assume that
any variables that are not yet in the flow analysis state haven't been
declared yet (and hence can be ignored), so no variable is every
erroneously placed into the "write captured" state.

Fixes #47991.

Bug: https://github.com/dart-lang/sdk/issues/47991
Change-Id: I8d84fab96fad063f1d3ade3b8b9a6e9af88c3737
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227361
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-01-11 15:42:04 +00:00
Lasse R.H. Nielsen 0a8298d14c Add test of new enum features.
Change-Id: I3aece084b53a1a23c9c8d9ebaf40a8a7e4764a6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221081
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-01-07 13:14:17 +00:00
Lasse R.H. Nielsen cd0606e425 Simplify asyncExpectThrows and enhance Expect.throws.
For `asyncExpectThrows`, instead of taking a function,
then checking if that function can be called with zero arguments,
and then immediately calling it and checking that it returns a future,
just take the future as argument.

Since synchronus errors from calling the function were not caught
anyway, doing the entire `Future` computation directly shouldn't
change behavior.

Also make `asyncExpectThrows` and `Expect.throws` return the caught error,
so that you can use normal `Expect.something` checks on it afterwards,
instead of doing that in the `check` function.
That basically makes the `check` function unnecessary (but hard to remove
with the existing test corpus using it heavily).

This makes some uses of the `asyncExpectThrows` function slightly more
complicated, those that have no other way to create a future than calling
the argument function anyway, but other uses become simpler
when they can avoid adding the function wrapper.

TEST= Refactoring. If the tests keep running, it's successful.

Change-Id: I983eb65ea4805760339073fabc27f78c57f9a471
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226102
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-01-06 17:06:47 +00:00
Daco Harkes acdf82de17 [vm/ffi] ABI-specific integers
This CL adds support for users defining integers which are mapped to
differing sizes and signedness based on the application binary interface
the Dart VM is running on.

Notable implementation design decisions:
- ABIs are open world, so that adding an ABI to the Dart VM does not
  break existing definitions. Thus, we only figure out in the VM that
  we're missing a mapping. We throw compile-time errors.
  - In AOT, these show up in the precompilation step.
  - In JIT, these show up as `_CompileTimeError` at runtime. Note that
    these can be caught. So in subsequent compilation steps we need to
    ensure that we also throw the same compile-time error.
- We match on the call-sites (streaming_flowgraph_builder) rather than
  method bodies (kernel_to_il) of AbiSpecific loads and stores so that
  we can compile for the int-size of the call site.

API design decisions:
https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001

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

TEST=tests/ffi_2/abi_*_test.dart
TEST=tests/ffi/function_*_generated_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart
Change-Id: I8c8df36fab939b6fb614c5f1ee8e1bf46b6e9521
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221501
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-12-16 22:07:00 +00:00
Sergey G. Grekhov 2f9b2d10cc [co19] HttpRequestUpload tests enabled in status files
Change-Id: Ied7cdc131541711f80cd1d053660438bfcdc55ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223421
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-12-13 09:39:49 +00:00
Srujan Gaddam 4c924bb669 Add tests for static interop type erasure/typing
Tests to make sure static interop classes are erased as expected,
can be used as expected, and that the typing/subtyping relationships
are correct.

Change-Id: Icd68b63f4b7b7f06ec1490a411e31792e9e1fea8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216274
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2021-12-10 18:36:00 +00:00
Srujan Gaddam 45c350052d [dart2js/ddc] Rename BaseJavaScriptObject to JavaScriptObject
Part 2 of the renaming to create the new parent type. Also modifies
some existing tests to reflect the change in name and function of
JavaScriptObject.

Change-Id: If37f34dd8477b7fc1fe459d3225ecf2537fb9f1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217156
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-12-10 18:36:00 +00:00
Srujan Gaddam da01ce02fc [dart2js/ddc] Rename JavaScriptObject to LegacyJavaScriptObject
Changes in type hierarchy will have JavaScriptObject as the new
parent class of interop and native types instead. Also modifies
js_interop_constructor_name tests to reflect addition of static
interop.

Change-Id: I74957ca89aea1726a01e0677548fbb3c5c981323
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215949
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-12-10 18:36:00 +00:00
Srujan Gaddam 758cb462f5 [pkg:js] Erase static interop types
Closes https://github.com/dart-lang/sdk/issues/47324

Erases static interop class types in favor of `BaseJavaScriptObject`.
Types are erased everywhere except for constructors, whose invocations
are instead wrapped with a cast. Constructor type erasure is avoided
to ensure the AST is still type-valid. Factories with bodies have
static stubs added instead, and tests are added for this change.

Change-Id: I7231aaaf32d22bc6261adb672a602e8a9e6c86a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215948
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2021-12-10 18:36:00 +00:00
Joshua Litt 2da9688cfb [modular] Create repro of issue building full dills from summaries.
Change-Id: I67db9eefe508ddbe072238e8773109c7b7f25d1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222560
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2021-12-10 17:00:00 +00:00
Mo 8caaa1b9cf Added sourcePort to Socket.connect()/startConnect() as optional parameter.
This allows to specify the local port for TCP client sockets.

All prototypes in Socket,RawSocket,_Rawsocket,_NativeSocket have been adopted,
aswell as the native counterpart to nativeCreateBindConnect.

TEST=new tests added

Change-Id: I3408b687cbfd7eaaaeafdda29f7093d92c92aea0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217604
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Moritz Feldmann <moritz.feldmann@kabelmail.de>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2021-12-08 18:33:00 +00:00
Michael Thomsen 71e3dac037 Remove deprecated packageRoot API, which doesn't work in Dart 2
Bug: https://github.com/dart-lang/sdk/issues/47769
Change-Id: I1cbd7761e7119c07f2697d7624bec703ba4c4641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221340
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2021-12-07 14:44:49 +00:00
Sergey G. Grekhov c4d5a2ed8a [co19] co19/LibTest/html/responseText_A01_t02 test enabled
Change-Id: I4ca667b2b82cb5587854686851e6f9992a1fc233
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221462
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-12-07 11:14:19 +00:00
Nicholas Shahan 95684da0d1 [tests] Add regression test missing super helpers
DDC compiled output is missing getter and setter helper methods when a super
field is both read and written in a constructor.

Issue: https://github.com/dart-lang/sdk/issues/47698
Change-Id: I45302aa8880a168847d72517b2cecb25e31d2b67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221742
Reviewed-by: Mark Zhou <markzipan@google.com>
2021-12-02 22:12:57 +00:00
Daco Harkes 663357209c [vm/ffi] Introduce Abi
This introduces the application binary interface (ABI) concept to
`dart:ffi` as a class with opaque instances.

We will use this for providing mappings for ABI-specific types.
Bug: https://github.com/dart-lang/sdk/issues/42563
Bug: https://github.com/dart-lang/sdk/issues/42816
Closes: https://github.com/dart-lang/sdk/issues/45254

Later, we might open up the contents of `Abi` if need be.

Some API design discussion notes:
https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001

TEST=tests/ffi/abi_test.dart

Change-Id: Iebf290fc12f37d6f4236432ddf27ab3e12bde06d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221627
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-12-01 19:19:37 +00:00
Ryan Macnak ae5def7b0d [test] Account for new locale string returned on macOS.
TEST=ci
Change-Id: I29bf54c8a75c016a11921ce78c60076009d347ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221720
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-12-01 00:22:45 +00:00
Clement Skau 7344e5e619 [test] Skip regress_47594_test in Product
Bug: https://github.com/dart-lang/sdk/issues/47811
Change-Id: I16af738c8d01c1b82052d6f1aaf55d1650143f11
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-product-arm-try,app-kernel-linux-product-x64-try,vm-ffi-android-product-arm64c-try,vm-kernel-linux-product-x64-try,vm-kernel-mac-product-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-win-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221620
Auto-Submit: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-11-30 11:11:04 +00:00
Riley Porter fc560bab9e [package:js] Test optional default value arguments in extensions
Change-Id: Ia28d53bfca87dab143701ce0099a16580fdc14b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221560
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2021-11-30 04:45:04 +00:00
Clement Skau 034824f80e [test] Skip failing bots on regress_47594_test
- DartDev is not available on Android.
- DynamicLibrary.process() is not available on Windows.

Change-Id: I6606159168dd01e0fa0b9bc97b5316641123d42b
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-ffi-android-release-arm64c-try,vm-ffi-android-release-arm-try,vm-ffi-android-product-arm64c-try,vm-ffi-android-product-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-win-release-x64-try,vm-kernel-win-release-ia32-try,vm-kernel-win-product-x64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-precomp-nnbd-win-release-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-debug-x64-try,pkg-win-release-try,dart-sdk-win-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221500
Auto-Submit: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-11-29 22:36:04 +00:00
Clement Skau bd4a27ff81 [vm/ffi] Adds transition information to FFI leaf calls.
This change sets `top_exit_frame_info` and `vmtag` on FFI leaf calls.
We have to set this info on the thread so that the stack walker can
interpret the frame correctly.
Without it, anyone trying to walk the stack during an FFI leaf call
- like the profiler - will misinterpret the top frame and cause
a segfault.

TEST=Added regression test.

Bug: https://github.com/dart-lang/sdk/issues/47594
Change-Id: If83aeab194aa0213aee82558bb9541cd7294a935
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220360
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-11-29 10:12:36 +00:00
Alexander Thomas ef181bbc29 [test] Skip Language/Types/Interface_Types/subtype_t27
The test is causing frequent CQ failures right now.

Bug: https://github.com/dart-lang/sdk/issues/42641
Change-Id: I46727cab95eb8da5feec7de860426e94d5875314
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221325
Auto-Submit: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2021-11-26 11:31:23 +00:00
Stephen Adams 12dae45e5a [corelib] Properly check radix in BigInt.toRadixString.
Change-Id: Ieb1b541db3c35984f4a75b618f9df1c82f4d37da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221201
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-11-25 22:53:53 +00:00
Vyacheslav Egorov 71c9c2cd83 [vm] Remove support for non-bare AOT snapshots
Every AOT user out there has been using bare instructions mode
and continuing to maintaining non-bare instructions mode simply
adds costs (both in terms of time spent making changes to work
in a mode that is not used and CI resources spent on testing it).

This change removes FLAG_use_bare_instructions and changes the code
to assume that FLAG_precompiled_mode implies bare instructions.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,app-kernel-linux-release-x64-try,app-kernel-linux-debug-x64-try
Change-Id: I5032b13bfcb613f79865f2cfa139cca8d1b42556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220964
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-11-24 13:03:52 +00:00
Daco Harkes 00ea62f713 [cfe/ffi] Handle invalid types in Array
Closes: https://github.com/dart-lang/sdk/issues/47673

TEST=tests/ffi(_2)/regress_47673(_2)_test.dart

Change-Id: I8fdafc5378797ed071250b0caed1ab944873a218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220760
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2021-11-19 13:38:47 +00:00
Mayank Patke 6b382a03b0 [dart2js] Add failing tests for #47691.
Bug: https://github.com/dart-lang/sdk/issues/47691
Change-Id: I14a0b5f027b6a5ed74dd22b63e3c103b380823eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220780
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-11-18 20:37:36 +00:00
Brian Quinlan 051c198bff Add a test where we attempt to rename a file.
Change-Id: I9901f8abefe1e652307e15f05ef66d033a16a02f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220420
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-11-17 21:59:20 +00:00
Brian Quinlan 0e5f3f49c3 Fix an issue where rename on Windows would delete the target directory.
TEST=tests updated
Bug: https://github.com/dart-lang/sdk/issues/35217, https://github.com/dart-lang/sdk/issues/47633, https://github.com/dart-lang/sdk/issues/47634
Change-Id: I9582c76e8eb75548ba2d67205353de63d110c294
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219501
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-11-17 19:41:50 +00:00
Simon Binder 0d6c343196 [dart:io] Add overrides for stdio
Add overrides to control the `stdin`, `stdout` and `stderr` getters in
`dart:io`.

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

Change-Id: I6071ad0845df96f8508d2281a6c013f1745ca880
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219792
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-11-17 15:40:15 +00:00
Nicholas Shahan ecdcde3a83 [ddc] Ensure mixin class is emitted before use
Moves the class definition to appear before uses in compiled
code.

Change-Id: I00558040a510c7bc8668794b82fa3bd67dde64e9
Fixes: https://github.com/dart-lang/sdk/issues/47645
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220071
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-11-12 19:21:52 +00:00
Lasse R.H. Nielsen e1428ba911 Remove references to constructor-tearoff experiment.
TEST=Modifying existing tests.

Change-Id: I22fa11a5f2efc4bd6d1d54a656106f40bbfeafb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220002
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2021-11-11 14:04:43 +00:00
Lasse R.H. Nielsen 2360783808 Expire experiments released in earlier stable versions.
Remove messages referring to expired `non-nullable` experiment.
Remove occurrences of --enable-experiment with expired experiments.

TEST=Flags were expired. If existing tests still run, it's a success.

Change-Id: Id66d78eb0a3191ec5e31375faf0effd9ea7b768f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219789
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2021-11-11 08:28:31 +00:00
Lasse R.H. Nielsen 62f4712523 Don't assume that a stack overflow is an Error.
A new test captures a stack overflow error and rethrows it.
It assumed that it would be a Dart `Error`, but on dartdevk it's not.
Now just catches whatever it is and checks that it's the same
object again.

Bug: http://dartbug.com/47664
Change-Id: I2355ab1b43adf82806b0b76fc26aa5879ddb0d87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219788
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-11-10 21:36:13 +00:00
Stephen Adams 0afb365804 [dart2js] Fix #47566 by disabling optimization
The JavaScript-to-JavaScript async transform had an inconsisent
handling of switch statements that contained an await, but only in the
expression.

For now the special handling of the expression-only case is disabled.

Change-Id: Ia79ff3951d681ba933df638da7e0e518d401ed9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219746
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-11-09 00:43:02 +00:00