[release/7.0] [NativeAOT] Save full ARM64 SIMD arg registers in UniversalTransition #74958
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #74888 to release/7.0
/cc @VSadov
Customer Impact
UniversalTransition stubs call managed helpers to figure what target method needs to be called. To ensure that the helper does not mess up the arguments which will be passed to the target method, we store the content of argument registers on the stack and restore after calling the helper.
The issue was that we were only storing the lower floating-pont halves of vector registers.
Even though unlikely, there are several ways how the helper could use vector registers indirectly. Most notably, a GC may happen (since it is managed code) and there is a possibility that some native functions used by GC, like
memcopycould be vectorized now or in the future and change the value of vector registers.To ensure that there is no silent data corruption, we need to save/restore complete SIMD registers, not just their lower halves.
Testing
Risk
Low. We do the same thing, we just store/restore q0-q7 128bit registers instead of d0-d7, which are the lower 64bit parts.