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>2015-10-01 00:47:24 +0300
committerScott Mosier <smosier@microsoft.com>2015-10-01 00:47:24 +0300
commitad0323ab91a7b1469b42ca5457ddd631b94294fe (patch)
tree88fae57e1ec3aae90288463dc07e58f7aebc1de8 /src/Native/Runtime/GCHelpers.cpp
parent6763d16387778f126ec510c0421783952602f8f7 (diff)
Initial population of CoreRT Runtime files.
Diffstat (limited to 'src/Native/Runtime/GCHelpers.cpp')
-rw-r--r--src/Native/Runtime/GCHelpers.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/Native/Runtime/GCHelpers.cpp b/src/Native/Runtime/GCHelpers.cpp
new file mode 100644
index 000000000..25b091ec3
--- /dev/null
+++ b/src/Native/Runtime/GCHelpers.cpp
@@ -0,0 +1,114 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+//
+// Unmanaged helpers exposed by the System.GC managed class.
+//
+
+#include "gcrhenv.h"
+#include "restrictedcallouts.h"
+
+COOP_PINVOKE_HELPER(void, RhSuppressFinalize, (OBJECTREF refObj))
+{
+ if (!refObj->get_EEType()->HasFinalizer())
+ return;
+
+ GCHeap::GetGCHeap()->SetFinalizationRun(refObj);
+}
+
+EXTERN_C REDHAWK_API void __cdecl RhWaitForPendingFinalizers(BOOL allowReentrantWait)
+{
+ // This must be called via p/invoke rather than RuntimeImport since it blocks and could starve the GC if
+ // called in cooperative mode.
+ ASSERT(!GetThread()->PreemptiveGCDisabled());
+
+ GCHeap::GetGCHeap()->FinalizerThreadWait(INFINITE, allowReentrantWait);
+}
+
+COOP_PINVOKE_HELPER(Int32, RhGetMaxGcGeneration, ())
+{
+ return GCHeap::GetGCHeap()->GetMaxGeneration();
+}
+
+COOP_PINVOKE_HELPER(Int32, RhGetGcCollectionCount, (Int32 generation, Boolean getSpecialGCCount))
+{
+ return GCHeap::GetGCHeap()->CollectionCount(generation, getSpecialGCCount);
+}
+
+COOP_PINVOKE_HELPER(Int32, RhGetGeneration, (OBJECTREF obj))
+{
+ return GCHeap::GetGCHeap()->WhichGeneration(obj);
+}
+
+COOP_PINVOKE_HELPER(void, RhReRegisterForFinalizeHelper, (OBJECTREF obj))
+{
+ if (obj->get_EEType()->HasFinalizer())
+ GCHeap::GetGCHeap()->RegisterForFinalization(-1, obj);
+}
+
+COOP_PINVOKE_HELPER(Int32, RhGetGcLatencyMode, ())
+{
+ return GCHeap::GetGCHeap()->GetGcLatencyMode();
+}
+
+COOP_PINVOKE_HELPER(void, RhSetGcLatencyMode, (Int32 newLatencyMode))
+{
+ GCHeap::GetGCHeap()->SetGcLatencyMode(newLatencyMode);
+}
+
+COOP_PINVOKE_HELPER(Boolean, RhIsServerGc, ())
+{
+ return GCHeap::IsServerHeap();
+}
+
+COOP_PINVOKE_HELPER(Int64, RhGetGcTotalMemoryHelper, ())
+{
+ return GCHeap::GetGCHeap()->GetTotalBytesInUse();
+}
+
+COOP_PINVOKE_HELPER(Boolean, RhRegisterGcCallout, (GcRestrictedCalloutKind eKind, void * pCallout))
+{
+ return RestrictedCallouts::RegisterGcCallout(eKind, pCallout);
+}
+
+COOP_PINVOKE_HELPER(void, RhUnregisterGcCallout, (GcRestrictedCalloutKind eKind, void * pCallout))
+{
+ RestrictedCallouts::UnregisterGcCallout(eKind, pCallout);
+}
+
+COOP_PINVOKE_HELPER(Boolean, RhIsPromoted, (OBJECTREF obj))
+{
+ return GCHeap::GetGCHeap()->IsPromoted(obj);
+}
+
+COOP_PINVOKE_HELPER(Int32, RhGetLohCompactionMode, ())
+{
+ return GCHeap::GetGCHeap()->GetLOHCompactionMode();
+}
+
+COOP_PINVOKE_HELPER(void, RhSetLohCompactionMode, (Int32 newLohCompactionMode))
+{
+ GCHeap::GetGCHeap()->SetLOHCompactionMode(newLohCompactionMode);
+}
+
+COOP_PINVOKE_HELPER(Int64, RhGetCurrentObjSize, ())
+{
+ return GCHeap::GetGCHeap()->GetCurrentObjSize();
+}
+
+COOP_PINVOKE_HELPER(Int64, RhGetGCNow, ())
+{
+ return GCHeap::GetGCHeap()->GetNow();
+}
+
+COOP_PINVOKE_HELPER(Int64, RhGetLastGCStartTime, (Int32 generation))
+{
+ return GCHeap::GetGCHeap()->GetLastGCStartTime(generation);
+}
+
+COOP_PINVOKE_HELPER(Int64, RhGetLastGCDuration, (Int32 generation))
+{
+ return GCHeap::GetGCHeap()->GetLastGCDuration(generation);
+}