From: Sergey Andreenko Date: Tue, 24 Oct 2017 03:45:04 +0000 (-0700) Subject: Report registers as dead in GCInfo before the RhpPInvoke helper. (#14664) X-Git-Tag: accepted/tizen/base/20180629.140029~807 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2207dadf19fc976c6ccd04e12d46924a7b733457;p=platform%2Fupstream%2Fcoreclr.git 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 --- diff --git a/src/jit/codegenarmarch.cpp b/src/jit/codegenarmarch.cpp index 3880305..56cad32 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 7da42ce..f1730b9 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 b8877f2..5c20a87 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 3ff6375..6a64a7b 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 c6a999f..c2258f0 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 fed5d6e..55ebe5e 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);