Skip to content

Remove 64bit hack in Span#125351

Closed
EgorBo wants to merge 1 commit intodotnet:mainfrom
EgorBo:remove-span-hack
Closed

Remove 64bit hack in Span#125351
EgorBo wants to merge 1 commit intodotnet:mainfrom
EgorBo:remove-span-hack

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Mar 9, 2026

Just to check the diffs again (but I suspect it should be good for arm64)

Copilot AI review requested due to automatic review settings March 9, 2026 22:12
@EgorBo EgorBo changed the title Remove 64bit hack again Remove 64bit hack in Span Mar 9, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-memory
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

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

Removes the TARGET_64BIT-specific bounds-check “fast path” from Span<T> / ReadOnlySpan<T> constructors and Slice(start, length), consolidating on the (uint)-based check used on 32-bit.

Changes:

  • Drop #if TARGET_64BIT bounds-check implementations for array ctors in Span<T> and ReadOnlySpan<T>.
  • Drop #if TARGET_64BIT bounds-check implementations for Slice(int start, int length) and introduce a local curLength before checking.

Reviewed changes

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

File Description
src/libraries/System.Private.CoreLib/src/System/Span.cs Removes 64-bit-specific bounds checks and updates Slice to use a local length before validation.
src/libraries/System.Private.CoreLib/src/System/ReadOnlySpan.cs Removes 64-bit-specific bounds checks and updates Slice to use a local length before validation.

this = default;
return; // returns default
}
#if TARGET_64BIT
Copy link
Member

Choose a reason for hiding this comment

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

We had copied this pattern and referenced it in more than just ROSpan and Span from what I recall. It possibly exists in Tensor and a few other places as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I was just checking diffs for Span specifically since it's where most bounds check come from, and this pattern makes jit life more complicated. Unfortunately, it's still a regression

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

3 participants