Skip to content

Commit f53c8dc

Browse files
authored
Revert workarounds for dotnet/linker#2181 (#57451)
* Revert workarounds for dotnet/linker#2181 Trying to revert both. The Http3RequestStream is definitely fixed by the linker changes. The ArrayPool ones probably not, but trying to get a repro. * Fully revert ArrayPool workaround
1 parent c5f5b99 commit f53c8dc

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,14 @@ public bool Trim()
211211
// Under high pressure, release all thread locals.
212212
if (pressure == Utilities.MemoryPressure.High)
213213
{
214-
#if !MONO // TODO https://github.com/mono/linker/issues/2181: Remove !MONO ifdefs in this method once is fixed
215-
if (log.IsEnabled())
214+
if (!log.IsEnabled())
215+
{
216+
foreach (KeyValuePair<ThreadLocalArray[], object?> tlsBuckets in _allTlsBuckets)
217+
{
218+
Array.Clear(tlsBuckets.Key);
219+
}
220+
}
221+
else
216222
{
217223
foreach (KeyValuePair<ThreadLocalArray[], object?> tlsBuckets in _allTlsBuckets)
218224
{
@@ -226,14 +232,6 @@ public bool Trim()
226232
}
227233
}
228234
}
229-
else
230-
#endif
231-
{
232-
foreach (KeyValuePair<ThreadLocalArray[], object?> tlsBuckets in _allTlsBuckets)
233-
{
234-
Array.Clear(tlsBuckets.Key);
235-
}
236-
}
237235
}
238236
else
239237
{
@@ -268,14 +266,10 @@ public bool Trim()
268266
{
269267
// Time noticeably wrapped, or we've surpassed the threshold.
270268
// Clear out the array, and log its being trimmed if desired.
271-
if (Interlocked.Exchange(ref buckets[i].Array, null) is T[] buffer)
269+
if (Interlocked.Exchange(ref buckets[i].Array, null) is T[] buffer &&
270+
log.IsEnabled())
272271
{
273-
#if !MONO
274-
if (log.IsEnabled())
275-
{
276-
log.BufferTrimmed(buffer.GetHashCode(), buffer.Length, Id);
277-
}
278-
#endif
272+
log.BufferTrimmed(buffer.GetHashCode(), buffer.Length, Id);
279273
}
280274
}
281275
}

0 commit comments

Comments
 (0)