Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2017-02-24 01:29:15 +0300
committerdotnet-bot <dotnet-bot@microsoft.com>2017-02-24 01:29:15 +0300
commita2cd6d2f6c2a094b4b691dcbc4df4dd095af638a (patch)
tree8766daf07645f136cef28c320eeb07bdd84dd694 /src/Native/Runtime/GCHelpers.cpp
parentdf88109355f96ca75cc949352d38ea8dfdbc4cff (diff)
Implement GC APIs for .NET Standard 2.0
This change adds a number of GC APIs to ProjectN in accordance with .NETStandard 2.0: * GC.GetGeneration(WeakReference) * GC.RegisterForFullGCNotification * GC.WaitForFullGCApproach * GC.WaitForFullGCComplete * GC.CancelFullGCNotification * GC.TryStartNoGCRegion * GC.EndNoGCRegion [tfs-changeset: 1648730]
Diffstat (limited to 'src/Native/Runtime/GCHelpers.cpp')
-rw-r--r--src/Native/Runtime/GCHelpers.cpp57
1 files changed, 55 insertions, 2 deletions
diff --git a/src/Native/Runtime/GCHelpers.cpp b/src/Native/Runtime/GCHelpers.cpp
index 56884aef9..a09ac5fc9 100644
--- a/src/Native/Runtime/GCHelpers.cpp
+++ b/src/Native/Runtime/GCHelpers.cpp
@@ -56,6 +56,28 @@ EXTERN_C REDHAWK_API Int64 __cdecl RhpGetGcTotalMemory()
return ret;
}
+EXTERN_C REDHAWK_API Int32 __cdecl RhpStartNoGCRegion(Int64 totalSize, Boolean hasLohSize, Int64 lohSize, Boolean disallowFullBlockingGC)
+{
+ Thread *pCurThread = GetThread();
+ ASSERT(!pCurThread->IsCurrentThreadInCooperativeMode());
+
+ pCurThread->SetupHackPInvokeTunnel();
+ pCurThread->DisablePreemptiveMode();
+
+ int result = GCHeapUtilities::GetGCHeap()->StartNoGCRegion(totalSize, hasLohSize, lohSize, disallowFullBlockingGC);
+
+ pCurThread->EnablePreemptiveMode();
+
+ return result;
+}
+
+EXTERN_C REDHAWK_API Int32 __cdecl RhpEndNoGCRegion()
+{
+ ASSERT(!GetThread()->IsCurrentThreadInCooperativeMode());
+
+ return GCHeapUtilities::GetGCHeap()->EndNoGCRegion();
+}
+
COOP_PINVOKE_HELPER(void, RhSuppressFinalize, (OBJECTREF refObj))
{
if (!refObj->get_EEType()->HasFinalizer())
@@ -90,9 +112,9 @@ COOP_PINVOKE_HELPER(Int32, RhGetGcLatencyMode, ())
return GCHeapUtilities::GetGCHeap()->GetGcLatencyMode();
}
-COOP_PINVOKE_HELPER(void, RhSetGcLatencyMode, (Int32 newLatencyMode))
+COOP_PINVOKE_HELPER(Int32, RhSetGcLatencyMode, (Int32 newLatencyMode))
{
- GCHeapUtilities::GetGCHeap()->SetGcLatencyMode(newLatencyMode);
+ return GCHeapUtilities::GetGCHeap()->SetGcLatencyMode(newLatencyMode);
}
COOP_PINVOKE_HELPER(Boolean, RhIsServerGc, ())
@@ -144,3 +166,34 @@ COOP_PINVOKE_HELPER(Int64, RhGetLastGCDuration, (Int32 generation))
{
return GCHeapUtilities::GetGCHeap()->GetLastGCDuration(generation);
}
+
+COOP_PINVOKE_HELPER(Boolean, RhRegisterForFullGCNotification, (Int32 maxGenerationThreshold, Int32 largeObjectHeapThreshold))
+{
+ ASSERT(maxGenerationThreshold >= 1 && maxGenerationThreshold <= 99);
+ ASSERT(largeObjectHeapThreshold >= 1 && largeObjectHeapThreshold <= 99);
+ return GCHeapUtilities::GetGCHeap()->RegisterForFullGCNotification(maxGenerationThreshold, largeObjectHeapThreshold)
+ ? Boolean_true : Boolean_false;
+}
+
+COOP_PINVOKE_HELPER(Boolean, RhCancelFullGCNotification, ())
+{
+ return GCHeapUtilities::GetGCHeap()->CancelFullGCNotification() ? Boolean_true : Boolean_false;
+}
+
+COOP_PINVOKE_HELPER(Int32, RhWaitForFullGCApproach, (Int32 millisecondsTimeout))
+{
+ ASSERT(millisecondsTimeout >= -1);
+ ASSERT(GetThread()->IsCurrentThreadInCooperativeMode());
+
+ int timeout = millisecondsTimeout == -1 ? INFINITE : millisecondsTimeout;
+ return GCHeapUtilities::GetGCHeap()->WaitForFullGCApproach(millisecondsTimeout);
+}
+
+COOP_PINVOKE_HELPER(Int32, RhWaitForFullGCComplete, (Int32 millisecondsTimeout))
+{
+ ASSERT(millisecondsTimeout >= -1);
+ ASSERT(GetThread()->IsCurrentThreadInCooperativeMode());
+
+ int timeout = millisecondsTimeout == -1 ? INFINITE : millisecondsTimeout;
+ return GCHeapUtilities::GetGCHeap()->WaitForFullGCComplete(millisecondsTimeout);
+}