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

On 64 bit platforms, "stelem.ref" and "ldelema" ignore the high bits of a native int index #71571

Merged
merged 6 commits into from
Jul 6, 2022

Conversation

davidwrighton
Copy link
Member

Fixes #52817

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

Do we need to update Mono too?

@jkotas
Copy link
Member

jkotas commented Jul 2, 2022

We had the same problem for NewArray helper some time ago and we fixed it there by changing the NewArray helper to take native int. Would it be better to do the same thing here to avoid the code duplication?

For R2R, we have introduced a new compat band in .NET 7, so it is ok to make JIT helper breaking changes without doing anything special about it.

@@ -830,7 +830,7 @@ private static unsafe void StelemRef_Helper(ref object element, MethodTable* ele
}

ref object rawData = ref Unsafe.As<byte, object>(ref Unsafe.As<RawArrayData>(array).Data);
return ref Unsafe.Add(ref rawData, index);
return ref Unsafe.Add(ref rawData, (int)index);
Copy link
Member

Choose a reason for hiding this comment

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

There is Unsafe.Add overload that takes IntPtr. It should not be necessary to cast the index to int here. It just going to add an extra unnecessary instruction.

Copy link
Member

Choose a reason for hiding this comment

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

If the problem is that the "minimal runtime" does not compile without the cast, just add the necessary method to the minimal Unsafe used by the minimal runtime.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM otherwise. Thank you!

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
@davidwrighton davidwrighton merged commit 0e30a6f into dotnet:main Jul 6, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 6, 2022
@davidwrighton davidwrighton deleted the fix_52817 branch April 13, 2023 18:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On x64 platform, "stelem.ref" ignores high bits of "native int" index
4 participants