summaryrefslogtreecommitdiff
path: root/src/jit/inlinepolicy.cpp
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2016-04-29 17:27:40 -0700
committerAndy Ayers <andya@microsoft.com>2016-05-03 09:31:38 -0700
commitf57f3737a356f12fb494945c5750980fe14af020 (patch)
treedc058ccd3ab7cb5107dd0f94bf79bfe0a325479a /src/jit/inlinepolicy.cpp
parentea040083e57c706c6fe4c34f5a51b5851c249b43 (diff)
downloadcoreclr-f57f3737a356f12fb494945c5750980fe14af020.tar.gz
coreclr-f57f3737a356f12fb494945c5750980fe14af020.tar.bz2
coreclr-f57f3737a356f12fb494945c5750980fe14af020.zip
Inliner: initial version of SizePolicy
Add a new inline policy that tries to inline as much as possible without increasing method size. Fix one test that had an expected inline that doesn't happen under the SizePolicy, by marking a method with AggressiveInline.
Diffstat (limited to 'src/jit/inlinepolicy.cpp')
-rw-r--r--src/jit/inlinepolicy.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/jit/inlinepolicy.cpp b/src/jit/inlinepolicy.cpp
index 9615bdcfb5..73e22d4530 100644
--- a/src/jit/inlinepolicy.cpp
+++ b/src/jit/inlinepolicy.cpp
@@ -43,6 +43,14 @@ InlinePolicy* InlinePolicy::GetPolicy(Compiler* compiler, bool isPrejitRoot)
#if defined(DEBUG) || defined(INLINE_DATA)
+ // Optionally install the SizePolicy.
+ bool useSizePolicy = JitConfig.JitInlinePolicySize() != 0;
+
+ if (useSizePolicy)
+ {
+ return new (compiler, CMK_Inlining) SizePolicy(compiler, isPrejitRoot);
+ }
+
// Optionally install the FullPolicy.
bool useFullPolicy = JitConfig.JitInlinePolicyFull() != 0;
@@ -1948,4 +1956,73 @@ void FullPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
return;
}
+//------------------------------------------------------------------------/
+// SizePolicy: construct a new SizePolicy
+//
+// Arguments:
+// compiler -- compiler instance doing the inlining (root compiler)
+// isPrejitRoot -- true if this compiler is prejitting the root method
+
+SizePolicy::SizePolicy(Compiler* compiler, bool isPrejitRoot)
+ : DiscretionaryPolicy(compiler, isPrejitRoot)
+{
+ // Empty
+}
+
+//------------------------------------------------------------------------
+// DetermineProfitability: determine if this inline is profitable
+//
+// Arguments:
+// methodInfo -- method info for the callee
+
+void SizePolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
+{
+ // Do some homework
+ MethodInfoObservations(methodInfo);
+ EstimateCodeSize();
+
+ // Does this inline increase the estimated size beyond
+ // the original size estimate?
+ const InlineStrategy* strategy = m_RootCompiler->m_inlineStrategy;
+ const int initialSize = strategy->GetInitialSizeEstimate();
+ const int currentSize = strategy->GetCurrentSizeEstimate();
+ const int newSize = currentSize + m_ModelCodeSizeEstimate;
+
+ if (newSize <= initialSize)
+ {
+ // Estimated size impact is acceptable, so inline here.
+ JITLOG_THIS(m_RootCompiler,
+ (LL_INFO100000,
+ "Inline profitable, root size estimate %d is less than initial size %d\n",
+ newSize / SIZE_SCALE, initialSize / SIZE_SCALE));
+
+ if (m_IsPrejitRoot)
+ {
+ SetCandidate(InlineObservation::CALLEE_IS_SIZE_DECREASING_INLINE);
+ }
+ else
+ {
+ SetCandidate(InlineObservation::CALLSITE_IS_SIZE_DECREASING_INLINE);
+ }
+ }
+ else
+ {
+ // Estimated size increase is too large, so no inline here.
+ //
+ // Note that we ought to reconsider this inline if we make
+ // room in the budget by inlining a bunch of size decreasing
+ // inlines after this one. But for now, we won't do this.
+ if (m_IsPrejitRoot)
+ {
+ SetNever(InlineObservation::CALLEE_NOT_PROFITABLE_INLINE);
+ }
+ else
+ {
+ SetFailure(InlineObservation::CALLSITE_NOT_PROFITABLE_INLINE);
+ }
+ }
+
+ return;
+}
+
#endif // defined(DEBUG) || defined(INLINE_DATA)