Skip to content

[ddc] Implement new runtime type system #48585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nshahan opened this issue Mar 16, 2022 · 0 comments
Closed

[ddc] Implement new runtime type system #48585

nshahan opened this issue Mar 16, 2022 · 0 comments
Assignees
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. P2 A bug or feature request we're likely to work on web-dev-compiler

Comments

@nshahan
Copy link
Contributor

nshahan commented Mar 16, 2022

New type system is needed to support deferred imports and stateful hot reload.

Requirements:

  • Type representation separate from class representation (types can be loaded separately from the class code)
  • Modular compilation and loading (types can be added as needed when module loads)
  • Support existing weak null safety with null safety warnings/errors modes.
  • Update dwds to use new type system logic (before flipping the flag in ddc to enable new type system)
    Update dwds for new DDC type system webdev#1949
@nshahan nshahan added web-dev-compiler area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. labels Mar 16, 2022
@nshahan nshahan self-assigned this Mar 16, 2022
copybara-service bot pushed a commit that referenced this issue May 5, 2022
Change-Id: Idc8e6a13f6b253b4b1030fe0d0b9a272cebbd079
Issue: #48585
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243843
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
copybara-service bot pushed a commit that referenced this issue Oct 28, 2022
- Support interface types without generic parameters in type tests.
- Add '|' symbol to recipes to separate the library identifier from
  the type. This is used in the modular setting where types are not
  guaranteed to have a unique name.
- Add a runtime method to strip library identifiers when printing
  type names.
- Add a runtime method to retrieve original Dart type name from
  constructors.

Issue: #48585
Change-Id: Ib2a69c29177ebb7c582bff3246ee985666cd5919
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243362
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mayank Patke <[email protected]>
Reviewed-by: Anna Gringauze <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
Reviewed-by: Sigmund Cherem <[email protected]>
copybara-service bot pushed a commit that referenced this issue Nov 11, 2022
- Introduce type environments in the compiler used for evaluating type
  parameters from generic classes and generic function types.

Issue: #48585
Change-Id: Ib5641eb666527acc3b7f13a4a00dea34e0122b52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266540
Reviewed-by: Mark Zhou <[email protected]>
copybara-service bot pushed a commit that referenced this issue Nov 11, 2022
Issue: #48585
Change-Id: I0a338e672467b8fec5158f5959da01fa100f3ae8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266541
Reviewed-by: Anna Gringauze <[email protected]>
copybara-service bot pushed a commit that referenced this issue Nov 18, 2022
Followup for https://dart-review.git.corp.google.com/c/sdk/+/266540.

Create a public API to better document the interaction between 
`TypeRecipeGenerator` and `_TypeRecipeVisitor`.

Issue: #48585
Change-Id: Ideeea0e6fa313e77a40e8bc04987c5bf1ed380ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269482
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Anna Gringauze <[email protected]>
@nshahan nshahan added the P2 A bug or feature request we're likely to work on label Nov 18, 2022
copybara-service bot pushed a commit that referenced this issue Dec 3, 2022
Generate type hierarchy rules for all interface types used in a
module. These rules are utilized by the `isSubtype()` to determine
interface subtypes.

Issue: #48585
Change-Id: I63f64075d4947f234eca5e730ad15588e60b9e1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266542
Reviewed-by: Anna Gringauze <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Dec 8, 2022
In the new runtime type system when running with weak null safety,
perform type tests multiple times to produce optional warnings or
errors when a test passes but would fail in sound null safety.
This is the same technique DDC uses with the current type system.

Issue: #48585
Change-Id: Ic1514987a6f4ffeb127a0d2be5ec15b606016212
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266543
Reviewed-by: Mark Zhou <[email protected]>
Reviewed-by: Anna Gringauze <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Dec 10, 2022
Use the "extension type" class as the interceptor object for the
dart:_rti library. This applies to the new type system for values
that are represented as a native JavaScript type. For example:
Number, bool, String, Array, etc.

Issue: #48585
Change-Id: Ie6214aa897d3ae8abb4f9619cd2be984eeb9c4ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266544
Reviewed-by: Mark Zhou <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue May 16, 2023
Adds the ability to call functions/methods/tearoffs with
generic type arguments when running with the new type system.

Issue: #48585
Change-Id: I28b8cdad56d614a6b9904995634c0cef67d88ebc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296960
Reviewed-by: Mayank Patke <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Anna Gringauze <[email protected]>
copybara-service bot pushed a commit that referenced this issue May 26, 2023
Ensures all interface types in a module have rules listed in
the universe for use in type tests.

Issue: #48585
Change-Id: I08ef4da27cb21d3560fbfe54d33355b853848d5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304826
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 2, 2023
Issue: #48585
Change-Id: I7a5d9c412696ea038af8320734790456d4e2880a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306914
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 5, 2023
- Use the correct name/symbol when looking up the default type 
  arguments.
- Copy default type arguments signatures when applying a mixin.

Issue: #48585
Change-Id: Ided28aeac931e3d9ac71759db85d89bf57456cb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306915
Reviewed-by: Mark Zhou <[email protected]>
Reviewed-by: Anna Gringauze <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 5, 2023
The CFE was reporting that instance constants in legacy libraries
have a legacy type. This isn't supported by the runtime library
so we need to force the nullability of the outermost interface type
to be non-nullable.

Issue: #48585
Change-Id: I43d59072bb849a5b63a029c27db9427f974a035c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307508
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 8, 2023
Previous search was missing the type arguments that appear on mixins.

Issue: #48585
Change-Id: I52e017d3d68d423e5aeb5481e222f196ecf3c186
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307963
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 8, 2023
Encodes the necessary type rules and adds type identifier
tags to support the legacy JavaScript interop behavior.

Issue: #48585
Change-Id: I933db1c9899711898fb829821f3e051043f33be2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305845
Reviewed-by: Srujan Gaddam <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mayank Patke <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 9, 2023
Issue: #48585
Change-Id: Ie0a69406686512426e30fdc0b7334263d3e596d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306135
Reviewed-by: Srujan Gaddam <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 16, 2023
Type rules for classes appearing in the type hierarchy above types
in the current module were missing. Specifically types that appear
in instantiations of supertypes.

Issue: #48585
Change-Id: I11f2af1435f18ab7567766c865d9898d60b9272b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309827
Reviewed-by: Sigmund Cherem <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jul 6, 2023
Inline calls to the extract function directly with the type arguments
inserted as extractions from the instance.

Issue: #48585
Change-Id: I6b791c59478c2e609df30163835e3fd0863a2d94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307514
Reviewed-by: Mark Zhou <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jul 6, 2023
The types implemented transitively through mixins were missing from
the tags we manually attach. 

Issue: #48585
Change-Id: I7fa00fd79963914cd25c2f87f52d8acc76c9c359
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312202
Reviewed-by: Mark Zhou <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jul 6, 2023
Issue: #48585
Change-Id: I119c0d649461ddfd3879f75ef232ee8010ebf787
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312203
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jul 6, 2023
- They should match the calling convention and use the "dartx" symbol.
- Skip adding signatures for static methods since they can't be
  called dynamically anyway.

Issue: #48585
Issue: #52867
Change-Id: If5a76f52163b2267129880dbfe8d145a3fd93408
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312204
Reviewed-by: Mark Zhou <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Aug 29, 2023
- Provides fast access for types that are used multiple times in the
  same module.
- Enable the existing type table cache when running with new types.
- Add a similar cache for instantiated generic classes. This cache
  is used in the current type system as well to help keep the
  difference between types and classes more clear.

Issue: #48585
Change-Id: I32103cf0c0bcf9b9771e789c0d04e63a4365a066
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321320
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
copybara-service bot pushed a commit that referenced this issue Aug 30, 2023
This reverts commit a9fc9ff.

Reason for revert: Breaks some expression evaluation tests in DWDS

Original change's description:
> [ddc] Add module local caches for new types
>
> - Provides fast access for types that are used multiple times in the
>   same module.
> - Enable the existing type table cache when running with new types.
> - Add a similar cache for instantiated generic classes. This cache
>   is used in the current type system as well to help keep the
>   difference between types and classes more clear.
>
> Issue: #48585
> Change-Id: I32103cf0c0bcf9b9771e789c0d04e63a4365a066
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321320
> Commit-Queue: Nicholas Shahan <[email protected]>
> Reviewed-by: Mark Zhou <[email protected]>

Issue: #48585
Change-Id: Ied36cd006249cce32426b8d0b52d3443fdbce59a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323500
Auto-Submit: Nicholas Shahan <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Commit-Queue: Rubber Stamper <[email protected]>
copybara-service bot pushed a commit that referenced this issue Sep 1, 2023
This is a reland of commit a9fc9ff

Additional changes:

- Set incremental mode on generic class table
  - fixes expression evaluation failure discovered by dwds tests
    (generic class table was not always defined in compiled expression)
- Allow expression evaluation while the app is running in e2e suite
- Add regression tests for the expression evaluation failure.

Original change's description:
> [ddc] Add module local caches for new types
>
> - Provides fast access for types that are used multiple times in the
>   same module.
> - Enable the existing type table cache when running with new types.
> - Add a similar cache for instantiated generic classes. This cache
>   is used in the current type system as well to help keep the
>   difference between types and classes more clear.
>
> Issue: #48585
> Change-Id: I32103cf0c0bcf9b9771e789c0d04e63a4365a066
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321320
> Commit-Queue: Nicholas Shahan <[email protected]>
> Reviewed-by: Mark Zhou <[email protected]>

Change-Id: I9c31d1d07d7f9bb15645ac9aa6e91d35e8906e85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323501
Reviewed-by: Mark Zhou <[email protected]>
Commit-Queue: Anna Gringauze <[email protected]>
Reviewed-by: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Sep 8, 2023
Optimize repetitive calls to isSubtype with a caches to store pairwise
results.

There are currently two caches for sound and unsound results but in the
future that can be combined into a single cache once the library is
aware of error reporting. That single cache could stores "pass", "fail", 
or "fails when sound mode but passes in unsound null safety".

Issue: #48585
Change-Id: I49e5794703fd58f1b2bba50e426e25146800fbb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323707
Reviewed-by: Mayank Patke <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Sep 15, 2023
- Avoids the need to set the value in the JSArray factories.
- Delays the construction of the rti value until it is actually needed.

Issue: #48585
Change-Id: Iecc28533453742eaeedc0cbc48053b7660e3eee3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325450
Reviewed-by: Sigmund Cherem <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Sep 30, 2023
Adds simple method inlining for select patterns only in the dart:_rti
library as an optimization. This helps avoid chains of costly
accesses method calls that in the end simply perform a single
operation and return the result.

For example and snipet from the compiled SDK before:

```
if (_rti._isString(object)) {...}
```
and after:

```
if(typeof object == "string") {...}
```

Issue: #48585
Change-Id: I90596294d35a8fd75d74014c6a12f6e8c726cfcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324571
Reviewed-by: Sigmund Cherem <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
copybara-service bot pushed a commit that referenced this issue Nov 6, 2023
Ensures that `toString()` of types that contain embedded js types 
will appear the same in the old and new runtime type systems.

Issue: #48585
Change-Id: I71ec0e13943281e745bcf05e10aa36d093cbc0c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334003
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Srujan Gaddam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. P2 A bug or feature request we're likely to work on web-dev-compiler
Projects
None yet
Development

No branches or pull requests

1 participant