diff options
author | Sean Gillespie <sean@swgillespie.me> | 2017-04-05 09:57:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 09:57:50 -0700 |
commit | be8504bd8a63962c84567990f0b84019f299166c (patch) | |
tree | 68678a8bf8b65d84ce55dffe62321a4514e270a7 /src/vm/gcenv.ee.cpp | |
parent | 854bb352a37686afe255045aa728302fdfb3bae2 (diff) | |
download | coreclr-be8504bd8a63962c84567990f0b84019f299166c.tar.gz coreclr-be8504bd8a63962c84567990f0b84019f299166c.tar.bz2 coreclr-be8504bd8a63962c84567990f0b84019f299166c.zip |
[Local GC] Move Weak Reference finalization out of the GC (#10676)
* [Local GC] Move Weak Reference finalization out of the GC
* Address two issues:
1) Use GetGCSafeMethodTable instead of GetMethodTable, so that the
mark bit is correctly masked off the object's method table pointer,
2) Address code review feedback by re-inserting a missed call to
GetCanonicalMethodTable and rename the new API to EagerFinalized to
better illustrate its broader purpose.
* Repair the GC sample
Diffstat (limited to 'src/vm/gcenv.ee.cpp')
-rw-r--r-- | src/vm/gcenv.ee.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp index f3c139e66d..a652359c4f 100644 --- a/src/vm/gcenv.ee.cpp +++ b/src/vm/gcenv.ee.cpp @@ -29,6 +29,15 @@ #include "comcallablewrapper.h" #endif // FEATURE_COMINTEROP +// the method table for the WeakReference class +extern MethodTable* pWeakReferenceMT; + +// The canonical method table for WeakReference<T> +extern MethodTable* pWeakReferenceOfTCanonMT; + +// Finalizes a weak reference directly. +extern void FinalizeWeakReference(Object* obj); + void GCToEEInterface::SuspendEE(SUSPEND_REASON reason) { WRAPPER_NO_CONTRACT; @@ -1359,3 +1368,16 @@ bool GCToEEInterface::ShouldFinalizeObjectForUnload(AppDomain* pDomain, Object* // to move them to a new app domain instead of finalizing them here. return true; } + +bool GCToEEInterface::EagerFinalized(Object* obj) +{ + MethodTable* pMT = obj->GetGCSafeMethodTable(); + if (pMT == pWeakReferenceMT || + pMT->GetCanonicalMethodTable() == pWeakReferenceOfTCanonMT) + { + FinalizeWeakReference(obj); + return true; + } + + return false; +} |