summaryrefslogtreecommitdiff
path: root/src/gc
diff options
context:
space:
mode:
authorSean Gillespie <sean@swgillespie.me>2017-04-01 14:25:07 -0700
committerGitHub <noreply@github.com>2017-04-01 14:25:07 -0700
commited57233f4d26114d45b1293ced80a09f879f72cf (patch)
tree19eb9884c7cd1a5f51efd5e065042e44e14b6634 /src/gc
parent036ff00ad33e3bdd8f0eef7513af331eb841d5b9 (diff)
downloadcoreclr-ed57233f4d26114d45b1293ced80a09f879f72cf.tar.gz
coreclr-ed57233f4d26114d45b1293ced80a09f879f72cf.tar.bz2
coreclr-ed57233f4d26114d45b1293ced80a09f879f72cf.zip
[Local GC] Remove static fields from GC interface (#10566)
* Remove max_generation from GC interface * [Local GC] Clean up the GC interface by removing all static fields from it: 1) gcHeapType is replaced by g_heap_type (EE side) and g_gc_heap_type (GC side), each of which is set on initialization. g_heap_type is read by the DAC to determine what kind of heap is being used. 2) maxGeneration is not necessary due to the GC DAC changes. * Rebase against master * Comments and cleanup * Use a heap allocation instead of alloca * Code review feedback: remove a redundant cast and allocate generation count table once, on first use * Address code review feedback: cache some calls to GetMaxGeneration
Diffstat (limited to 'src/gc')
-rw-r--r--src/gc/gc.cpp5
-rw-r--r--src/gc/gc.h14
-rw-r--r--src/gc/gccommon.cpp16
-rw-r--r--src/gc/gcinterface.dac.h6
-rw-r--r--src/gc/gcinterface.dacvars.def1
-rw-r--r--src/gc/gcinterface.h22
6 files changed, 20 insertions, 44 deletions
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index 515069b7c2..d8a59cd5e4 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -36946,10 +36946,7 @@ void PopulateDacVars(GcDacVars *gcDacVars)
gcDacVars->build_variant = &g_build_variant;
gcDacVars->gc_structures_invalid_cnt = const_cast<int32_t*>(&GCScan::m_GcStructuresInvalidCnt);
gcDacVars->generation_size = sizeof(generation);
-#ifdef FEATURE_SVR_GC
- gcDacVars->gc_heap_type = &IGCHeap::gcHeapType;
-#endif // FEATURE_SVR_GC
- gcDacVars->max_gen = &IGCHeap::maxGeneration;
+ gcDacVars->max_gen = &g_max_generation;
#ifndef MULTIPLE_HEAPS
gcDacVars->mark_array = &gc_heap::mark_array;
gcDacVars->ephemeral_heap_segment = reinterpret_cast<dac_heap_segment**>(&gc_heap::ephemeral_heap_segment);
diff --git a/src/gc/gc.h b/src/gc/gc.h
index ecb791f728..821b21ddb8 100644
--- a/src/gc/gc.h
+++ b/src/gc/gc.h
@@ -87,6 +87,7 @@ class IGCHeapInternal;
/* misc defines */
#define LARGE_OBJECT_SIZE ((size_t)(85000))
+#define max_generation 2
#ifdef GC_CONFIG_DRIVEN
#define MAX_GLOBAL_GC_MECHANISMS_COUNT 6
@@ -110,6 +111,8 @@ extern "C" uint32_t* g_gc_card_bundle_table;
extern "C" uint32_t* g_gc_card_table;
extern "C" uint8_t* g_gc_lowest_address;
extern "C" uint8_t* g_gc_highest_address;
+extern "C" GCHeapType g_gc_heap_type;
+extern "C" uint32_t g_max_generation;
::IGCHandleTable* CreateGCHandleTable();
@@ -219,7 +222,7 @@ public:
unsigned GetMaxGeneration()
{
- return IGCHeap::maxGeneration;
+ return max_generation;
}
bool IsValidSegmentSize(size_t cbSize)
@@ -235,8 +238,6 @@ public:
BOOL IsLargeObject(MethodTable *mt)
{
- WRAPPER_NO_CONTRACT;
-
return mt->GetBaseSize() >= LARGE_OBJECT_SIZE;
}
@@ -270,18 +271,15 @@ extern IGCHandleTable* g_theGCHandleTable;
#ifndef DACCESS_COMPILE
inline bool IsGCInProgress(bool bConsiderGCStart = false)
{
- WRAPPER_NO_CONTRACT;
-
return g_theGCHeap != nullptr ? g_theGCHeap->IsGCInProgressHelper(bConsiderGCStart) : false;
}
#endif // DACCESS_COMPILE
inline bool IsServerHeap()
{
- LIMITED_METHOD_CONTRACT;
#ifdef FEATURE_SVR_GC
- _ASSERTE(IGCHeap::gcHeapType != IGCHeap::GC_HEAP_INVALID);
- return (IGCHeap::gcHeapType == IGCHeap::GC_HEAP_SVR);
+ assert(g_gc_heap_type != GC_HEAP_INVALID);
+ return g_gc_heap_type == GC_HEAP_SVR;
#else // FEATURE_SVR_GC
return false;
#endif // FEATURE_SVR_GC
diff --git a/src/gc/gccommon.cpp b/src/gc/gccommon.cpp
index 8f6d1ac2be..1cd3c824ac 100644
--- a/src/gc/gccommon.cpp
+++ b/src/gc/gccommon.cpp
@@ -14,12 +14,6 @@
#include "gcenv.h"
#include "gc.h"
-#ifdef FEATURE_SVR_GC
-SVAL_IMPL_INIT(uint32_t,IGCHeap,gcHeapType,IGCHeap::GC_HEAP_INVALID);
-#endif // FEATURE_SVR_GC
-
-SVAL_IMPL_INIT(uint32_t,IGCHeap,maxGeneration,2);
-
IGCHeapInternal* g_theGCHeap;
IGCHandleTable* g_theGCHandleTable;
@@ -47,6 +41,8 @@ uint32_t* g_gc_card_bundle_table;
uint8_t* g_gc_lowest_address = 0;
uint8_t* g_gc_highest_address = 0;
+GCHeapType g_gc_heap_type = GC_HEAP_INVALID;
+uint32_t g_max_generation = max_generation;
#ifdef GC_CONFIG_DRIVEN
void record_global_mechanism (int mech_index)
@@ -122,9 +118,9 @@ void InitializeHeapType(bool bServerHeap)
{
LIMITED_METHOD_CONTRACT;
#ifdef FEATURE_SVR_GC
- IGCHeap::gcHeapType = bServerHeap ? IGCHeap::GC_HEAP_SVR : IGCHeap::GC_HEAP_WKS;
+ g_gc_heap_type = bServerHeap ? GC_HEAP_SVR : GC_HEAP_WKS;
#ifdef WRITE_BARRIER_CHECK
- if (IGCHeap::gcHeapType == IGCHeap::GC_HEAP_SVR)
+ if (g_gc_heap_type == GC_HEAP_SVR)
{
g_GCShadow = 0;
g_GCShadowEnd = 0;
@@ -163,9 +159,9 @@ bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap** gcHeap, IGCHandleTa
}
#ifdef FEATURE_SVR_GC
- assert(IGCHeap::gcHeapType != IGCHeap::GC_HEAP_INVALID);
+ assert(g_gc_heap_type != GC_HEAP_INVALID);
- if (IGCHeap::gcHeapType == IGCHeap::GC_HEAP_SVR)
+ if (g_gc_heap_type == GC_HEAP_SVR)
{
heap = SVR::CreateGCHeap();
SVR::PopulateDacVars(gcDacVars);
diff --git a/src/gc/gcinterface.dac.h b/src/gc/gcinterface.dac.h
index 84c8ffb36a..647101fa1f 100644
--- a/src/gc/gcinterface.dac.h
+++ b/src/gc/gcinterface.dac.h
@@ -18,12 +18,6 @@
#define MAX_GLOBAL_GC_MECHANISMS_COUNT 6
#define NUMBERGENERATIONS 4
-// TODO(segilles) - Implement this scheme for Server GC
-namespace SVR {
- class heap_segment;
- class gc_heap;
-}
-
// Analogue for the GC heap_segment class, containing information regarding a single
// heap segment.
class dac_heap_segment {
diff --git a/src/gc/gcinterface.dacvars.def b/src/gc/gcinterface.dacvars.def
index f9c2078ee3..b788079dcb 100644
--- a/src/gc/gcinterface.dacvars.def
+++ b/src/gc/gcinterface.dacvars.def
@@ -38,7 +38,6 @@ GC_DAC_VAR (uint8_t, build_variant)
GC_DAC_VAR (bool, built_with_svr)
GC_DAC_ARRAY_VAR (size_t, gc_global_mechanisms)
GC_DAC_ARRAY_VAR (dac_generation, generation_table)
-GC_DAC_VAR (uint32_t, gc_heap_type)
GC_DAC_VAR (uint32_t, max_gen)
GC_DAC_PTR_VAR (uint32_t, mark_array)
GC_DAC_VAR (c_gc_state, current_c_gc_state)
diff --git a/src/gc/gcinterface.h b/src/gc/gcinterface.h
index b5a9e0e8f9..66d8b31a53 100644
--- a/src/gc/gcinterface.h
+++ b/src/gc/gcinterface.h
@@ -163,8 +163,6 @@ struct segment_info
// one for the object header, and one for the first field in the object.
#define min_obj_size ((sizeof(uint8_t*) + sizeof(uintptr_t) + sizeof(size_t)))
-#define max_generation 2
-
// The bit shift used to convert a memory address into an index into the
// Software Write Watch table.
#define SOFTWARE_WRITE_WATCH_AddressToTableByteIndexShift 0xc
@@ -379,6 +377,13 @@ typedef enum
HNDTYPE_WEAK_WINRT = 9
} HandleType;
+typedef enum
+{
+ GC_HEAP_INVALID = 0,
+ GC_HEAP_WKS = 1,
+ GC_HEAP_SVR = 2
+} GCHeapType;
+
typedef bool (* walk_fn)(Object*, void*);
typedef void (* gen_walk_fn)(void* context, int generation, uint8_t* range_start, uint8_t* range_end, uint8_t* range_reserved);
typedef void (* record_surv_fn)(uint8_t* begin, uint8_t* end, ptrdiff_t reloc, void* context, bool compacting_p, bool bgc_p);
@@ -729,19 +734,6 @@ public:
IGCHeap() {}
virtual ~IGCHeap() {}
-
- typedef enum
- {
- GC_HEAP_INVALID = 0,
- GC_HEAP_WKS = 1,
- GC_HEAP_SVR = 2
- } GC_HEAP_TYPE;
-
-#ifdef FEATURE_SVR_GC
- SVAL_DECL(uint32_t, gcHeapType);
-#endif
-
- SVAL_DECL(uint32_t, maxGeneration);
};
#ifdef WRITE_BARRIER_CHECK