Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilip Navara <navara@emclient.com>2022-09-29 10:06:28 +0300
committerGitHub <noreply@github.com>2022-09-29 10:06:28 +0300
commit42874532250b66ff83d451859d0983bbe60e7926 (patch)
tree9168e995c4670250af40819e0a0715c88bf76673 /src/libraries
parentf518c05eb42776b7d34c974bb83efcc821122bd5 (diff)
[Mono] Implement eager finalization of WeakReference (#76173)
* [Mono] Implement eager finalization of WeakReference * Make the finalization really eager * Move the eager finalization a bit earlier - to sgen_finalize_in_range (PR suggestion) Co-authored-by: vsadov <8218165+VSadov@users.noreply.github.com>
Diffstat (limited to 'src/libraries')
-rw-r--r--src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs17
-rw-r--r--src/libraries/System.Private.CoreLib/src/System/WeakReference.cs3
2 files changed, 0 insertions, 20 deletions
diff --git a/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs b/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs
index 648a89def9a..3d48ec61d81 100644
--- a/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs
@@ -130,8 +130,6 @@ namespace System
}
}
-// eager finalization is NYI on Mono
-#if !MONO
// Note: While WeakReference<T> is formally a finalizable type, the finalizer does not actually run.
// Instead the instances are treated specially in GC when scanning for no longer strongly-reachable
// finalizable objects.
@@ -142,21 +140,6 @@ namespace System
}
#pragma warning restore CA1821 // Remove empty Finalizers
-#else
- // Free all system resources associated with this reference.
- ~WeakReference()
- {
- IntPtr handle = Handle;
- if (handle != default(IntPtr))
- {
- GCHandle.InternalFree(handle);
-
- // keep the bit that indicates whether this reference was tracking resurrection
- _handleAndKind &= TracksResurrectionBit;
- }
- }
-#endif
-
#endif
}
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/WeakReference.cs b/src/libraries/System.Private.CoreLib/src/System/WeakReference.cs
index 77c83d8e8d3..2f56806b48c 100644
--- a/src/libraries/System.Private.CoreLib/src/System/WeakReference.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/WeakReference.cs
@@ -150,10 +150,7 @@ namespace System
// Unlike WeakReference<T> case, the instance could be of a derived type and
// in such case it is finalized via a finalizer.
-// eager finalization is NYI on Mono
-#if !MONO
Debug.Assert(this.GetType() != typeof(WeakReference));
-#endif
IntPtr handle = Handle;
if (handle != default(IntPtr))