From 2207dadf19fc976c6ccd04e12d46924a7b733457 Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Mon, 23 Oct 2017 20:45:04 -0700 Subject: Report registers as dead in GCInfo before the RhpPInvoke helper. (#14664) * move killGCRefs to the compiler It makes it accessible from codegen. * use killGCRefs in codeGen It terminates live of GCRefs before RhpPInvoke. * small ref --- src/jit/codegenarmarch.cpp | 2 +- src/jit/codegenxarch.cpp | 2 +- src/jit/compiler.cpp | 30 ++++++++++++++++++++++++++++++ src/jit/compiler.h | 2 ++ src/jit/lsra.cpp | 31 +------------------------------ src/jit/lsra.h | 2 -- 6 files changed, 35 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/jit/codegenarmarch.cpp b/src/jit/codegenarmarch.cpp index 38803054b9..56cad32bf0 100644 --- a/src/jit/codegenarmarch.cpp +++ b/src/jit/codegenarmarch.cpp @@ -2265,7 +2265,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call) // the GC pointer state before the callsite. // We can't utilize the typical lazy killing of GC pointers // at (or inside) the callsite. - if (call->IsUnmanaged()) + if (compiler->killGCRefs(call)) { genDefineTempLabel(genCreateTempLabel()); } diff --git a/src/jit/codegenxarch.cpp b/src/jit/codegenxarch.cpp index 7da42ce7e5..f1730b9999 100644 --- a/src/jit/codegenxarch.cpp +++ b/src/jit/codegenxarch.cpp @@ -5283,7 +5283,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call) // the GC pointer state before the callsite. // We can't utilize the typical lazy killing of GC pointers // at (or inside) the callsite. - if (call->IsUnmanaged()) + if (compiler->killGCRefs(call)) { genDefineTempLabel(genCreateTempLabel()); } diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp index b8877f22f5..5c20a87e5f 100644 --- a/src/jit/compiler.cpp +++ b/src/jit/compiler.cpp @@ -11391,3 +11391,33 @@ HelperCallProperties Compiler::s_helperCallProperties; /*****************************************************************************/ /*****************************************************************************/ + +//------------------------------------------------------------------------ +// killGCRefs: +// Given some tree node return does it need all GC refs to be spilled from +// callee save registers. +// +// Arguments: +// tree - the tree for which we ask about gc refs. +// +// Return Value: +// true - tree kills GC refs on callee save registers +// false - tree doesn't affect GC refs on callee save registers +bool Compiler::killGCRefs(GenTreePtr tree) +{ + if (tree->IsCall()) + { + GenTreeCall* call = tree->AsCall(); + if (call->IsUnmanaged()) + { + return true; + } + + if (call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_JIT_PINVOKE_BEGIN)) + { + assert(opts.ShouldUsePInvokeHelpers()); + return true; + } + } + return false; +} diff --git a/src/jit/compiler.h b/src/jit/compiler.h index 3ff6375a57..6a64a7b648 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -9564,6 +9564,8 @@ public: void fgMorphMultiregStructArgs(GenTreeCall* call); GenTreePtr fgMorphMultiregStructArg(GenTreePtr arg, fgArgTabEntryPtr fgEntryPtr); + bool killGCRefs(GenTreePtr tree); + }; // end of class Compiler // Inline methods of CompAllocator. diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp index c6a999fc95..c2258f0646 100644 --- a/src/jit/lsra.cpp +++ b/src/jit/lsra.cpp @@ -3083,7 +3083,7 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo } } - if (killGCRefs(tree)) + if (compiler->killGCRefs(tree)) { RefPosition* pos = newRefPosition((Interval*)nullptr, currentLoc, RefTypeKillGCRefs, tree, (allRegs(TYP_REF) & ~RBM_ARG_REGS)); @@ -3094,35 +3094,6 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo return false; } -//------------------------------------------------------------------------ -// killGCRefs: -// Given some tree node return does it need all GC refs to be spilled from -// callee save registers. -// -// Arguments: -// tree - the tree for which we ask about gc refs. -// -// Return Value: -// true - tree kills GC refs on callee save registers -// false - tree doesn't affect GC refs on callee save registers -bool LinearScan::killGCRefs(GenTree* tree) -{ - if (tree->IsCall()) - { - if ((tree->gtFlags & GTF_CALL_UNMANAGED) != 0) - { - return true; - } - - if (tree->AsCall()->gtCallMethHnd == compiler->eeFindHelper(CORINFO_HELP_JIT_PINVOKE_BEGIN)) - { - assert(compiler->opts.ShouldUsePInvokeHelpers()); - return true; - } - } - return false; -} - //---------------------------------------------------------------------------- // defineNewInternalTemp: Defines a ref position for an internal temp. // diff --git a/src/jit/lsra.h b/src/jit/lsra.h index fed5d6ea86..55ebe5e8d5 100644 --- a/src/jit/lsra.h +++ b/src/jit/lsra.h @@ -772,8 +772,6 @@ private: // Given some tree node add refpositions for all the registers this node kills bool buildKillPositionsForNode(GenTree* tree, LsraLocation currentLoc); - bool killGCRefs(GenTree* tree); - regMaskTP allRegs(RegisterType rt); regMaskTP allRegs(GenTree* tree); regMaskTP allMultiRegCallNodeRegs(GenTreeCall* tree); -- cgit v1.2.3