Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

This is basically a revert of dotnet/corert#2117 and port of dotnet/coreclr#7895 instead.

Now that RyuJIT implements the optimization for Equals (#122779), we only need GetHashCode and the GetHashCode optimization can be implemented the same way how it's implemented on CoreCLR VM.

Cc @dotnet/ilc-contrib @EgorBo

This is basically a revert of dotnet/corert#2117 and port of dotnet/coreclr#7895 instead.

Now that RyuJIT implements the optimization for `Equals` (dotnet#122779), we only need `GetHashCode` and the `GetHashCode` optimization can be implemented the same way how it's implemented on CoreCLR VM.
@dotnet-policy-service
Copy link
Contributor

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

Copy link
Contributor

Copilot AI left a 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 simplifies the enum GetHashCode optimization by removing custom IL thunk generation and instead leveraging RyuJIT's built-in optimization for Equals (added in PR #122779) and using a simpler approach for GetHashCode that's consistent with CoreCLR VM.

Changes:

  • Removed custom EnumEqualsThunk and EnumGetHashCodeThunk IL stub classes (no longer needed since RyuJIT handles Equals optimization directly)
  • Simplified GetHashCode optimization to replace enum type with its underlying type during constrained call resolution
  • Updated project files to remove references to deleted enum thunk files

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs Added simplified enum GetHashCode optimization that replaces enum type with underlying type
src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs Added matching enum GetHashCode optimization for the IL scanner
src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj Removed references to deleted EnumThunks and EnumMethods files
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs Removed call to GetAllMethodsForEnum since enum thunks are no longer needed
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs Deleted - enum method resolution no longer needed
src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs Deleted - IL thunks for enum Equals/GetHashCode no longer needed
src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs Deleted - sorting support for deleted EnumThunks

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.

Thanks!

@MichalStrehovsky MichalStrehovsky merged commit c143c4f into dotnet:main Jan 12, 2026
106 of 107 checks passed
@MichalStrehovsky MichalStrehovsky deleted the enumequals branch January 12, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants