Skip to content

Commit

Permalink
Block inlining of IntroSort (#89310)
Browse files Browse the repository at this point in the history
With PGO and (via #88749) one level of recursive inlining enabled, the jit sees
the recursive call made by `IntroSort` as an attractive inline candidate,
but it isn't.

Fixes #89106.
  • Loading branch information
AndyAyersMS authored Jul 21, 2023
1 parent 18024f4 commit f79676c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/Array.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,9 @@ private void IntrospectiveSort(int left, int length)
}
}

// IntroSort is recursive; block it from being inlined into itself as
// this is currenly not profitable.
[MethodImpl(MethodImplOptions.NoInlining)]
private void IntroSort(int lo, int hi, int depthLimit)
{
Debug.Assert(hi >= lo);
Expand Down Expand Up @@ -2421,6 +2424,9 @@ private void IntrospectiveSort(int left, int length)
}
}

// IntroSort is recursive; block it from being inlined into itself as
// this is currenly not profitable.
[MethodImpl(MethodImplOptions.NoInlining)]
private void IntroSort(int lo, int hi, int depthLimit)
{
Debug.Assert(hi >= lo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ internal static void IntrospectiveSort(Span<T> keys, Comparison<T> comparer)
}
}

// IntroSort is recursive; block it from being inlined into itself as
// this is currenly not profitable.
[MethodImpl(MethodImplOptions.NoInlining)]
private static void IntroSort(Span<T> keys, int depthLimit, Comparison<T> comparer)
{
Debug.Assert(!keys.IsEmpty);
Expand Down Expand Up @@ -402,6 +405,9 @@ private static void Swap(ref T i, ref T j)
j = t;
}

// IntroSort is recursive; block it from being inlined into itself as
// this is currenly not profitable.
[MethodImpl(MethodImplOptions.NoInlining)]
private static void IntroSort(Span<T> keys, int depthLimit)
{
Debug.Assert(!keys.IsEmpty);
Expand Down

0 comments on commit f79676c

Please sign in to comment.