This updates the exhaustive checking algorithm to produce a list of
witnesses instead of a single witness in case of a non-exhaustive error.
This is used to create a witness for each missing subtype when checking
"sealed static types", for instance enums and sealed classes.
The current error reporting isn't changed and only reports the first
witness. Use of the multiple witnesses in error messages and/or lints
must be done in the CFE and analyzer.
Change-Id: I950816f6a9eca16773f182d5d820929bdcb39684
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357160
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
In discussion with the language team, we've decided to ship this
feature in Dart 3.4. This CL contains a minimal CHANGELOG entry for
the feature; I plan to expand on it once I'm finished with the feature
specification document.
Change-Id: Iac86ebed322feb8e478bf5a6780d50adb433ed7f
Tested: trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355900
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Ran with the TextExpectationsCollector to automatically update the tests.
Change-Id: I968edc8e258274b28a37d0280ba23299811d8ab0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357381
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
TEST=ci
CoreLibraryReviewExempt: No files in other platforms were changed.
Change-Id: I567dae64226867c2036809739a14c14fdf52077b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357211
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
The dart run argument parser was incorrectly parsing any argument following an
option that the VM treats as having a default (e.g., --observe and
--enable-vm-service), resulting in a "File not found ''" error and the
VM failing to start the user program. The following invocations would
fail due to 'foo.dart' being treated as the value for the option to the
left:
- dart run --observe foo.dart
- dart run --enable-vm-service foo.dart
This change strips these two options from the arguments sent to dartdev
as both are handled directly in the VM and are only included in the dart
run argument parser for the help message.
Fixes https://github.com/dart-lang/sdk/issues/55185
TEST=regression test added to run_test.dart.
Fixed: 55185
Change-Id: I1c89fec3ee46296ee4ebb847eb47a7845dfdb399
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357360
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
TFA now produces direct call metadata for function calls based on the
results of the analysis.
VM reads direct call metadata for function calls, but only uses it
if target is a tear-off, as it cannot handle inlining of an arbitrary
closure function yet (due to scope building dependencies between
compilation of a closure and its parent function).
TEST=pkg/vm/testcases/transformations/type_flow/transformer/closures.dart
Issue: https://github.com/dart-lang/sdk/issues/39692
Change-Id: Idf0b6988534bfca1a64c6661a82df8d453272abf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357180
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
For LSP we sometimes split the display text to populate a number of different fields (for example when the display text is `foo => bar` we only want `foo` in the `filterText`).
We previously split on spaces but that fails for the new `override foo()` display texts, so this was changed to split on equals instead (and trim to remove any trailing spaces).
Fixes https://github.com/dart-lang/sdk/issues/32677
Change-Id: I7494426cfcc95388f0f1f91f7f9ff7bcac0f23ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
With register calling conventions some parameters might arrive in
registers and later be spilled on the stack and addresses of those
stack slots passed as handles into native code.
This means we need to unpoison spill slot area otherwise
MSAN will complain.
Fixes https://github.com/dart-lang/sdk/issues/55179
TEST=existing msan configuration
R=kustermann@google.com
Fixed: 55179
Cq-Include-Trybots: luci.dart.try:vm-aot-msan-linux-release-x64-try,vm-msan-linux-release-x64-try
Change-Id: I592cde9cb623c2eabc848c7a39d0453e757e97f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357340
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
The VM service may now give us `dart-macro+package:` URIs in addition to normal `package:` URIs. These can be mapped to `dart-macro+file:` URIs in the same way that we map `package:` to `file:`.
If the client editor has advertised that they support our custom Dart URIs, we can send these through to the client and let them use the analyzer-provided local sources. Otherwise, we'll treat them like other unknown sources and download them from the VM.
Change-Id: If67523a615c66c469db7b1f52d281c63241eb859
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357143
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Moves RepresentationOfArrayElement out of LoadIndexed and StoreIndexed
into RepresentationUtils. Adjusts RepresentationOfArrayElement
to work for all concrete typed data classes. Changes
RepresentationOfArrayElement to return the precise representation of
the array element, which requires adding two new representations,
kUnboxedInt8 and kUnboxedInt16.
Remove Address::OperandSizeFor and its only (ignored) use in the
RISCV assembler and change Address::OperandSizeFor in the ARM and
ARM64 assemblers to use RepresentationUtils::OperandSize and RepresentationUtils::RepresentationOfArrayElement appropriately.
Add Boxing::NativeRepresentation, which converts representations for
unboxed integers smaller than 4 bytes to kUnboxedIntPtr and otherwise
returns the original representation. This mimics the current semantics
for LoadIndexed and StoreIndexed where returned values represented by
unboxed integer values smaller than 4 bytes are zero or sign extended
to word size appropriately, and received values represented by unboxed
integer values smaller than 4 bytes are appropriately truncated from a
word sized signed integer.
Create LoadIndexedInstr::ReturnRepresentation and
StoreIndexedInstr::ValueRepresentation, which use
Boxing::NativeRepresentation to convert the precise representation
returned by RepresentationUtils::RepresentationOfArrayElement to
the actual returned/expected representation for those instructions.
Also use Boxing::NativeRepresentation to appropriately adjust
the representations used for SIMD operations returning int8_t.
Add checks that unboxing and integer conversion never get
representations which result in a different representation when
passed to Boxing::NativeRepresentation, as those instructions do
not currently work with unboxed integer representations smaller than
4 bytes. (Adding such support can be done in a future CL.)
Inside the optimizing compiler, use the precise representation of the
array element where appropriate. That is:
* Range analysis
* Type propagation
* Redundancy elimination
This CL also cleans up how Representations are printed to C, making
that part of RepresentationUtils. It also removes the representation
printing and parsing utils from Location since they were only used by
the original IL serializer and deserializer, which has been removed.
It also renames RepresentationUtils::IsUnsigned to IsUnsignedInteger,
to make it clear that it only returns true for unboxed integer
representations.
TEST=standalone/bytedata_test
Fixes: https://github.com/dart-lang/sdk/issues/54622
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_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-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-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-release-ia32-try
Change-Id: I8c0dab911463ee4d0c55cd59ffea9d01e0f0bb7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354885
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This is a redo of https://dart-review.googlesource.com/c/sdk/+/332220
where extra timeout wasn't given to a new process after a timeout
actually occurred, which can lead to cascades of timeouts in unfortunate
circumstances.
The extra startup time is furthermore increased from 30 seconds to 60
seconds.
Change-Id: I7d052fc1e04b374d3a6d1d82370f8edc1143291e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357280
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: William Hesse <whesse@google.com>
The added method is required for the resolution of redirection targets
to work: it replaces the immediate target invocation node with the
final target invocation node.
Closes https://github.com/dart-lang/sdk/issues/55135
Change-Id: I421f182192aae17f4bd3dcfe6d8216befde0e93e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357161
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
This removes the Declaration from RecordFieldDeclaration and renames it
to RecordField. The fields of a record type are not declarations but
are similar to FormalParameter of a FunctionTypeAnnotation; they contain
part of the information for the RecordTypeAnnotation but are not
identifiable on their own.
Change-Id: Iaa9d95d49f2152096b970c6e2d24c524327f933e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355740
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Without an explicit deduction guide compilation fails with
```
error: 'SimpleAllocator' may not intend to support class template argument deduction [-Werror,-Wctad-maybe-unsupported]
53 | SimpleAllocator cpu_allocator(DartCallingConvention::kCpuRegistersForArgs);
```
TEST=verified by manual build with a flag
R=aam@google.com
Change-Id: I858863f7febb44ab81635e2c8466f84055c6e8b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357144
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
The tests for the language feature `inference-update-3` are adjusted
to verify that the following hold true for an if-null expression of
the form `e1 ??= e2`:
- If the static type of `e2` is not a subtype of the write type of
`e1`, but it is assignable via a coercion, then the coercion is
performed, and the coerced type of `e2` is used to compute the
static type of the whole `??=` expression.
- If `e1` is a promoted local variable, then coercions are performed
based solely on the declared (unpromoted) type of `e1`.
These behaviors apply regardless of whether feature
`inference-update-3` is enabled; accordingly, this commit updates both
the `_test.dart` and `_disabled_test.dart` variants of the tests. I've
manually verified that even with the work on `inference-update-3`
reverted, the `_disabled_test.dart` tests continue to pass, so we can
be reasonably certain that these behaviors pre-date the work on the
`inference-update-3` feature.
Note: the diff is large due to the fact that the front end has 6
different code paths for handling `??=`, depending on the form of the
LHS, so to make sure that we have adequate test coverage, there are
tests for every possible LHS form. However, the diffs for all the
tests are pretty much the same except for
`if_null_assignment_local_disabled_test.dart` and
`if_null_assignment_local_test.dart`, which have extra test cases to
cover promotion behaviors.
Bug: https://github.com/dart-lang/language/issues/1618
Change-Id: I711d62d9dc00fc20a2efd3967d60066d9bfaec03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356303
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This only changes `_SecureRandom._getBytes` to make the rest of the code
work. Implementation is currently slow: for each random number
generation, it allocates one JS `Uint8Array`, and because we can't
directly read from a JS `Uint8Array` using `dart:js_interop`, a Dart
`Uint8List` wrapper for it. We can optimize separately.
Fixes#55031.
Fixes test lib/math/random_secure_test on browsers. The test keeps
failing in d8 as d8 doesn't define the `crypto` object.
Change-Id: I9d6bbd1bb576c0d0b7206cb2939ee65d987ec297
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356040
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Following the lead of unboxed calling conventions augment
out backend to support passing arguments in registers on
ARM, ARM64 and X64.
Similar to unboxing the calling convention change only applies
to functions which are invoked statically or through
global dispatch table. Functions which are invoked from native
code or directly invoked by dynamic call sites are not allowed
to use register calling convention.
This CL avoid messing too much with call instructions and
instead leans on adjusting existing machinery: MoveArgument
instructions corresponding to register arguments are simply
detached from the graph and are processed as input constraints
by the register allocator.
The computation of the calling convention is centralized in
`ComputeCallingConvention` in `flow_graph.cc` and is used
by callees and callers.
While working on this CL I have also discovered an existing bug
in catch move handling (see added test runtime/tests/vm/dart/try_catch_parameter_sync_test.dart).
On a large Flutter app this decreases the size of generated code
by 1.8% (380Kb) and there a mixed bag of improvements in runing time, e.g.
```
build_bench (Pixel 6a)
-3.536% (0.2 noise)423.16 438.68
animation_bench_close_first_frame (Pixel 6a)
-3.717% (0.0 noise)253.64 263.43
rrect_contains_bench (Pixel 6a)
-3.796% (0.0 noise)0.088700 0.092200
sync_star_sync_star (Pixel 6a)
-5.039% (0.0 noise)2.4310 2.5600
sync_star_list (Pixel 6a)
-5.329% (0.0 noise)1.0660 1.1260
velocity_tracker_bench (Pixel 6a)
-5.731% (0.1 noise)62.039 65.811
sync_star_generated (Pixel 6a)
-6.438% (0.0 noise)1.090 01.1650
matrix_utils_transform_point_perspective (Pixel 6a)
-6.844% (0.2 noise)0.012520 0.013439
matrix_utils_transform_rect_perspective (Pixel 6a)
-7.818% (0.2 noise)0.028117 0.030502
matrix_utils_transform_rect_affine
-27.05% (0.7 noise) 0.017494 0.023981
```
TEST=ci
Issue https://github.com/dart-lang/sdk/issues/54955
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try
Change-Id: I9a134a764666a541d4693e6ca9f6813025ecd63e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353404
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
This is currently behind an `initializationOption` supplied by the client (so that in the short-term we can control this behaviour without SDK changes, for example deciding to enable this in the next stable without having to decide before the branch).
When conditions are met (the client flag, and applyEdit/changeAnnotations) instead of showing a prompt pointing the user to the website to learn about "dart fix" give buttons for running them in-editor. An example of how the prompt looks is here:
https://github.com/Dart-Code/Dart-Code/issues/5022#issuecomment-1991562705
Initially, the new commands and this client flag will be gated on an experimental flag to allow wider testing before it starts showing up.
Change-Id: I64254162e8d146ebf4075bade37b2efef76e11c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357120
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
This is a reland of commit 7ad5a57bf2
Original change's description:
> Preserve non-synthetic function types when resolving invocations of functions with type parameters
>
>
> Update existing tests to require existing parameter elements
>
>
> Add tests for staticParameterElement in generic functions
>
> R=leafp@google.com
>
> Bug: https://dartbug.com/54669
> Change-Id: Ie899f58df56ad1a6b49426ca4d7f4e611975b284
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350920
> Auto-Submit: Mylo Fawcett <mylo.fawcett@gmail.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Bug: https://dartbug.com/54669
Change-Id: I6fc02655d651d6525a9507af29d5c47a337cce74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355320
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The file URI used for the nodes in merged augmentation library should
not use the import URI of the synthesized library but instead the
corresponding file URI. This ensures the their source can be looked up
directly in the `Component.uriToSource` map like normal nodes.
The test for re-offset node have been updated to ensure that macro
sources are always found through the FileUriNode. Previously these
nodes where implictly skipped by the wrongful use of the import URI.
Change-Id: Id7d99137d6683d2a8106cd9c62129a574a47810e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356404
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Right now the _ListBase.[] looks like this in -O4 mode:
(func $_ListBase.[] (param $var0 (ref $Object))
(param $var1 i64)
(result (ref null $#Top))
local.get $var0
ref.cast $_ListBase
struct.get $_ListBase $field4
local.get $var1
i32.wrap_i64
array.get $Array<Object?>
)
Binaryen doesn't inline this because it thinks its too big. Though we'd
really want reads/writes to fixed length lists to be inlined.
For typed data we already have `@pragma('wasm:prefer-inline')`
annotations so it makes sense to also do this here.
Change-Id: I3e976d98717df6e60e9de133dec37d10cd1b9097
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357140
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Run on `release`, not `debug`, the release bot runs by default on PRs so it's more convenient.
Increase the test step timeout from 30s to 60s, I've seen an occasional timeout.
Change-Id: Ie7ce062b4d326763a651b8b607d1aef90e1f65f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356840
Commit-Queue: William Hesse <whesse@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
Reviewed-by: William Hesse <whesse@google.com>
This moves the ClassBuilder.rawType and its associated getters to
ClassBuilderImpl since these are only used from inside the class builder
itself.
Also fixed the use of rawType to trigger for non-generic types. The code
assumed that these had `arguments == null` but the call site actually
uses `arguments.isEmpty`.
Change-Id: I1af5093b95304added4b209165315e205fa46186
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356240
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
* Switch to `std::unique_ptr<wchar_t[]>` to represent a
dynamically strings instead of wrappers like
`StringRAII` and `Utf8ToWideScope`;
* Avoid back and forth conversion between UTF8 and UTF16:
convert to UTF16 first then work on that. This also simplifies
code - previously it tried to work with strings allocated in
different ways uniformly, which is actually unnecessary if
resulting string needs to be converted to UTF16 (and allocated
with `malloc`) anyway;
* Fix a bug in `File::CreateLink`: it was handling relative
links with long paths incorrectly. Change file_long_path_test
to cover this case and make it run on non-Windows systems as
well to ensure that all behavior that can match actually
matches.
TEST=ci
Change-Id: I1279aff1d2cdace5e2ce8633c2f7ea69a34fe41a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356680
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>