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

Fix DynamicInvokeMethodThunk hash code collisions #103274

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ private int AcquireHashCode()
}

/// <summary>
/// Compute HashCode. Should only be overridden by a MethodDesc that represents an instantiated method.
/// Compute HashCode. This hashcode is persisted into the image.
/// The algorithm to compute it must be in sync with the one used at runtime.
/// </summary>
protected virtual int ComputeHashCode()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ public override MethodSignature Signature
}
}

protected override int ComputeHashCode()
{
// The hashcode of DynamicInvoke thunks is not persisted. It allows us to override default and
// use a hashcode with good distribution to reduce hash table collisions.
return base.ComputeHashCode() ^ _targetSignature.GetHashCode();
filipnavara marked this conversation as resolved.
Show resolved Hide resolved
}

public override string Name => "DynamicInvoke";

public override string DiagnosticName => "DynamicInvoke";
Expand Down
Loading