Skip to content

Commit cb730c5

Browse files
author
Sergey Andreenko
authored
Fix callKillSet for CORINFO_HELP_ASSIGN_BYREF on x64. (dotnet#19780) (dotnet#19803)
* Fix callKillSet for CORINFO_HELP_ASSIGN_BYREF. on x64.
1 parent d05c93d commit cb730c5

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/jit/codegencommon.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,19 @@ regMaskTP Compiler::compNoGCHelperCallKillSet(CorInfoHelpFunc helper)
737737

738738
switch (helper)
739739
{
740+
case CORINFO_HELP_ASSIGN_BYREF:
741+
#if defined(_TARGET_X86_)
742+
// This helper only trashes ECX.
743+
return RBM_ECX;
744+
#elif defined(_TARGET_AMD64_)
745+
// This uses and defs RDI and RSI.
746+
return RBM_CALLEE_TRASH_NOGC & ~(RBM_RDI | RBM_RSI);
747+
#elif defined(_TARGET_ARMARCH_)
748+
return RBM_CALLEE_GCTRASH_WRITEBARRIER_BYREF;
749+
#else
750+
assert(!"unknown arch");
751+
#endif
752+
740753
#if defined(_TARGET_XARCH_)
741754
case CORINFO_HELP_PROF_FCN_ENTER:
742755
return RBM_PROFILER_ENTER_TRASH;
@@ -748,16 +761,7 @@ regMaskTP Compiler::compNoGCHelperCallKillSet(CorInfoHelpFunc helper)
748761
return RBM_PROFILER_TAILCALL_TRASH;
749762
#endif // defined(_TARGET_XARCH_)
750763

751-
#if defined(_TARGET_X86_)
752-
case CORINFO_HELP_ASSIGN_BYREF:
753-
// This helper only trashes ECX.
754-
return RBM_ECX;
755-
#endif // defined(_TARGET_X86_)
756-
757764
#if defined(_TARGET_ARMARCH_)
758-
case CORINFO_HELP_ASSIGN_BYREF:
759-
return RBM_CALLEE_GCTRASH_WRITEBARRIER_BYREF;
760-
761765
case CORINFO_HELP_ASSIGN_REF:
762766
case CORINFO_HELP_CHECKED_ASSIGN_REF:
763767
return RBM_CALLEE_GCTRASH_WRITEBARRIER;

src/vm/amd64/jithelpers_fast.S

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ LEAF_END JIT_PatchedCodeLast, _TEXT
228228
// RSI - address of the data (source)
229229
//
230230
// Note: RyuJIT assumes that all volatile registers can be trashed by
231-
// the CORINFO_HELP_ASSIGN_BYREF helper (i.e. JIT_ByRefWriteBarrier).
232-
// The precise set is defined by RBM_CALLEE_TRASH.
231+
// the CORINFO_HELP_ASSIGN_BYREF helper (i.e. JIT_ByRefWriteBarrier)
232+
// except RDI and RSI. This helper uses and defines RDI and RSI, so
233+
// they remain as live GC refs or byrefs, and are not killed.
234+
//
233235
//
234236
// RCX is trashed
235237
// RAX is trashed

0 commit comments

Comments
 (0)