Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch CoreCLR WeakReference to unified managed implementation #77196

Merged
merged 30 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4b6a696
Delete managed CoreClr WR
VSadov Oct 14, 2022
079818b
all but com works
VSadov Oct 18, 2022
1dafd25
COM tests are passing
VSadov Oct 18, 2022
30636bc
HandleTagBits const for NativeAot
VSadov Oct 19, 2022
5876f7b
Exclusive Set
VSadov Oct 19, 2022
9d7636c
fix
VSadov Oct 19, 2022
109e7a6
Use sign bit
VSadov Oct 19, 2022
628f8c3
Platforms not supporting COM can mask only one bit.
VSadov Oct 19, 2022
9ad5897
new approach
VSadov Oct 21, 2022
bf57457
fix mono build
VSadov Oct 21, 2022
a917cff
check for FEATURE_COMWRAPPERS too
VSadov Oct 21, 2022
d42dca3
stub NativeAOT support (NYI).
VSadov Oct 21, 2022
b089f32
current
VSadov Oct 21, 2022
333ae9f
moved handle tags on the managed side to one location
VSadov Oct 21, 2022
99f299e
Getter optimizations
VSadov Oct 22, 2022
a119ad6
Optimizations for Setter
VSadov Oct 22, 2022
3f1de5a
accessibility of some members
VSadov Oct 22, 2022
c4624ec
ensure identity of the rehydrated RCW
VSadov Oct 29, 2022
92787ab
make ComWeakRefToObject a QCall
VSadov Oct 29, 2022
22b7507
delete unused pWeakReferenceOfTCanonMT and pWeakReferenceMT
VSadov Oct 29, 2022
87055ed
byte-aligned
VSadov Oct 29, 2022
1a89e73
cleanup unreachable code
VSadov Oct 29, 2022
e709dfb
renamed WeakReferenceObject::m_Handle -> WeakReferenceObject::m_tagge…
VSadov Oct 29, 2022
e51f50c
Apply suggestions from code review
VSadov Oct 31, 2022
06d66e3
some PR feedback
VSadov Oct 31, 2022
9bbbdb5
GetWeakHandle no longer cares about inlining.
VSadov Oct 31, 2022
90dd2bb
turn ObjectToComWeakRef into a QCall
VSadov Oct 31, 2022
ea7c3ee
revert changes under coreclr\gc
VSadov Oct 31, 2022
a5a8a98
added a note to eventually remove HNDTYPE_WEAK_NATIVE_COM
VSadov Nov 1, 2022
230a3e6
Update src/coreclr/gc/gcinterface.h
VSadov Nov 1, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
<Compile Include="$(BclSourcesRoot)\System\Collections\Generic\Comparer.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\Generic\ComparerHelpers.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\Generic\EqualityComparer.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\ComAwareWeakReference.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Currency.cs" />
<Compile Include="$(BclSourcesRoot)\System\Delegate.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Diagnostics\Debugger.cs" />
Expand Down Expand Up @@ -244,8 +245,6 @@
<Compile Include="$(BclSourcesRoot)\System\TypeLoadException.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\TypeNameParser.cs" />
<Compile Include="$(BclSourcesRoot)\System\ValueType.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReference.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReference.T.CoreCLR.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureComWrappers)' == 'true'">
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ComWrappers.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

#if FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
namespace System
{
internal sealed partial class ComAwareWeakReference
{
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ComWeakRefToObject")]
private static partial void ComWeakRefToObject(IntPtr pComWeakRef, long wrapperId, ObjectHandleOnStack retRcw);

internal static object? ComWeakRefToObject(IntPtr pComWeakRef, long wrapperId)
{
object? retRcw = null;
ComWeakRefToObject(pComWeakRef, wrapperId, ObjectHandleOnStack.Create(ref retRcw));
return retRcw;
}

[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern IntPtr ObjectToComWeakRef(object target, out long wrapperId);
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public static void KeepAlive(object? obj)
//
public static int GetGeneration(WeakReference wo)
{
int result = GetGenerationWR(wo.m_handle);
int result = GetGenerationWR(wo.WeakHandle);
KeepAlive(wo);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace System.Runtime.InteropServices
public partial struct GCHandle
{
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern IntPtr InternalAlloc(object? value, GCHandleType type);
internal static extern IntPtr InternalAlloc(object? value, GCHandleType type);

[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void InternalFree(IntPtr handle);
Expand Down

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7858,10 +7858,6 @@ void CALLBACK DacHandleWalker::EnumCallbackSOS(PTR_UNCHECKED_OBJECTREF handle, u
data.Type = param->Type;
if (param->Type == HNDTYPE_DEPENDENT)
data.Secondary = GetDependentHandleSecondary(handle.GetAddr()).GetAddr();
#ifdef FEATURE_COMINTEROP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that SOS no longer has insight into weak references?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regular weak references did not change from the introspection point of view.

The thing that changed is that there is no need to special case native COM weak handles, since they no longer exist. The implementation uses regular managed objects now and they will be reachable in SOS walks like any other managed object.

else if (param->Type == HNDTYPE_WEAK_NATIVE_COM)
data.Secondary = HndGetHandleExtraInfo(handle.GetAddr());
#endif // FEATURE_COMINTEROP
else
data.Secondary = 0;
data.AppDomain = param->AppDomain;
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7601,10 +7601,6 @@ UINT32 DacRefWalker::GetHandleWalkerMask()
if ((mHandleMask & CorHandleWeakRefCount) || (mHandleMask & CorHandleStrongRefCount))
result |= (1 << HNDTYPE_REFCOUNTED);
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
if (mHandleMask & CorHandleWeakNativeCom)
result |= (1 << HNDTYPE_WEAK_NATIVE_COM);
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS

if (mHandleMask & CorHandleStrongDependent)
result |= (1 << HNDTYPE_DEPENDENT);
Expand Down Expand Up @@ -7778,11 +7774,6 @@ void CALLBACK DacHandleWalker::EnumCallbackDac(PTR_UNCHECKED_OBJECTREF handle, u
data.i64ExtraData = refCnt;
break;
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
case HNDTYPE_WEAK_NATIVE_COM:
data.dwType = (DWORD)CorHandleWeakNativeCom;
break;
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS

case HNDTYPE_DEPENDENT:
data.dwType = (DWORD)CorHandleStrongDependent;
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3210,9 +3210,6 @@ HRESULT ClrDataAccess::GetHandleEnum(ISOSHandleEnum **ppHandleEnum)
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
HNDTYPE_WEAK_NATIVE_COM
#endif // FEATURE_COMINTEROP
};

return GetHandleEnumForTypes(types, ARRAY_SIZE(types), ppHandleEnum);
Expand Down Expand Up @@ -3251,9 +3248,6 @@ HRESULT ClrDataAccess::GetHandleEnumForGC(unsigned int gen, ISOSHandleEnum **ppH
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
HNDTYPE_WEAK_NATIVE_COM
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
};

DacHandleWalker *walker = new DacHandleWalker();
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/gchandletable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Object* GCHandleManager::InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE h
HandleType GCHandleManager::HandleFetchType(OBJECTHANDLE handle)
{
uint32_t type = ::HandleFetchType(handle);
assert(type >= HNDTYPE_WEAK_SHORT && type <= HNDTYPE_WEAK_NATIVE_COM);
assert(type >= HNDTYPE_WEAK_SHORT && type <= HNDTYPE_SIZEDREF);
return static_cast<HandleType>(type);
}

Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/gc/gcinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,6 @@ typedef enum
*
*/
HNDTYPE_SIZEDREF = 8,

/*
* NATIVE WEAK HANDLES
*
* Native weak reference handles hold two different types of weak handles to any
* RCW with an underlying COM object that implements IWeakReferenceSource. The
* object reference itself is a short weak handle to the RCW. In addition an
* IWeakReference* to the underlying COM object is stored, allowing the handle
* to create a new RCW if the existing RCW is collected. This ensures that any
* code holding onto a native weak reference can always access an RCW to the
* underlying COM object as long as it has not been released by all of its strong
* references.
*/
HNDTYPE_WEAK_NATIVE_COM = 9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GC/VM interface change. cc @dotnet/gc

Copy link
Member

@mangod9 mangod9 Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks ok, assuming this enum is not shared between clrgc and coreclr? We need to ensure that latest clrgc continues to work with .net 7 runtime.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in gcinterface.h is shared between clrgc and coreclr.

We need to ensure that latest clrgc continues to work with .net 7 runtime.

The changes under src/coreclr/gc need to be reverted if you would like to maintain this invariant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continues to work with .net 7 runtime

Is this a temporary requirement?
Have we already revved the API version for the frozen string literals work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have added a new method to IGCHeap as part of the frozen literals work, that does not prevent new clrgc + old coreclr from working.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. Considering how much GC and VM are coupled, it feels like compat requirement like this is not sustainable for long. Hopefully this is just for the short term.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why that's not sustainable. we just don't delete things from the interface. yes, it'd be a bit nice to be able to delete things but considering the benefit it seems like the right tradeoff.

} HandleType;

typedef enum
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/gc/handletable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,6 @@ void HndDestroyHandleOfUnknownType(HHANDLETABLE hTable, OBJECTHANDLE handle)
// sanity check handle we are being asked to free
_ASSERTE(handle);

#ifdef FEATURE_COMINTEROP
// If we're being asked to destroy a native COM weak handle, that will cause a leak
// of the IWeakReference* that it holds in its extra data. Instead of using this
// API use DestroyNativeComWeakHandle instead.
_ASSERTE(HandleFetchType(handle) != HNDTYPE_WEAK_NATIVE_COM);
#endif // FEATURE_COMINTEROP

// fetch the type and then free normally
HndDestroyHandle(hTable, HandleFetchType(handle), handle);
}
Expand Down
30 changes: 2 additions & 28 deletions src/coreclr/gc/objecthandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@ void CALLBACK ScanPointerForProfilerAndETW(_UNCHECKED_OBJECTREF *pObjRef, uintpt
break;
case HNDTYPE_WEAK_SHORT:
case HNDTYPE_WEAK_LONG:
#ifdef FEATURE_COMINTEROP
case HNDTYPE_WEAK_NATIVE_COM:
#endif // FEATURE_COMINTEROP
rootFlags |= kEtwGCRootFlagsWeakRef;
break;

Expand Down Expand Up @@ -519,7 +516,6 @@ static const uint32_t s_rgTypeFlags[] =
HNDF_EXTRAINFO, // HNDTYPE_DEPENDENT
HNDF_NORMAL, // HNDTYPE_ASYNCPINNED
HNDF_EXTRAINFO, // HNDTYPE_SIZEDREF
HNDF_EXTRAINFO, // HNDTYPE_WEAK_NATIVE_COM
};

int getNumberOfSlots()
Expand Down Expand Up @@ -1383,14 +1379,7 @@ void Ref_CheckAlive(uint32_t condemned, uint32_t maxgen, uintptr_t lp1)

LOG((LF_GC, LL_INFO10000, "Checking liveness of referents of short-weak handles in generation %u\n", condemned));

// perform a multi-type scan that checks for unreachable objects
uint32_t types[] =
{
HNDTYPE_WEAK_SHORT
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
, HNDTYPE_WEAK_NATIVE_COM
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
};
uint32_t type = HNDTYPE_WEAK_SHORT;
uint32_t flags = (((ScanContext*) lp1)->concurrent) ? HNDGCF_ASYNC : HNDGCF_NORMAL;

int uCPUindex = getSlotNumber((ScanContext*) lp1);
Expand All @@ -1403,7 +1392,7 @@ void Ref_CheckAlive(uint32_t condemned, uint32_t maxgen, uintptr_t lp1)
{
HHANDLETABLE hTable = walk->pBuckets[i]->pTable[uCPUindex];
if (hTable)
HndScanHandlesForGC(hTable, CheckPromoted, lp1, 0, types, ARRAY_SIZE(types), condemned, maxgen, flags);
HndScanHandlesForGC(hTable, CheckPromoted, lp1, 0, &type, 1, condemned, maxgen, flags);
}
}
walk = walk->pNext;
Expand Down Expand Up @@ -1446,9 +1435,6 @@ void Ref_UpdatePointers(uint32_t condemned, uint32_t maxgen, ScanContext* sc, Re
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL) || defined(FEATURE_NATIVEAOT)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL || FEATURE_NATIVEAOT
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
HNDTYPE_WEAK_NATIVE_COM,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
HNDTYPE_SIZEDREF,
};

Expand Down Expand Up @@ -1492,9 +1478,6 @@ void Ref_ScanHandlesForProfilerAndETW(uint32_t maxgen, uintptr_t lp1, handle_sca
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL) || defined(FEATURE_NATIVEAOT)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL || FEATURE_NATIVEAOT
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
HNDTYPE_WEAK_NATIVE_COM,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
HNDTYPE_PINNED,
// HNDTYPE_VARIABLE,
#ifdef FEATURE_ASYNC_PINNED_HANDLES
Expand Down Expand Up @@ -1648,9 +1631,6 @@ void Ref_AgeHandles(uint32_t condemned, uint32_t maxgen, uintptr_t lp1)
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL) || defined(FEATURE_NATIVEAOT)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL || FEATURE_NATIVEAOT
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
HNDTYPE_WEAK_NATIVE_COM,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
#ifdef FEATURE_ASYNC_PINNED_HANDLES
HNDTYPE_ASYNCPINNED,
#endif
Expand Down Expand Up @@ -1693,9 +1673,6 @@ void Ref_RejuvenateHandles(uint32_t condemned, uint32_t maxgen, uintptr_t lp1)
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL) || defined(FEATURE_NATIVEAOT)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL || FEATURE_NATIVEAOT
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
HNDTYPE_WEAK_NATIVE_COM,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
#ifdef FEATURE_ASYNC_PINNED_HANDLES
HNDTYPE_ASYNCPINNED,
#endif
Expand Down Expand Up @@ -1737,9 +1714,6 @@ void Ref_VerifyHandleTable(uint32_t condemned, uint32_t maxgen, ScanContext* sc)
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS) || defined(FEATURE_OBJCMARSHAL) || defined(FEATURE_NATIVEAOT)
HNDTYPE_REFCOUNTED,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS || FEATURE_OBJCMARSHAL || FEATURE_NATIVEAOT
#if defined(FEATURE_COMINTEROP) || defined(FEATURE_COMWRAPPERS)
HNDTYPE_WEAK_NATIVE_COM,
#endif // FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
#ifdef FEATURE_ASYNC_PINNED_HANDLES
HNDTYPE_ASYNCPINNED,
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pThreadClass, ::g_pThreadClass)
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pPredefinedArrayTypes, ::g_pPredefinedArrayTypes)
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_TypedReferenceMT, ::g_TypedReferenceMT)

DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pWeakReferenceClass, ::g_pWeakReferenceClass)
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pWeakReferenceOfTClass, ::g_pWeakReferenceOfTClass)

#ifdef FEATURE_COMINTEROP
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pBaseCOMObject, ::g_pBaseCOMObject)
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/ObjectLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,5 @@ static uintptr_t const MAX_STRING_LENGTH = 0x3FFFFFDF;
class WeakReference : public Object
{
public:
uintptr_t m_HandleAndKind;
uintptr_t m_taggedHandle;
};
11 changes: 8 additions & 3 deletions src/coreclr/nativeaot/Runtime/gcrhenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,10 +1181,15 @@ bool GCToEEInterface::EagerFinalized(Object* obj)
// Managed code should not be running.
ASSERT(GCHeapUtilities::GetGCHeap()->IsGCInProgressHelper());

// the lowermost 1 bit is reserved for storing additional info about the handle
const uintptr_t HandleTagBits = 1;

WeakReference* weakRefObj = (WeakReference*)obj;
OBJECTHANDLE handle = (OBJECTHANDLE)(weakRefObj->m_HandleAndKind & ~(uintptr_t)1);
HandleType handleType = (weakRefObj->m_HandleAndKind & 1) ? HandleType::HNDTYPE_WEAK_LONG : HandleType::HNDTYPE_WEAK_SHORT;
weakRefObj->m_HandleAndKind &= (uintptr_t)1;
OBJECTHANDLE handle = (OBJECTHANDLE)(weakRefObj->m_taggedHandle & ~HandleTagBits);
_ASSERTE((weakRefObj->m_taggedHandle & 2) == 0);
HandleType handleType = (weakRefObj->m_taggedHandle & 1) ? HandleType::HNDTYPE_WEAK_LONG : HandleType::HNDTYPE_WEAK_SHORT;
// keep the bit that indicates whether this reference was tracking resurrection, clear the rest.
weakRefObj->m_taggedHandle &= (uintptr_t)1;
VSadov marked this conversation as resolved.
Show resolved Hide resolved
GCHandleUtilities::GetGCHandleManager()->DestroyHandleOfType(handle, handleType);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
<Compile Include="System\Collections\Generic\Comparer.NativeAot.cs" />
<Compile Include="System\Collections\Generic\EqualityComparer.NativeAot.cs" />
<Compile Include="System\Collections\Generic\EqualOnlyComparer.cs" />
<Compile Include="System\ComAwareWeakReference.NativeAot.cs" />
<Compile Include="System\InvokeUtils.cs" />
<Compile Include="System\IO\FileLoadException.NativeAot.cs" />
<Compile Include="System\RuntimeMethodHandle.cs" />
Expand Down
Loading