review feedback
authorAndy Ayers <andya@microsoft.com>
Fri, 24 Feb 2017 21:35:37 +0000 (13:35 -0800)
committerAndy Ayers <andya@microsoft.com>
Fri, 24 Feb 2017 21:35:37 +0000 (13:35 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/b515aeee2d58c9bcf3d2d2114b8c1df60ce67368

src/coreclr/src/jit/flowgraph.cpp
src/coreclr/src/jit/importer.cpp

index ffec180..04489a2 100644 (file)
@@ -22445,21 +22445,31 @@ GenTreePtr Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
 
 void Compiler::fgInlineAppendStatements(InlineInfo* inlineInfo, BasicBlock* block, GenTreePtr stmtAfter)
 {
-    // If this inlinee was passed a generic context but didn't look at
-    // it, we can decrement the "generic context was used" ref count.
+    // If this inlinee was passed a runtime lookup generic context and
+    // ignores it, we can decrement the "generic context was used" ref
+    // count, because we created a new lookup tree and incremented the
+    // count when we imported the type parameter argument to pass to
+    // the inlinee. See corresponding logic in impImportCall that
+    // checks the sig for CORINFO_CALLCONV_PARAMTYPE.
+    //
+    // Does this method require a context (type) parameter?
     if ((inlineInfo->inlineCandidateInfo->methInfo.args.callConv & CORINFO_CALLCONV_PARAMTYPE) != 0)
     {
-        // Did the context require the caller to perform a runtime lookup?
+        // Did the computation of that parameter require the
+        // caller to perform a runtime lookup?
         if (inlineInfo->inlineCandidateInfo->exactContextNeedsRuntimeLookup)
         {
-            // Fetch the temp for the generic context
+            // Fetch the temp for the generic context as it would
+            // appear in the inlinee's body.
             const unsigned typeCtxtArg = inlineInfo->typeContextArg;
             const unsigned tmpNum      = inlineInfo->lclTmpNum[typeCtxtArg];
 
             // Was it used in the inline body?
             if (tmpNum == BAD_VAR_NUM)
             {
-                // No, so the runtime lookup is not needed.
+                // No -- so the associated runtime lookup is not needed
+                // and also no longer provides evidence that the generic
+                // context should be kept alive.
                 JITDUMP("Inlinee ignores runtime lookup generics context\n");
                 assert(lvaGenericsContextUseCount > 0);
                 lvaGenericsContextUseCount--;
index 24ba90a..cfd2785 100644 (file)
@@ -6376,7 +6376,7 @@ var_types Compiler::impImportCall(OPCODE                  opcode,
     GenTreeArgList*        args                           = nullptr;
     CORINFO_THIS_TRANSFORM constraintCallThisTransform    = CORINFO_NO_THIS_TRANSFORM;
     CORINFO_CONTEXT_HANDLE exactContextHnd                = nullptr;
-    BOOL                   exactContextNeedsRuntimeLookup = FALSE;
+    bool                   exactContextNeedsRuntimeLookup = false;
     bool                   canTailCall                    = true;
     const char*            szCanTailCallFailReason        = nullptr;
     int                    tailCall                       = prefixFlags & PREFIX_TAILCALL;
@@ -6634,10 +6634,9 @@ var_types Compiler::impImportCall(OPCODE                  opcode,
         // Work out what sort of call we're making.
         // Dispense with virtual calls implemented via LDVIRTFTN immediately.
 
-        constraintCallThisTransform = callInfo->thisTransform;
-
+        constraintCallThisTransform    = callInfo->thisTransform;
         exactContextHnd                = callInfo->contextHandle;
-        exactContextNeedsRuntimeLookup = callInfo->exactContextNeedsRuntimeLookup;
+        exactContextNeedsRuntimeLookup = callInfo->exactContextNeedsRuntimeLookup == TRUE;
 
         // Recursive call is treaded as a loop to the begining of the method.
         if (methHnd == info.compMethodHnd)
@@ -7401,7 +7400,7 @@ var_types Compiler::impImportCall(OPCODE                  opcode,
 #endif // defined(DEBUG) || defined(INLINE_DATA)
 
                 // Is it an inline candidate?
-                impMarkInlineCandidate(call, exactContextHnd, exactContextNeedsRuntimeLookup == TRUE, callInfo);
+                impMarkInlineCandidate(call, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo);
             }
 
             // append the call node.
@@ -7625,7 +7624,7 @@ DONE:
 #endif // defined(DEBUG) || defined(INLINE_DATA)
 
         // Is it an inline candidate?
-        impMarkInlineCandidate(call, exactContextHnd, exactContextNeedsRuntimeLookup == TRUE, callInfo);
+        impMarkInlineCandidate(call, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo);
     }
 
 DONE_CALL: