Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

Use results of whole program analysis to drive devirtualization - #5050

Merged
MichalStrehovsky merged 3 commits into
dotnet:masterfrom
MichalStrehovsky:devirtMgr
Dec 8, 2017
Merged

Use results of whole program analysis to drive devirtualization#5050
MichalStrehovsky merged 3 commits into
dotnet:masterfrom
MichalStrehovsky:devirtMgr

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Split into 3 commits for better reviewability.

Fixes #5019. Besides fixing that, I also made this do "sealing" of types that we see never have a derived type allocated (because it was easy). This results in more than double the number of potential successful devirtualizations (for the web app template, we see an increase from 800 to 1800 cases where resolveVirtualMethod returns a method that is reported as final).

@benaadams

Copy link
Copy Markdown
Member

Could it also switch interface params to concrete types where there is a single caller type? Though may not be worth it.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

Could it also switch interface params to concrete types where there is a single caller type? Though may not be worth it.

Yes, I have that in my backlog already. Might be particularly useful for things like dependency injection where interfaces are basically only needed because of testability. It will need a RyuJIT change though.

@davidwrighton davidwrighton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely convinced the jit interface change is right, but the rest looks good. Since we don't have the same implementation concerns on CoreRT I'm ok with checking in what we have here, but be aware its not completely general purpose.


// method or class might have the final bit
if (method.IsFinal || (owningMetadataType != null && owningMetadataType.IsSealed))
if (_compilation.IsEffectivelySealed(method))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this is right. This will effectively result in methods being reported as sealed in the scanner phase, but not in the compiler phase. At least in the nutc world that could lead to failures.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is mitigated by the fact that both behaviors (whether to use the sealing information to devirtualize in the scanner already, and whether to report something that was sealed in the scanner as unsealed to the compiler) is fully wrapped within the scanner. The scanner as we have it here doesn't use the sealing information for anything.

If we were to reuse the scanner for different codegens with different scanning policies, this would be a place we make abstract/virtual. The scanner is not trying to be general purpose for all codegens; we'll have places we need to tweak.

@MichalStrehovsky
MichalStrehovsky merged commit b206827 into dotnet:master Dec 8, 2017
@MichalStrehovsky
MichalStrehovsky deleted the devirtMgr branch December 8, 2017 09:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use scanner analysis to aid devirtualization

3 participants