summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-12-03 13:48:29 -0800
committerJan Kotas <jkotas@microsoft.com>2015-12-03 13:48:29 -0800
commitfda07d5e1ef6c177a539a639f2b92473a35fc0be (patch)
treeb5f0b6fccd01e4e1f688939b447ff6a64e07905f /src
parentcfb1a0b47dd2e352413302755bca1c1d09e072d2 (diff)
downloadcoreclr-fda07d5e1ef6c177a539a639f2b92473a35fc0be.tar.gz
coreclr-fda07d5e1ef6c177a539a639f2b92473a35fc0be.tar.bz2
coreclr-fda07d5e1ef6c177a539a639f2b92473a35fc0be.zip
Update GC from CoreRT
https://github.com/dotnet/corert/tree/master/src/Native/gc 17232964a899c5403abbef1ab022f6d161f8b9ff
Diffstat (limited to 'src')
-rw-r--r--src/gc/env/gcenv.base.h76
-rw-r--r--src/gc/env/gcenv.structs.h80
-rw-r--r--src/gc/gc.cpp37
-rw-r--r--src/gc/handletable.cpp2
-rw-r--r--src/gc/handletable.h2
-rw-r--r--src/gc/objecthandle.cpp2
6 files changed, 114 insertions, 85 deletions
diff --git a/src/gc/env/gcenv.base.h b/src/gc/env/gcenv.base.h
index 72b74bd14d..57fbb0460b 100644
--- a/src/gc/env/gcenv.base.h
+++ b/src/gc/env/gcenv.base.h
@@ -32,6 +32,7 @@ typedef uint32_t BOOL;
typedef uint32_t DWORD;
typedef void* LPVOID;
typedef uint32_t UINT;
+typedef int32_t LONG;
typedef uintptr_t ULONG_PTR;
typedef void VOID;
typedef void* PVOID;
@@ -43,19 +44,6 @@ typedef size_t SIZE_T;
typedef void * HANDLE;
-typedef union _LARGE_INTEGER {
- struct {
-#if BIGENDIAN
- int32_t HighPart;
- uint32_t LowPart;
-#else
- uint32_t LowPart;
- int32_t HighPart;
-#endif
- } u;
- int64_t QuadPart;
-} LARGE_INTEGER, *PLARGE_INTEGER;
-
#define SIZE_T_MAX ((size_t)-1)
#define SSIZE_T_MAX ((ptrdiff_t)(SIZE_T_MAX / 2))
@@ -121,35 +109,6 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x)
#define sprintf_s snprintf
#endif
-#ifdef WIN32
-
-#pragma pack(push, 8)
-
-typedef struct _RTL_CRITICAL_SECTION {
- void* DebugInfo;
-
- //
- // The following three fields control entering and exiting the critical
- // section for the resource
- //
-
- int32_t LockCount;
- int32_t RecursionCount;
- HANDLE OwningThread; // from the thread's ClientId->UniqueThread
- HANDLE LockSemaphore;
- uintptr_t SpinCount; // force size on 64-bit systems when packed
-} CRITICAL_SECTION, RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
-
-#pragma pack(pop)
-
-#else
-
-typedef struct _RTL_CRITICAL_SECTION {
- pthread_mutex_t mutex;
-} CRITICAL_SECTION, RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
-
-#endif
-
#define WINBASEAPI extern "C"
#define WINAPI __stdcall
@@ -552,6 +511,18 @@ T VolatileLoad(T const * pt)
return val;
}
+template<typename T>
+inline
+T VolatileLoadWithoutBarrier(T const * pt)
+{
+#ifndef DACCESS_COMPILE
+ T val = *(T volatile const *)pt;
+#else
+ T val = *pt;
+#endif
+ return val;
+}
+
//
// VolatileStore stores a T into the target of a pointer to T. Is is guaranteed that this store will
// not be optimized away by the compiler, and that any operation that occurs before this store, in program
@@ -567,30 +538,9 @@ void VolatileStore(T* pt, T val)
*(T volatile *)pt = val;
}
-struct GCSystemInfo
-{
- DWORD dwNumberOfProcessors;
- DWORD dwPageSize;
- DWORD dwAllocationGranularity;
-};
-
extern GCSystemInfo g_SystemInfo;
void InitializeSystemInfo();
-// An 'abstract' definition of Windows MEMORYSTATUSEX. In practice, the only difference is the missing struct size
-// field and one field that Windows documents to always be 0. If additional information is available on other OSes,
-// this information should be surfaced through this structure as additional fields that the GC may optionally depend on.
-struct GCMemoryStatus
-{
- uint32_t dwMemoryLoad;
- uint64_t ullTotalPhys;
- uint64_t ullAvailPhys;
- uint64_t ullTotalPageFile;
- uint64_t ullAvailPageFile;
- uint64_t ullTotalVirtual;
- uint64_t ullAvailVirtual;
-};
-
void
GetProcessMemoryLoad(
GCMemoryStatus* lpBuffer);
diff --git a/src/gc/env/gcenv.structs.h b/src/gc/env/gcenv.structs.h
new file mode 100644
index 0000000000..e3bfb17f56
--- /dev/null
+++ b/src/gc/env/gcenv.structs.h
@@ -0,0 +1,80 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+#ifndef __GCENV_STRUCTS_INCLUDED__
+#define __GCENV_STRUCTS_INCLUDED__
+//
+// Structs shared between the GC and the environment
+//
+
+struct GCSystemInfo
+{
+ uint32_t dwNumberOfProcessors;
+ uint32_t dwPageSize;
+ uint32_t dwAllocationGranularity;
+};
+
+// An 'abstract' definition of Windows MEMORYSTATUSEX. In practice, the only difference is the missing struct size
+// field and one field that Windows documents to always be 0. If additional information is available on other OSes,
+// this information should be surfaced through this structure as additional fields that the GC may optionally depend on.
+struct GCMemoryStatus
+{
+ uint32_t dwMemoryLoad;
+ uint64_t ullTotalPhys;
+ uint64_t ullAvailPhys;
+ uint64_t ullTotalPageFile;
+ uint64_t ullAvailPageFile;
+ uint64_t ullTotalVirtual;
+ uint64_t ullAvailVirtual;
+};
+
+typedef void * HANDLE;
+
+#ifndef _INC_WINDOWS
+
+typedef union _LARGE_INTEGER {
+ struct {
+#if BIGENDIAN
+ int32_t HighPart;
+ uint32_t LowPart;
+#else
+ uint32_t LowPart;
+ int32_t HighPart;
+#endif
+ } u;
+ int64_t QuadPart;
+} LARGE_INTEGER, *PLARGE_INTEGER;
+
+#ifdef WIN32
+
+#pragma pack(push, 8)
+
+typedef struct _RTL_CRITICAL_SECTION {
+ void* DebugInfo;
+
+ //
+ // The following three fields control entering and exiting the critical
+ // section for the resource
+ //
+
+ int32_t LockCount;
+ int32_t RecursionCount;
+ HANDLE OwningThread; // from the thread's ClientId->UniqueThread
+ HANDLE LockSemaphore;
+ uintptr_t SpinCount; // force size on 64-bit systems when packed
+} CRITICAL_SECTION, RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
+
+#pragma pack(pop)
+
+#else
+
+typedef struct _RTL_CRITICAL_SECTION {
+ pthread_mutex_t mutex;
+} CRITICAL_SECTION, RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
+
+#endif
+
+#endif // _INC_WINDOWS
+
+#endif // __GCENV_STRUCTS_INCLUDED__
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index c341acd226..53e58f9189 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -3113,6 +3113,7 @@ in_range_for_segment(uint8_t* add, heap_segment* seg)
struct bk
{
uint8_t* add;
+ size_t val;
};
class sorted_table
@@ -3133,7 +3134,7 @@ public:
void delete_sorted_table();
void delete_old_slots();
void enqueue_old_slot(bk* sl);
- BOOL insure_space_for_insert();
+ BOOL ensure_space_for_insert();
};
sorted_table*
@@ -3199,7 +3200,7 @@ sorted_table::lookup (uint8_t*& add)
if ((ti > 0) && (buck[ti-1].add <= add))
{
add = buck[ti-1].add;
- return 0;
+ return buck[ti - 1].val;
}
high = mid - 1;
}
@@ -3208,7 +3209,7 @@ sorted_table::lookup (uint8_t*& add)
if (buck[ti+1].add > add)
{
add = buck[ti].add;
- return 0;
+ return buck[ti].val;
}
low = mid + 1;
}
@@ -3218,7 +3219,7 @@ sorted_table::lookup (uint8_t*& add)
}
BOOL
-sorted_table::insure_space_for_insert()
+sorted_table::ensure_space_for_insert()
{
if (count == size)
{
@@ -3242,8 +3243,6 @@ sorted_table::insure_space_for_insert()
BOOL
sorted_table::insert (uint8_t* add, size_t val)
{
- //val is ignored for non concurrent gc
- val = val;
//grow if no more room
assert (count < size);
@@ -3267,6 +3266,7 @@ sorted_table::insert (uint8_t* add, size_t val)
buck [k] = buck [k-1];
}
buck[ti].add = add;
+ buck[ti].val = val;
count++;
return TRUE;
}
@@ -3282,6 +3282,7 @@ sorted_table::insert (uint8_t* add, size_t val)
buck [k] = buck [k-1];
}
buck[ti+1].add = add;
+ buck[ti+1].val = val;
count++;
return TRUE;
}
@@ -3290,7 +3291,6 @@ sorted_table::insert (uint8_t* add, size_t val)
}
assert (0);
return TRUE;
-
}
void
@@ -3436,11 +3436,11 @@ void seg_mapping_table_remove_ro_segment (heap_segment* seg)
heap_segment* ro_segment_lookup (uint8_t* o)
{
- uint8_t* ro_seg = 0;
- gc_heap::seg_table->lookup (ro_seg);
+ uint8_t* ro_seg_start = o;
+ heap_segment* seg = (heap_segment*)gc_heap::seg_table->lookup (ro_seg_start);
- if (ro_seg && in_range_for_segment (o, (heap_segment*)ro_seg))
- return (heap_segment*)ro_seg;
+ if (ro_seg_start && in_range_for_segment (o, seg))
+ return seg;
else
return 0;
}
@@ -4549,7 +4549,7 @@ gc_heap::get_segment (size_t size, BOOL loh_p)
if (!result)
{
#ifndef SEG_MAPPING_TABLE
- if (!seg_table->insure_space_for_insert ())
+ if (!seg_table->ensure_space_for_insert ())
return 0;
#endif //SEG_MAPPING_TABLE
void* mem = virtual_alloc (size);
@@ -7435,10 +7435,10 @@ BOOL gc_heap::insert_ro_segment (heap_segment* seg)
{
enter_spin_lock (&gc_heap::gc_lock);
- if (!gc_heap::seg_table->insure_space_for_insert () ||
- (!(should_commit_mark_array() && commit_mark_array_new_seg (__this, seg))))
+ if (!gc_heap::seg_table->ensure_space_for_insert ()
+ || (should_commit_mark_array() && !commit_mark_array_new_seg(__this, seg)))
{
- leave_spin_lock (&gc_heap::gc_lock);
+ leave_spin_lock(&gc_heap::gc_lock);
return FALSE;
}
@@ -7448,8 +7448,7 @@ BOOL gc_heap::insert_ro_segment (heap_segment* seg)
heap_segment_next (seg) = oldhead;
generation_start_segment (gen2) = seg;
- ptrdiff_t sdelta = 0;
- seg_table->insert ((uint8_t*)seg, sdelta);
+ seg_table->insert (heap_segment_mem(seg), (size_t)seg);
#ifdef SEG_MAPPING_TABLE
seg_mapping_table_add_ro_segment (seg);
@@ -10152,7 +10151,7 @@ gc_heap::init_gc_heap (int h_number)
gc_done_event_set = false;
#ifndef SEG_MAPPING_TABLE
- if (!gc_heap::seg_table->insure_space_for_insert ())
+ if (!gc_heap::seg_table->ensure_space_for_insert ())
{
return 0;
}
@@ -10217,7 +10216,7 @@ gc_heap::init_gc_heap (int h_number)
ephemeral_heap_segment = seg;
#ifndef SEG_MAPPING_TABLE
- if (!gc_heap::seg_table->insure_space_for_insert ())
+ if (!gc_heap::seg_table->ensure_space_for_insert ())
{
return 0;
}
diff --git a/src/gc/handletable.cpp b/src/gc/handletable.cpp
index be415bccf1..e14316bd08 100644
--- a/src/gc/handletable.cpp
+++ b/src/gc/handletable.cpp
@@ -876,7 +876,7 @@ void HndWriteBarrier(OBJECTHANDLE handle, OBJECTREF objref)
*
*/
void HndEnumHandles(HHANDLETABLE hTable, const uint32_t *puType, uint32_t uTypeCount,
- HANDLESCANPROC pfnEnum, uintptr_t lParam1, uintptr_t lParam2, BOOL fAsync)
+ HANDLESCANPROC pfnEnum, uintptr_t lParam1, uintptr_t lParam2, bool fAsync)
{
WRAPPER_NO_CONTRACT;
diff --git a/src/gc/handletable.h b/src/gc/handletable.h
index 2c2786df65..f900bbd2d6 100644
--- a/src/gc/handletable.h
+++ b/src/gc/handletable.h
@@ -113,7 +113,7 @@ typedef void (CALLBACK *HANDLESCANPROC)(PTR_UNCHECKED_OBJECTREF pref, uintptr_t
* NON-GC handle enumeration
*/
void HndEnumHandles(HHANDLETABLE hTable, const uint32_t *puType, uint32_t uTypeCount,
- HANDLESCANPROC pfnEnum, uintptr_t lParam1, uintptr_t lParam2, BOOL fAsync);
+ HANDLESCANPROC pfnEnum, uintptr_t lParam1, uintptr_t lParam2, bool fAsync);
/*
* GC-time handle scanning
diff --git a/src/gc/objecthandle.cpp b/src/gc/objecthandle.cpp
index 23a8d2b2dc..8b72d0d430 100644
--- a/src/gc/objecthandle.cpp
+++ b/src/gc/objecthandle.cpp
@@ -1218,7 +1218,7 @@ void Ref_TraceRefCountHandles(HANDLESCANPROC callback, uintptr_t lParam1, uintpt
{
HHANDLETABLE hTable = walk->pBuckets[i]->pTable[j];
if (hTable)
- HndEnumHandles(hTable, &handleType, 1, callback, lParam1, lParam2, FALSE);
+ HndEnumHandles(hTable, &handleType, 1, callback, lParam1, lParam2, false);
}
}
}