-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mono]: Add support for callee saved XMM registers on Windows x64. #97326
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -1782,6 +1782,23 @@ mono_arch_allocate_vars (MonoCompile *cfg) | |||
if (AMD64_IS_CALLEE_SAVED_REG (i) && (cfg->arch.saved_iregs & (1 << i))) { | ||||
offset += sizeof (target_mgreg_t); | ||||
} | ||||
|
||||
#if defined(AMD64_CALLEE_SAVED_XREGS) | ||||
if (cfg->method->save_lmf) { | ||||
#if defined(MONO_HAVE_SIMD_REG) | ||||
int xreg_size = sizeof (MonoContextSimdReg); | ||||
#else | ||||
int xreg_size = sizeof (double); | ||||
#endif | ||||
offset = ALIGN_TO (offset, xreg_size); | ||||
for (guint i = 0; i < AMD64_XMM_NREG; ++i) { | ||||
if (AMD64_IS_CALLEE_SAVED_XREG (i)) { | ||||
offset += xreg_size; | ||||
} | ||||
} | ||||
} | ||||
#endif | ||||
|
||||
if (!cfg->arch.omit_fp) | ||||
cfg->arch.reg_save_area_offset = -offset; | ||||
|
||||
|
@@ -8046,6 +8063,38 @@ MONO_RESTORE_WARNING | |||
} | ||||
} | ||||
|
||||
#if defined(AMD64_CALLEE_SAVED_XREGS) | ||||
if (method->save_lmf) { | ||||
#if defined(MONO_HAVE_SIMD_REG) | ||||
int xreg_size = sizeof (MonoContextSimdReg); | ||||
#else | ||||
int xreg_size = sizeof (double); | ||||
#endif | ||||
save_area_offset = ALIGN_TO (save_area_offset, xreg_size); | ||||
|
||||
for (guint16 i = 0; i < AMD64_XMM_NREG; ++i) { | ||||
if (AMD64_IS_CALLEE_SAVED_XREG (i)) { | ||||
#if defined(MONO_HAVE_SIMD_REG) | ||||
amd64_movdqu_membase_reg (code, cfg->frame_reg, save_area_offset, i); | ||||
#else | ||||
amd64_movsd_membase_reg (code, cfg->frame_reg, save_area_offset, i); | ||||
#endif | ||||
if (cfg->arch.omit_fp) { | ||||
mono_emit_unwind_op_offset (cfg, code, AMD64_NREG + i, - (cfa_offset - save_area_offset)); | ||||
/* These are handled automatically by the stack marking code */ | ||||
mini_gc_set_slot_type_from_cfa (cfg, - (cfa_offset - save_area_offset), SLOT_NOREF); | ||||
} else { | ||||
mono_emit_unwind_op_offset (cfg, code, AMD64_NREG + i, - (-save_area_offset + (2 * 8))); | ||||
// FIXME: GC | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That code is mainly a copy/paste, so kept the original comments as well, I guess that fixme have been in there for many many years, so no follow up have been planned, not even sure its relevant anymore, but if we drop it here, we should also drop it from the source where it got copied, runtime/src/mono/mono/mini/mini-amd64.c Line 8041 in c105e7d
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect it is some artifact from the times we had precise stack scanning. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If stack scanning is always conservative (is that the case?) then there is nothing needed here for GC. |
||||
} | ||||
|
||||
save_area_offset += xreg_size; | ||||
async_exc_point (code); | ||||
} | ||||
} | ||||
} | ||||
#endif | ||||
|
||||
/* store runtime generic context */ | ||||
if (cfg->rgctx_var) { | ||||
g_assert (cfg->rgctx_var->opcode == OP_REGOFFSET && | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to either fix llvm to emit dwarf unwind info for these, or add this unwind info to the generic info when thats loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move back to just use windows unwind ops for llvm frames, right now we enable dwarf + native unwind codes in llvm generated code, and then dwarf is not following the windows ABI (since it misses the XMM registers) since the dwarf implementation was not meant to be used under Windows. It is probably better to add handling of additional native unwind codes for llvm frames and remove the patch that emits dwarf for llvm frames. That will also remove the duplication that we currently carry in the Windows x64 images. That change could be done as a follow up to this PR, if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vargaz @lateralusX could you create a GH issue for the follow up work