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

Make casting helpers look more like in CoreCLR #86029

Merged
merged 4 commits into from
May 11, 2023

Conversation

MichalStrehovsky
Copy link
Member

Speeds up casting to interfaces by about 50%. Speeds up casting to classes by about 20%.

There are small differences compared to CoreCLR:

  • NativeAOT runtime considers interfaces implementable by arrays to be variant. We don't need to special case casting arrays to non-variant (in IL sense) interfaces because those naturally take the variant paths.
  • The base type field on arrays holds the array element type so we need to check for the array case before starting to chase the base hierarchy.

Otherwise the top level helpers now look mostly the same as the CoreCLR ones.

Cc @dotnet/ilc-contrib

Speeds up casting to interfaces by about 50%. Speeds up casting to classes by about 20%.

There are small differences compared to CoreCLR:
* NativeAOT runtime considers interfaces implementable by arrays to be variant. We don't need to special case casting arrays to non-variant (in IL sense) interfaces because those naturally take the variant paths.
* The base type field on arrays holds the array element type so we need to check for the array case before starting to chase the base hierarchy.

Otherwise the top level helpers now look mostly the same as the CoreCLR ones.
@ghost
Copy link

ghost commented May 10, 2023

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

Issue Details

Speeds up casting to interfaces by about 50%. Speeds up casting to classes by about 20%.

There are small differences compared to CoreCLR:

  • NativeAOT runtime considers interfaces implementable by arrays to be variant. We don't need to special case casting arrays to non-variant (in IL sense) interfaces because those naturally take the variant paths.
  • The base type field on arrays holds the array element type so we need to check for the array case before starting to chase the base hierarchy.

Otherwise the top level helpers now look mostly the same as the CoreCLR ones.

Cc @dotnet/ilc-contrib

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

return null;
}
[RuntimeExport("RhTypeCast_CheckCastClassSpecial")]
private static unsafe object CheckCastClassSpecial(MethodTable* pTargetType, object obj)
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to unify the names with CoreCLR impl (Check vs. Chk) so that the implementations are easy to match (and eventually share). It can be separate rename-only PR.

@VSadov
Copy link
Member

VSadov commented May 10, 2023

I think this PR will resolve #84464

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks!

@jkotas jkotas merged commit d4175a8 into dotnet:main May 11, 2023
@MichalStrehovsky MichalStrehovsky deleted the cast branch May 12, 2023 01:37
@ghost ghost locked as resolved and limited conversation to collaborators Jun 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants