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

[NativeAOT][8.0] Make casting logic closer to CoreCLR #90234

Merged
merged 5 commits into from
Aug 9, 2023

Conversation

VSadov
Copy link
Member

@VSadov VSadov commented Aug 9, 2023

Reduced version of #89548 (no JIT changes)

Fixes: #84464

The actual changes are not as big here as might seem. For the most part this is a refactoring of existing code to have a shape closer to CoreCLR cast helpers, so that similar patterns could be used - in a few places where that has not been done already in earlier changes.
For example cases like CheckCastAny - could start with a cache lookup, since uncached code path can be complex and thus relatively slow. (also addresses some old TODOs in this area)

@ghost
Copy link

ghost commented Aug 9, 2023

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

Issue Details

Reduced version of #89548 (no JIT changes)

Fixes: #84464

The actual changes are not as big here as might seem. For the most part this is a refactoring of existing code to have a shape closer to CoreCLR cast helpers, so that similar patterns could be used - in a few places where that has not been done already in earlier changes.
For example cases like CheckCastAny - could start with a cache lookup, since uncached code path can be complex and thus relatively slow. (also addresses some old TODOs in this area)

Author: VSadov
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@VSadov
Copy link
Member Author

VSadov commented Aug 9, 2023

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -268,6 +274,17 @@ private static void LoadInvalidType()
Console.WriteLine($"-- {typeof(ValueTypeWithInstanceMethod).Name}");
}

private static void TestCastsOptimizations()
Copy link
Member

Choose a reason for hiding this comment

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

I thought that this test needs a fix in the JIT and JIT/EE interface to pass.

Copy link
Member Author

@VSadov VSadov Aug 9, 2023

Choose a reason for hiding this comment

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

If we do not optimize isinst that classified as ANY, the test should pass.

The troubles start when array casts are classified as ANY, then we need to optimize ANY form of isinst , but ANY includes other subtle cases (equivalence, nullable) that are not optimizable and need to be sorted out.

Copy link
Member Author

@VSadov VSadov Aug 9, 2023

Choose a reason for hiding this comment

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

Note that array and ANY casts can end up calling the same helpers (helpers for ANY cases can handle array casts), but the initial classification is meaningful to the JIT when deciding what is optimizable.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I see.

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.

Thank you!

@VSadov
Copy link
Member Author

VSadov commented Aug 9, 2023

Thanks!!

@VSadov VSadov merged commit 41bc935 into dotnet:main Aug 9, 2023
156 of 180 checks passed
@VSadov VSadov deleted the casts02 branch August 9, 2023 21:28
@ghost ghost locked as resolved and limited conversation to collaborators Sep 9, 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.

[NativeAOT] Possible perf improvements in casting
2 participants