Thanks to visit codestin.com
Credit goes to github.com

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
14 changes: 9 additions & 5 deletions src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ internal enum GC_ALLOC_FLAGS
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern Array AllocateNewArray(IntPtr typeHandle, int length, GC_ALLOC_FLAGS flags);

[MethodImpl(MethodImplOptions.InternalCall)]
private static extern int GetGenerationWR(IntPtr handle);

[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "GCInterface_GetTotalMemory")]
private static partial long GetTotalMemory();

Expand Down Expand Up @@ -290,9 +287,16 @@ public static void KeepAlive(object? obj)
//
public static int GetGeneration(WeakReference wo)
{
int result = GetGenerationWR(wo.WeakHandle);
// Note - This throws an NRE if given a null weak reference.
object? obj = GCHandle.InternalGet(wo.WeakHandle);
KeepAlive(wo);
return result;

if (obj is null)
{
throw new ArgumentNullException(nameof(wo));
}

return GetGeneration(obj);
}

// Returns the maximum GC generation. Currently assumes only 1 heap.
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/coreclr/inc/contract.inl
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void CONTRACT_ASSERT(const char *szElaboration,
{
char Buf[512*20 + 2048 + 1024];

sprintf_s(Buf,ARRAY_SIZE(Buf), "CONTRACT VIOLATION by %s at \"%s\" @ %d\n\n%s\n", szFunction, szFile, lineNum, szElaboration);
sprintf_s(Buf,ARRAY_SIZE(Buf), "CONTRACT VIOLATION by %s at \"%s\":%d\n\n%s\n", szFunction, szFile, lineNum, szElaboration);

int count = 20;
ContractStackRecord *pRec = CheckClrDebugState() ? CheckClrDebugState()->GetContractStackTrace() : NULL;
Expand Down Expand Up @@ -530,7 +530,7 @@ void CONTRACT_ASSERT(const char *szElaboration,
}

sprintf_s(tmpbuf,ARRAY_SIZE(tmpbuf),
"\n%s %s in %s at \"%s\" @ %d",
"\n%s %s in %s at \"%s\":%d",
fshowconflict ? "VIOLATED-->" : " ",
pRec->m_construct,
pRec->m_szFunction,
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/utilcode/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ bool _DbgBreakCheck(

sprintf_s(formatBuffer, sizeof(formatBuffer),
"\nAssert failure(PID %d [0x%08x], Thread: %d [0x%04x]): %s\n"
" File: %s Line: %d\n"
" File: %s:%d\n"
" Image: %s\n\n",
GetCurrentProcessId(), GetCurrentProcessId(),
GetCurrentThreadId(), GetCurrentThreadId(),
Expand Down Expand Up @@ -517,7 +517,7 @@ void DECLSPEC_NORETURN __FreeBuildAssertFail(const char *szFile, int iLine, cons

SString buffer;
buffer.Printf("CLR: Assert failure(PID %d [0x%08x], Thread: %d [0x%x]): %s\n"
" File: %s, Line: %d Image:\n%s\n",
" File: %s:%d Image:\n%s\n",
GetCurrentProcessId(), GetCurrentProcessId(),
GetCurrentThreadId(), GetCurrentThreadId(),
szExpr, szFile, iLine, modulePath.GetUTF8());
Expand All @@ -528,7 +528,7 @@ void DECLSPEC_NORETURN __FreeBuildAssertFail(const char *szFile, int iLine, cons

// Log to the stress log. Note that we can't include the szExpr b/c that
// may not be a string literal (particularly for formatt-able asserts).
STRESS_LOG2(LF_ASSERT, LL_ALWAYS, "ASSERT:%s, line:%d\n", szFile, iLine);
STRESS_LOG2(LF_ASSERT, LL_ALWAYS, "ASSERT:%s:%d\n", szFile, iLine);

FailFastOnAssert();
UNREACHABLE();
Expand Down
27 changes: 0 additions & 27 deletions src/coreclr/vm/comutilnative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,33 +795,6 @@ extern "C" int QCALLTYPE GCInterface_EndNoGCRegion()
return retVal;
}

/*===============================GetGenerationWR================================
**Action: Returns the generation in which the object pointed to by a WeakReference is found.
**Returns:
**Arguments: args->handle -- the OBJECTHANDLE to the object which we're locating.
**Exceptions: ArgumentException if handle points to an object which is not accessible.
==============================================================================*/
FCIMPL1(int, GCInterface::GetGenerationWR, LPVOID handle)
{
FCALL_CONTRACT;

int iRetVal = 0;

HELPER_METHOD_FRAME_BEGIN_RET_0();

OBJECTREF temp;
temp = ObjectFromHandle((OBJECTHANDLE) handle);
if (temp == NULL)
COMPlusThrowArgumentNull(W("wo"));

iRetVal = (INT32)GCHeapUtilities::GetGCHeap()->WhichGeneration(OBJECTREFToObject(temp));

HELPER_METHOD_FRAME_END();

return iRetVal;
}
FCIMPLEND

FCIMPL0(int, GCInterface::GetLastGCPercentTimeInGC)
{
FCALL_CONTRACT;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/comutilnative.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class GCInterface {
static FCDECL1(void, SetLOHCompactionMode, int newLOHCompactionyMode);
static FCDECL2(FC_BOOL_RET, RegisterForFullGCNotification, UINT32 gen2Percentage, UINT32 lohPercentage);
static FCDECL0(FC_BOOL_RET, CancelFullGCNotification);
static FCDECL1(int, GetGenerationWR, LPVOID handle);
static FCDECL1(int, GetGeneration, Object* objUNSAFE);
static FCDECL0(UINT64, GetSegmentSize);
static FCDECL0(int, GetLastGCPercentTimeInGC);
Expand Down
25 changes: 0 additions & 25 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,31 +216,6 @@ DEFINE_FIELD(STUBMETHODINFO, HANDLE, m_value)

DEFINE_CLASS(CONSTRUCTOR_INFO, Reflection, ConstructorInfo)

DEFINE_CLASS_U(Reflection, CustomAttributeEncodedArgument, CustomAttributeValue)
DEFINE_FIELD_U(m_primitiveValue, CustomAttributeValue, m_rawValue)
DEFINE_FIELD_U(m_arrayValue, CustomAttributeValue, m_value)
DEFINE_FIELD_U(m_stringValue, CustomAttributeValue, m_enumOrTypeName)
DEFINE_FIELD_U(m_type, CustomAttributeValue, m_type)
DEFINE_CLASS(CUSTOM_ATTRIBUTE_ENCODED_ARGUMENT, Reflection, CustomAttributeEncodedArgument)

DEFINE_CLASS_U(Reflection, CustomAttributeNamedParameter, CustomAttributeNamedArgument)
DEFINE_FIELD_U(m_argumentName, CustomAttributeNamedArgument, m_argumentName)
DEFINE_FIELD_U(m_fieldOrProperty, CustomAttributeNamedArgument, m_propertyOrField)
DEFINE_FIELD_U(m_padding, CustomAttributeNamedArgument, m_padding)
DEFINE_FIELD_U(m_type, CustomAttributeNamedArgument, m_type)
DEFINE_FIELD_U(m_encodedArgument, CustomAttributeNamedArgument, m_value)

DEFINE_CLASS_U(Reflection, CustomAttributeCtorParameter, CustomAttributeArgument)
DEFINE_FIELD_U(m_type, CustomAttributeArgument, m_type)
DEFINE_FIELD_U(m_encodedArgument, CustomAttributeArgument, m_value)

DEFINE_CLASS_U(Reflection, CustomAttributeType, CustomAttributeType)
DEFINE_FIELD_U(m_enumName, CustomAttributeType, m_enumName)
DEFINE_FIELD_U(m_encodedType, CustomAttributeType, m_tag)
DEFINE_FIELD_U(m_encodedEnumType, CustomAttributeType, m_enumType)
DEFINE_FIELD_U(m_encodedArrayType, CustomAttributeType, m_arrayType)
DEFINE_FIELD_U(m_padding, CustomAttributeType, m_padding)

DEFINE_CLASS_U(Globalization, CultureInfo, CultureInfoBaseObject)
DEFINE_FIELD_U(_compareInfo, CultureInfoBaseObject, _compareInfo)
DEFINE_FIELD_U(_textInfo, CultureInfoBaseObject, _textInfo)
Expand Down
Loading