summaryrefslogtreecommitdiff
path: root/src/gc
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-12-04 09:58:25 -0800
committerJan Kotas <jkotas@microsoft.com>2015-12-04 21:39:19 -0800
commit3b7689a032bea090ce3bd727d7f91fcab1913c44 (patch)
tree658b3409ca2fac7fdbbaac69e31023568f625906 /src/gc
parentc28fdd314ee4bdcaab02689cf47b0fb497b0bca2 (diff)
downloadcoreclr-3b7689a032bea090ce3bd727d7f91fcab1913c44.tar.gz
coreclr-3b7689a032bea090ce3bd727d7f91fcab1913c44.tar.bz2
coreclr-3b7689a032bea090ce3bd727d7f91fcab1913c44.zip
Update GC from CoreRT
https://github.com/dotnet/corert/tree/master/src/Native/gc 6fb4eecd513d3b3e1ae7584a22ece46107e98069
Diffstat (limited to 'src/gc')
-rw-r--r--src/gc/env/gcenv.object.h4
-rw-r--r--src/gc/gc.cpp102
-rw-r--r--src/gc/gcdesc.h4
-rw-r--r--src/gc/gcpriv.h32
-rw-r--r--src/gc/sample/CMakeLists.txt18
-rw-r--r--src/gc/sample/GCSample.cpp2
6 files changed, 86 insertions, 76 deletions
diff --git a/src/gc/env/gcenv.object.h b/src/gc/env/gcenv.object.h
index 0e1c248d2d..31dfe838dd 100644
--- a/src/gc/env/gcenv.object.h
+++ b/src/gc/env/gcenv.object.h
@@ -19,9 +19,9 @@
class ObjHeader
{
private:
-#if defined(_WIN64)
+#if defined(BIT64)
uint32_t m_uAlignpad;
-#endif // _WIN64
+#endif // BIT64
uint32_t m_uSyncBlockValue;
public:
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index 6ec0f6e25e..44450c0b1b 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -58,11 +58,11 @@ inline BOOL ShouldTrackMovementForProfilerOrEtw()
#define demotion_plug_len_th (6*1024*1024)
-#ifdef _WIN64
+#ifdef BIT64
#define MARK_STACK_INITIAL_LENGTH 1024
#else
#define MARK_STACK_INITIAL_LENGTH 128
-#endif //_WIN64
+#endif // BIT64
#define LOH_PIN_QUEUE_LENGTH 100
#define LOH_PIN_DECAY 10
@@ -2071,7 +2071,7 @@ uint8_t* gc_heap::pad_for_alignment_large (uint8_t* newAlloc, int requiredAlignm
#ifdef SERVER_GC
-#ifdef _WIN64
+#ifdef BIT64
#define INITIAL_ALLOC ((size_t)((size_t)4*1024*1024*1024))
#define LHEAP_ALLOC ((size_t)(1024*1024*256))
@@ -2081,11 +2081,11 @@ uint8_t* gc_heap::pad_for_alignment_large (uint8_t* newAlloc, int requiredAlignm
#define INITIAL_ALLOC ((size_t)(1024*1024*64))
#define LHEAP_ALLOC ((size_t)(1024*1024*32))
-#endif // _WIN64
+#endif // BIT64
#else //SERVER_GC
-#ifdef _WIN64
+#ifdef BIT64
#define INITIAL_ALLOC ((size_t)(1024*1024*256))
#define LHEAP_ALLOC ((size_t)(1024*1024*128))
@@ -2095,7 +2095,7 @@ uint8_t* gc_heap::pad_for_alignment_large (uint8_t* newAlloc, int requiredAlignm
#define INITIAL_ALLOC ((size_t)(1024*1024*16))
#define LHEAP_ALLOC ((size_t)(1024*1024*16))
-#endif // _WIN64
+#endif // BIT64
#endif //SERVER_GC
@@ -2299,7 +2299,7 @@ size_t gc_heap::gc_gen0_desired_high;
float gc_heap::short_plugs_pad_ratio = 0;
#endif //SHORT_PLUGS
-#if defined(_WIN64)
+#if defined(BIT64)
#define MAX_ALLOWED_MEM_LOAD 85
// consider putting this in dynamic data -
@@ -2314,7 +2314,7 @@ size_t gc_heap::mem_one_percent;
uint64_t gc_heap::total_physical_mem;
uint64_t gc_heap::available_physical_mem;
-#endif //_WIN64
+#endif // BIT64
#ifdef BACKGROUND_GC
CLREvent gc_heap::bgc_start_event;
@@ -3374,11 +3374,11 @@ size_t seg_mapping_word_of (uint8_t* add)
#else //GROWABLE_SEG_MAPPING_TABLE
BOOL seg_mapping_table_init()
{
-#ifdef _WIN64
+#ifdef BIT64
uint64_t total_address_space = (uint64_t)8*1024*1024*1024*1024;
#else
uint64_t total_address_space = (uint64_t)4*1024*1024*1024;
-#endif //_WIN64
+#endif // BIT64
size_t num_entries = (size_t)(total_address_space / gc_heap::min_segment_size);
seg_mapping_table = new seg_mapping[num_entries];
@@ -4293,9 +4293,9 @@ static size_t get_valid_segment_size (BOOL large_seg=FALSE)
}
#ifdef MULTIPLE_HEAPS
-#ifdef _WIN64
+#ifdef BIT64
if (!large_seg)
-#endif //_WIN64
+#endif // BIT64
{
if (g_SystemInfo.dwNumberOfProcessors > 4)
initial_seg_size /= 2;
@@ -5601,9 +5601,9 @@ void gc_mechanisms::init_mechanisms()
allocations_allowed = TRUE;
#endif //BACKGROUND_GC
-#ifdef _WIN64
+#ifdef BIT64
entry_memory_load = 0;
-#endif //_WIN64
+#endif // BIT64
#ifdef STRESS_HEAP
stress_induced = FALSE;
@@ -6969,11 +6969,11 @@ int gc_heap::grow_brick_card_tables (uint8_t* start,
top = saved_g_highest_address;
}
size_t ps = ha-la;
-#ifdef _WIN64
+#ifdef BIT64
if (ps > (uint64_t)200*1024*1024*1024)
ps += (uint64_t)100*1024*1024*1024;
else
-#endif //_WIN64
+#endif // BIT64
ps *= 2;
if (saved_g_lowest_address < g_lowest_address)
@@ -8129,11 +8129,11 @@ void gc_heap::combine_mark_lists()
#endif //MULTIPLE_HEAPS
#endif //MARK_LIST
-#ifdef _WIN64
+#ifdef BIT64
#define TOTAL_TIMES_TO_SHIFT 6
#else
#define TOTAL_TIMES_TO_SHIFT 5
-#endif // _WIN64
+#endif // BIT64
size_t round_up_power2 (size_t size)
{
@@ -14605,9 +14605,9 @@ int gc_heap::generation_to_condemn (int n_initial,
if (heap_number == 0)
{
-#ifdef _WIN64
+#ifdef BIT64
available_physical_mem = ms.ullAvailPhys;
-#endif //_WIN64
+#endif // BIT64
local_settings->entry_memory_load = ms.dwMemoryLoad;
}
@@ -14709,7 +14709,7 @@ int gc_heap::generation_to_condemn (int n_initial,
if (evaluate_elevation && (low_ephemeral_space || high_memory_load || v_high_memory_load))
{
*elevation_requested_p = TRUE;
-#ifdef _WIN64
+#ifdef BIT64
// if we are in high memory load and have consumed 10% of the gen2 budget, do a gen2 now.
if (high_memory_load || v_high_memory_load)
{
@@ -14725,7 +14725,7 @@ int gc_heap::generation_to_condemn (int n_initial,
if (n <= max_generation)
{
-#endif //_WIN64
+#endif // BIT64
if (high_fragmentation)
{
//elevate to max_generation
@@ -14756,9 +14756,9 @@ int gc_heap::generation_to_condemn (int n_initial,
n = max (n, max_generation - 1);
dprintf (GTC_LOG, ("h%d: nf c %d", heap_number, n));
}
-#ifdef _WIN64
+#ifdef BIT64
}
-#endif //_WIN64
+#endif // BIT64
}
if ((n == (max_generation - 1)) && (n_alloc < (max_generation -1)))
@@ -15488,10 +15488,10 @@ void gc_heap::gc1()
{
desired_per_heap = min_gc_size;
}
-#ifdef _WIN64
+#ifdef BIT64
desired_per_heap = joined_youngest_desired (desired_per_heap);
dprintf (2, ("final gen0 new_alloc: %Id", desired_per_heap));
-#endif //_WIN64
+#endif // BIT64
gc_data_global.final_youngest_desired = desired_per_heap;
}
@@ -20027,7 +20027,7 @@ size_t gc_heap::update_brick_table (uint8_t* tree, size_t current_brick,
void gc_heap::plan_generation_start (generation* gen, generation* consing_gen, uint8_t* next_plug_to_allocate)
{
-#ifdef _WIN64
+#ifdef BIT64
// We should never demote big plugs to gen0.
if (gen == youngest_generation)
{
@@ -20059,7 +20059,7 @@ void gc_heap::plan_generation_start (generation* gen, generation* consing_gen, u
mark_stack_large_bos++;
}
}
-#endif //_WIN64
+#endif // BIT64
generation_plan_allocation_start (gen) =
allocate_in_condemned_generations (consing_gen, Align (min_obj_size), -1);
@@ -22101,7 +22101,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
BOOL should_compact= FALSE;
ephemeral_promotion = FALSE;
-#ifdef _WIN64
+#ifdef BIT64
if ((!settings.concurrent) &&
((condemned_gen_number < max_generation) &&
((settings.gen0_reduction_count > 0) || (settings.entry_memory_load >= 95))))
@@ -22124,11 +22124,11 @@ void gc_heap::plan_phase (int condemned_gen_number)
}
else
{
-#endif //_WIN64
+#endif // BIT64
should_compact = decide_on_compacting (condemned_gen_number, fragmentation, should_expand);
-#ifdef _WIN64
+#ifdef BIT64
}
-#endif //_WIN64
+#endif // BIT64
#ifdef FEATURE_LOH_COMPACTION
loh_compacted_p = FALSE;
@@ -23030,7 +23030,7 @@ void gc_heap::make_unused_array (uint8_t* x, size_t size, BOOL clearp, BOOL rese
((CObjectHeader*)x)->SetFree(size);
-#ifdef _WIN64
+#ifdef BIT64
#if BIGENDIAN
#error "This won't work on big endian platforms"
@@ -23076,7 +23076,7 @@ void gc_heap::clear_unused_array (uint8_t* x, size_t size)
((CObjectHeader*)x)->UnsetFree();
-#ifdef _WIN64
+#ifdef BIT64
#if BIGENDIAN
#error "This won't work on big endian platforms"
@@ -29737,7 +29737,7 @@ void gc_heap::compute_promoted_allocation (int gen_number)
compute_in (gen_number);
}
-#ifdef _WIN64
+#ifdef BIT64
inline
size_t gc_heap::trim_youngest_desired (uint32_t memory_load,
size_t total_new_allocation,
@@ -29795,7 +29795,7 @@ size_t gc_heap::joined_youngest_desired (size_t new_allocation)
return final_new_allocation;
}
-#endif //_WIN64
+#endif // BIT64
inline
gc_history_per_heap* gc_heap::get_gc_data_per_heap()
@@ -29873,9 +29873,9 @@ void gc_heap::compute_new_dynamic_data (int gen_number)
{
dd_desired_allocation (dd) = higher_bound;
}
-#if defined (_WIN64) && !defined (MULTIPLE_HEAPS)
+#if defined (BIT64) && !defined (MULTIPLE_HEAPS)
dd_desired_allocation (dd) = joined_youngest_desired (dd_desired_allocation (dd));
-#endif //_WIN64 && !MULTIPLE_HEAPS
+#endif // BIT64 && !MULTIPLE_HEAPS
trim_youngest_desired_low_memory();
dprintf (2, ("final gen0 new_alloc: %Id", dd_desired_allocation (dd)));
}
@@ -29977,7 +29977,7 @@ void gc_heap::decommit_ephemeral_segment_pages()
if (settings.condemned_generation >= (max_generation-1))
{
size_t new_slack_space =
-#ifdef _WIN64
+#ifdef BIT64
max(min(min(get_valid_segment_size()/32, dd_max_size(dd)), (generation_size (max_generation) / 10)), dd_desired_allocation(dd));
#else
#ifdef FEATURE_CORECLR
@@ -29985,7 +29985,7 @@ void gc_heap::decommit_ephemeral_segment_pages()
#else
dd_max_size (dd);
#endif //FEATURE_CORECLR
-#endif //_WIN64
+#endif // BIT64
slack_space = min (slack_space, new_slack_space);
}
@@ -30165,9 +30165,9 @@ BOOL gc_heap::decide_on_compacting (int condemned_gen_number,
}
}
-#ifdef _WIN64
+#ifdef BIT64
BOOL high_memory = FALSE;
-#endif // _WIN64
+#endif // BIT64
if (!should_compact)
{
@@ -30193,7 +30193,7 @@ BOOL gc_heap::decide_on_compacting (int condemned_gen_number,
#endif // BACKGROUND_GC
}
-#ifdef _WIN64
+#ifdef BIT64
// check for high memory situation
if(!should_compact)
{
@@ -30224,7 +30224,7 @@ BOOL gc_heap::decide_on_compacting (int condemned_gen_number,
high_memory = TRUE;
}
}
-#endif // _WIN64
+#endif // BIT64
}
// The purpose of calling ensure_gap_allocation here is to make sure
@@ -30241,9 +30241,9 @@ BOOL gc_heap::decide_on_compacting (int condemned_gen_number,
{
//check the progress
if (
-#ifdef _WIN64
+#ifdef BIT64
(high_memory && !should_compact) ||
-#endif // _WIN64
+#endif // BIT64
generation_size (max_generation) <= generation_plan_size (max_generation))
{
dprintf (2, (" Elevation: gen2 size: %d, gen2 plan size: %d, no progress, elevation = locked",
@@ -30453,7 +30453,7 @@ CObjectHeader* gc_heap::allocate_large_object (size_t jsize, int64_t& alloc_byte
size_t maxObjectSize = (INT32_MAX - 7 - Align(min_obj_size));
-#ifdef _WIN64
+#ifdef BIT64
if (g_pConfig->GetGCAllowVeryLargeObjects())
{
maxObjectSize = (INT64_MAX - 7 - Align(min_obj_size));
@@ -33470,13 +33470,13 @@ HRESULT GCHeap::Initialize ()
if (hr != S_OK)
return hr;
-#if defined(_WIN64)
+#if defined(BIT64)
GCMemoryStatus ms;
GetProcessMemoryLoad (&ms);
gc_heap::total_physical_mem = ms.ullTotalPhys;
gc_heap::mem_one_percent = gc_heap::total_physical_mem / 100;
gc_heap::youngest_gen_desired_th = gc_heap::mem_one_percent;
-#endif // _WIN64
+#endif // BIT64
WaitForGCEvent = new (nothrow) CLREvent;
@@ -34626,7 +34626,7 @@ BOOL should_collect_optimized (dynamic_data* dd, BOOL low_memory_p)
HRESULT
GCHeap::GarbageCollect (int generation, BOOL low_memory_p, int mode)
{
-#if defined(_WIN64)
+#if defined(BIT64)
if (low_memory_p)
{
size_t total_allocated = 0;
@@ -34655,7 +34655,7 @@ GCHeap::GarbageCollect (int generation, BOOL low_memory_p, int mode)
return S_OK;
}
}
-#endif //_WIN64
+#endif // BIT64
#ifdef MULTIPLE_HEAPS
gc_heap* hpt = gc_heap::g_heaps[0];
diff --git a/src/gc/gcdesc.h b/src/gc/gcdesc.h
index e155576cae..c56a33c649 100644
--- a/src/gc/gcdesc.h
+++ b/src/gc/gcdesc.h
@@ -12,9 +12,9 @@
#ifndef _GCDESC_H_
#define _GCDESC_H_
-#ifdef _WIN64
+#ifdef BIT64
typedef uint32_t HALF_SIZE_T;
-#else // _WIN64
+#else // BIT64
typedef uint16_t HALF_SIZE_T;
#endif
diff --git a/src/gc/gcpriv.h b/src/gc/gcpriv.h
index c5d88c2d1f..78d4e93d7e 100644
--- a/src/gc/gcpriv.h
+++ b/src/gc/gcpriv.h
@@ -179,19 +179,19 @@ void GCLogConfig (const char *fmt, ... );
#ifdef SERVER_GC
-#ifdef _WIN64
+#ifdef BIT64
#define MAX_INDEX_POWER2 30
#else
#define MAX_INDEX_POWER2 26
-#endif // _WIN64
+#endif // BIT64
#else //SERVER_GC
-#ifdef _WIN64
+#ifdef BIT64
#define MAX_INDEX_POWER2 28
#else
#define MAX_INDEX_POWER2 24
-#endif // _WIN64
+#endif // BIT64
#endif //SERVER_GC
@@ -626,9 +626,9 @@ public:
bool stress_induced;
#endif // STRESS_HEAP
-#ifdef _WIN64
+#ifdef BIT64
uint32_t entry_memory_load;
-#endif //_WIN64
+#endif // BIT64
void store (gc_mechanisms* gm)
{
@@ -657,9 +657,9 @@ public:
stress_induced = (gm->stress_induced != 0);
#endif // STRESS_HEAP
-#ifdef _WIN64
+#ifdef BIT64
entry_memory_load = gm->entry_memory_load;
-#endif //_WIN64
+#endif // BIT64
}
};
@@ -2521,14 +2521,14 @@ protected:
PER_HEAP
void decommit_ephemeral_segment_pages();
-#ifdef _WIN64
+#ifdef BIT64
PER_HEAP_ISOLATED
size_t trim_youngest_desired (uint32_t memory_load,
size_t total_new_allocation,
size_t total_min_allocation);
PER_HEAP_ISOLATED
size_t joined_youngest_desired (size_t new_allocation);
-#endif //_WIN64
+#endif // BIT64
PER_HEAP_ISOLATED
size_t get_total_heap_size ();
PER_HEAP
@@ -2979,7 +2979,7 @@ public:
float short_plugs_pad_ratio;
#endif //SHORT_PLUGS
-#ifdef _WIN64
+#ifdef BIT64
PER_HEAP_ISOLATED
size_t youngest_gen_desired_th;
@@ -2991,7 +2991,7 @@ public:
PER_HEAP_ISOLATED
uint64_t available_physical_mem;
-#endif //_WIN64
+#endif // BIT64
PER_HEAP_ISOLATED
size_t last_gc_index;
@@ -3462,11 +3462,11 @@ protected:
alloc_list loh_alloc_list[NUM_LOH_ALIST-1];
#define NUM_GEN2_ALIST (12)
-#ifdef _WIN64
+#ifdef BIT64
#define BASE_GEN2_ALIST (1*256)
#else
#define BASE_GEN2_ALIST (1*128)
-#endif //_WIN64
+#endif // BIT64
PER_HEAP
alloc_list gen2_alloc_list[NUM_GEN2_ALIST-1];
@@ -4371,11 +4371,11 @@ extern "C" uint8_t* g_ephemeral_high;
// The value of card_size is determined empirically according to the average size of an object
// In the code we also rely on the assumption that one card_table entry (uint32_t) covers an entire os page
//
-#if defined (_WIN64)
+#if defined (BIT64)
#define card_size ((size_t)(2*OS_PAGE_SIZE/card_word_width))
#else
#define card_size ((size_t)(OS_PAGE_SIZE/card_word_width))
-#endif //_WIN64
+#endif // BIT64
inline
size_t card_word (size_t card)
diff --git a/src/gc/sample/CMakeLists.txt b/src/gc/sample/CMakeLists.txt
index 9a26c26cc4..8bed3adee2 100644
--- a/src/gc/sample/CMakeLists.txt
+++ b/src/gc/sample/CMakeLists.txt
@@ -34,20 +34,30 @@ endif()
if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
add_definitions(-D_TARGET_AMD64_=1)
- add_definitions(-D_WIN64=1)
+ set(IS_64BIT_BUILD 1)
elseif(CLR_CMAKE_PLATFORM_ARCH_I386)
add_definitions(-D_TARGET_X86_=1)
- add_definitions(-D_WIN32=1)
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
add_definitions(-D_TARGET_ARM_=1)
- add_definitions(-D_WIN32=1)
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
add_definitions(-D_TARGET_ARM64_=1)
- add_definitions(-D_WIN64=1)
+ set(IS_64BIT_BUILD 1)
else()
clr_unknown_arch()
endif()
+if(IS_64BIT_BUILD)
+ add_definitions(-DBIT64=1)
+endif(IS_64BIT_BUILD)
+
+if(WIN32)
+ add_definitions(-DWIN32)
+ add_definitions(-D_WIN32=1)
+ if(IS_64BIT_BUILD)
+ add_definitions(-D_WIN64=1)
+ endif()
+endif(WIN32)
+
add_executable(gcsample
${SOURCES}
)
diff --git a/src/gc/sample/GCSample.cpp b/src/gc/sample/GCSample.cpp
index 5a6e4900eb..7ae6c2d115 100644
--- a/src/gc/sample/GCSample.cpp
+++ b/src/gc/sample/GCSample.cpp
@@ -79,7 +79,7 @@ Object * AllocateObject(MethodTable * pMT)
return pObject;
}
-#if defined(_WIN64)
+#if defined(BIT64)
// Card byte shift is different on 64bit.
#define card_byte_shift 11
#else