From fa684e19f9f3b9197dce4080ac39fc2abebf2c8a Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Thu, 30 Aug 2018 16:35:15 -0700 Subject: [PATCH 1/2] Fix callKillSet for CORINFO_HELP_ASSIGN_BYREF. on x64. --- src/jit/codegencommon.cpp | 22 +++++++++++++--------- src/vm/amd64/jithelpers_fast.S | 5 +++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp index e4ba8e6f933a..9a31e7455579 100644 --- a/src/jit/codegencommon.cpp +++ b/src/jit/codegencommon.cpp @@ -639,6 +639,19 @@ regMaskTP Compiler::compNoGCHelperCallKillSet(CorInfoHelpFunc helper) switch (helper) { + case CORINFO_HELP_ASSIGN_BYREF: +#if defined(_TARGET_X86_) + // This helper only trashes ECX. + return RBM_ECX; +#elif defined(_TARGET_AMD64_) + // This uses and defs rdi and rci. + return RBM_CALLEE_TRASH_NOGC & ~(RBM_RDI | RBM_RSI); +#elif defined(_TARGET_ARMARCH_) + return RBM_CALLEE_GCTRASH_WRITEBARRIER_BYREF; +#else + assert(!"unknown arch"); +#endif + #if defined(_TARGET_XARCH_) case CORINFO_HELP_PROF_FCN_ENTER: return RBM_PROFILER_ENTER_TRASH; @@ -650,16 +663,7 @@ regMaskTP Compiler::compNoGCHelperCallKillSet(CorInfoHelpFunc helper) return RBM_PROFILER_TAILCALL_TRASH; #endif // defined(_TARGET_XARCH_) -#if defined(_TARGET_X86_) - case CORINFO_HELP_ASSIGN_BYREF: - // This helper only trashes ECX. - return RBM_ECX; -#endif // defined(_TARGET_X86_) - #if defined(_TARGET_ARMARCH_) - case CORINFO_HELP_ASSIGN_BYREF: - return RBM_CALLEE_GCTRASH_WRITEBARRIER_BYREF; - case CORINFO_HELP_ASSIGN_REF: case CORINFO_HELP_CHECKED_ASSIGN_REF: return RBM_CALLEE_GCTRASH_WRITEBARRIER; diff --git a/src/vm/amd64/jithelpers_fast.S b/src/vm/amd64/jithelpers_fast.S index 37f41421b10b..e8fea7b657d1 100644 --- a/src/vm/amd64/jithelpers_fast.S +++ b/src/vm/amd64/jithelpers_fast.S @@ -228,8 +228,9 @@ LEAF_END JIT_PatchedCodeLast, _TEXT // RSI - address of the data (source) // // Note: RyuJIT assumes that all volatile registers can be trashed by -// the CORINFO_HELP_ASSIGN_BYREF helper (i.e. JIT_ByRefWriteBarrier). -// The precise set is defined by RBM_CALLEE_TRASH. +// the CORINFO_HELP_ASSIGN_BYREF helper (i.e. JIT_ByRefWriteBarrier) +// except RDI and RCI that are incoming and outgoing registers. +// // // RCX is trashed // RAX is trashed From ee771eedbb30657373b13044f06625c7978ad4ef Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Thu, 30 Aug 2018 18:20:21 -0700 Subject: [PATCH 2/2] Fix typos. --- src/jit/codegencommon.cpp | 2 +- src/vm/amd64/jithelpers_fast.S | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp index 9a31e7455579..b1b780fb4694 100644 --- a/src/jit/codegencommon.cpp +++ b/src/jit/codegencommon.cpp @@ -644,7 +644,7 @@ regMaskTP Compiler::compNoGCHelperCallKillSet(CorInfoHelpFunc helper) // This helper only trashes ECX. return RBM_ECX; #elif defined(_TARGET_AMD64_) - // This uses and defs rdi and rci. + // This uses and defs RDI and RSI. return RBM_CALLEE_TRASH_NOGC & ~(RBM_RDI | RBM_RSI); #elif defined(_TARGET_ARMARCH_) return RBM_CALLEE_GCTRASH_WRITEBARRIER_BYREF; diff --git a/src/vm/amd64/jithelpers_fast.S b/src/vm/amd64/jithelpers_fast.S index e8fea7b657d1..6f955b0bee22 100644 --- a/src/vm/amd64/jithelpers_fast.S +++ b/src/vm/amd64/jithelpers_fast.S @@ -229,7 +229,8 @@ LEAF_END JIT_PatchedCodeLast, _TEXT // // Note: RyuJIT assumes that all volatile registers can be trashed by // the CORINFO_HELP_ASSIGN_BYREF helper (i.e. JIT_ByRefWriteBarrier) -// except RDI and RCI that are incoming and outgoing registers. +// except RDI and RSI. This helper uses and defines RDI and RSI, so +// they remain as live GC refs or byrefs, and are not killed. // // // RCX is trashed