Commit Graph

23753 Commits

Author SHA1 Message Date
Alexander Aprelev 4715ebd181 [vm/shared] Update mutator count as entering/exiting mutator thread.
Running dart code on mutator thread outside of isolate still should follow limits on number of concurrent mutators in the vm.
Also this fixes inconsistency when entering isolate group as mutator, where original worker was marked as blocked while thread was actually running dart code. That inconsitency showed up as sporadic crash on isolate_group_shared_init_test with increased number of spawned isolates.

TEST=isolate_group_shared_init_test
BUG=https://github.com/dart-lang/sdk/issues/60877

Change-Id: I8917be903bb5517940dad3e5dab143d5ed5fdf79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432900
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-09 10:34:40 -07:00
Ivan Inozemtsev 15c58a889f Add static variants of Dart engine library and update samples
Fixes https://github.com/dart-lang/sdk/issues/60799

Change-Id: I16a8dd2c854ed6915f14e1b71547879f50f2de0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432920
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-06-06 04:00:45 -07:00
Alexander Aprelev ef4e39a6ef [vm/shared] Ensure exclusive execution of shared field initialization.
Add a mutex to guard execution of vm:shared field initialization.

TEST=isolate_group_shared_init_test
BUG=dartbug.com/60699

Change-Id: If544351fc26bfcc7fb9703954efe785989d488bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431742
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-06-05 14:12:33 -07:00
Brian Quinlan 0ac78fb92f [io] Fix a bug where the proxy configuration parser did not correctly validate proxy passwords.
Closes https://github.com/dart-lang/sdk/pull/60476

GitOrigin-RevId: c2f3b31db38755c7d439daa862e86c528744739c
Change-Id: I498dcfae0b0c9614fc388f102f8d88630e0761ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420381
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2025-06-05 13:52:34 -07:00
Daco Harkes 47cc2606f4 [ffi/test] Address lints
Change-Id: I3b13731935c8520b8ca17ee45d967499fccdcbe9
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432940
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-06-04 07:53:51 -07:00
Paul Berry eec56c088e [flow analysis] Mark false branches of trivial is tests unreachable.
When an `is` test is trivially satisfied (i.e. `expr is T`, when the
static type of `expr` is a subtype of `T`), the `is` test is
guaranteed by soundness to evaluate to `true`, so any code path that
follows from the `is` test evaluating to `false` is unreachable.

This reasoning wasn't valid prior to sound null safety, because in
mixed mode programs, it was possible for an expression to evaluate to
`null` even if its static type wasn't nullable, and hence `expr is T`
might evaluate to `false` even if the static type of `expr` was a
subtype of `T`. So this change is gated on the `sound-flow-analysis`
language flag (which is enabled in Dart 3.9).

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

Change-Id: I66a65580b738162f23b6fb468b71fcac66bfbb95
Bug: https://github.com/dart-lang/sdk/issues/60718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431740
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-04 05:17:21 -07:00
Paul Berry 9602464304 [flow analysis] Don't clear types of interest on full demotion.
Previously, when assiging to a local variable that was promoted, if
the newly assigned value was not compatible with any of the promotions
(i.e., the variable was fully demoted back to its declared type), then
the set of types of interest was cleared.

This behavior was not documented anywhere in the spec, and it seems
oddly inconsistent to me; as far as I can tell, flow analysis doesn't
clear types of interest in any other circumstances. I've looked
through git history as well as my personal notes, and I've been unable
to find any justification for this behavior. So, with the agreement of
the language team, I'm removing it when sound-flow-analysis is
enabled.

Fixes https://github.com/dart-lang/language/issues/4380.

Bug: https://github.com/dart-lang/language/issues/4380
Change-Id: Ic1ca80a61e21482e659afa8796b08fce707db3c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429227
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-03 14:19:53 -07:00
Tess Strickland f8e21c5c94 [pkg/test_runner] Only use .dll for assembled snapshots on Windows.
Use "out.aotsnapshot" as the name for all non-assembled snapshots and
names with the appropriate shared object extension for the host OS for
assembled snapshots.

This ensures the test checks for .dll extensions added in
https://dart-review.googlesource.com/c/sdk/+/428200 only trigger
for assembled snapshots as expected, and not for other formats
(e.g., Windows trybots using sanitizers, which still use direct
to ELF snapshots).

Also fixes incorrect line numbers in dwarf_stack_trace_test.dart.

TEST=vm/dart/build_id_test
     standalone/dwarf_stack_trace_test

Cq-Include-Trybots: luci.dart.try:vm-asan-win-release-x64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try
Bug: https://github.com/dart-lang/sdk/issues/60846
Change-Id: Ife06613d86874d76adeb99dcbc50fc3723aae584
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432660
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-06-03 06:23:04 -07:00
Tess Strickland f7699740cc [vm] Allow manual loading of Mach-O dynamic library snapshots.
Adds a Mach-O loader, similar to the existing ELF loader, that
can be used on platforms that do not support loading Mach-O dynamic
libraries via dlopen().

Other changes:

* Renames the --force-load-elf-from-memory command line argument
  to --force-load-from-memory.
* Use CPU_TYPE_ANY and CPU_SUBTYPE_ANY for architectures that do
  not have specific constants in <mach/machine.h> (e.g., RISCV),
  as the snapshot header check after loading also catches architecture
  mismatches.
* Emit the unwinding information at the end of the text segment
  for Windows Mach-O snapshots as is done for ELF ones.

TEST=vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: I34a2a334f47d18d5c4f4a712956e71fd0ac94024
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try,vm-win-release-x64-try,vm-win-release-arm64-try,vm-aot-win-debug-arm64-try,vm-win-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430100
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-03 05:56:59 -07:00
Paul Berry 9f0e5229fa [flow analysis] Fix layering of type promotions in try/finally.
A tricky part of the implementation of flow analysis is the handling
of try/finally statements. Although promotions are tracked separately
in the `try` and `finally` blocks, promotions from both blocks need to
be merged together at the conclusion of the finally block. This
creates an ambiguity, because each type in a promotion chain is
required to be a subtype of the previous, and hence multiple
promotions of the same variable are inherently ordered. The ambiguity
is: when the promotions from the `try` and `finally` block are merged,
which promotions should be applied first?

In discussion with the language team, we've decided that the
promotions from the `try` block should be applied first, because that
matches the order of code execution. This change makes the behavior of
flow analysis more uniform, which should make it easier to reason
about and maintain.

In practice, the difference in behavior is quite subtle, and I don't
expect users to notice. However, to be on the safe side, the change in
behavior is conditioned on the `sound-flow-analysis` flag, so it will
only take effect when the user deliberately upgrades to language
version 3.9, and it will not affect already-published packages.

A test in google3 showed that no internal code would be broken by
force-enabling this change.

Fixes https://github.com/dart-lang/language/issues/4382.

Change-Id: I0e9f6db808a964e0b4325d3020654a9f2be273a2
Bug: https://github.com/dart-lang/language/issues/4382
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432001
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-02 13:57:11 -07:00
Ryan Macnak 03301c9bfb [vm] Support assembly output for Windows.
The resulting DLL lacks debugging information / PDB.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60812
Bug: https://github.com/dart-lang/sdk/issues/60813
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try
Change-Id: I305bad0081ec24f27249ad9b75ff8d32fa9c4893
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428200
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-02 12:12:04 -07:00
Alexander Aprelev 86341c9b8a [vm/gardening] Skip isolate_group_shared_send_test on fuchsia.
The test requires --experimental-shared-data flag, passing of flags is not supported for fuchsia testing.

Fixes failures https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8713156044238231937/+/u/test_results/new_test_failures__logs_

Change-Id: I534dd24325e79f44e882f7ab35f78be1f959c925
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432324
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-02 11:43:57 -07:00
Ryan Macnak 56636971dc [test_runner] Remove nnbd mode options.
In particular, this means the VM tests stop getting invoked with the now-invalid --sound-null-safety flag.

Change-Id: Ia8f5a59e0bf1fd7094508fdc4bb146ebf3034148
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431360
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-02 10:59:31 -07:00
Paul Berry bf6ddd25c4 [flow analysis] Do not promote to mutual subtypes.
Previously, flow analysis had the rule that type promotion only
occurred when the type being tested was a subtype of the previously
promoted type (or the declared type, if there was no previous
promotion). This led to counterintuitive behaviors when the type being
tested and the previously promoted type were mutual subtypes (see
https://github.com/dart-lang/language/issues/4368).

With this change, the rule is updated so that type promotion only
occurs when the type being tested is a subtype of the previously
promoted type _and_ the previously promoted type is _not_ a subtype of
the type being tested. The user-visible difference is that promotion
to a mutual subtype no longer occurs.

This change makes flow analysis easier to reason about, and improves
its behavior in corner cases, but I believe it will have minimal
impact on real-world code. But to reduce the risk to existing code,
the change only takes effect when the `sound-flow-analysis` language
feature is enabled.

Fixes https://github.com/dart-lang/language/issues/4368.

Bug: https://github.com/dart-lang/language/issues/4368
Change-Id: I30dab017e043e75603d618df721c8a2683667cd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-02 10:27:03 -07:00
Alexander Aprelev 65d0d8581a [vm/shared] Move forward_table from Isolate to Thread.
Having forwarding tables on the Thread allows for those tables to be used in dart mutator thread running in IsolateGroup-shared context. On 32-bit platforms(arm) the forwarding tables are used during [SendPort.send] message verification.

Fixes https://github.com/dart-lang/sdk/issues/60817
TEST=isolate_group_shared_send_test

Change-Id: I58b33c14026584330b594776e812fe1d48bc2fd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431942
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-02 10:04:39 -07:00
Sergey G. Grekhov df126594e9 [co19] Roll co19 to 3388e8e9073d57e6fdca6582568fdfa6f9a6bc61
2025-06-02 sgrekhov22@gmail.com dart-lang/co19#3180. Add tests for NullableUndefineableJSAnyExtension. (dart-lang/co19#3205)
2025-06-02 sgrekhov22@gmail.com Fixes dart-lang/co19#3212. Fix the new roll failures. Add issue numbers (dart-lang/co19#3213)
2025-06-02 sgrekhov22@gmail.com dart-lang/co19#3057. Update promotion_switch_A05_t03.dart according to the current implementation (dart-lang/co19#3214)
2025-05-28 sgrekhov22@gmail.com Fixes dart-lang/co19#3201. Allow getter/setter with different types (dart-lang/co19#3207)
2025-05-28 sgrekhov22@gmail.com Fixes dart-lang/co19#3206. Update expected errors positions for CFE (dart-lang/co19#3208)
2025-05-27 sgrekhov22@gmail.com dart-lang/co19#2868. Add test for a member invocation of an extension on nullable type (dart-lang/co19#3204)
2025-05-26 sgrekhov22@gmail.com dart-lang/co19#3057. Add more tests for promotion in switch (dart-lang/co19#3185)
2025-05-26 sgrekhov22@gmail.com dart-lang/co19#3057. Add switch statements/expressions patterns matching tests (dart-lang/co19#3169)
2025-05-23 sgrekhov22@gmail.com dart-lang/co19#3198. Remove accidental code (dart-lang/co19#3202)
2025-05-23 sgrekhov22@gmail.com Fixes dart-lang/co19#3198. Don't use string representation of `Type` objects (dart-lang/co19#3200)
2025-05-23 sgrekhov22@gmail.com dart-lang/co19#3182. Update augmenting_declarations_A05_*.dart (dart-lang/co19#3199)

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try
Change-Id: I89444579e87815f0087ac538bb2ea264f93d2180
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432280
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2025-06-02 09:06:52 -07:00
Ryan Macnak 2565128cb0 [infra] Shard Mac AOT builders.
Use a combination of gen_snapshot's new ability to generate dylibs directly and the copy of llvm in buildtools to avoid using XCode, which is not available in shards.

Add definitions for debug builders now that they can complete without timing out.

Cq-Include-Trybots: luci.dart.try:vm-aot-mac-product-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try
Change-Id: I79924128f11aafab4cd74ea6e9ab5848c64557da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431700
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-02 08:21:35 -07:00
Alexander Markov c006202dc6 [vm,dyn_modules] Convert function type args to instance type args when allocating an object in constructor tear-off
TEST=tests/language/regress/regress60816_test.dart
Fixes https://github.com/dart-lang/sdk/issues/60816

Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try
Change-Id: Id4c9ae3dc14cf680ba5f04d54d019ebe589ad96d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432100
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-06-02 07:30:58 -07:00
Stephen Adams d49cd3c552 [dart2js] Track, rather than compute, isCallOnInterceptor
By tracking `isCallOnInterceptor`, we avoid the need for class context
information in the `sourceElement` to compute the value. `sourceElement`
is now purely advisory to the choice of local names in codegen, and
can't be the wrong kind of element as in issue #60793.

Bug: #60793
Change-Id: I8bb68b6bf864a3a6f9f2beb40f68a6254431d49a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432003
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-05-30 11:38:22 -07:00
Johnni Winther ac2fc57446 [cfe] Combine getter/setter and final field/setter into one property builder
This combines getter/setter and final field/setter pairs into a single
SourcePropertyBuilder. This prepares for handling augmentation of
properties.

Change-Id: Ie2d9b89baa1ae72e53d7d09d672d2aa2327ef7ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431100
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-28 00:38:32 -07:00
Kallen Tu 89552236ff [analyzer] Dot shorthands: Infer type parameters in constructor tearoffs.
This CL fixes co19/LanguageFeatures/Static-access-shorthand
/semantics_A05_t01.dart.

While working on this, I realized the static type was wrong and we weren't doing any inference for the constructor references so I updated the logic.

Unit tests passing, language test expectations are actually better than before and that particular co19 test passing.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I7437079c33640f53f48a4445890fadfebc9ec158
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430561
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-27 11:44:00 -07:00
Chloe Stefantsova 6fa858cfe8 Enable 'getter-setter-error' flag in 3.9
TEST=existing

Change-Id: Ic4a5735adda7cf8ef1565b9356ca277d9b62b064
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-26 08:08:31 -07:00
Alexander Aprelev 0f34fdde1d [gardening] Skip isolate_group_shared_callback_test on hot reload bots.
The test in reload is very slow in "--shared_slow_path_triggers_gc" configuration.

Fixes https://github.com/dart-lang/sdk/issues/60758
TEST=ci

Change-Id: I16e9ff1de273464a866db6db8fa839b7aa03dca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430882
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-23 11:14:31 -07:00
Alexander Aprelev 6497b412e2 [vm/shared] Ensure dart mutator thread stack is walked during gc.
Fix asynchronous aspect of the test.

Fixes https://github.com/dart-lang/sdk/issues/60756
TEST=ci

Change-Id: Ife311d5663665e7fa6e8dd3977fc31f5ed22cc17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430580
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2025-05-23 07:23:22 -07:00
Martin Kustermann 226a667ef9 [dart2wasm] Add const bool.fromEnvironment('dart.tool.dart2wasm.minify')
We add the `dart.tool.dart2wasm.minify` environment define (analogous to
how dart2js exposes `dart.tool.dart2js.minify`).

We make `package:expect/variations.dart` then expose to tests what
guarantees they can assume, namely

   * `readableTypeStrings`
   * `preciseErrorsWithDetails`

Change-Id: I43da09ed924ca9137721f4d70b7a494e01bf36e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430680
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-05-23 01:26:38 -07:00
Nicholas Shahan f4c87f2ae8 [ddc] Add hot reload checks to instance getter accesses
Checks the compile and current hot reload generations. If they are not
equal the value is checked to have a getter of the expected name and
if so it gets called. If not, `.noSuchMethod` is invoked instead.

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

Change-Id: Ib80582b45f87f2ab41b943e0f263167b38601e0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429066
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-05-22 13:27:31 -07:00
Alexander Aprelev 3718baa446 [ffi/isolate_group_shared] Keep isolate alive for isolate group shared callback.
To fix encountered tsan race(patchset 3)  split Metadata into MetadataEntry as discussed on https://github.com/dart-lang/sdk/issues/60728#event-17760701621

TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/60728

Change-Id: I9308d6fb6a9b819221f7fe4668aefb3a578fe8a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430122
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-22 09:02:01 -07:00
Alexander Aprelev 56819231be [vm/shared] Fix LoadStaticField calls initializer behavior.
With b32e5e5a91 under --experimental_shared_data flag, `LoadStaticField` calls initializer stub to confirm presence of isolate when accessing non-shared static fields. This breaks the role that `calls_initializer` attribute/parameter used to play where it was specifically describing neccessity to call initializer, which is important in how `LoadStaticField` instruction is used in static field setters - it should not attempt to call initialzer.

This CL fixes the problem by renaming current `calls_initializer` `LoadStaticFieldInstr` attribute to `does_slow_checks`, and "adding" separate `calls_initializer` parameter to the instruction to signify specifically whether initializer has to be called.

TEST=ci

Change-Id: Ib81424864c98d889fb6dbb9dd15dac9a39c530f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429062
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-22 09:02:01 -07:00
Nate Biggs e688981385 [ddc] Fix capture issue with temp names within async scopes.
`needsCapture` will ensure that any variables used within an async scope get included in the 'asyncScope' object that's created for that scope.

The variables used to lower Dart late variables in particular get emitted separately. But they can still be used across async scopes so they need the special capture logic as well.

Bug: https://github.com/dart-lang/sdk/issues/60748
Change-Id: I2486fce41f88f186fd799029c2cc59635f7ad8f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429780
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-05-21 17:49:22 -07:00
Ömer Ağacan 0246c485e0 [dart2wasm] Check types of JS references when boxing JSValues as non-interop types
To make sure Dart values with typed data types like `Uint8List`, `List`,
`String` etc. hold the right type of JS values, check types of JS
references in boxing functions that return Dart typed data types.

To reflect what the functions actually do, and for consistency with
other functions, boxing factory names are changed from `fromJSArray` to
`fromRef`.

New boxing functions `fromRefUnchecked` added for the call sites that
already know the reference type to be the right type, for example in
`dartifyRaw`.

These unchecked functions will also be used in CL 424021 where we
replace some `dartifyRaw` calls with more precise "dartify" functions
that only converts when the type is right. (`dartifyRaw` always boxes
the argument regardless of the type)

Issue: https://github.com/dart-lang/sdk/issues/60357
Change-Id: Icdfb49b9b235d35af2af0c4be51b295ee68d99fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429362
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2025-05-20 09:38:12 -07:00
Chloe Stefantsova 9189341de2 [ffi] Remove a test that relies on not-Null Safe subtyping
This CL does not clean up the null checks that are discussed in
https://github.com/dart-lang/sdk/issues/47486

Change-Id: Iff5891d48dd9e0602940896001a7bb29538f6016
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429620
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-20 01:52:52 -07:00
Ryan Macnak b3beefb5bd [test] Await closing server socket before reusing the same fixed port.
Bug: https://github.com/dart-lang/sdk/issues/51477
Change-Id: I591fb791d262d392212995bd75b6ff865b9fc5df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427323
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-05-19 14:16:59 -07:00
Ryan Macnak 0a6fa7ac03 [vm] Fix --gc_at_throw, etc for isolate group callbacks.
TEST=ffi/isolate_group_shared_callback_test
Change-Id: Ib4c241d59a36544495c264c51848753a0bc22bf4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429460
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-19 14:07:50 -07:00
Martin Kustermann 7882084ab5 [dart2wasm] Correctly deal with abstract members in selector building
When we create a `Selector` we compute various information
based on all members belonging to that selector. Before this
CL this was split up: Some things like `ParameterInfo` was
calculated&updated while discovering members, others was
calculated after all members were discovered.

We now make all fields whose value depends on knowing all
members `late final` and initialize those fields after
having found all members of a selector.

When we compute the `ParameterInfo` of the selector we take
special care:

If there's non-abstract implementations and the selector is
not overridable by dynamic modules then we create the
`ParameterInfo` by looking only at the non-abstract members

=> This increases precision as we ignore the types and
   default values of optional parameters for abstract members

If there's no implementations of the selector it may still be
referred to by instance invocation AST nodes (which are
unreachable). The current code generator still needs a
`Selector.signature` in order to evaluate arguments for such
nodes.

=> We calculate `ParameterInfo` based on the abstract member
   and use `defaultSentinel` for optional parameters.

If a selector can have implementations in dynamic modules
then we cannot determine whether all implementations have
the same default value of optional parameters.

=> We calculate `ParameterInfo` using `defaultSentinel`
   value for all optional parameters. Ensuring the caller
   doesn't pass them but the callee will default to it's
   default value if it wasn't passed by caller.

See added test case for when we (before this CL) may
use unreachable members in the param info / signature
calculation and how that could lead to a compiler bug
(before this CL) due to a missing
 `VariableDeclaration.initializer`

TEST=web/wasm/unreachable_selector_implementation_test

Change-Id: I3628177f8e93c5d24ff0eb0ff8fee6121a4a08d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428541
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-05-19 06:46:18 -07:00
Chloe Stefantsova 617d0a8e96 [model] Remove more nullability-related assignability error messages
This is a preparation for removing the subtype checking procedure that
ignores the nullability in the input types.

Change-Id: I3c1db55abde0433e9059d949f1c98aaeb61e210c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428980
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-19 00:18:57 -07:00
Alexander Aprelev 4a63257e4c [gardening] Fix ffi\native_assets\infer_native_assets_yaml_dart_kernel_snapshot_test.dart on Windows.
When running the test from Powershell Platform.executable is absolute path, rather than relative when invoked from Command shell. That breaks the test when running from Powershell.

This change fixes the test to always use Platform.resolvedExecutable.

```
PS C:\src\d\sdk> out\DebugX64\dart.exe  tests\ffi\native_assets\infer_native_assets_yaml_dart_kernel_snapshot_test.dart
invoke helper with --package=...
File copied to file:///C:/Users/aam/AppData/Local/Temp/tests_ffi_native_assets_b0de5819/infer_native_assets_yaml_dart_kernel_snapshot_helper.dart.
Unhandled exception:
Unsupported operation: Cannot extract a file path from a c URI
<asynchronous suspension>
<asynchronous suspension>
<asynchronous suspension>
<asynchronous suspension>
<asynchronous suspension>
PS C:\src\d\sdk>
```

after

```
PS C:\src\d\sdk> out\DebugX64\dart.exe  tests\ffi\native_assets\infer_native_assets_yaml_dart_kernel_snapshot_test.dart
invoke helper with --package=...
File copied to file:///C:/Users/aam/AppData/Local/Temp/tests_ffi_native_assets_3dfd90fc/infer_native_assets_yaml_dart_kernel_snapshot_helper.dart.
File native_assets.yaml written to file:///C:/Users/aam/AppData/Local/Temp/tests_ffi_native_assets_3dfd90fc/.dart_tool/native_assets.yaml.
dill file created: file:///C:/Users/aam/AppData/Local/Temp/tests_ffi_native_assets_3dfd90fc/infer_native_assets_yaml_dart_kernel_snapshot_helper.dart.dill
invoke helper with --package=... done
invoke helper in working dir
File copied to file:///C:/Users/aam/AppData/Local/Temp/tests_ffi_native_assets_c7f57eac/infer_native_assets_yaml_dart_kernel_snapshot_helper.dart.
File native_assets.yaml written to file:///C:/Users/aam/AppData/Local/Temp/tests_ffi_native_assets_c7f57eac/.dart_tool/native_assets.yaml.
dill file created: infer_native_assets_yaml_dart_kernel_snapshot_helper.dart.dill
invoke helper in working dir done
```

TEST=ci, manually from powershell.

Change-Id: Ie0d6cdb2ecdd69bb44a8ea820ce71405344c1307
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429080
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2025-05-18 23:51:52 -07:00
Paul Berry 929d058a1e Fix typo in demotion_and_type_of_interest_promotion_test.dart
Thanks to Lasse for pointing this out (see
https://dart-review.googlesource.com/c/sdk/+/427920/comment/0c3c5efc_f0a11a0f/).

Change-Id: Iea6dafd067d95651b9b7b80b5cff3979c1fd9989
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428843
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
2025-05-16 01:04:31 -07:00
Chloe Stefantsova 1f26ddfee2 [ffi] Account for position variance in converting native types
This CL introduces variance-dependent treatment of the `Handle` native
type when converting native types to Dart types. Since `Handle` can
represent any object, it should match any type. To achive that in
cases when `Handle` appears as the subtype in the subtype checks, it's
converted to `Never` in covariant positions and to `Object?` in
covariant ones.

TEST=existing

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

Change-Id: Ie16a210491ada80d21f4d0f1c0fa3b3804881ede
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426880
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-15 22:53:41 -07:00
Ryan Macnak 018c5349a8 [vm] Handle short writes in Builtin_PrintString.
Also avoid polluting the repository working directory when fuzzing.

TEST=lib/mirrors/invocation_fuzz_test
Bug: https://github.com/dart-lang/sdk/issues/60721
Change-Id: Ibe2f2d35479bbf969cff74c954acd606c1fc0679
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428381
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-13 14:25:36 -07:00
Ryan Macnak c0e2f38f02 [dart:io] Fix some code to be safe in the face of reflective invocation.
Reflection can invoke public members of dart:* private types when values of the private types can be returned from public members.

TEST=lib/mirrors/invocation_fuzz_test
CoreLibraryReviewExempt: does not change public API
Bug: https://github.com/dart-lang/sdk/issues/31838
Bug: https://github.com/dart-lang/sdk/issues/46435
Bug: https://github.com/dart-lang/sdk/issues/51213
Change-Id: I969cd935d60455bd9cf4775b8df19838f9e6107c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428065
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-13 10:39:23 -07:00
Kallen Tu ecc6b93abd [cfe/analyzer] Dot shorthands: Abstract constructors can't be instantiated or torn off.
Adding a few errors on when we instantiate or tear off abstract constructors. Should be parallel to how we currently check for these errors in the CFE and analyzer.

Follow up to https://dart-review.googlesource.com/c/sdk/+/426682

Language test added, co19 test passing, and unit tests added.

Bug: https://github.com/dart-lang/sdk/issues/59758, https://github.com/dart-lang/sdk/issues/59835
Change-Id: I9b34e5f960856ce50aa969ca27e56907ae3a2a8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428201
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-13 10:10:51 -07:00
Paul Berry 6cea1790bd [flow analysis] Fix invalid type of interest promotion.
This change closes a loophole whereby it was possible for "type of
interest" promotion to promote to a type that was not a subtype of the
declared type.

I've gone ahead and included more extensive tests (both in unit test
and language test form) of demotion and type of interest promotion, to
try to make sure there aren't other loopholes.

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

Bug: https://github.com/dart-lang/sdk/issues/60620
Change-Id: Ifef04cde6fda2aee80ec002c7ca04f2be6cff987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427920
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-13 06:10:25 -07:00
Srujan Gaddam 8f3dd793a8 Update Chrome to v137
Also filters two WebGL-related tests. Starting with
Chrome 137, WebGL is unsupported for devices without a
GPU and therefore, the try bots start failing on these
tests.

https://chromestatus.com/feature/5166674414927872

Change-Id: Ic5eaf972188aae0f44de4273c2f42f3d2337bfa2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428062
Reviewed-by: Nate Biggs <natebiggs@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-05-12 21:59:07 -07:00
Paul Berry 7436b97ba4 [flow analysis] Allow non-cascaded field accesses to participate in field promotion.
The way this is accomplished is that in
`_FlowAnalysisImpl.nullAwareAccess_rightBegin`, any expression
reference associated with the target of the null-aware access is
restored, and the corresponding SSA node is associated with the guard
variable (if any). These changes ensure that if the null-aware access
is a property get, the subsequent call to `propertyGet` will pick up
the appropriate SSA node, so it will be able to locate the promotion
key for the property.

This functionality is only enabled when the language feature
`sound-flow-analysis` is enabled.

To prevent test regressions, a few related changes need to be made at
the same time:

- `_FlowAnalysisImpl.nullAwareAccess_end` is changed so that it clears
  any expression info or expression reference that was associated with
  the null-aware access expression. This prevents flow analysis
  information from being erroneously propagated out of a null-aware
  expression, which would have led to assertion failures when
  analyzing null-aware expressions inside of conditional
  expressions. This wasn't previously a problem because the expression
  reference used to be consumed by
  `_FlowAnalysisImpl.nullAwareAccess_rightBegin`, preventing further
  expression references and expression infos from being recorded
  further along in the null-aware access.

- The test framework in `mini_ast.dart` is fixed so that `!` is
  considered to participate in null shorting. This was a bug in the
  test framework that wasn't previously caught because it happened not
  to produce any test failures.

- The analyzer's method `PostfixExpressionResolver._resolveNullCheck`
  is changed so that it calls `nonNullAssert_end` before terminating
  null-aware access. Previously, the order was swapped, causing
  `nullAwareAccess_end` to be called before `nonNullAssert_end` when
  analyzing expressions like `a?.b!`. This used to be benign, but now
  that non-cascaded field accesses participate in field promotion,
  flow analysis needs the methods to be called in the correct order.

Fixes https://github.com/dart-lang/language/issues/4344.

Bug: https://github.com/dart-lang/language/issues/4344
Change-Id: I523be1b4be1af3f68654a745187a546728c878fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427820
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-12 08:25:20 -07:00
Alexander Aprelev 5db3125726 [gardening] Fix isolate_group_shared_callback_test so it allows for slow execution.
Accept the fact that on slow platforms(like android arm devices) it might take longer for callback to respond.

Fixes https://github.com/dart-lang/sdk/issues/60700
TEST=ci

Change-Id: I67e322b29aaec1cf926790b5eeba67a411a8eaec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427801
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2025-05-09 16:25:51 -07:00
Paul Berry a757d2af41 Enable sound-flow-analysis for Dart 3.9.
Bug: https://github.com/dart-lang/sdk/issues/60438
Change-Id: I908d4e4a9143142281d8198870f40eba6cf6f67f
Tested: trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427500
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-09 14:50:26 -07:00
Stephen Adams a42401ab3e [dart2js] Remove checks to support migration with mixed null safety
`_potentiallyAssertNotNull` would insert null checks to catch issues
from mixing libraries sound and unsound null safety. The null checks
are now always optimized away so we might as well never insert them.

Bug: #60327
Change-Id: I092a4fb336e46bf33b9b3cd9867dd7b6d8f9c65e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427569
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-05-09 14:41:52 -07:00
Alexander Aprelev 893e37a517 [vm/shared] Add timeout to ConditionVariable.wait.
Update isolate_group_shared_callback_test to use that and also use flag to print exceptions.

TEST=ci
CoreLibraryReviewExempt: only internal library is affected
Change-Id: Ia53ca7a6dc847b551229ccf00bbbfe302a260fcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427680
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-09 11:29:30 -07:00
Kallen Tu 29bc21c6d7 [analyzer] Dot shorthands: Add DotShorthandMixin to PostfixExpression to handle null-assert expressions.
The parser now handles the `!` operator which wouldn't be captured originally because we are parsing the shorthand with SELECTOR_PRECEDENCE.

Added a language test since no tests currently cover the usage of `!` and a few unit tests.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I66bdcc9a083c98d91b16d3ce8c952b8d4010ecd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425155
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-09 09:57:28 -07:00
Ryan Macnak 119116f8a6 [gardening] Mark some slow tests.
Change-Id: I68c45a230a77819af29264eb352cba35e3036787
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427326
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-07 19:47:04 -07:00