Skip to content

Use fast hashing helpers for types with trailing padding #118986

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichalStrehovsky
Copy link
Member

This is same as #111620 but with an extra thing: enable unconditional method body folding on __GetFieldHelper overrides (both the simplified ones that just return a negative number and normal ones).

Fixes #111542

This is same as dotnet#111620 but with an extra thing: enable unconditional method body folding on `__GetFieldHelper` overrides (both the simplified ones that just return a negative number and normal ones).
@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 10:34
Copy link
Contributor

@Copilot 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 improves performance of value type hashing and equality comparisons by enabling fast hashing helpers for types with trailing padding. The changes allow value types to use memory-based comparisons up to a specified offset rather than requiring field-by-field comparisons when there's trailing padding.

Key changes:

  • Modified the compiler to enable method body folding for __GetFieldHelper overrides unconditionally
  • Enhanced the fast path logic to handle value types with trailing padding by comparing memory up to the last field's end offset
  • Updated the API semantics to use negative return values to indicate the byte offset for memory comparison

Reviewed Changes

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

File Description
ObjectDataInterner.cs Enables unconditional method body folding for ValueTypeGetFieldHelperMethodOverride methods
ValueTypeGetFieldHelperMethodOverride.cs Adds fast path for value types that can use memory comparison up to a specific offset
ComparerIntrinsics.cs Extends the analysis to support partial memory comparison up to the last field's end offset
ValueType.cs Updates the runtime implementation to handle negative return values as byte offsets for memory comparison

Copy link
Contributor

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

@MichalStrehovsky MichalStrehovsky marked this pull request as draft August 22, 2025 10:36
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.

[NativeAOT] __GetFieldHelper emitted for simple contiguous struct
1 participant