Skip to content

Use built-in HashCode in ILC instead of rolling our own - #136712

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
agocke:use-stock-hash
Oct 31, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
agocke:use-stock-hash

Conversation

@agocke

@agocke agocke commented Oct 30, 2026

Copy link
Copy Markdown
Member

Replaces custom hashing algorithms in MetadataRecord with the default framework hash (xxhash32).

Replaces custom hashing algorithms in MetadataRecord with the default framework hash (xxhash32).
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the metadata hashing update.

No open issues 🎉

What changed in this PR

Replaces ILC metadata records’ custom hash-combining logic with the framework’s System.HashCode, updating both the generator and its generated output.

Changes:

  • Uses HashCode.Add for record-specific seeds, member values, and collection elements.
  • Caches the result of ToHashCode() while retaining existing member-selection and recursion-guard logic.
File Description
src/​coreclr/​tools/​Common/​Internal/​Metadata/​NativeFormat/​Generator/​WriterGen.cs Generates HashCode-based implementations instead of custom bitwise hashing.
src/​coreclr/​tools/​aot/​ILCompiler.MetadataTransform/​Internal/​Metadata/​NativeFormat/​Writer/​NativeFormatWriterGen.cs Updates generated metadata record implementations to match the generator.

Review effort: Balanced

@MichalStrehovsky
MichalStrehovsky merged commit 0f7855c into dotnet:main Oct 31, 2026
105 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Oct 31, 2026
@agocke
agocke deleted the use-stock-hash branch October 31, 2026 20:27
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants