-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fixing SpanHelpers.LastIndexOfAnyValueType to no longer create out of bounds GC refs #75857
Conversation
Tagging subscribers to this area: @dotnet/area-system-memory Issue DetailsThis resolves #75792
|
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.
@tannergooding big thanks for your help! PTAL at my comments, I think I've found a bug
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs
Outdated
Show resolved
Hide resolved
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.
LGTM!
@stephentoub, would appreciate a secondary sign-off from you before merging. Great to have a second pair of eyes since we're backporting for .NET 7 |
continue; | ||
} | ||
|
||
return ComputeLastIndex(ref searchSpace, ref currentSearchSpace, equals); | ||
return ComputeLastIndex(offset, equals); |
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.
It doesn't affect this PR, but I wonder why it's written like this rather than:
if (equals != Vector128<TValue>.Zero)
{
return ComputeLastIndex(offset, equals);
}
Is this just style, or we expect the not found case to be the most common and want the branch predictor to default to that?
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.
we expect the not found case to be the most common and want the branch predictor to default to that
That was my assumption when I was implementing it.
/backport to release/7.0-rc2 |
Started backporting to release/7.0-rc2: https://github.com/dotnet/runtime/actions/runs/3089699377 |
This resolves #75792