Skip to content

[mono][jit] Don't truncate the high bits when ldelema index is nint#88986

Merged
BrzVlad merged 5 commits into
dotnet:mainfrom
BrzVlad:fix-nindex-out-of-range
Sep 8, 2023
Merged

[mono][jit] Don't truncate the high bits when ldelema index is nint#88986
BrzVlad merged 5 commits into
dotnet:mainfrom
BrzVlad:fix-nindex-out-of-range

Conversation

@BrzVlad

@BrzVlad BrzVlad commented Jul 17, 2023

Copy link
Copy Markdown
Member

JIT only fix from #73799. Interp fix might be more invasive.

@BrzVlad

BrzVlad commented Jul 19, 2023

Copy link
Copy Markdown
Member Author

A little bit of complication because, according to comments, emitting the SEXT_I4 normally would interfere with bounds check removal. @vargaz Please take a look

Previous code was assuming index is i4. Remove MONO_ARCH_EMIT_BOUNDS_CHECK on amd64 since it was doing a I4 comparison, while the index reg is i8. Use MONO_EMIT_DEFAULT_BOUNDS_CHECK instead also on amd64.

On llvm we might not be able to insert the sign extending because it apparently interferes with abcrem optimization. We therefore split OP_BOUNDS_CHECK into two separate opcodes, so, after abcrem, we know whether we have to insert the sext or not.
Fix passing of i4 to wrapper accepting native int. The wrapper no longer does the sign extend in order to not lose high bits of native int.
@BrzVlad
BrzVlad force-pushed the fix-nindex-out-of-range branch from f92e772 to caf60c0 Compare August 22, 2023 14:36
@BrzVlad

BrzVlad commented Sep 6, 2023

Copy link
Copy Markdown
Member Author

@vargaz Could I have a review on this ?

Comment thread src/mono/mono/mini/method-to-ir.c
Comment thread src/mono/mono/mini/mini-ops.h Outdated
@BrzVlad
BrzVlad merged commit 840e8fa into dotnet:main Sep 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 8, 2023
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.

2 participants