Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Update GC from dotnet/runtime #8059

Merged
merged 40 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
316242f
Parenthesize macros (dotnet/coreclr#23982)
Oct 1, 2019
474d75a
oom (dotnet/coreclr#26457)
Maoni0 Oct 1, 2019
4addfee
BGC tuning using the free list with PI loops (dotnet/coreclr#26695)
Maoni0 Oct 23, 2019
8c2caeb
Card mark steal (dotnet/coreclr#25986)
PeterSolMS Oct 23, 2019
e39f88b
Use half-fences for volatile loads/stores on Windows ARM64 (dotnet/co…
VSadov Oct 25, 2019
9a47dec
Delete null comparisons of non-null arguments (dotnet/coreclr#27523)
am11 Oct 29, 2019
33106f4
Fix available memory extraction on Linux (dotnet/coreclr#26764)
janvorli Sep 24, 2019
0297745
Normalize trailing whitespaces (dotnet/coreclr#27626)
jkotas Nov 2, 2019
bd767af
Suspension fixes (dotnet/coreclr#27578)
PeterSolMS Nov 4, 2019
d003e6a
Change m_fPreemptiveGCDisabled to bool (dotnet/coreclr#27648)
Nov 4, 2019
fd77a4d
Fixing an assert in card stealing. (dotnet/coreclr#27822)
VSadov Nov 12, 2019
01f6945
Bgc suspension fixes (dotnet/coreclr#27729)
PeterSolMS Nov 13, 2019
c40be81
ARM32 compilation fixes with GCC (dotnet/coreclr#27795)
franksinankaya Nov 13, 2019
ab9dadf
Unifying the type used for number of heaps/locks/threads (dotnet/core…
VSadov Nov 14, 2019
d160342
fix volatile float/double on win-arm64 (make sure compiler does not d…
VSadov Nov 20, 2019
d7973ec
Fix getting affinity set on MUSL on Jetson TX2 (#206)
janvorli Nov 22, 2019
f4862f4
Fix named cgroup handling in docker (#980)
janvorli Dec 18, 2019
fbe60a3
Delete strong name cruft (#1006)
jkotas Dec 18, 2019
3f699f3
Fix GC heap corruption on ARM. (#1389)
AntonLapounov Jan 8, 2020
009bd50
gc, pal: Avoid linking libnuma.so on non-NUMA systems (#1468)
lpereira Jan 11, 2020
1aa2ac1
Enable TRACE_GC for the whole gc.cpp (#1604)
cshung Jan 11, 2020
b1d5074
Review large alignment code in GC (#1351)
AntonLapounov Jan 17, 2020
57ec05b
Flush GC log on shutdown (#1721)
cshung Jan 17, 2020
1e20749
Remove unwanted instrumentation code (#1820)
cshung Jan 21, 2020
1c7c5ab
Remove gc_lh_block_event (#2059)
cshung Jan 23, 2020
fbe045f
fixed few races when setting or clearing card bundle bits (#2132)
VSadov Jan 24, 2020
38697e9
Allow allocating large object from free list while background sweepin…
cshung Jan 28, 2020
42903d7
Refactor handling of non-SOH generations (#1688)
VSadov Jan 29, 2020
d698117
Configure Host OS APIs based on HOST macros (#31774)
sdmaclea Feb 6, 2020
f79ca50
Always fire join events for an rjoin (#651)
Feb 7, 2020
b20fffb
Add assert to Unix GCToOSInterface::GetCurrentProcessorNumber for cla…
jkotas Feb 11, 2020
ef4d022
Introducing Pinned Object Heap (#32283)
VSadov Feb 17, 2020
28c2426
Fix verify_heap to handle > 1 UOH generations (#32586)
VSadov Feb 20, 2020
6ce2c64
Fix build without FEATURE_EVENT_TRACE (#32746)
am11 Feb 25, 2020
5bef37c
Remove `AllocLHeap`. (#33402)
VSadov Mar 11, 2020
ce26e4b
Replace manually managed TLS slots with regular thread_local statics …
jkotas Mar 16, 2020
0ba4114
Fix native components build for Android (#32800)
am11 Mar 17, 2020
6458d3b
Adding public API for Pinned Object Heap allocations (#33526)
VSadov Mar 18, 2020
2614623
Fix build break with latest VS preview (#33996)
jkotas Mar 24, 2020
eafb87c
Fix wrong assert in cgroups code (#34291)
janvorli Mar 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Native/Runtime/GCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ COOP_PINVOKE_HELPER(Int64, RhGetAllocatedBytesForCurrentThread, ())
{
Thread *pThread = ThreadStore::GetCurrentThread();
gc_alloc_context *ac = pThread->GetAllocContext();
Int64 currentAllocated = ac->alloc_bytes + ac->alloc_bytes_loh - (ac->alloc_limit - ac->alloc_ptr);
Int64 currentAllocated = ac->alloc_bytes + ac->alloc_bytes_uoh - (ac->alloc_limit - ac->alloc_ptr);
return currentAllocated;
}

Expand Down Expand Up @@ -336,10 +336,14 @@ static Array* AllocateUninitializedArrayImpl(Thread* pThread, EEType* pArrayEETy
}
}

UInt32 uFlags = GC_ALLOC_ZEROING_OPTIONAL;
if (size > RH_LARGE_OBJECT_SIZE)
uFlags |= GC_ALLOC_LARGE_OBJECT_HEAP;

// Save the EEType for instrumentation purposes.
RedhawkGCInterface::SetLastAllocEEType(pArrayEEType);

Array* pArray = (Array*)GCHeapUtilities::GetGCHeap()->Alloc(pThread->GetAllocContext(), size, GC_ALLOC_ZEROING_OPTIONAL);
Array* pArray = (Array*)GCHeapUtilities::GetGCHeap()->Alloc(pThread->GetAllocContext(), size, uFlags);
if (pArray == NULL)
{
return NULL;
Expand Down
11 changes: 4 additions & 7 deletions src/Native/Runtime/gcrhenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,13 @@ COOP_PINVOKE_HELPER(void*, RhpGcAlloc, (EEType *pEEType, UInt32 uFlags, UIntNati
}
}

if (cbSize > RH_LARGE_OBJECT_SIZE)
uFlags |= GC_ALLOC_LARGE_OBJECT_HEAP;

// Save the EEType for instrumentation purposes.
RedhawkGCInterface::SetLastAllocEEType(pEEType);

Object * pObject;
#ifdef FEATURE_64BIT_ALIGNMENT
if (uFlags & GC_ALLOC_ALIGN8)
pObject = GCHeapUtilities::GetGCHeap()->AllocAlign8(pThread->GetAllocContext(), cbSize, uFlags);
else
#endif // FEATURE_64BIT_ALIGNMENT
pObject = GCHeapUtilities::GetGCHeap()->Alloc(pThread->GetAllocContext(), cbSize, uFlags);
Object * pObject = GCHeapUtilities::GetGCHeap()->Alloc(pThread->GetAllocContext(), cbSize, uFlags);

// NOTE: we cannot call PublishObject here because the object isn't initialized!

Expand Down
8 changes: 0 additions & 8 deletions src/Native/Runtime/gctoclreventsink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,12 @@ void GCToCLREventSink::FireGCFullNotify_V1(uint32_t genNumber, uint32_t isAlloc)

void GCToCLREventSink::FireSetGCHandle(void* handleID, void* objectID, uint32_t kind, uint32_t generation)
{
#ifdef _WIN32
FireEtwSetGCHandle(handleID, objectID, kind, generation, -1, GetClrInstanceId());
#else // _WIN32
FireEtwSetGCHandle(handleID, objectID, kind, generation, GetClrInstanceId());
#endif // _WIN32
}

void GCToCLREventSink::FirePrvSetGCHandle(void* handleID, void* objectID, uint32_t kind, uint32_t generation)
{
#ifdef _WIN32
FireEtwPrvSetGCHandle(handleID, objectID, kind, generation, -1, GetClrInstanceId());
#else // _WIN32
FireEtwPrvSetGCHandle(handleID, objectID, kind, generation, GetClrInstanceId());
#endif // _WIN32
}

void GCToCLREventSink::FireDestroyGCHandle(void *handleID)
Expand Down
1 change: 1 addition & 0 deletions src/Native/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include(CheckFunctionExists)
include(CheckStructHasMember)
include(CheckCXXSourceCompiles)
include(CheckCXXSourceRuns)
include(CheckCXXSymbolExists)

add_compile_options(-I${CMAKE_CURRENT_SOURCE_DIR}/Common)

Expand Down
14 changes: 12 additions & 2 deletions src/Native/gc/env/etmdummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#define FireEtwGCMarkHandles(HeapNum, ClrInstanceID) 0
#define FireEtwGCMarkOlderGenerationRoots(HeapNum, ClrInstanceID) 0
#define FireEtwFinalizeObject(TypeID, ObjectID, ClrInstanceID) 0
#define FireEtwSetGCHandle(HandleID, ObjectID, Kind, Generation, ClrInstanceID) 0
#define FireEtwSetGCHandle(HandleID, ObjectID, Kind, Generation, DomainAddr, ClrInstanceID) 0
#define FireEtwDestroyGCHandle(HandleID, ClrInstanceID) 0
#define FireEtwGCSampledObjectAllocationLow(Address, TypeID, ObjectCountForTypeSample, TotalSizeForTypeSample, ClrInstanceID) 0
#define FireEtwPinObjectAtGCTime(HandleID, ObjectID, ObjectSize, TypeName, ClrInstanceID) 0
Expand Down Expand Up @@ -376,7 +376,7 @@
#define FireEtwFailFast(FailFastUserMessage, FailedEIP, OSExitCode, ClrExitCode, ClrInstanceID) 0
#define FireEtwPrvFinalizeObject(TypeID, ObjectID, ClrInstanceID, TypeName) 0
#define FireEtwCCWRefCountChange(HandleID, ObjectID, COMInterfacePointer, NewRefCount, AppDomainID, ClassName, NameSpace, Operation, ClrInstanceID) 0
#define FireEtwPrvSetGCHandle(HandleID, ObjectID, Kind, Generation, ClrInstanceID) 0
#define FireEtwPrvSetGCHandle(HandleID, ObjectID, Kind, Generation, DomainAddr, ClrInstanceId) 0
#define FireEtwPrvDestroyGCHandle(HandleID, ClrInstanceID) 0
#define FireEtwFusionMessageEvent(ClrInstanceID, Prepend, Message) 0
#define FireEtwFusionErrorCodeEvent(ClrInstanceID, Category, ErrorCode) 0
Expand All @@ -398,3 +398,13 @@
#define FireEtwBeginCreateManagedReference(ClrInstanceID) 0
#define FireEtwEndCreateManagedReference(ClrInstanceID) 0
#define FireEtwObjectVariantMarshallingToManaged(TypeName, Int1, ClrInstanceID) 0
#define FireEtwGCDynamicEvent(EventName, PayloadSize, Payload, ClrInstanceId) 0
#define FireEtwBGC1stSweepEnd(GenNumber, ClrInstanceId) 0
#define FireEtwResolutionAttempted(ClrInstanceId, asmName, stage, assemblyLoadContextName, result, resultAsmName, resultAsmPath, errMsg) 0
#define FireEtwResolutionAttempted(ClrInstanceId, asmName, event, alcName, result, resultAsmName, resultAsmPath, errMsg) 0
#define FireEtwKnownPathProbed(ClrInstanceId, path, source, hr) 0
#define FireEtwContentionStop_V1(managedContention, ClrInstanceId, elapsedTimeInNanosecond) 0
#define FireEtwAssemblyLoadContextResolvingHandlerInvoked(ClrInstanceId, assemblyName, handlerName, alcName, resultAssemblyName, resultAssemblyPath) 0
#define FireEtwAppDomainAssemblyResolveHandlerInvoked(ClrInstanceId, assemblyName, handlerName, resultAssemblyName, resultAssemblyPath) 0
#define FireEtwAssemblyLoadFromResolveHandlerInvoked(ClrInstanceId, assemblyName, isTrackedAssembly, requestingAssemblyPath, requestedAssemblyPath) 0
#define FireEtwEventSource(eventID, eventName, eventSourceName, payload) 0
20 changes: 12 additions & 8 deletions src/Native/gc/env/gcenv.base.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
#define NOINLINE __declspec(noinline)
#endif // _MSC_VER

#ifdef _MSC_VER
#define __UNREACHABLE() __assume(0)
#else
#define __UNREACHABLE() __builtin_unreachable()
#endif

#ifndef SIZE_T_MAX
#define SIZE_T_MAX ((size_t)-1)
#endif
Expand Down Expand Up @@ -128,7 +134,7 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter);
#define WAIT_TIMEOUT 258
#define WAIT_FAILED 0xFFFFFFFF

#if defined(_MSC_VER)
#if defined(_MSC_VER)
#if defined(_ARM_)

__forceinline void YieldProcessor() { }
Expand All @@ -147,25 +153,25 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter);
#define MemoryBarrier() { __dmb(_ARM64_BARRIER_SY); }

#elif defined(_AMD64_)

extern "C" void
_mm_pause (
void
);

extern "C" void
_mm_mfence (
void
);

#pragma intrinsic(_mm_pause)
#pragma intrinsic(_mm_mfence)

#define YieldProcessor _mm_pause
#define MemoryBarrier _mm_mfence

#elif defined(_X86_)

#define YieldProcessor() __asm { rep nop }
#define MemoryBarrier() MemoryBarrierImpl()
__forceinline void MemoryBarrierImpl()
Expand Down Expand Up @@ -272,7 +278,7 @@ inline uint8_t BitScanForward64(uint32_t *bitIndex, uint64_t mask)
uint32_t hi = (mask >> 32) & 0xFFFFFFFF;
uint32_t lo = mask & 0xFFFFFFFF;
uint32_t fakeBitIndex = 0;

uint8_t result = BitScanForward(bitIndex, lo);
if (result == 0)
{
Expand Down Expand Up @@ -509,8 +515,6 @@ inline bool dbgOnly_IsSpecialEEThread()
return false;
}

#define ClrFlsSetThreadType(type)

//
// Performance logging
//
Expand Down
10 changes: 5 additions & 5 deletions src/Native/gc/env/gcenv.ee.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ class GCToEEInterface
static void SuspendEE(SUSPEND_REASON reason);
static void RestartEE(bool bFinishedGC); //resume threads.

//
//
// The GC roots enumeration callback
//
static void GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc);

//
//
// Callbacks issues during GC that the execution engine can do its own bookeeping
//

// start of GC call back - single threaded
static void GcStartWork(int condemned, int max_gen);
static void GcStartWork(int condemned, int max_gen);

//EE can perform post stack scanning action, while the
// user threads are still suspended
//EE can perform post stack scanning action, while the
// user threads are still suspended
static void AfterGcScanRoots(int condemned, int max_gen, ScanContext* sc);

// Called before BGC starts sweeping, the heap is walkable
Expand Down
6 changes: 3 additions & 3 deletions src/Native/gc/env/gcenv.interlocked.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Interlocked
template<typename T>
static void Or(T volatile *destination, T value);

// Set a 32-bit variable to the specified value as an atomic operation.
// Set a 32-bit variable to the specified value as an atomic operation.
// Parameters:
// destination - value to be exchanged
// value - value to set the destination to
Expand Down Expand Up @@ -84,7 +84,7 @@ class Interlocked
template<typename T>
static T ExchangeAddPtr(T volatile* addend, T value);

// Performs an atomic compare-and-exchange operation on the specified values.
// Performs an atomic compare-and-exchange operation on the specified values.
// Parameters:
// destination - value to be exchanged
// exchange - value to set the destination to
Expand All @@ -95,7 +95,7 @@ class Interlocked
template<typename T>
static T CompareExchange(T volatile *destination, T exchange, T comparand);

// Performs an atomic compare-and-exchange operation on the specified pointers.
// Performs an atomic compare-and-exchange operation on the specified pointers.
// Parameters:
// destination - value to be exchanged
// exchange - value to set the destination to
Expand Down
6 changes: 3 additions & 3 deletions src/Native/gc/env/gcenv.interlocked.inl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ __forceinline T Interlocked::Decrement(T volatile *addend)
#endif
}

// Set a 32-bit variable to the specified value as an atomic operation.
// Set a 32-bit variable to the specified value as an atomic operation.
// Parameters:
// destination - value to be exchanged
// value - value to set the destination to
Expand All @@ -76,7 +76,7 @@ __forceinline T Interlocked::Exchange(T volatile *destination, T value)
#endif
}

// Performs an atomic compare-and-exchange operation on the specified values.
// Performs an atomic compare-and-exchange operation on the specified values.
// Parameters:
// destination - value to be exchanged
// exchange - value to set the destinaton to
Expand Down Expand Up @@ -217,7 +217,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, std::null
#endif
}

// Performs an atomic compare-and-exchange operation on the specified pointers.
// Performs an atomic compare-and-exchange operation on the specified pointers.
// Parameters:
// destination - value to be exchanged
// exchange - value to set the destinaton to
Expand Down
8 changes: 4 additions & 4 deletions src/Native/gc/env/gcenv.object.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class MethodTable

bool HasComponentSize()
{
// Note that we can't just check m_componentSize != 0 here. The VM
// may still construct a method table that does not have a component
// size, according to this method, but still has a number in the low
// Note that we can't just check m_componentSize != 0 here. The VM
// may still construct a method table that does not have a component
// size, according to this method, but still has a number in the low
// 16 bits of the method table flags parameter.
//
// The solution here is to do what the VM does and check the
Expand Down Expand Up @@ -130,7 +130,7 @@ class Object

public:
ObjHeader * GetHeader()
{
{
return ((ObjHeader *)this) - 1;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Native/gc/env/gcenv.os.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class GCToOSInterface
// true if it has succeeded, false if it has failed
static bool VirtualDecommit(void *address, size_t size);

// Reset virtual memory range. Indicates that data in the memory range specified by address and size is no
// Reset virtual memory range. Indicates that data in the memory range specified by address and size is no
// longer of interest, but it should not be decommitted.
// Parameters:
// address - starting virtual address
Expand Down Expand Up @@ -368,7 +368,7 @@ class GCToOSInterface
// Get numeric id of the current thread if possible on the
// current platform. It is indended for logging purposes only.
// Return:
// Numeric id of the current thread or 0 if the
// Numeric id of the current thread or 0 if the
static uint64_t GetCurrentThreadIdForLogging();

// Get id of the current process
Expand Down Expand Up @@ -431,10 +431,10 @@ class GCToOSInterface
// non zero if it has succeeded, 0 if it has failed
// *is_restricted is set to true if asked and running in restricted.
// Remarks:
// If a process runs with a restricted memory limit, it returns the limit. If there's no limit
// If a process runs with a restricted memory limit, it returns the limit. If there's no limit
// specified, it returns amount of actual physical memory.
//
// PERF TODO: Requires more work to not treat the restricted case to be special.
// PERF TODO: Requires more work to not treat the restricted case to be special.
// To be removed before 3.0 ships.
static uint64_t GetPhysicalMemoryLimit(bool* is_restricted=NULL);

Expand Down
2 changes: 2 additions & 0 deletions src/Native/gc/env/gcenv.unix.inl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ extern uint32_t g_pageSizeUnixInl;

#define OS_PAGE_SIZE GCToOSInterface::GetPageSize()

#ifndef DACCESS_COMPILE
__forceinline size_t GCToOSInterface::GetPageSize()
{
return g_pageSizeUnixInl;
}
#endif // DACCESS_COMPILE

#endif // __GCENV_UNIX_INL__
Loading