Repository navigation
Conversation
|
Just when I thought it was finished, turns out the same issue exists on macOS+arm64 (or on more arm64 platforms as well?)... That will be fun without access to the native hardware, but I suppose it's gonna be the same principle but easier since those platforms do support inline asm. |
…ndows and ARM64 On win64, xmm6-xmm15 are preserved registers, but the prologues and epilogues of JITted code don't handle these. The issue occurs when calling into the JIT code again via an internal handler (like call_user_func). Therefore, we want to save/restore xmm registers upon entering/leaving execute_ex. Since MSVC x64 does not support inline assembly, we create an assembly wrapper around the real execute_ex function. The alternative is to always save/restore these xmm registers into the fixed call frame, but this causes unnecessary overhead. The same issue occurs for ARM64 platforms for floating point register 8 to 15. However, there we can use inline asm to fix this.
| #if defined(__GNUC__) && defined(__aarch64__) | ||
| __asm__ __volatile__ (""::: "v8","v9","v10","v11","v12","v13","v14","v15"); | ||
| #endif | ||
|
|
There was a problem hiding this comment.
I think we do. The reason we don't save registers in HYBRID VM JIT'ed code is that execute_ex does it in HYBRID_JIT_GUARD() before calling handlers, but this doesn't save these registers.
There was a problem hiding this comment.
Yes. If I remember correctly, the test also originally failed on circleci which is Linux+arm64+gcc so should use hybrid VM.
arnaud-lb
left a comment
There was a problem hiding this comment.
This looks good to me. It also fixes the test for me on both Windows/x86_64 and Linux/aarch64.
On win64, xmm6-xmm15 are preserved registers, but the prologues and epilogues of JITted code don't handle these. The issue occurs when calling into the JIT code again via an internal handler (like call_user_func). Therefore, we want to save/restore xmm registers upon entering/leaving execute_ex. Since MSVC x64 does not support inline assembly, we create an assembly wrapper around the real execute_ex function.
The alternative is to always save/restore these xmm registers into the fixed call frame, but this causes unnecessary overhead.
The same issue occurs for ARM64 platforms for floating point register 8 to 15. However, there we can use inline asm to fix this.