Commit Graph

23731 Commits

Author SHA1 Message Date
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
Kallen Tu f6063e52f6 [analyzer] Dot shorthands: Error - constructors with type parameters.
Add `WRONG_NUMBER_OF_TYPE_ARGUMENTS_DOT_SHORTHAND_CONSTRUCTOR` for dot shorthand constructor invocations with type parameters.

Unit tests added and co19 tests + language tests such as `type_parameter_error_test.dart`.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: Ie8314f1678248f168744646dc0c3d2622cf61551
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426283
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-07 16:27:01 -07:00
Alexander Aprelev 73971941f5 [gardening] Clean up fuchsia build for IsolateGroup shared callbacks.
Follow-up to 50e0e0d99d

TEST=ci

Change-Id: I48114f5677a010561638fedf37390479885c8eef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427041
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-06 15:39:57 -07:00
Alexander Aprelev 50e0e0d99d [vm/shared] Introduce NativeCallable.isolateGroupShared
This method allows for synchronous execution of dart callbacks from native code. The execution happens on dart mutator thread, from which dart code can only access isolate-group variables - those which are tagged with .

Bug: https://github.com/dart-lang/sdk/issues/54530
Bug: https://github.com/dart-lang/sdk/issues/56841
Change-Id: Ia1a6b01327be493f003f1eea82e558bb6b147dd3
CoreLibraryReviewExempt: only internal library change
TEST=isolate_group_shared_callback_test
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422920
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-06 13:28:44 -07:00
Alexander Aprelev b32e5e5a91 [vm/shared] Throw AccessError when isolategroup mutator accesses static fields.
Sample snapshot size comparison before/after:

===
dart2js_aot.dart.snapshot before: 19946368
                          after:  19998800  (with flag turned on)
                          delta:     52432 0.26%
===

Bug: https://github.com/dart-lang/sdk/issues/54530
Bug: https://github.com/dart-lang/sdk/issues/56841
CoreLibraryReviewExempt: internal library change only
Change-Id: I34b1945c040bbad22cb3ec6fdb6e6776df31a82f
TEST=run_isolate_group_run_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422360
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-06 10:42:44 -07:00
Alexander Aprelev fddb38ecab [vm/shared] Introduce IsolateGroup.runSync()
Allow dart code execution on mutator thread, do not require an isolate.

It moves some states that was kept on an isolate to thread or isolate group.

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

TEST=run_isolate_group_run_test

CoreLibraryReviewExempt: only internal library is being updated
Change-Id: I99df09e23954755387ea6230bfd166493d78e989
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418503
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-05 14:52:07 -07:00
Paul Berry c3e91333b6 Test interactions between null-aware accesses and field promotion.
As discussed in https://github.com/dart-lang/language/issues/4344, the
current implementation has some inconsistencies in how null-aware
accesses interact with field promotion. I intend to fix these
inconsistencies as part of the `sound-flow-analysis` language feature.

In this CL, I'm adding a regression test of the behavior that's
currently implemented (as of Dart 3.8), to help me make sure that when
I implement the new behavior, the changes will only take effect when
`sound-flow-analysis` is enabled.

Bug: https://github.com/dart-lang/language/issues/4344
Change-Id: If52a0ad044399904e3389af2130ca802efdd7058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425922
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-05-05 06:59:41 -07:00
Robert Nystrom d6ef495a9a Format tests/lib/mirrors using 3.8 style.
Change-Id: I9f922f8a4106f993c63b55ebbe3c54ea999cbbd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426287
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-05-05 02:31:55 -07:00
Robert Nystrom 36117c443c Format tests/lib/typed_data/ using 3.8 style.
Change-Id: I85d53883d8f976246cae6f3caece157f906cf829
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426320
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2025-05-05 02:24:20 -07:00
Robert Nystrom 8717ff636a Format tests/lib/math/ using 3.8 style.
Change-Id: Ib34bac4962df8927cf2952a4cc5e388c84dcea79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425984
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-05-05 02:23:50 -07:00
Robert Nystrom 4e8a4a3b44 Format tests/modular/ using 3.8 style.
Change-Id: I059d96ef2db91ea43cc1a6d2fffd0d6e7718659b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426288
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2025-05-05 02:09:59 -07:00
Robert Nystrom a323c55162 Format tests/standalone/ using 3.8 style.
Change-Id: I4d492a63a41880ef8cd69321372a4853825b9efd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426321
Reviewed-by: Liam Appelbe <liama@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2025-05-04 17:45:09 -07:00
Robert Nystrom ba40d9bece Format tests/web/ using the 3.8 formatting style.
Change-Id: I73edeeaf4934899b71d6335dcb4b4b54dce46bae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426340
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-05-02 20:17:11 -07:00
Nicholas Shahan 010a4b8227 [tests] Add regression test for dartbug.com/60643
Change-Id: I71d506e8cb7708478466b2162ccc40f0682f308c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425941
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2025-05-02 16:57:28 -07:00
Nicholas Shahan d791aa29fb [tests] Fix bad merge
Two changes landed that touched this test and they didn't merge cleanly.

Change-Id: Ie199dcb30b63627164ce2213fe4d61e65d664371
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426285
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-05-02 16:04:50 -07:00
MarkZ 028914a3ef [ddc] Emitting embedder link functions via symbol property.
Fixes errors when top level 'link' members exist.

Change-Id: I0a339298ff9f51f6cd1f6af7c983eeda4a013956
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426002
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-05-02 15:00:17 -07:00
Nicholas Shahan b97f723c45 [ddc] Improve NoSuchMethod error for closures
Changes the text from "NoSuchMethodError: ''" to
"NoSuchMethodError: '<anonymous closure>'" for some failed invocations.

Adds more test cases involving getter and field invocations.

Change-Id: I685772fc69c7216ae67ea2535de38c8b925c0809
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425940
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2025-05-02 14:27:53 -07:00
Nicholas Shahan 6127d6cb8f [ddc] Add checks to static invocations in closures
Previously, code in a closure was compiled with the assumption that
invocations known to be statically sound didn't need any runtime checks
to guaranty soundness.

Now, if the code is retained from an earlier compile and executed after
a hot reload, any assumptions regarding soundness may be invalid.

This change transforms what was an invocation expression into a larger
expression that performs additional checks (similar to a dynamic call).

All checks are skipped if the compile generation matches the current hot
reload generation at runtime.

The soundness checks are handled by a new runtime helper method
`hotReloadCorrectnessChecks`. Any argument expressions are hoisted into
let variables to preserve their evaluation order and to ensure they are
only evaluated once. The helper checks for the existence of the
invocation target, the shape of the method signature, and runtime type
of the passed arguments. Mismatches result in an invocation of
`NoSuchMethod`. Any returned value is cast to the expected static type
of the original invocation.

Change-Id: If925f1a9b475d5ac581b2526403ab7c95753ffef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421640
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-05-02 12:52:05 -07:00
Kallen Tu 73d6821a81 [analyzer] Dot shorthands: Report error when type arguments are not assignable.
This is a bug fix of the current implementation of dot shorthands type argument resolution. We want to make sure we're doing inference with the proper context type given at that point (with the element based on the dot shorthand context type we've saved).

Then I made sure there was proper argument checking, not just for `FunctionExpressionInvocation`s, but with `DotShorthandInvocation`s as well.

Tested with unit tests and language tests.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I795046502214628389c6471e9424aca7152657e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425780
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-02 09:28:52 -07:00
Robert Nystrom c9d54c12f6 Reformat tests/language/s** using 3.8 style.
Change-Id: I3c5cfbc1bc5e41d2ef1598427067dea00f9f42b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425403
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2025-05-02 04:46:00 -07:00
Robert Nystrom 200e0c83bd Reformat tests/language/r** using the 3.8 style.
Change-Id: Ibfa8df8eb3cdeec9afd45fa8448a7186869ae2c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425345
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-05-02 04:45:20 -07:00
Robert Nystrom 1ba6da2d08 Reformat tests/language/t** using 3.8 style.
Change-Id: I9627ebe0aa4d51d053a8dd1bd85873ba72e8e03c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425325
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2025-05-02 04:28:39 -07:00
Robert Nystrom cf4813a6cc Reformat tests/language/u** using 3.8 style.
Change-Id: I0618aa2abf0cd541dad70a77430a2745340f485a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425405
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2025-05-02 04:26:26 -07:00