summaryrefslogtreecommitdiff
path: root/src/gc
diff options
context:
space:
mode:
authorAditya Mandaleeka <adityam@microsoft.com>2017-03-23 16:23:05 -0700
committerAditya Mandaleeka <adityam@microsoft.com>2017-03-29 12:05:39 -0700
commit8d02c0786825a27d67fb2af150f751dbda360bef (patch)
treec702d97c98dbf10da04aa28e89f6a642898e261e /src/gc
parent066793782f1100b55cf092f50fa15d6901d6be75 (diff)
downloadcoreclr-8d02c0786825a27d67fb2af150f751dbda360bef.tar.gz
coreclr-8d02c0786825a27d67fb2af150f751dbda360bef.tar.bz2
coreclr-8d02c0786825a27d67fb2af150f751dbda360bef.zip
Create a GCHandleTable interface with Init/Shutdown.
Diffstat (limited to 'src/gc')
-rw-r--r--src/gc/CMakeLists.txt1
-rw-r--r--src/gc/gc.h5
-rw-r--r--src/gc/gccommon.cpp13
-rw-r--r--src/gc/gceesvr.cpp2
-rw-r--r--src/gc/gceewks.cpp1
-rw-r--r--src/gc/gchandletable.cpp24
-rw-r--r--src/gc/gchandletableimpl.h18
-rw-r--r--src/gc/gcinterface.h10
-rw-r--r--src/gc/sample/CMakeLists.txt1
-rw-r--r--src/gc/sample/GCSample.cpp15
10 files changed, 80 insertions, 10 deletions
diff --git a/src/gc/CMakeLists.txt b/src/gc/CMakeLists.txt
index cba1aa9778..59c18ffd87 100644
--- a/src/gc/CMakeLists.txt
+++ b/src/gc/CMakeLists.txt
@@ -31,6 +31,7 @@ set( GC_SOURCES_DAC_AND_WKS_COMMON
set( GC_SOURCES_WKS
${GC_SOURCES_DAC_AND_WKS_COMMON}
+ gchandletable.cpp
gceesvr.cpp
gceewks.cpp
handletablecache.cpp)
diff --git a/src/gc/gc.h b/src/gc/gc.h
index 478e8cdb99..ecb791f728 100644
--- a/src/gc/gc.h
+++ b/src/gc/gc.h
@@ -111,6 +111,8 @@ extern "C" uint32_t* g_gc_card_table;
extern "C" uint8_t* g_gc_lowest_address;
extern "C" uint8_t* g_gc_highest_address;
+::IGCHandleTable* CreateGCHandleTable();
+
namespace WKS {
::IGCHeapInternal* CreateGCHeap();
class GCHeap;
@@ -262,6 +264,9 @@ extern void FinalizeWeakReference(Object * obj);
// The single GC heap instance, shared with the VM.
extern IGCHeapInternal* g_theGCHeap;
+// The single GC handle table instance, shared with the VM.
+extern IGCHandleTable* g_theGCHandleTable;
+
#ifndef DACCESS_COMPILE
inline bool IsGCInProgress(bool bConsiderGCStart = false)
{
diff --git a/src/gc/gccommon.cpp b/src/gc/gccommon.cpp
index c1760515a6..8f6d1ac2be 100644
--- a/src/gc/gccommon.cpp
+++ b/src/gc/gccommon.cpp
@@ -21,6 +21,7 @@ SVAL_IMPL_INIT(uint32_t,IGCHeap,gcHeapType,IGCHeap::GC_HEAP_INVALID);
SVAL_IMPL_INIT(uint32_t,IGCHeap,maxGeneration,2);
IGCHeapInternal* g_theGCHeap;
+IGCHandleTable* g_theGCHandleTable;
#ifdef FEATURE_STANDALONE_GC
IGCToCLR* g_theGCToCLR;
@@ -145,7 +146,7 @@ namespace SVR
extern void PopulateDacVars(GcDacVars* dacVars);
}
-bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap** gcHeap, GcDacVars* gcDacVars)
+bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap** gcHeap, IGCHandleTable** gcHandleTable, GcDacVars* gcDacVars)
{
LIMITED_METHOD_CONTRACT;
@@ -153,6 +154,14 @@ bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap** gcHeap, GcDacVars*
assert(gcDacVars != nullptr);
assert(gcHeap != nullptr);
+ assert(gcHandleTable != nullptr);
+
+ IGCHandleTable* handleTable = CreateGCHandleTable();
+ if (handleTable == nullptr)
+ {
+ return false;
+ }
+
#ifdef FEATURE_SVR_GC
assert(IGCHeap::gcHeapType != IGCHeap::GC_HEAP_INVALID);
@@ -169,7 +178,6 @@ bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap** gcHeap, GcDacVars*
#else
heap = WKS::CreateGCHeap();
WKS::PopulateDacVars(gcDacVars);
-
#endif
if (heap == nullptr)
@@ -187,6 +195,7 @@ bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap** gcHeap, GcDacVars*
assert(clrToGC == nullptr);
#endif
+ *gcHandleTable = handleTable;
*gcHeap = heap;
return true;
}
diff --git a/src/gc/gceesvr.cpp b/src/gc/gceesvr.cpp
index aacae486f5..2e6dbe2d08 100644
--- a/src/gc/gceesvr.cpp
+++ b/src/gc/gceesvr.cpp
@@ -12,9 +12,11 @@
#include "gc.h"
#include "gcscan.h"
+#include "gchandletableimpl.h"
#define SERVER_GC 1
+
namespace SVR {
#include "gcimpl.h"
#include "gcee.cpp"
diff --git a/src/gc/gceewks.cpp b/src/gc/gceewks.cpp
index 72a7d3bdb9..f23038f012 100644
--- a/src/gc/gceewks.cpp
+++ b/src/gc/gceewks.cpp
@@ -10,6 +10,7 @@
#include "gc.h"
#include "gcscan.h"
+#include "gchandletableimpl.h"
#ifdef SERVER_GC
#undef SERVER_GC
diff --git a/src/gc/gchandletable.cpp b/src/gc/gchandletable.cpp
new file mode 100644
index 0000000000..a4c3352b86
--- /dev/null
+++ b/src/gc/gchandletable.cpp
@@ -0,0 +1,24 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+#include "common.h"
+#include "gcenv.h"
+#include "gchandletableimpl.h"
+#include "objecthandle.h"
+
+IGCHandleTable* CreateGCHandleTable()
+{
+ return new(nothrow) GCHandleTable();
+}
+
+bool GCHandleTable::Initialize()
+{
+ return Ref_Initialize();
+}
+
+void GCHandleTable::Shutdown()
+{
+ Ref_Shutdown();
+}
diff --git a/src/gc/gchandletableimpl.h b/src/gc/gchandletableimpl.h
new file mode 100644
index 0000000000..233e326a64
--- /dev/null
+++ b/src/gc/gchandletableimpl.h
@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+#ifndef GCHANDLETABLE_H_
+#define GCHANDLETABLE_H_
+
+#include "gcinterface.h"
+
+class GCHandleTable : public IGCHandleTable
+{
+public:
+ virtual bool Initialize();
+
+ virtual void Shutdown();
+};
+
+#endif // GCHANDLETABLE_H_
diff --git a/src/gc/gcinterface.h b/src/gc/gcinterface.h
index 7aae605633..77425b1cc3 100644
--- a/src/gc/gcinterface.h
+++ b/src/gc/gcinterface.h
@@ -171,11 +171,12 @@ struct segment_info
class Object;
class IGCHeap;
+class IGCHandleTable;
// Initializes the garbage collector. Should only be called
// once, during EE startup. Returns true if the initialization
// was successful, false otherwise.
-bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap **gcHeap, GcDacVars* gcDacVars);
+bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap** gcHeap, IGCHandleTable** gcHandleTable, GcDacVars* gcDacVars);
// The runtime needs to know whether we're using workstation or server GC
// long before the GCHeap is created. This function sets the type of
@@ -384,6 +385,13 @@ typedef void (* record_surv_fn)(uint8_t* begin, uint8_t* end, ptrdiff_t reloc, v
typedef void (* fq_walk_fn)(bool, void*);
typedef void (* fq_scan_fn)(Object** ppObject, ScanContext *pSC, uint32_t dwFlags);
typedef void (* handle_scan_fn)(Object** pRef, Object* pSec, uint32_t flags, ScanContext* context, bool isDependent);
+class IGCHandleTable {
+public:
+
+ virtual bool Initialize() = 0;
+
+ virtual void Shutdown() = 0;
+};
// IGCHeap is the interface that the VM will use when interacting with the GC.
class IGCHeap {
diff --git a/src/gc/sample/CMakeLists.txt b/src/gc/sample/CMakeLists.txt
index 29fd32f2ff..5fe7887963 100644
--- a/src/gc/sample/CMakeLists.txt
+++ b/src/gc/sample/CMakeLists.txt
@@ -10,6 +10,7 @@ set(SOURCES
gcenv.ee.cpp
../gccommon.cpp
../gceewks.cpp
+ ../gchandletable.cpp
../gcscan.cpp
../gcwks.cpp
../handletable.cpp
diff --git a/src/gc/sample/GCSample.cpp b/src/gc/sample/GCSample.cpp
index 2c32048bbb..5d5371c76e 100644
--- a/src/gc/sample/GCSample.cpp
+++ b/src/gc/sample/GCSample.cpp
@@ -126,17 +126,12 @@ int __cdecl main(int argc, char* argv[])
g_pFreeObjectMethodTable = &freeObjectMT;
//
- // Initialize handle table
- //
- if (!Ref_Initialize())
- return -1;
-
- //
// Initialize GC heap
//
GcDacVars dacVars;
IGCHeap *pGCHeap;
- if (!InitializeGarbageCollector(nullptr, &pGCHeap, &dacVars))
+ IGCHandleTable *pGCHandleTable;
+ if (!InitializeGarbageCollector(nullptr, &pGCHeap, &pGCHandleTable, &dacVars))
{
return -1;
}
@@ -145,6 +140,12 @@ int __cdecl main(int argc, char* argv[])
return -1;
//
+ // Initialize handle table
+ //
+ if (!pGCHandleTable->Initialize())
+ return -1;
+
+ //
// Initialize current thread
//
ThreadStore::AttachCurrentThread();