Skip to content

Commit

Permalink
Remove calls to empty RuntimeHelpers.PrepareConstrainedRegions() dotn…
Browse files Browse the repository at this point in the history
  • Loading branch information
Marusyk committed Mar 4, 2020
1 parent b5afe95 commit 2ee0780
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Globalization;
using System.IO;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -1020,7 +1019,6 @@ private void ReleaseLocks(ref bool thisLockTaken, ref bool sessionHandleLockTake

if (thisLockTaken || sessionHandleLockTaken)
{
RuntimeHelpers.PrepareConstrainedRegions();
try
{
}
Expand Down Expand Up @@ -1104,7 +1102,6 @@ private static void ReleaseLock(object lockObject, ref bool lockTaken)
Debug.Assert(lockObject != null, "'lockObject' MUST NOT be NULL.");
if (lockTaken)
{
RuntimeHelpers.PrepareConstrainedRegions();
try
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Buffers;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -128,7 +127,6 @@ protected void Initialize(SafeBuffer buffer, long offset, long length, FileAcces
unsafe
{
byte* pointer = null;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
buffer.AcquirePointer(ref pointer);
Expand Down Expand Up @@ -260,7 +258,6 @@ public override void CopyTo(ReadOnlySpanAction<byte, object?> callback, object?
{
byte* pointer = null;

RuntimeHelpers.PrepareConstrainedRegions();
try
{
_buffer.AcquirePointer(ref pointer);
Expand Down Expand Up @@ -490,7 +487,6 @@ internal int ReadCore(Span<byte> buffer)
{
byte* pointer = null;

RuntimeHelpers.PrepareConstrainedRegions();
try
{
_buffer.AcquirePointer(ref pointer);
Expand Down Expand Up @@ -606,7 +602,6 @@ public override int ReadByte()
unsafe
{
byte* pointer = null;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
_buffer.AcquirePointer(ref pointer);
Expand Down Expand Up @@ -786,7 +781,6 @@ internal unsafe void WriteCore(ReadOnlySpan<byte> buffer)
}

byte* pointer = null;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
_buffer.AcquirePointer(ref pointer);
Expand Down Expand Up @@ -920,7 +914,6 @@ public override void WriteByte(byte value)
unsafe
{
byte* pointer = null;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
_buffer.AcquirePointer(ref pointer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
===========================================================*/

using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Diagnostics;

Expand Down Expand Up @@ -235,10 +234,6 @@ public MemoryFailPoint(int sizeInMegabytes)
if (!needPageFile)
continue;

// Attempt to grow the OS's page file. Note that we ignore
// any allocation routines from the host intentionally.
RuntimeHelpers.PrepareConstrainedRegions();

// This shouldn't overflow due to the if clauses above.
UIntPtr numBytes = new UIntPtr(segmentSize);
GrowPageFileIfNecessaryAndPossible(numBytes);
Expand Down Expand Up @@ -286,8 +281,6 @@ public MemoryFailPoint(int sizeInMegabytes)
if (LastKnownFreeAddressSpace < 0)
CheckForFreeAddressSpace(segmentSize, true);

RuntimeHelpers.PrepareConstrainedRegions();

AddMemoryFailPointReservation((long)size);
_mustSubtractReservation = true;
}
Expand Down Expand Up @@ -317,8 +310,6 @@ private void Dispose(bool disposing)
// within the GC heap.
if (_mustSubtractReservation)
{
RuntimeHelpers.PrepareConstrainedRegions();

AddMemoryFailPointReservation(-((long)_reservedMemory));
_mustSubtractReservation = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

Expand All @@ -18,10 +17,6 @@ private sealed class DisposableData : CriticalDisposableObject

public DisposableData(IDisposable accessor, SafeBuffer safeBuffer, long offset)
{
// Make sure the current thread isn't aborted in between acquiring the pointer and assigning the fields.
#if !NETSTANDARD1_1
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
Expand All @@ -38,11 +33,6 @@ public DisposableData(IDisposable accessor, SafeBuffer safeBuffer, long offset)

protected override void Release()
{
// Make sure the current thread isn't aborted in between zeroing the references and releasing/disposing.
// Safe buffer only frees the underlying resource if its ref count drops to zero, so we have to make sure it does.
#if !NETSTANDARD1_1
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

Expand All @@ -22,10 +21,6 @@ private unsafe sealed class DisposableData : CriticalDisposableObject

public DisposableData(int size)
{
// make sure the current thread isn't aborted in between allocating and storing the pointer
#if !NETSTANDARD1_1
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
Expand All @@ -37,10 +32,6 @@ public DisposableData(int size)

protected override void Release()
{
// make sure the current thread isn't aborted in between zeroing the pointer and freeing the memory
#if !NETSTANDARD1_1
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

Expand All @@ -18,10 +17,6 @@ internal sealed class PinnedObject : CriticalDisposableObject

public PinnedObject(object obj)
{
// Make sure the current thread isn't aborted in between allocating the handle and storing it.
#if !NETSTANDARD1_1
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
Expand All @@ -34,10 +29,6 @@ public PinnedObject(object obj)

protected override void Release()
{
// Make sure the current thread isn't aborted in between zeroing the handle and freeing it.
#if !NETSTANDARD1_1
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Collections.Generic;
using System.Reflection.Internal;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

Expand Down Expand Up @@ -46,10 +45,6 @@ private VirtualHeap()

protected override void Release()
{
// Make sure the current thread isn't aborted in the middle of the operation.
#if !NETSTANDARD1_1
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
Expand Down Expand Up @@ -95,9 +90,6 @@ internal MemoryBlock AddBlob(uint rawHandle, byte[] value)
var blobs = GetBlobs();

MemoryBlock result;
#if !NETSTANDARD1_1
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
}
Expand Down

0 comments on commit 2ee0780

Please sign in to comment.