Add budget check to RandomPolicy
authorAndy Ayers <andya@microsoft.com>
Fri, 13 May 2016 18:32:49 +0000 (11:32 -0700)
committerAndy Ayers <andya@microsoft.com>
Fri, 13 May 2016 18:32:49 +0000 (11:32 -0700)
Prevents RandomPolicy from being overly aggressive with small methods
that can lead to excessive inlining.

Closes #4711. Undoes #4704.

src/jit/inlinepolicy.cpp
tests/src/JIT/opt/Inline/tests/LotsOfInlines.csproj

index deaa849..6eb0174 100644 (file)
@@ -999,6 +999,18 @@ void RandomPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
     assert(InlDecisionIsCandidate(m_Decision));
     assert(m_Observation == InlineObservation::CALLEE_IS_DISCRETIONARY_INLINE);
 
+    // Budget check.
+    if (!m_IsPrejitRoot)
+    {
+        InlineStrategy* strategy = m_RootCompiler->m_inlineStrategy;
+        bool overBudget = strategy->BudgetCheck(m_CodeSize);
+        if (overBudget)
+        {
+            SetFailure(InlineObservation::CALLSITE_OVER_BUDGET);
+            return;
+        }
+    }
+
     // Use a probability curve that roughly matches the observed
     // behavior of the LegacyPolicy. That way we're inlining
     // differently but not creating enormous methods.
index 93a5b79..ae4ef5d 100644 (file)
@@ -32,7 +32,6 @@
     <NoStandardLib>True</NoStandardLib>
     <Noconfig>True</Noconfig>
     <DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
-    <JitOptimizationSensitive>true</JitOptimizationSensitive>
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="LotsOfInlines.cs" />