Inliner: add JitInlineLimit check to LegacyPolicy under debug
authorAndy Ayers <andya@microsoft.com>
Thu, 5 May 2016 23:48:53 +0000 (16:48 -0700)
committerAndy Ayers <andya@microsoft.com>
Thu, 5 May 2016 23:48:53 +0000 (16:48 -0700)
Adds the ability to limit the number of inlines done by the LegacyPolicy.
Useful in trying to binary search for inlines that cause correctness
issues.

This limit impacts inlining in all methods, so effective isolation may
also require use of JitNoInlineRange to hone in on the root method that
is the source of problems.

src/jit/inlinepolicy.cpp

index 73e22d4..5aade9f 100644 (file)
@@ -736,6 +736,23 @@ int LegacyPolicy::DetermineCallsiteNativeSizeEstimate(CORINFO_METHOD_INFO* methI
 
 void LegacyPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
 {
+
+#if defined(DEBUG)
+
+    // Punt if we're inlining and we've reached the acceptance limit.
+    int limit = JitConfig.JitInlineLimit();
+    unsigned current = m_RootCompiler->m_inlineStrategy->GetInlineCount();
+
+    if (!m_IsPrejitRoot &&
+        (limit >= 0) &&
+        (current >= static_cast<unsigned>(limit)))
+    {
+        SetFailure(InlineObservation::CALLSITE_OVER_INLINE_LIMIT);
+        return;
+    }
+
+#endif // defined(DEBUG)
+
     assert(InlDecisionIsCandidate(m_Decision));
     assert(m_Observation == InlineObservation::CALLEE_IS_DISCRETIONARY_INLINE);