Skip to content

Commit f79676c

Browse files
authored
Block inlining of IntroSort (#89310)
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.
1 parent 18024f4 commit f79676c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/libraries/System.Private.CoreLib/src/System/Array.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,9 @@ private void IntrospectiveSort(int left, int length)
22072207
}
22082208
}
22092209

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

2427+
// IntroSort is recursive; block it from being inlined into itself as
2428+
// this is currenly not profitable.
2429+
[MethodImpl(MethodImplOptions.NoInlining)]
24242430
private void IntroSort(int lo, int hi, int depthLimit)
24252431
{
24262432
Debug.Assert(hi >= lo);

src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ internal static void IntrospectiveSort(Span<T> keys, Comparison<T> comparer)
128128
}
129129
}
130130

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

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

0 commit comments

Comments
 (0)