-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Specialize __GetFieldHelper per generic instantiation #117253
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
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
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.
Pull Request Overview
This PR refactors the value-type field helper stub to support per-instantiation specialization and avoids unnecessary MethodTable creation for generic parameters. Key changes include:
- Switched the
ValueTypeMethodHashtablefromDefTypetoMetadataTypefor broader type keying. - Updated
ValueTypeGetFieldHelperMethodOverrideto inherit fromSpecializableILStubMethodand split IL emission into open and specialized paths. - Introduced common
EmitILCommonto share most of the emitter logic.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs | Changed hashtable key and method signatures from DefType to MetadataType. |
| src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs | Converted stub to SpecializableILStubMethod, added overload for specialized IL emission, and centralized IL generation in EmitILCommon. |
Comments suppressed due to low confidence (1)
src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs:65
- Add unit tests for
ValueTypeGetFieldHelperMethodOverridecovering both the open and specialized IL emission paths, including scenarios with signature-variable fields and inline arrays to ensure correctness after these refactorings.
public override MethodIL EmitIL(MethodDesc specializedMethod)
src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs
Outdated
Show resolved
Hide resolved
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Thanks
We have an optimization that tries to avoid bringing in constructed
MethodTablefor struct fields that are reference types. However, if the type of the field is T on a generic type, we had to be conservative because we didn't know if it was a valuetype or not. UseSpecializableILStubMethodinstead ofILStubMethodso we know.Cc @dotnet/ilc-contrib