summaryrefslogtreecommitdiff
path: root/src/mscorlib/Common/PinnableBufferCache.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/Common/PinnableBufferCache.cs')
-rw-r--r--src/mscorlib/Common/PinnableBufferCache.cs97
1 files changed, 0 insertions, 97 deletions
diff --git a/src/mscorlib/Common/PinnableBufferCache.cs b/src/mscorlib/Common/PinnableBufferCache.cs
index fee3e46f46..fc6e13a899 100644
--- a/src/mscorlib/Common/PinnableBufferCache.cs
+++ b/src/mscorlib/Common/PinnableBufferCache.cs
@@ -4,9 +4,6 @@
#define ENABLE
#define MINBUFFERS
using System;
-#if !FEATURE_CORECLR
-using System.Diagnostics.Tracing;
-#endif
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
using System.Collections.Generic;
@@ -45,12 +42,6 @@ namespace System
/// Create a PinnableBufferCache that works on any object (it is intended for OverlappedData)
/// This is only used in mscorlib.
/// </summary>
-#if (ENABLE || MINBUFFERS)
-#pragma warning disable 618
- [EnvironmentPermission(SecurityAction.Assert, Unrestricted = true)]
-#pragma warning restore 618
- [System.Security.SecuritySafeCritical]
-#endif
internal PinnableBufferCache(string cacheName, Func<object> factory)
{
m_NotGen2 = new List<object>(DefaultNumberOfBuffers);
@@ -103,7 +94,6 @@ namespace System
/// <summary>
/// Get a object from the buffer manager. If no buffers exist, allocate a new one.
/// </summary>
- [System.Security.SecuritySafeCritical]
internal object Allocate()
{
#if ENABLE
@@ -149,7 +139,6 @@ namespace System
/// <summary>
/// Return a buffer back to the buffer manager.
/// </summary>
- [System.Security.SecuritySafeCritical]
internal void Free(object buffer)
{
#if ENABLE
@@ -188,7 +177,6 @@ namespace System
/// Called when we don't have any buffers in our free list to give out.
/// </summary>
/// <returns></returns>
- [System.Security.SecuritySafeCritical]
private void Restock(out object returnBuffer)
{
lock (this)
@@ -241,7 +229,6 @@ namespace System
/// <summary>
/// See if we can promote the buffers to the free list. Returns true if sucessful.
/// </summary>
- [System.Security.SecuritySafeCritical]
private bool AgePendingBuffers()
{
if (m_gen1CountAtLastRestock < GC.CollectionCount(GC.MaxGeneration - 1))
@@ -317,7 +304,6 @@ namespace System
/// otherwise, we root the cache to the Gen2GcCallback object, and leak the cache even when
/// the application no longer needs it.
/// </summary>
- [System.Security.SecuritySafeCritical]
private static bool Gen2GcCallbackFunc(object targetObj)
{
return ((PinnableBufferCache)(targetObj)).TrimFreeListIfNeeded();
@@ -328,7 +314,6 @@ namespace System
/// NOTE: DO NOT CALL THIS DIRECTLY FROM THE GEN2GCCALLBACK. INSTEAD CALL IT VIA A STATIC FUNCTION (SEE ABOVE).
/// If you register a non-static function as a callback, then this object will be leaked.
/// </summary>
- [System.Security.SecuritySafeCritical]
private bool TrimFreeListIfNeeded()
{
int curMSec = Environment.TickCount;
@@ -481,7 +466,6 @@ namespace System
/// </summary>
internal sealed class Gen2GcCallback : CriticalFinalizerObject
{
- [System.Security.SecuritySafeCritical]
public Gen2GcCallback()
: base()
{
@@ -506,14 +490,12 @@ namespace System
private Func<object, bool> m_callback;
private GCHandle m_weakTargetObj;
- [System.Security.SecuritySafeCritical]
private void Setup(Func<object, bool> callback, object targetObj)
{
m_callback = callback;
m_weakTargetObj = GCHandle.Alloc(targetObj, GCHandleType.Weak);
}
- [System.Security.SecuritySafeCritical]
~Gen2GcCallback()
{
// Check to see if the target object is still alive.
@@ -549,8 +531,6 @@ namespace System
#endregion
}
-
-#if FEATURE_CORECLR
internal sealed class PinnableBufferCacheEventSource
{
public static readonly PinnableBufferCacheEventSource Log = new PinnableBufferCacheEventSource();
@@ -581,86 +561,9 @@ namespace System
return 0;
}
- [System.Security.SecuritySafeCritical]
static internal unsafe long AddressOfObject(byte[] array)
{
return 0;
}
}
-#else
- /// <summary>
- /// PinnableBufferCacheEventSource is a private eventSource that we are using to
- /// debug and monitor the effectiveness of PinnableBufferCache
- /// </summary>
-#if PINNABLEBUFFERCACHE_MSCORLIB
- [EventSource(Name = "Microsoft-DotNETRuntime-PinnableBufferCache")]
-#else
- [EventSource(Name = "Microsoft-DotNETRuntime-PinnableBufferCache-System")]
-#endif
- internal sealed class PinnableBufferCacheEventSource : EventSource
- {
- public static readonly PinnableBufferCacheEventSource Log = new PinnableBufferCacheEventSource();
-
- [Event(1, Level = EventLevel.Verbose)]
- public void DebugMessage(string message) { if (IsEnabled()) WriteEvent(1, message); }
- [Event(2, Level = EventLevel.Verbose)]
- public void DebugMessage1(string message, long value) { if (IsEnabled()) WriteEvent(2, message, value); }
- [Event(3, Level = EventLevel.Verbose)]
- public void DebugMessage2(string message, long value1, long value2) { if (IsEnabled()) WriteEvent(3, message, value1, value2); }
- [Event(18, Level = EventLevel.Verbose)]
- public void DebugMessage3(string message, long value1, long value2, long value3) { if (IsEnabled()) WriteEvent(18, message, value1, value2, value3); }
-
- [Event(4)]
- public void Create(string cacheName) { if (IsEnabled()) WriteEvent(4, cacheName); }
-
- [Event(5, Level = EventLevel.Verbose)]
- public void AllocateBuffer(string cacheName, ulong objectId, int objectHash, int objectGen, int freeCountAfter) { if (IsEnabled()) WriteEvent(5, cacheName, objectId, objectHash, objectGen, freeCountAfter); }
- [Event(6)]
- public void AllocateBufferFromNotGen2(string cacheName, int notGen2CountAfter) { if (IsEnabled()) WriteEvent(6, cacheName, notGen2CountAfter); }
- [Event(7)]
- public void AllocateBufferCreatingNewBuffers(string cacheName, int totalBuffsBefore, int objectCount) { if (IsEnabled()) WriteEvent(7, cacheName, totalBuffsBefore, objectCount); }
- [Event(8)]
- public void AllocateBufferAged(string cacheName, int agedCount) { if (IsEnabled()) WriteEvent(8, cacheName, agedCount); }
- [Event(9)]
- public void AllocateBufferFreeListEmpty(string cacheName, int notGen2CountBefore) { if (IsEnabled()) WriteEvent(9, cacheName, notGen2CountBefore); }
-
- [Event(10, Level = EventLevel.Verbose)]
- public void FreeBuffer(string cacheName, ulong objectId, int objectHash, int freeCountBefore) { if (IsEnabled()) WriteEvent(10, cacheName, objectId, objectHash, freeCountBefore); }
- [Event(11)]
- public void FreeBufferStillTooYoung(string cacheName, int notGen2CountBefore) { if (IsEnabled()) WriteEvent(11, cacheName, notGen2CountBefore); }
-
- [Event(13)]
- public void TrimCheck(string cacheName, int totalBuffs, bool neededMoreThanFreeList, int deltaMSec) { if (IsEnabled()) WriteEvent(13, cacheName, totalBuffs, neededMoreThanFreeList, deltaMSec); }
- [Event(14)]
- public void TrimFree(string cacheName, int totalBuffs, int freeListCount, int toBeFreed) { if (IsEnabled()) WriteEvent(14, cacheName, totalBuffs, freeListCount, toBeFreed); }
- [Event(15)]
- public void TrimExperiment(string cacheName, int totalBuffs, int freeListCount, int numTrimTrial) { if (IsEnabled()) WriteEvent(15, cacheName, totalBuffs, freeListCount, numTrimTrial); }
- [Event(16)]
- public void TrimFreeSizeOK(string cacheName, int totalBuffs, int freeListCount) { if (IsEnabled()) WriteEvent(16, cacheName, totalBuffs, freeListCount); }
- [Event(17)]
- public void TrimFlush(string cacheName, int totalBuffs, int freeListCount, int notGen2CountBefore) { if (IsEnabled()) WriteEvent(17, cacheName, totalBuffs, freeListCount, notGen2CountBefore); }
- [Event(20)]
- public void AgePendingBuffersResults(string cacheName, int promotedToFreeListCount, int heldBackCount) { if (IsEnabled()) WriteEvent(20, cacheName, promotedToFreeListCount, heldBackCount); }
- [Event(21)]
- public void WalkFreeListResult(string cacheName, int freeListCount, int gen0BuffersInFreeList) { if (IsEnabled()) WriteEvent(21, cacheName, freeListCount, gen0BuffersInFreeList); }
-
-
- static internal ulong AddressOf(object obj)
- {
- var asByteArray = obj as byte[];
- if (asByteArray != null)
- return (ulong)AddressOfByteArray(asByteArray);
- return 0;
- }
-
- [System.Security.SecuritySafeCritical]
- static internal unsafe long AddressOfByteArray(byte[] array)
- {
- if (array == null)
- return 0;
- fixed (byte* ptr = array)
- return (long)(ptr - 2 * sizeof(void*));
- }
- }
-#endif
}