Commit graph

100423 commits

Author SHA1 Message Date
YoloMao 5b812f2a16 fix: confused comment content
Closes https://github.com/dart-lang/sdk/pull/55192

GitOrigin-RevId: 6283a7c9d1a753a4fa334ac37860e42a14d7ec66
Change-Id: I58e312a761636e5728f0cfc69b5ce771d393db78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357580
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-03-14 08:57:38 +00:00
Johnni Winther a7d5560ede [_fe_analyzer_shared] Compute multiple witnesses
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>
2024-03-14 08:36:28 +00:00
Chloe Stefantsova 2fe60769d3 [analyzer][cfe] Add id testing for type constraint generation
Part of https://github.com/dart-lang/sdk/issues/54902

Change-Id: If0565c634c0b6ab0dbbdb75a15ff632e623b3fcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357100
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-03-14 08:22:45 +00:00
Konstantin Shcheglov 9d1872644f Macro. Issue 54848. Disable MacroCodeOptimizer for now.
Bug: https://github.com/dart-lang/sdk/issues/54848
Change-Id: Ia3cb73cd930194c434921ba2e9bab9c714d792f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-03-14 00:32:28 +00:00
Ryan Macnak 52f7908b27 [vm, compiler] Account for pair locations in MoveArgumentInstr on riscv32.
TEST=dart-fuzz
Bug: https://github.com/dart-lang/sdk/issues/55181
Change-Id: I075f0b341858b8fcf408378dea1473bab07a87ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357214
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-03-13 22:32:11 +00:00
Paul Berry fb210554eb Enable feature inference-update-3.
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>
2024-03-13 22:04:23 +00:00
Keerti Parthasarathy a1726f82ff Sort the completions tests expectations to be based on relevance then kind.
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>
2024-03-13 21:49:09 +00:00
Konstantin Shcheglov 1d3cb611b4 Issue 43738. Recover in type arguments of incomplete function declaration.
Bug: https://github.com/dart-lang/sdk/issues/43738
Change-Id: I8009804193ced020533a5fda61c50b16686a78f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-03-13 21:13:44 +00:00
David Morgan 078532a6a9 [ddc] Fix flaky test, move timeout to explicit arg.
R=nshahan@google.com

Change-Id: I720b3154c2c5768213027849ab6b06bc91b9b840
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357300
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
2024-03-13 18:06:16 +00:00
asiva 9f951f7fb5 [VM / vmservice] Run service isolate in sound null safe mode (JIT)
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>
2024-03-13 17:56:49 +00:00
Konstantin Shcheglov 3411564829 Completion. Suggest types in RecordTypeAnnotation, using InScopeCompletionPass.
Bug: https://github.com/dart-lang/sdk/issues/55177
Change-Id: I3f75fecf5d0e2acc89b94ee21290b77eea7b1708
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357210
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-03-13 17:32:06 +00:00
Ben Konyi 9c78c8f14b [ CLI ] Strip --observe and --enable-vm-service from dartdev argument list
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>
2024-03-13 17:08:39 +00:00
Alexander Markov 8c1f86e5dd [vm/aot] Devirtualization of function calls
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>
2024-03-13 16:48:34 +00:00
Danny Tuppeny 84c05f7e0c [analysis_server] Fix handling of LSP completion display text with spaces
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>
2024-03-13 16:44:36 +00:00
Vyacheslav Egorov 0fea05cf4c [vm] Unpoison spill slot area in FfiCall
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>
2024-03-13 16:32:54 +00:00
Alexander Markov 8e7137ea81 [vm/compiler] Enable CSE and LICM for tear-off closure allocations
Benchmarks:
JIT:
TearOff.NotInlined*
+32-33% (x64) +60-63% (arm32) +70-76% (arm64) +46-49% (arm64c)
TearOff.Inlined.InTry
+591% (x64) +431% (arm32) +810% (arm64) +509% (arm64c)
AOT:
TearOff.NotInlined
+49-65% (x64) +64-99% (arm32) +121-131% (arm64) +94-109% (arm64c)

TEST=runtime/tests/vm/dart/tearoff_optimizations_il_test.dart
Issue: https://github.com/dart-lang/sdk/issues/54808
Change-Id: I885e68c1ba0ce935c64882b7b91bcbdfe1615df9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356900
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-03-13 16:11:17 +00:00
Sam Rawlins 34c7057331 analyzer: Remove unused extension getters
Change-Id: I5f37a50508c7b16b4ae661dcefe89ad6efea01f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357209
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2024-03-13 16:04:29 +00:00
Sam Rawlins 3059b3957a analyzer: unreachable_from_main: reach typedef used as constructor
Fixes https://github.com/dart-lang/linter/issues/4911

Change-Id: I499f7934a927836f221a8e198143e0fae4498533
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357182
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-03-13 15:48:29 +00:00
Danny Tuppeny 038a07b383 [dds][dap] Add support for macro file-like URIs in the debug adapter
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>
2024-03-13 15:05:47 +00:00
Johnni Winther 2f19d9a378 [cfe] Create RecordFieldImpl for macros
Change-Id: I334025af027b50846762f0b4dbcde9025c76d908
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355762
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-03-13 14:36:20 +00:00
Alexander Markov 1695da67c7 [vm] Move creation of closure functions to kernel loader
This change disentangles creation of closure functions from
flow graph building.

TEST=ci

Change-Id: Ia008c21202453062dd722f64be615e5e6af3bdc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357222
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-03-13 14:33:48 +00:00
Tess Strickland ecf5abcbd3 [vm/compiler] Better handle small array element representations.
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>
2024-03-13 14:14:55 +00:00
Alexander Thomas a5d0ee057e Add requirement to fix downstream repositories
Closes https://github.com/dart-lang/sdk/pull/54982

Fixes: https://github.com/dart-lang/sdk/issues/54947
GitOrigin-RevId: ac418d660ebaf8966a55847bcd2e98ce464cebe2
Change-Id: I7bab8fa99dd3c438bb135635fb156f3510300fad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353660
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Matan Lurey <matanl@google.com>
2024-03-13 14:13:49 +00:00
Jens Johansen e8a1fe81be [service tests] Set batch mode expectations to ExtraSlow trying to avoid flakes
See also https://github.com/dart-lang/sdk/issues/53672

TEST=Existing tests.
Change-Id: I91ce7af3ae1766ff56e086c2574177c244651979
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357281
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-03-13 12:42:12 +00:00
Jens Johansen ae019bda36 [test_runner] First batch test after compiler launch gets more timeout (v2)
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>
2024-03-13 10:21:10 +00:00
Chloe Stefantsova ef6d68c040 [cfe] Add ExtensionTypeRepresentationFieldInitializer.replaceChild
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>
2024-03-13 09:43:57 +00:00
Johnni Winther c506bb80ba [macros] Remove Declaration from RecordField
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>
2024-03-13 09:37:56 +00:00
Vyacheslav Egorov 734e0735bd [vm] Unbreak build with -Wctad-maybe-unsupported
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>
2024-03-13 07:42:13 +00:00
Konstantin Shcheglov e2e6ee8b02 Completion. Don't update @FailingTest expectations.
Change-Id: I627a2b82fd663c56636f52699237380cbf98e750
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357181
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-03-13 01:18:58 +00:00
Konstantin Shcheglov c78f973ce8 Completion. Issue 32677. Prepend 'override' for display text.
Bug: https://github.com/dart-lang/sdk/issues/32677
Change-Id: I3eb3f8248cb90cb435f67760ddc9f744bc973659
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357203
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-03-13 01:18:04 +00:00
Paul Berry 6d12146e75 Additional tests of ??= coercion behaviors for inference-update-3.
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>
2024-03-12 22:45:28 +00:00
Ömer Sinan Ağacan 12859761b9 [dart2wasm] Implement _SecureRandom._getBytes
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>
2024-03-12 21:26:51 +00:00
Brian Wilkerson ff0f5c4bdb Improve the highlight range for several lints
Change-Id: Iac481053665a840bc660e491f544095d4b786760
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356660
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-03-12 20:45:57 +00:00
Vyacheslav Egorov 1ab083ae48 [vm/compiler] Pass arguments in registers
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>
2024-03-12 20:44:49 +00:00
Keerti Parthasarathy 9becf40378 Suggest constructor tearoffs in const context.
Fixes https://github.com/dart-lang/sdk/issues/42264.

Change-Id: I19767d9afffd9270dedde71cad695ec439279674
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-03-12 20:14:49 +00:00
Vyacheslav Egorov 3bb1ada6e6 [kernel] Improve readability of ast_to_text output for metadata
TEST=ci

Change-Id: Iacd5689ec3a4c7e06d4ae18ed1cea471ad8db7b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357141
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-03-12 20:08:10 +00:00
Konstantin Shcheglov a7831723fc Completion. Issue 43919. Discover formal parameters of a getter return type.
Bug: https://github.com/dart-lang/sdk/issues/43919
Change-Id: Ida34c53d534ac7f3785681937ba1ba5488747470
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-03-12 19:27:15 +00:00
Sam Rawlins 23d7347c90 Bump dartdoc to 89a3b4ae0b89c4e540fb00f27a61f0652ada6314
Change-Id: I0877aa6fd671356223d25bc5be950d67240d5094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356926
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-03-12 18:19:00 +00:00
Danny Tuppeny df3d7e339d [analysis_server] Add the ability for the "dart fix" prompt to use in-editor application of all fixes
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>
2024-03-12 17:15:17 +00:00
Ryan Macnak af700baa49 [test] Stop passing -nostdlib when building dynamic libraries on Mac.
Bug: https://github.com/dart-lang/sdk/issues/55105
Change-Id: I3f81875ad10f05deccf8440a8b163423e5446333
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356923
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2024-03-12 16:39:54 +00:00
Abitofevrything e9dd95a10b Reland "Preserve non-synthetic function types when resolving invocations of functions with type parameters"
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>
2024-03-12 16:37:15 +00:00
Keerti Parthasarathy 06490d1032 Add some more test cases for innvocation completions.
Change-Id: I5a9bc4a624cd62970e8aa3d8e9bea1a8387e0329
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-03-12 16:27:29 +00:00
Martin Kustermann bca5e833cb [vm/wasm] Make HashMap<K, V> use non-generic _HashMapEntry object
TEST=ci

Change-Id: Ifef2ef8859a037cd2830182520e6d19cb9b2281e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357142
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-03-12 14:36:38 +00:00
Johnni Winther 0a68ca97b9 [cfe] Use macro file uri on re-offset FileUriNode
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>
2024-03-12 14:02:38 +00:00
Martin Kustermann 4b9dd9d586 [dart2wasm] Force-inline the List.[] List.[]= operations
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>
2024-03-12 13:57:29 +00:00
David Morgan e38f4fa4ac [macros] Tweaks to macro_build test.
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>
2024-03-12 12:46:19 +00:00
Martin Kustermann 0f839e8d1d [dart2wasm] Add some notes on benchmarking & flutter hhh testing
Change-Id: Ic37c3d214294d7267e3a2d7f7bd5e59a4bcd1da2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356403
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-03-12 11:54:14 +00:00
Vyacheslav Egorov f694d3ea18 [infra] Undo accidental change in test runner
R=whesse@google.com

Change-Id: If496048ce4f4d9d16ea6f0f976958199b6e605c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357020
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2024-03-12 10:32:14 +00:00
Johnni Winther f15dd6980a [cfe] Fix rawType
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>
2024-03-12 09:41:51 +00:00
Slava Egorov c2e9ceeb6b [vm/io] Cleanup long path handling on Windows
* 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>
2024-03-12 08:29:36 +00:00