Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 0 additions & 7 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7587,9 +7587,6 @@ UINT32 DacRefWalker::GetHandleWalkerMask()
if (mHandleMask & CorHandleStrongDependent)
result |= (1 << HNDTYPE_DEPENDENT);

if (mHandleMask & CorHandleStrongSizedByref)
result |= (1 << HNDTYPE_SIZEDREF);

return result;
}

Expand Down Expand Up @@ -7725,10 +7722,6 @@ HRESULT DacHandleWalker::Next(ULONG count, DacGcReference roots[], ULONG *pFetch
roots[i].dwType = (DWORD)CorHandleStrongDependent;
roots[i].i64ExtraData = GetDependentHandleSecondary(CLRDATA_ADDRESS_TO_TADDR(handle.Handle)).GetAddr();
break;

case HNDTYPE_SIZEDREF:
roots[i].dwType = (DWORD)CorHandleStrongSizedByref;
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/dacimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ class DacHandleWalker : public DefaultCOMImpl<ISOSHandleEnum, IID_ISOSHandleEnum
void WalkHandles();
static inline bool IsAlwaysStrongReference(unsigned int type)
{
return type == HNDTYPE_STRONG || type == HNDTYPE_PINNED || type == HNDTYPE_SIZEDREF;
return type == HNDTYPE_STRONG || type == HNDTYPE_PINNED;
}

private:
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3800,7 +3800,7 @@ ClrDataAccess::GetThreadLocalModuleData(CLRDATA_ADDRESS thread, unsigned int ind
HRESULT ClrDataAccess::GetHandleEnum(ISOSHandleEnum **ppHandleEnum)
{
unsigned int types[] = {HNDTYPE_WEAK_SHORT, HNDTYPE_WEAK_LONG, HNDTYPE_STRONG, HNDTYPE_PINNED, HNDTYPE_DEPENDENT,
HNDTYPE_SIZEDREF, HNDTYPE_WEAK_INTERIOR_POINTER,
HNDTYPE_WEAK_INTERIOR_POINTER,
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL
Expand Down Expand Up @@ -3838,7 +3838,6 @@ HRESULT ClrDataAccess::GetHandleEnumForGC(unsigned int gen, ISOSHandleEnum **ppH
SOSDacEnter();

unsigned int types[] = {HNDTYPE_WEAK_SHORT, HNDTYPE_WEAK_LONG, HNDTYPE_STRONG, HNDTYPE_PINNED, HNDTYPE_DEPENDENT,
HNDTYPE_SIZEDREF,
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL
Expand Down
13 changes: 11 additions & 2 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21424,7 +21424,7 @@ bool gc_heap::init_table_for_region (int gen_number, heap_segment* region)
// The following 2 methods Use integer division to prevent potential floating point exception.
// FPE may occur if we use floating point division because of speculative execution.
//
// Return the percentage of efficiency (between 0 and 100) of the allocator.
// Return the percentage of efficiency (between 0 and 100) of the allocator.
inline
size_t gc_heap::generation_allocator_efficiency_percent (generation* inst)
{
Expand Down Expand Up @@ -22910,7 +22910,7 @@ void gc_heap::gc1()
{
trigger_bgc_for_rethreading_p = false;
}

process_datas_sample();
}
#endif //DYNAMIC_HEAP_COUNT
Expand Down Expand Up @@ -29714,7 +29714,10 @@ void gc_heap::mark_phase (int condemned_gen_number)
#endif //USE_REGIONS

GCToEEInterface::BeforeGcScanRoots(condemned_gen_number, /* is_bgc */ false, /* is_concurrent */ false);

#ifdef FEATURE_SIZED_REF_HANDLES
num_sizedrefs = GCToEEInterface::GetTotalNumSizedRefHandles();
#endif // FEATURE_SIZED_REF_HANDLES

#ifdef FEATURE_EVENT_TRACE
informational_event_enabled_p = EVENT_ENABLED (GCMarkWithType);
Expand Down Expand Up @@ -29801,6 +29804,7 @@ void gc_heap::mark_phase (int condemned_gen_number)
slow = MAX_PTR;
#endif //MULTIPLE_HEAPS

#ifdef FEATURE_SIZED_REF_HANDLES
if ((condemned_gen_number == max_generation) && (num_sizedrefs > 0))
{
GCScan::GcScanSizedRefs(GCHeap::Promote, condemned_gen_number, max_generation, &sc);
Expand All @@ -29822,6 +29826,7 @@ void gc_heap::mark_phase (int condemned_gen_number)
#endif //MULTIPLE_HEAPS
}
}
#endif // FEATURE_SIZED_REF_HANDLES

#if defined(FEATURE_BASICFREEZE) && !defined(USE_REGIONS)
if (ro_segments_in_range)
Expand Down Expand Up @@ -38347,7 +38352,9 @@ void gc_heap::background_mark_phase ()
concurrent_print_time_delta ("CRWW");
#endif // FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP

#ifdef FEATURE_SIZED_REF_HANDLES
num_sizedrefs = GCToEEInterface::GetTotalNumSizedRefHandles();
#endif // FEATURE_SIZED_REF_HANDLES

// this c_write is not really necessary because restart_vm
// has an instruction that will flush the cpu cache (interlocked
Expand Down Expand Up @@ -38426,6 +38433,7 @@ void gc_heap::background_mark_phase ()

disable_preemptive (true);

#ifdef FEATURE_SIZED_REF_HANDLES
if (num_sizedrefs > 0)
{
GCScan::GcScanSizedRefs(background_promote, max_generation, max_generation, &sc);
Expand All @@ -38443,6 +38451,7 @@ void gc_heap::background_mark_phase ()

disable_preemptive (true);
}
#endif // FEATURE_SIZED_REF_HANDLES

dprintf (3,("BGC: handle table marking"));
GCScan::GcScanHandles(background_promote,
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/gc/gcinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ typedef enum
* are scanned as strong roots during each GC but only during full GCs would the size
* be calculated.
*
* NOTE: HNDTYPE_SIZEDREF is no longer used in the VM starting .NET 9
* but we are keeping it here for backward compatibility purposes"
*/
HNDTYPE_SIZEDREF = 8,

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/gc/gcscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ void GCScan::GcWeakPtrScanBySingleThread( int condemned, int max_gen, ScanContex
GCToEEInterface::SyncBlockCacheWeakPtrScan(&CheckPromoted, (uintptr_t)sc, 0);
}

#ifdef FEATURE_SIZED_REF_HANDLES
void GCScan::GcScanSizedRefs(promote_func* fn, int condemned, int max_gen, ScanContext* sc)
{
Ref_ScanSizedRefHandles(condemned, max_gen, sc, fn);
}
#endif // FEATURE_SIZED_REF_HANDLES

void GCScan::GcShortWeakPtrScan(int condemned, int max_gen, ScanContext* sc)
{
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/gc/gcscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ struct DhContext
class GCScan
{
public:

#ifdef FEATURE_SIZED_REF_HANDLES
static void GcScanSizedRefs(promote_func* fn, int condemned, int max_gen, ScanContext* sc);
#endif // FEATURE_SIZED_REF_HANDLES

// Regular stack Roots
static void GcScanRoots (promote_func* fn, int condemned, int max_gen, ScanContext* sc);
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/gc/handletableconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifdef BUILD_AS_STANDALONE
#define FEATURE_ASYNC_PINNED_HANDLES // No longer used in .NET 8+
#define FEATURE_WEAK_NATIVE_COM_HANDLES // No longer used in .NET 8+
#define FEATURE_SIZED_REF_HANDLES // No longer used in .NET 9+
#endif

#define INITIAL_HANDLE_TABLE_ARRAY_SIZE 10
Expand Down
25 changes: 22 additions & 3 deletions src/coreclr/gc/objecthandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,20 @@ void CALLBACK ScanPointerForProfilerAndETW(_UNCHECKED_OBJECTREF *pObjRef, uintpt
case HNDTYPE_WEAK_INTERIOR_POINTER:
#ifdef FEATURE_WEAK_NATIVE_COM_HANDLES
case HNDTYPE_WEAK_NATIVE_COM:
#endif // FEATURE_WEAK_NATIVE_COM_HANDLES
#endif
rootFlags |= kEtwGCRootFlagsWeakRef;
break;

case HNDTYPE_STRONG:
#ifdef FEATURE_SIZED_REF_HANDLES
case HNDTYPE_SIZEDREF:
#endif
break;

case HNDTYPE_PINNED:
#ifdef FEATURE_ASYNC_PINNED_HANDLES
case HNDTYPE_ASYNCPINNED:
#endif // FEATURE_ASYNC_PINNED_HANDLES
#endif
rootFlags |= kEtwGCRootFlagsPinning;
break;

Expand Down Expand Up @@ -1103,7 +1105,12 @@ void Ref_TraceNormalRoots(uint32_t condemned, uint32_t maxgen, ScanContext* sc,

// promote objects pointed to by strong handles
// during ephemeral GCs we also want to promote the ones pointed to by sizedref handles.
uint32_t types[2] = {HNDTYPE_STRONG, HNDTYPE_SIZEDREF};
uint32_t types[2] = {
HNDTYPE_STRONG,
#ifdef FEATURE_SIZED_REF_HANDLES
HNDTYPE_SIZEDREF
#endif
Comment thread
elinor-fung marked this conversation as resolved.
};
uint32_t uTypeCount = (((condemned >= maxgen) && !g_theGCHeap->IsConcurrentGCInProgress()) ? 1 : ARRAY_SIZE(types));
uint32_t flags = (sc->concurrent) ? HNDGCF_ASYNC : HNDGCF_NORMAL;

Expand Down Expand Up @@ -1480,6 +1487,7 @@ void TraceDependentHandlesBySingleThread(HANDLESCANPROC pfnTrace, uintptr_t lp1,
}
}

#ifdef FEATURE_SIZED_REF_HANDLES
void ScanSizedRefByCPU(uint32_t maxgen, HANDLESCANPROC scanProc, ScanContext* sc, Ref_promote_func* fn, uint32_t flags)
{
HandleTableMap *walk = &g_HandleTableMap;
Expand Down Expand Up @@ -1519,6 +1527,7 @@ void Ref_ScanSizedRefHandles(uint32_t condemned, uint32_t maxgen, ScanContext* s

ScanSizedRefByCPU(maxgen, CalculateSizedRefSize, sc, fn, flags);
}
#endif // FEATURE_SIZED_REF_HANDLES

void Ref_CheckAlive(uint32_t condemned, uint32_t maxgen, ScanContext *sc)
{
Expand Down Expand Up @@ -1602,7 +1611,9 @@ void Ref_UpdatePointers(uint32_t condemned, uint32_t maxgen, ScanContext* sc, Re
#ifdef FEATURE_WEAK_NATIVE_COM_HANDLES
HNDTYPE_WEAK_NATIVE_COM,
#endif
#ifdef FEATURE_SIZED_REF_HANDLES
HNDTYPE_SIZEDREF,
#endif
Comment thread
elinor-fung marked this conversation as resolved.
};

// perform a multi-type scan that updates pointers
Expand Down Expand Up @@ -1665,7 +1676,9 @@ void Ref_ScanHandlesForProfilerAndETW(uint32_t maxgen, uintptr_t lp1, handle_sca
#ifdef FEATURE_ASYNC_PINNED_HANDLES
HNDTYPE_ASYNCPINNED,
#endif
#ifdef FEATURE_SIZED_REF_HANDLES
HNDTYPE_SIZEDREF,
#endif
HNDTYPE_WEAK_INTERIOR_POINTER
};

Expand Down Expand Up @@ -1788,7 +1801,9 @@ void Ref_AgeHandles(uint32_t condemned, uint32_t maxgen, ScanContext* sc)
#ifdef FEATURE_ASYNC_PINNED_HANDLES
HNDTYPE_ASYNCPINNED,
#endif
#ifdef FEATURE_SIZED_REF_HANDLES
HNDTYPE_SIZEDREF,
#endif
HNDTYPE_WEAK_INTERIOR_POINTER
};

Expand Down Expand Up @@ -1843,7 +1858,9 @@ void Ref_RejuvenateHandles(uint32_t condemned, uint32_t maxgen, ScanContext* sc)
#ifdef FEATURE_ASYNC_PINNED_HANDLES
HNDTYPE_ASYNCPINNED,
#endif
#ifdef FEATURE_SIZED_REF_HANDLES
HNDTYPE_SIZEDREF,
#endif
HNDTYPE_WEAK_INTERIOR_POINTER
};

Expand Down Expand Up @@ -1896,7 +1913,9 @@ void Ref_VerifyHandleTable(uint32_t condemned, uint32_t maxgen, ScanContext* sc)
#ifdef FEATURE_ASYNC_PINNED_HANDLES
HNDTYPE_ASYNCPINNED,
#endif
#ifdef FEATURE_SIZED_REF_HANDLES
HNDTYPE_SIZEDREF,
#endif
HNDTYPE_DEPENDENT,
HNDTYPE_WEAK_INTERIOR_POINTER
};
Expand Down
17 changes: 0 additions & 17 deletions src/coreclr/vm/gchandleutilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,6 @@ inline OBJECTHANDLE CreateRefcountedHandle(IGCHandleStore* store, OBJECTREF obje
return CreateHandleCommon(store, object, HNDTYPE_REFCOUNTED);
}

inline OBJECTHANDLE CreateSizedRefHandle(IGCHandleStore* store, OBJECTREF object)
{
return CreateHandleCommon(store, object, HNDTYPE_SIZEDREF);
}

inline OBJECTHANDLE CreateSizedRefHandle(IGCHandleStore* store, OBJECTREF object, int heapToAffinitizeTo)
{
OBJECTHANDLE hnd = store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_SIZEDREF, heapToAffinitizeTo);
if (!hnd)
{
COMPlusThrowOM();
}

DiagHandleCreated(hnd, object);
return hnd;
}

inline OBJECTHANDLE CreateDependentHandle(IGCHandleStore* store, OBJECTREF primary, OBJECTREF secondary)
{
OBJECTHANDLE hnd = store->CreateDependentHandle(OBJECTREFToObject(primary), OBJECTREFToObject(secondary));
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/marshalnative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ FCIMPL2(LPVOID, MarshalNative::GCHandleInternalAlloc, Object *obj, int type)
{
FCALL_CONTRACT;

assert(type >= HNDTYPE_WEAK_SHORT && type <= HNDTYPE_SIZEDREF);
assert(type >= HNDTYPE_WEAK_SHORT && type <= HNDTYPE_DEPENDENT);

if (CORProfilerTrackGC())
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/runtimehandles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ extern "C" PVOID QCALLTYPE QCall_GetGCHandleForTypeHandle(QCall::TypeHandle pTyp
GCX_COOP();

TypeHandle th = pTypeHandle.AsTypeHandle();
assert(handleType >= HNDTYPE_WEAK_SHORT && handleType <= HNDTYPE_SIZEDREF);
assert(handleType >= HNDTYPE_WEAK_SHORT && handleType <= HNDTYPE_DEPENDENT);
objHandle = AppDomain::GetCurrentDomain()->CreateTypedHandle(NULL, static_cast<HandleType>(handleType));
th.GetLoaderAllocator()->RegisterHandleForCleanup(objHandle);

Expand Down