1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 20:16:39 +00:00
Commit Graph

23249 Commits

Author SHA1 Message Date
Kallen Tu
6fcfa93008 [wildcard-variables][test] Fix wildcard language tests.
This CL fixes some bugs in a few tests and removes unnamed optional default tests.

Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: I41be6eb2f45598803eaeddd99375aa9cdb3fa990
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373324
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-06-27 19:40:48 +00:00
Srujan Gaddam
f9cd24327f Put expected value first in importModule tests
Change-Id: I1e1cb720c6bcc6991ab10def235dc3b97977c6c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373402
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
2024-06-27 13:58:53 +00:00
Srujan Gaddam
1c534e5fd5 [dart2wasm/ddc/dart2js] Lower Function.toJS and JSExportedDartFunction.toDart
Lowers these extension methods to some helper functions instead of
allowInterop to improve performance and get consistent semantics.

Specifically:
- Function.toJS no longer gives you the same JSFunction when calling
toJS on the same function multiple times in the JS compilers.
- Adds fast calling syntax for functions with 0-5 args in the JS
compilers.
- Allows additional args to be passed to converted functions that
are omitted in the JS compilers.
- The static type now determines the number of args that can be
passed to the JS function in the JS compilers.
- Fixes an issue in dart2wasm where if too few arguments are
passed, the call may succeed due to conversion of undefined to
null.
- Adds throws when a user tries to wrap a JS function that
returned from Function.toJS in the JS compilers.

Closes https://github.com/dart-lang/sdk/issues/55515
Addresses https://github.com/dart-lang/sdk/issues/48186

CoreLibraryReviewExempt: Changes to docs only in API surface.
Change-Id: I41d864dc5e02b597d9f1c16c88e3c04872f28225
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368065
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-06-26 23:06:36 +00:00
Srujan Gaddam
b8402f5c27 [dart:js_interop] Make ExternalDartReference generic
Closes https://github.com/dart-lang/sdk/issues/55342
Closes https://github.com/dart-lang/sdk/issues/55536
Closes https://github.com/dart-lang/sdk/issues/56015

- Adds a type parameter T that extends Object? to
ExternalDartReference to capture the type of the value
that was externalized.
-- In the JS compilers, the representation type of
ExternalDartReference is now T.
-- In dart2wasm, the representation type is now JSValue?.
- ExternalDartReference no longer implements Object.
- Return type of toDartObject is now T.
- ObjectToExternalDartReference and
ExternalDartReferenceToObject both now are on a T that is
bound to Object?.
- Internal patches for WeakReference and Finalizer are
updated.

Change-Id: Ic2dc834b17ec6a4eb2122cba3c495a6e0a1eae6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370663
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-06-26 21:53:53 +00:00
Srujan Gaddam
1550539558 [dart:js_interop] Make not and isTruthy return JSBoolean
Since these operators can't be written by users, prefer
to keep them as JS types.

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

Change-Id: Ifb9b581fb82e057ba14c669a5a3934f9c502d06f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359181
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-06-25 17:50:33 +00:00
Srujan Gaddam
0b761229cc [dart:js_interop] Change importModule to accept JSAny
Closes https://github.com/dart-lang/sdk/issues/55429
Closes https://github.com/dart-lang/sdk/issues/55508

Objects like TrustedScriptURLs can be passed to the dynamic import
function, and therefore importModule should accept any JS value.

Change-Id: I43ce9aeb1e8fbd628bc768a16b246ba19470b1dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363504
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-06-25 17:50:33 +00:00
Kallen Tu
ef1ec76054 [cfe] Wildcard import prefixes are non-binding.
Bug: https://github.com/dart-lang/sdk/issues/55655
Change-Id: I938c254fad2c656c9342e9cea5b146373b9f63e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372603
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-06-24 18:08:47 +00:00
Kallen Tu
523f03a749 [cfe] Local and top level function wildcard type parameters are non-binding.
This CL adds `isWildcard` to `StructuralVariableBuilder` and allows type variables in functions and function types. It also removes them from scope so they can't be used.

Bug: https://github.com/dart-lang/sdk/issues/55655
Change-Id: I26237375480318dd0c9a01cb59b3426b783ca7be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372240
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-06-21 17:59:29 +00:00
Slava Egorov
4928998ebe [vm/io] Follow up to c2e9cee
* Fix `ToWinAPIFilePath` handling of UNC paths. This function did
not handle UNC paths correctly: it was prefixing them with
`\\?\` instead of `\\?\UNC\`;
* Fix issue in `File::Copy` forcing the wrong path to long form:
temporary files are created next to the destination, so it
is destination (`new_path`) that should be forced into long form and
not the source;
* Fix issue in `GetDirectoryPath` not preserving the path separator.

The newly added test should cover all these corner cases to prevent
future regressions.

TEST=standalone/io/regress_56049

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

Fixed: 56049
Change-Id: I4970efd0674989b8cc291778cf87806b0ea318ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372400
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-06-20 19:55:19 +00:00
Ömer Sinan Ağacan
acd82f974b [tests] Add int.tryParse overflow check tests
See the comments before tests for details.

The test cases are generated with this Rust program:

```
use num::*;

fn main() {
    // 10111...., 65 bits
    let lo: u64 = (1 << 63) - 1;
    let mut err_pattern: BigUint = BigUint::from(lo);
    err_pattern.set_bit(64, true);

    // In the error case, the bit after the sign bit should be set (this bit will be lost), and
    // sign bit should be unset (so that overflow won't make the result negative).
    assert!(err_pattern.bit(64));
    assert!(!err_pattern.bit(63));

    // For each radix, find the number and digit where
    // `<error> = (<old number> * <radix>) + <digit>`.
    'radix_loop: for radix in 4..=36u32 {
        for digit in 0..radix {
            let i: BigUint = (err_pattern.clone() - BigUint::from(digit)) / BigUint::from(radix);
            if !i.bit(64) && !i.bit(63) {
                println!(
                    "{}: {} + {} ({} + {})",
                    radix,
                    i.to_str_radix(radix),

                    BigUint::from(digit).to_str_radix(radix),
                    i,
                    digit,
                );
                continue 'radix_loop;
            }
        }
    }
}
```
Change-Id: I6fe92c46b31373f465702744ee069394db949b60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372422
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-06-20 18:01:57 +00:00
Ömer Sinan Ağacan
d99a28fbe2 [tests] Remove reference to a removed test file, minor cleanup
This test file tested the old `onError` parameter of `int.parse` and was
removed in b3304af17d.

Also remove strange code from pre-null-safe days.

Change-Id: I224b4c4002c14050b67c29c7327e31b422b18ebb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372420
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-06-20 17:21:19 +00:00
Daco Harkes
a2b26effb0 [vm] Native asset path resolution symlinks with spaces
This CL fixes symlink resolution by properly decoding a URI to a file
path before doing symlink resolution (on the file path).
File paths have spaces, but URIs can be encoded with percent encoding.

Before resolving the relative paths, the symlink-resolved script path
is encoded as URI again. This encoding is trivial (percentage
encoding is optional), so it only needs to prepend a scheme.

Also, this CL improves the error message for the relative path
resolution if the dylib cannot be found to include the script uri.

TEST=tests/ffi/native_assets/asset_relative_test.dart

Closes: https://github.com/dart-lang/sdk/issues/56053
Change-Id: I3ac9748e971e6eacbe14f3485bf3a3943d587d7d
Cq-Include-Trybots: dart/try:vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-asan-linux-release-arm64-try,vm-msan-linux-release-arm64-try,vm-tsan-linux-release-arm64-try,vm-ubsan-linux-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372421
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-06-20 14:36:36 +00:00
Lasse R.H. Nielsen
001e5b3435 Forgotten last patch-set for landed CL
The https://dart-review.googlesource.com/c/sdk/+/371100
should have included this change, but I somehow managed
to not include it in the upload.

CoreLibraryReviewExempt: Would have been part of accepted CL
Change-Id: Ia9d133ef753413d4804d04db2478e73709e5e5ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372440
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-06-20 11:27:53 +00:00
Lasse R.H. Nielsen
a505bbc6a0 Add TypedDataList superinterface on typed data lists.
Adds an interface which implements both `TypedData`
and `List`. That allows abstracting over types that are both
`List` and `TypedData` without losing access to one of the
interfaces.

Tested: typed_data_interface_test.dart
Change-Id: Idbdfc084ea5d2d9a072887973e2e9d29a5fd94ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371100
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2024-06-20 08:18:38 +00:00
Kallen Tu
48cadec309 [cfe] Top level function wildcard parameters are non-binding.
This CL prevents function wildcard parameter collisions and avoids adding function wildcard parameters to scope.

Bug: https://github.com/dart-lang/sdk/issues/55655
Change-Id: I5a8b85ceef15b355f6a36a1d1d19df038980331d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371941
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-06-18 18:23:55 +00:00
Brian Wilkerson
a01d45ce82 Improve highlight range for some ffi diagnostics
Fixes: #54181
Change-Id: Ia1e3f5e121fc961bb8cf34cf83827125f4a3e5a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371782
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-17 15:25:06 +00:00
Kallen Tu
d15a3963e7 [cfe] Allow unnamed optional wildcard parameters to have no default value.
Wildcard optional parameters aren't used anyways, so it doesn't matter if they have a default value.
This CL removes the error that's typically there.

Bug: https://github.com/dart-lang/sdk/issues/55655
Change-Id: Ie7286e1c3650fa347b1c28f1cc4ebd657cca33de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371560
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-06-14 21:30:05 +00:00
Srujan Gaddam
06ec78851b [dart:js_interop] Add static error for converted functions that contain named params
Like type parameters, these parameters can't be passed from JS and
such functions already do not work as intended as there is no way
to pass named args to a JS function. These named parameters were
being silently ignored in dart2wasm when creating the function
trampoline.

Change-Id: Iebb890de05f8b242e0542c1ec8f2c0582c5232df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368062
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-06-14 19:42:10 +00:00
Martin Kustermann
689852e3f0 [dart2wasm] Fix new web/wasm/allow_import_export_pragmas_test test: Add --extra-compiler-option= before the flag name
This wasn't caught by default CI builders, because
default configurations use `pkg/dart2wasm/tool/compile_benchmark`
which passes all unknown flags to the compiler (for convenience
of local development) but `dart compile wasm` doesn't

Change-Id: I6a92d3f04848e027c92b1feee3d54e7efba9fd27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371661
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-06-14 10:18:23 +00:00
Martin Kustermann
6f21d19b02 [dart2wasm] Add flag to allow experimental wasm interop.
Adds a flag users can use via

    dart compile wasm \
        --extra-compiler-option=--enable-experimental-wasm-interop

which allows code to import `dart:_wasm` and use import/export
pragmas.

Similar to how we have a way to import `dart:ffi`

    dart compile wasm \
        --extra-compiler-option=--enable-experimental-ffi

TEST=web/wasm/allow_import_export_pragmas_test (positive test)
TEST=web/wasm/reject_import_export_pragmas_test (negative test)

Change-Id: Ibdbbac6c3aa049b2759e96b7b749dd30ecc6aaed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370063
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-14 07:01:58 +00:00
Sam Rawlins
50e4c576b9 analyzer: fix various issues for static extension member resolution
* Unqualified, out-of-scope static extension members are not
  accessible.
* Locally scoped extension members shadow others.
* Static and instance extension members do not conflict.

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

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

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Icd618d044b3857efa24f365c6835d42c0022c176
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370323
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-06-14 00:59:57 +00:00
Stephen Adams
18994e6e46 [typed_data] Remove UnmodifiableXXXView classes
In most cases, the (now removed) SDK class was patched so that the constructor redirected to a platform-specific implementation of the unmodifiable view. Uses of the SDK class in the platform code could be rewritten to the more direct use of the implementation class.

The big +/- file changes are from moving the implementation classes from the patch file (typed_data_patch.dart), where they are no longer needed, to the internal file (typed_data.dart).

TEST=ci
Bug: #53785
Change-Id: Iaa7370de25b7fc2d26b24f7733c2892868e593cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370661
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2024-06-13 22:18:29 +00:00
Mayank Patke
ca3e67a3b6 [dart2js] Add --interop-null-assertions.
This CL adds a new --interop-null-assertions flag (cf.
--native-null-assertions) with the goal of validating that JS interop
APIs with non-nullable static return types do not return null values.
This flag is currently disabled by default but is intended to assist in
sound null safety migrations.

In general, we don't guarantee type soundness of package:js interop
since users can write incorrect static types which are not backed by
any runtime checks. However, it is likely that during the null safety
migration, some interop APIs which should have been made nullable
weren't. Therefore, we want to offer some additional (but limited)
checking for this case.

For static invocations of functions with non-nullable return types, we
can simply perform a null check on the result of the call.
For instance methods (which could be invoked virtually/dynamically), we
want to perform a null check on the return value in the callee (the
interceptor method) itself when possible.

It's possible for multiple interop bindings to share the same
interceptor method. We produce a null check in the interceptor method
body if all the methods have non-nullable return types. Otherwise, we
insert checks at callsites when appropriate.

Change-Id: Ifd155d7f8326152b6d57d61199e0b7973c4a1211
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369784
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-06-12 21:28:23 +00:00
Kallen Tu
0b31d88594 [test][wildcard-variables] Fix typedef record type.
This switch would've failed regardless. This CL switches the types of the typedef R so that this test would pass.

Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: Ic36863a38e3197bd9012907caa9f445faf4945b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371021
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-06-12 18:43:39 +00:00
Daco Harkes
9588927faf [vm] Native asset relative path resolution with symlinks
This CL moves native assets resolution to the embedder.

The Dart VM looks up the asset path (for example
`['relative', 'foo.so']`) with the asset id. The embedder defines
callbacks for asset loading, and returns a handle to the dylib.
Then the VM calls the embedder again with `dlsym` to lookup the symbol.

The Dart VM & kernel compiler are responsible for the asset id to
asset path mapping. The kernel compiler compiles it into the snapshot
and the VM looks it up in the snapshot.

Relative paths are resolved relative to the isolate script uri (kernel
snapshot, jit snapshot, aot snapshot, or `dart compile exe` result).
The embedder is responsible for remembering the script uri it set when
spawning the isolate group.

This CL does not add `dlclose` or `dladdr` embedder callbacks yet.
Bug: https://github.com/dart-lang/sdk/issues/55521
Bug: https://github.com/dart-lang/sdk/issues/55966

TEST=pkg/dartdev/test/native_assets/build_test.dart
TEST=tests/ffi/native_assets/asset_relative_test.dart

Bug: https://github.com/dart-lang/sdk/issues/55410
Bug: https://github.com/dart-lang/sdk/issues/55523
Bug: https://github.com/dart-lang/sdk/issues/55207
Change-Id: I75ec4a368c5fb3d2f76b03771e796ff56bcac941
Cq-Include-Trybots: dart/try:vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-win-release-try,pkg-win-release-arm64-try,vm-aot-asan-linux-release-x64-try,vm-asan-linux-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-msan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361881
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-06-12 16:45:19 +00:00
Jens Johansen
c15466034e [status_files] Cleanup status files
Make tool (by default) give error when test entry specified in status
file does not exist. Make -w (by default) remove such entries.

Cleanup most status files, fixing a few entries containing `.dart` and
removing obsolete entries (i.e. entries pointing to nonexisting tests).

This should for instance have given an error in
https://dart-review.googlesource.com/c/sdk/+/370600 saying that the file
I specified didn't exist (in that I shouldn't have specified the `.dart`
part).

TEST=No tests, this is status file maintenance.

Change-Id: Ie977bf15dea2e3dad8d771fd3e99917317e975f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370886
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2024-06-12 10:21:23 +00:00
Konstantin Shcheglov
d0998d6996 DevX. Issue 29106. Don't NON_ABSTRACT_CLASS_XYZ if the concrete extended class also has this problem.
Bug: https://github.com/dart-lang/sdk/issues/29106
Change-Id: Ie676295f104fcbb8458fbb27f3f01ed52e99fef9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370662
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Sam Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-06-12 00:31:59 +00:00
Kallen Tu
549a1b1987 [wildcard-variables] More language tests on declarations - classes, enums, extension types.
Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: Id1c48c3f6345d13c9c5f88224085a863e30f5aaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367985
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-06-11 19:44:41 +00:00
Ömer Sinan Ağacan
4796b25a30 Reland "[dart2wasm] Check import/export pragmas in user code"
This is a reland of commit 35bc17a0fa

Changes from the original CL is that we now allow packages in
`allowedInteropLibrariesInDart2WasmPackages`.

Original change's description:
> [dart2wasm] Check import/export pragmas in user code
>
> Change-Id: I926d108a4571d685c67d3a174a8e506910cce8f7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369020
> Commit-Queue: Ömer Ağacan <omersa@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I69f61ecf246dfdbfcab372c6c2adb2a64f2d0b36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370900
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-06-11 13:12:27 +00:00
Martin Kustermann
847c35612a [dart2wasm] Make dart compile wasm compiled apps disable dart.library.ffi
This is a follow-up to [0]. That CL changed dart2wasm's modular
transformer to issue an error if `dart:ffi` is imported.

Users of packages that have specialized code for the VM (which supports
FFI) use conditional imports based on `dart.library.ffi`. We don't want
the VM-specific code to be used for web in dart2wasm (as dart2wasm
doesn't support the entirety of `dart:ffi`).

As a result we're going to make `dart.library.ffi` be false in
coditional imports (as well as in
`const bool.fromEnvironment('dart.library.ffi')`).

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

Issue https://github.com/dart-lang/sdk/issues/55948
Issue https://github.com/flutter/flutter/issues/149984

Change-Id: I70a775278ab701d1fd2596521e378cb6364edac2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370580
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2024-06-11 09:28:40 +00:00
Kallen Tu
07d2288908 [wildcard-variables] Add a test on unnamed optional parameters with no default value.
Bug: https://github.com/dart-lang/language/issues/3807
Change-Id: Ibeb29d3702b74379b64e8965c3ef9709c7bf2f41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369780
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-06-07 22:02:17 +00:00
Stephen Adams
b42bd24b78 Clean up DateTime tests
Followup to fb057ea4e0

Now that the web implementation of DateTime supports microseconds, the test special cases for not supporting microseconds can be removed.

Change-Id: I10991b25e42d643ae58850d7190621c9d11877b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367680
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-06-07 17:58:32 +00:00
Paul Berry
c007d3bc0c Front end: type infer all record literal fields before hoisting.
Previously, if a record literal had named fields, type inference of
the literal fields would happen as part of the process of
hoisting. This was a problem because the hoisting process requires
visiting the fields in reverse order, so as a result, the order in
which subexpressions were type inferred was the reverse of the order
in which they would be executed, leading to unsound type promotion
behavior.

Fixes #55914.

Bug: https://github.com/dart-lang/sdk/issues/55914
Change-Id: I2d8930e0e1d7579d065bfb850aa7472d28a8012c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369761
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-06-06 19:15:57 +00:00
Tess Strickland
d06d627c79 [vm] Remove --[no-]lazy-dispatchers flag.
No client of the VM uses this flag, only tests, and this flag was always
set to false in AOT mode. Thus, remove uses of this flag and instead
always lazily create dispatchers as needed when resolving method names
in JIT mode.

Remove the implicit value of `allow_add` for some Resolver
static methods. For callers that previously depended on the implicit
`true` value (which includes the AOT precompilier), pass `true` for
uses in the compiler and pass `!FLAG_precompiled_mode` for uses in the
runtime. Assert that `allow_add` is false when these methods are invoked
from the precompiled runtime.

Remove Resolver static methods that are no longer used.

TEST=ci

Change-Id: Ib6a7354f7a859e86743c381513a4129c14895753
Cq-Include-Trybots: luci.dart.try:vm-linux-debug-x64-try,vm-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-mac-debug-arm64-try,vm-mac-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366668
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-06-06 10:56:12 +00:00
Jackson Gardner
9fa160b706 Revert "[dart2wasm] Check import/export pragmas in user code"
This reverts commit 35bc17a0fa.

Reason for revert: Breaking flutter web engine unit tests: https://github.com/flutter/flutter/issues/149600

Original change's description:
> [dart2wasm] Check import/export pragmas in user code
>
> Change-Id: I926d108a4571d685c67d3a174a8e506910cce8f7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369020
> Commit-Queue: Ömer Ağacan <omersa@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: Iba57910e7492abb7371172ecdb4fc2cc18fed66e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369500
Reviewed-by: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2024-06-03 17:28:36 +00:00
Jens Johansen
1c3d4dbe42 [io/socket] Test of being able to read big chunks from a socket
Follow-up to https://dart-review.googlesource.com/c/sdk/+/369243 where
without that CL (i.e. after
https://dart-review.googlesource.com/c/sdk/+/369141 but before the fix)
the test will hang. With the CL the test finishes as it should.

Change-Id: I7b37be1c515a3666a8040d1790b55ff99b68a1be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369463
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-06-03 12:56:19 +00:00
Sergey G. Grekhov
4ff851e5b2 [co19] Roll co19 to 0a9f7daccd0e682ab791f04ecc23f1dbcee04977
2024-05-30 sgrekhov22@gmail.com dart-lang/co19#2641. Add super parameters tests (dart-lang/co19#2687)
2024-05-29 sgrekhov22@gmail.com Fixes dart-lang/co19#2678. Add more extension types static vs instance conflict tests (dart-lang/co19#2692)
2024-05-29 sgrekhov22@gmail.com Fixes dart-lang/co19#2668. Reorder switch expressions to avoid flow analysis secondary issues (dart-lang/co19#2693)
2024-05-28 sgrekhov22@gmail.com dart-lang/co19#2641. Add external functions and covariant parameters tests (dart-lang/co19#2691)
2024-05-28 sgrekhov22@gmail.com Fixes dart-lang/co19#2689. Add more extension methods tests (dart-lang/co19#2690)
2024-05-27 sgrekhov22@gmail.com dart-lang/co19#2641. Add extension types tests (dart-lang/co19#2688)

R=brianwilkerson@google.com

Change-Id: Ie5c551e3198e748b55d45ec5039d1ff836444ee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369000
Auto-Submit: Sergey Grekhov <sgrekhov22@gmail.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-06-03 09:12:56 +00:00
Vyacheslav Egorov
fc4bcab2ef [io] Propagate cancellation in _HttpOutgoing.addStream
If HttpResponse is being closed prematurally (e.g. because client
decided to close its request) we need to propagate cancellation
to the stream which is being piped into the response. Otherwise
we will keep that stream forever hanging around and leak underlying
resources.

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

TEST=tests/standalone/io/regress_55886_test.dart
R=kustermann@google.com

Change-Id: I7c294ed19cc7c350fd101b078bd650ce8a6526a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369061
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-02 20:33:26 +00:00
Martin Kustermann
a4d3ee054d [tests] Use asyncStart/asyncEnd for two language tests
In order for asynchronous tests to work on the web, they have to tell
the test runner that

* the test is async
* when the async test has finished running

This is done via calling asyncStart/asyncEnd.

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

Change-Id: I790960d7da708de4e36be9197ceb3e89f316a84e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368581
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-01 21:51:11 +00:00
Brian Quinlan
ea44765874 [vm/io] Add support for decompressing concatenated zip/gzip blocks.
Bug:https://github.com/dart-lang/sdk/issues/55469
Change-Id: I030e22cafba9164b305972c53d3ba9342503a836
Tested: unit tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363964
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2024-05-31 20:23:53 +00:00
Kallen Tu
fcfc66f834 [wildcard-variables] Add wildcard import prefix tests.
Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: I9f17727bcc96bec9fbb01664244a44710f8f02e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368061
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-05-31 17:39:54 +00:00
Stephen Adams
20316bcc5b Reapply "[js_runtime, js_dev_runtime] Implement microsecond field of DataTime"
Original change: https://dart-review.googlesource.com/c/sdk/+/366963

This reverts commit 72b2883c6f.


[js_runtime, js_dev_runtime] Implement `microsecond` field of `DataTime`

- Move DateTime implementation for dart2js and DDC into a shared place to reduce duplication.

- Add a _microsecond field to the web DateTime to track microseconds outside of the JavaScript Date.

- The cute dart2js optimization whereby `DateTime.now().millisecondsSinceEpoch` is compiled to `Date.now()` still works.

- Both implementations report better errors.

- Fixed VM bug with in-range sentinel.


Issue: https://github.com/dart-lang/sdk/issues/44876
Issue: https://github.com/firebase/flutterfire/issues/12102
Issue: b/342552853
CoreLibraryReviewExempt: Reapply of unchanged code
Change-Id: I7f14b69e412a052ef3fe6b43cc9cf9d96319adb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368380
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-05-31 15:42:14 +00:00
Ömer Sinan Ağacan
35bc17a0fa [dart2wasm] Check import/export pragmas in user code
Change-Id: I926d108a4571d685c67d3a174a8e506910cce8f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369020
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-05-31 09:22:28 +00:00
Ömer Sinan Ağacan
dbcf23a5ed [dart2wasm] Disallow dart:ffi in user code
Change-Id: I1d99637e4538a183d8fa567399bfb7c55675e60e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368568
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-05-31 07:12:21 +00:00
Kallen Tu
429f3e1a8d [wildcard-variables] Tests with this and super initializing formal parameters.
Next set of tests with initializing formal parameters.

Bug: https://github.com/dart-lang/sdk/issues/55652
Change-Id: I1d8ff69249ad75c8065a159c333f91b62b30f769
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367822
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-05-29 20:37:55 +00:00
Martin Kustermann
5963c95f47 [dart2wasm] Unskip lib/async/stream_periodic3_test
Closes https://github.com/dart-lang/sdk/issues/50901

Change-Id: If0d4cc4160fc038c93ee6d2357eb185dd42e5a17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368564
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-05-29 12:48:24 +00:00
Ryan Macnak
1a9acb9171 [vm, ffi] Make callbacks profiler-safe.
Delay changing Thread::vm_tag on callback entry and restore the tag early on callback return so that the profiler doesn't see the "running Dart" tag unless it can also see the fake return address marking the entry frame.

TEST=ffi/async_void_function_callbacks, ffi/function_callbacks_subtype, ffi/function_callbacks, ffi/isolate_local_function_callbacks
Bug: https://github.com/dart-lang/sdk/issues/52814
Change-Id: I40d80ec7c44063d078db0e211565e2d127c6b81e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367460
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-05-28 21:16:41 +00:00
Ömer Sinan Ağacan
a0f1bd5a4b Update test for #45060
Equal types should have the same hash, but they are not necessarily
identical.

Update the test to remove the identity check between a constant type and
a type constructed in runtime.

Change-Id: I0d6c6395c587391d3087c26b00fff36d645b33dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368340
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-05-28 07:10:39 +00:00
Martin Kustermann
827a7c4e95 [dart2wasm] Only perform compile-time lookup in constant list if index is in-bounds
We have an optimization that will do list lookups at compile time when
the receiver is a constant list and the index is a constant integer.

=> We should only perform this optimization if index is in-bounds.
=> If it's out-of-bounds it should be a [RangeError] thrown at runtime
   (if that code is ever executed)

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

Change-Id: I3e99cdd96c79e7ff3f490babb2d52131cbd83a88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368302
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-05-27 11:52:48 +00:00
Ivan Inozemtsev
72b2883c6f Revert "[js_runtime, js_dev_runtime] Implement microsecond field of DataTime"
This reverts commit fb057ea4e0.

Reason for revert: b/342552853

Original change's description:
> [js_runtime, js_dev_runtime] Implement `microsecond` field of `DataTime`
>
> - Move DateTime implementation for dart2js and DDC into a shared place to reduce duplication.
>
> - Add a _microsecond field to the web DateTime to track microseconds outside of the JavaScript Date.
>
> - The cute dart2js optimization whereby `DateTime.now().millisecondsSinceEpoch` is compiled to `Date.now()` still works.
>
> - Both implementations report better errors.
>
> - Fixed VM bug with in-range sentinel.
>
>
> Change-Id: I9156255bdb6ecc195500ae9bc88f91fb315b6297
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366963
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Stephen Adams <sra@google.com>

Change-Id: I58572256a7710df4589bb5e41c7afee295c2388b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368103
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-05-27 07:54:14 +00:00