Skip to content

Conversation

@davidwrighton
Copy link
Member

Fixes #52817

@ghost ghost added the area-VM-coreclr label Jul 2, 2022
@ghost ghost assigned davidwrighton Jul 2, 2022
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.


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ý <[email protected]>
@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