-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Optimize typeof(T).IsValueType #1157
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
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
jkotas
left a comment
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.
AndyAyersMS
left a comment
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).IsValueTypeorvar.GetType().IsValueType()with constants (true/false).E.g.:
Current codegen:
New codegen:
This PR also implements
Type.IsPrimitiveandType.IsClass. Probably can implement more for free, e.g.Type.IsArrayandType.IsEnum(this one is virtual)