Skip to content
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

Dynamic static generic virtual method leftover work #80602

Open
MichalStrehovsky opened this issue Jan 13, 2023 · 1 comment
Open

Dynamic static generic virtual method leftover work #80602

MichalStrehovsky opened this issue Jan 13, 2023 · 1 comment

Comments

@MichalStrehovsky
Copy link
Member

See the commented out tests in #80601.

@ghost
Copy link

ghost commented Jan 13, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

See the commented out tests in #80601.

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: 8.0.0

MichalStrehovsky added a commit to MichalStrehovsky/runtime that referenced this issue Feb 16, 2023
I'm looking at generic virtual method again because of dotnet#80602.

The analysis of generic virtual methods within the compiler is an N * M algorithm where N is the number of unique generic virtual method instantiations called and M is the number of types that implement generic virtual methods.

We use dynamic dependencies within the dependency analysis engine to model this relationship.

It is important to try to limit the N and M. Looking at things, I realized the N we're currently operating on is bigger than it needs to be:

```csharp
Foo f = new Bar();
f.Blah<int>();
f = new Baz();
f.Blah<double>();

class Foo { public virtual void Blah<T>() { } }
class Bar : Foo { public override void Blah<T> { } }
class Baz : Foo { public override void Blah<T> { } }
```

Previously, the analysis would see M = 3 and N = 6 because we would track each of the overrides as something that needs to be considered for each M. This changes the analysis to only look at the definition of the slot, i.e. N = 2 (one for int, other for double).

The result of the analysis will still be same, it will just take less time. The new GenericVirtualMethodImpl node responds false to HasDynamicDependencies and doesn't participate in expensive activities.
MichalStrehovsky added a commit that referenced this issue Feb 27, 2023
* Split generic virtual method slot use and impl tracking

I'm looking at generic virtual method again because of #80602.

The analysis of generic virtual methods within the compiler is an N * M algorithm where N is the number of unique generic virtual method instantiations called and M is the number of types that implement generic virtual methods.

We use dynamic dependencies within the dependency analysis engine to model this relationship.

It is important to try to limit the N and M. Looking at things, I realized the N we're currently operating on is bigger than it needs to be:

```csharp
Foo f = new Bar();
f.Blah<int>();
f = new Baz();
f.Blah<double>();

class Foo { public virtual void Blah<T>() { } }
class Bar : Foo { public override void Blah<T> { } }
class Baz : Foo { public override void Blah<T> { } }
```

Previously, the analysis would see M = 3 and N = 6 because we would track each of the overrides as something that needs to be considered for each M. This changes the analysis to only look at the definition of the slot, i.e. N = 2 (one for int, other for double).

The result of the analysis will still be same, it will just take less time. The new GenericVirtualMethodImpl node responds false to HasDynamicDependencies and doesn't participate in expensive activities.
@agocke agocke added this to AppModel Mar 6, 2023
@MichalStrehovsky MichalStrehovsky modified the milestones: 8.0.0, 9.0.0 Jul 20, 2023
@MichalStrehovsky MichalStrehovsky modified the milestones: 9.0.0, Future Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant