Skip to content

Fix ARM64 interpreter asm helpers#120958

Merged
janvorli merged 3 commits intodotnet:mainfrom
janvorli:fix-arm64-interpreter-asm-helpers
Oct 22, 2025
Merged

Fix ARM64 interpreter asm helpers#120958
janvorli merged 3 commits intodotnet:mainfrom
janvorli:fix-arm64-interpreter-asm-helpers

Conversation

@janvorli
Copy link
Member

Running the CoreCLR tests fully interpreted on macOS arm64 has revealed a number of bugs in the assembler helper routines for call stubs.

  • Load_Stack on macOS arm64 can get size that's not a multiple of 8
  • InterpreterStubRetBuff was loading the return buffer address from a slot that is usually not initialized by the x8. And the x8 is actually valid at that place, so we can get the value from it.
  • The Copy_Ref was fixed in another PR recently, but the same bug that was fixed for the copying by 16 bytes was there for copying by 8 and 1 byte.
  • The CallJittedMethodRetXXX functions were restoring the x2 from a SP relative address, but SP was modified after the x2 was stored there. The FP relative offset is stable, so I've switched to that one.

This change fixes all of these.

@janvorli janvorli added this to the 11.0.0 milestone Oct 21, 2025
@janvorli janvorli self-assigned this Oct 21, 2025
Copilot AI review requested due to automatic review settings October 21, 2025 22:57
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
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

This PR fixes multiple bugs in ARM64 interpreter assembly helper routines discovered through CoreCLR testing on macOS arm64. The fixes address incorrect register usage, stack pointer instability, and missing byte-level copy logic.

Key Changes:

  • Fixed InterpreterStubRetBuff to use register x8 directly instead of loading from uninitialized memory
  • Corrected Copy_Ref macro loop logic to handle 8-byte and 1-byte copies properly
  • Added byte-level copy support in Load_Stack for non-8-byte-aligned sizes
  • Fixed CallJittedMethodRetXXX functions to use stable frame pointer instead of modified stack pointer

Reviewed Changes

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

File Description
src/coreclr/vm/arm64/asmhelpers.asm Windows ARM64 assembly fixes for interpreter stubs, copy macros, and jitted method callers
src/coreclr/vm/arm64/asmhelpers.S Unix/macOS ARM64 assembly fixes mirroring the .asm changes plus Load_Stack byte copy support

@janvorli janvorli force-pushed the fix-arm64-interpreter-asm-helpers branch from d8d920b to 3321147 Compare October 21, 2025 23:04
Running the CoreCLR tests fully interpreted on macOS arm64 has revealed
a number of bugs in the assembler helper routines for call stubs.
* Load_Stack on macOS arm64 can get size that's not a multiple of 8
* InterpreterStubRetBuff was loading the return buffer address from a slot
  that is usually not initialized by the x8. And the x8 is actually valid
  at that place, so we can get the value from it.
* The Copy_Ref was fixed in another PR recently, but the same bug that was
  fixed for the copying by 16 bytes was there for copying by 8 and 1 byte.
* The CallJittedMethodRetXXX functions were restoring the x2 from a SP relative
  address, but SP was modified after the x2 was stored there. The FP relative
  offset is stable, so I've switched to that one.

This change fixes all of these.
@janvorli janvorli force-pushed the fix-arm64-interpreter-asm-helpers branch from 610402a to d19785f Compare October 22, 2025 15:48
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.

4 participants