-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Optimize typeof(T).IsValueType #1157
Conversation
I find the following tests quite weird (matching current behaviour): IsTrue (typeof(int*).IsClass)
IsTrue (typeof(Action<int>).IsClass);
IsFalse(typeof(ValueType).IsValueType);
IsTrue (typeof(ValueType).IsClass);
<removed> |
I believe that's because of the tests have a few copy&paste bugs. |
e3da25f
to
a6f6f13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
I would like somebody from the JIT team to sign-off on this as well before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too. Thanks.
Can now be JITted to a constant on .NET 5, see dotnet/runtime#1157
Fixes https://github.com/dotnet/coreclr/issues/23208
Also, contributes to https://github.com/dotnet/coreclr/issues/2591
Also, dotnet/aspnetcore@a42fff6
Replaces patterns like
typeof(T).IsValueType
orvar.GetType().IsValueType()
with constants (true/false).E.g.:
Current codegen:
New codegen:
This PR also implements
Type.IsPrimitive
andType.IsClass
. Probably can implement more for free, e.g.Type.IsArray
andType.IsEnum
(this one is virtual)