Commit Graph

10 Commits

Author SHA1 Message Date
Sigmund Cherem 354b0f8606 [dyn_modules] Support types in a dynamic interface.
This CL adds a new `can-be-used-as-type` section in the dynamic
interface to expose the type of a class or extension type, without
making them callable or exposing their members.

Details:
* add the new section to the documentation
* add support in the TFA transformation to annotate kernel nodes
* add support to the validator to check for proper usage from dynamic modules
* add CFE, transformation, and end2end tests.

The CL ignores DDC and Dart2wasm at the moment and we intend to approve
any failures. It's possible that DDC works due to its modular nature.

BUG=b/488343137
TEST=cfe, annotator, and e2e tests

Change-Id: I900b22b85950f8ac379eabaa2ef58f075e18519c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486340
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-12 09:46:50 -07:00
Alexander Markov d95e527aab [dyn_modules] Improve support for extendable mixins with private members
When mixin is applied, its instance members are cloned and copies
of the members would override original members.

This change fixes bugs and improved usability of extendable mixins with
private members:

- All instance members of extendable mixins and mixin classes are
  marked as can-be-overridden to allow overriding by cloned members
  when mixin is applied.

- TFA no longer takes privacy into account, as private members of
  mixins can be overridden by their clones in other libraries.

- Dynamic module validator always unwraps cloned members to originals
  before verifying if overriding is allowed. This eliminates overriding
  errors between clone(s) and original members of mixins.

TEST=pkg/dynamic_modules/test/data/mixin_private_member1,
     pkg/dynamic_modules/test/data/mixin_private_member2

Fixes b/470461203
Fixes b/469094721

Change-Id: If369c42c58e5ea4d707be83b1e7078ee9a8cc3ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470803
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2026-01-07 08:26:38 -08:00
Alexander Markov 849998846b [dyn_modules] Remove ability to specify library wildcards in dynamic_interface.yaml files
In future this would allow us to automatically include libraries
specified in dynamic_interface.yaml into the compilation set as if
they were imported from Dart code.

Bug: b/452833638
TEST=ci

CoreLibraryReviewExempt: no API changes, only pragmas
Change-Id: If5705159148cd48f49f21485550747db1365767c
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,vm-dyn-mac-debug-arm64-try,vm-ffi-dyn-mac-debug-simarm64_arm64-try,vm-ffi-dyn-mac-release-simarm64_arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456401
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2025-10-22 07:48:30 -07:00
Alexander Markov d2252b1fd6 [dyn_modules] Add option to dump detailed dynamic interface
Front-end server and gen_kernel tools now take

--dump-detailed-dynamic-interface=foo.json

option which can be used along with --dynamic-interface when
AOT-compiling application with exposed dynamic interface.

This option dumps dynamic interface broken down to members
and classes as JSON.

TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart
Fixes b/420811696

Change-Id: Id1b15521f47a4869fefd40e835044584fbfb5274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431901
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-30 07:53:45 -07:00
Johnni Winther a3953f12c7 [cfe] Include Procedure.isSynthetic in ast-to-text
In preparation for fixing #60490

TEST=existing

Change-Id: Iad3448a30de91e62f0d60bbaa9c425bc4706c799
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421100
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-10 00:59:49 -07:00
Alexander Markov 2ac7957077 [vm, dynamic_modules] Support extensions and extension types in dynamic interface annotator
TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart

Bug: b/404399018
Change-Id: I9b4baafc0c75b62f4fe15cb1191f0e31669a8538
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416340
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-03-19 06:30:48 -07:00
Alexander Markov 9e8e8e5fca [vm,dynamic_modules] Support members which are overridden implictly (transitively) by a dynamic module
Consider the following situation: member M1 is overridden by another
member M2; M2 is overridden in a dynamic module.

Members which can be overridden in a dynamic module (such as M2)
should be specified as 'can-be-overridden' in the dynamic interface.
Members which are overridden implicitly/transitively (such as M1)
are not required to be mentioned in the dynamic interface.
However, when determining possible targets for a call with
interface target M1, compiler should treat it as potentially
overridden in a dynamic module.

This change adds such handling to the VM/AOT. Dynamic interface
annotator now marks members such as M1 with
'dyn-module:can-be-overridden-implicitly' pragma, and
VM/AOT takes both can-be-overridden and can-be-overridden-implicitly
into account.

This change also simplifies handling of implicitly extenable classes
in the VM/AOT - now VM handles both extendable and implicitly-extendable
pragmas (from dynamic interface annotator) instead of recalculating
implicitly extendable classes on its own.

TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart
TEST=dynamic_modules_suite/implicitly_extendable

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

Change-Id: Id4570cc86303f8e45a061d696e9bca0d0b2b4b81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403951
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-01-15 08:13:52 -08:00
Nate Biggs 92ef752810 [dynamic-modules] Add pragma annotating implicitly extendable types.
All supertypes of classes marked as "dyn-module:extendable" are technically also extendable in dynamic modules since subtyping is transitive.

Also skip marking 'final' classes as dynamic module extendable.

Change-Id: I124eae56b78b98aba8712158fda87bbc8e652ed3
Tested: Ran tests for dynamic interface annotator.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403960
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-01-09 14:42:41 -08:00
Alexander Markov 4e0b69fbd9 [vm/aot] Improve dynamic interface annotator
Dynamic interface annotator now automatically annotates classes and
members which are used implicitly:

* Targets of redirecting factories.
* Classes and members used in constants.
* Instance fields of classes used in instance constants or
  having a callable const constructor.
* Everything used in the bodies of extendable mixin declarations and
  mixin classes.
* Possible dispatch targets of instance calls
  (overrides/implementations).

Front-end server now also exposes '--dynamic-interface' option,
similar to gen_kernel tool.

Also, this change includes a couple of minor fixes:
* Typo in ast.dart.
* In the front-end server, additional dill file specified with
  '--import-dill' option is not ignored when '--link-platform' is
  also used.

TEST=pkg/vm/testcases/transformations/dynamic_interface_annotator

Change-Id: I705b64efb1834dec6e0bdc5873025607f3472139
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377761
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-07-30 16:24:51 +00:00
Alexander Markov 17e12879fc Dynamic interface yaml file
TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart

Change-Id: Ib620a98b19067c51d913b499274bfed9aaa576f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370065
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-06-10 16:09:54 +00:00