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

Avoid expensive Stelem_Ref covariant checks in Trie #7675

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

benaadams
Copy link
Member

image

Changes

  • Perform own bounds checking and the Unsafe object assignment to avoid expensive Stelem_Ref checks from covariance on object[]
  • Move some inline throws to ThrowHelpers

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • No

Comment on lines +772 to +777
if ((uint)index > (uint)data.Length)
{
// Since we are accessing unsafely we need to do our own
// bounds check to ensure is safe; as the Jit won't help us.
ThrowIndexOutOfRangeException();
}
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could skip the checks in release mode as the index should come from previous logic and be correct (we never had out of range exception on this path)

@benaadams benaadams merged commit 65e0158 into master Oct 29, 2024
75 checks passed
@benaadams benaadams deleted the avoid-expensive-stelem_ref branch October 29, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants