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

Convert a few reflection FCalls to C# #92512

Merged
merged 5 commits into from
Sep 23, 2023
Merged

Convert a few reflection FCalls to C# #92512

merged 5 commits into from
Sep 23, 2023

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Sep 23, 2023

No description provided.

@ghost
Copy link

ghost commented Sep 23, 2023

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: jkotas
Assignees: jkotas
Labels:

area-System.Reflection

Milestone: -

namespace System
{
//
// This file contains methods on Type that are internal to the framework.
Copy link
Member Author

Choose a reason for hiding this comment

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

This historic split does not make sense anymore.

@Wraith2
Copy link
Contributor

Wraith2 commented Sep 23, 2023

The name IsActualValueType seems strange. What is actual about a type which makes it not possible to use IsValueType and is there a way to make that distinction clearer?

@jkotas
Copy link
Member Author

jkotas commented Sep 23, 2023

IsActualValueType matches the existing IsActualEnum name. The public Type.IsValueType and Type.IsEnum properties have a questionable behavior for generic parameters: They return true for the generic parameters in some cases (#90993 (comment)). It is a behavior one pretty much never wants and it leads to bugs. Also, this quirk makes the API slower.

More self-descripting name would be IsValueTypeWithoutTheGenericParameterQuirk and IsEnumWithoutTheGenericParameterQuirk that is a mouthful. I am going to add better comment.

TypeHandle th = GetNativeTypeHandle();

bool isInterface = !th.IsTypeDesc && th.AsMethodTable()->IsInterface;
GC.KeepAlive(this);
Copy link
Member

@EgorBo EgorBo Sep 23, 2023

Choose a reason for hiding this comment

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

I wonder if JIT is allowed to fold typeof(T).IsInterface without intrinsics at all - the RuntimeType object is on the NonGC heap, GetNativeTypeHandle() is basically MethodTable which is mostly immutable 🙂 so in theory jit could fold ->m_handle->field

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it would be possible in theory. I am not sure whether it would make things simpler overall.

@jkotas jkotas merged commit d45854c into dotnet:main Sep 23, 2023
172 of 174 checks passed
@jkotas jkotas deleted the fcalls branch September 23, 2023 18:09
@ghost ghost locked as resolved and limited conversation to collaborators Oct 23, 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.

3 participants