summaryrefslogtreecommitdiff
path: root/src/gc
diff options
context:
space:
mode:
authorAditya Mandaleeka <adityam@microsoft.com>2017-04-07 15:58:29 -0700
committerAditya Mandaleeka <adityam@microsoft.com>2017-04-10 14:37:31 -0700
commitac0ba59034c46da198b12812899e34dec21990e9 (patch)
treeb34a3e777f124e5eb0599692081388a52e2b24ed /src/gc
parent6ed4abcf2c1877073a303ebb58b21a364ddc5f2c (diff)
downloadcoreclr-ac0ba59034c46da198b12812899e34dec21990e9.tar.gz
coreclr-ac0ba59034c46da198b12812899e34dec21990e9.tar.bz2
coreclr-ac0ba59034c46da198b12812899e34dec21990e9.zip
Move handle destruction code to IGCHandleTable.
Conflicts: src/vm/gchandletableutilities.h
Diffstat (limited to 'src/gc')
-rw-r--r--src/gc/gchandletable.cpp17
-rw-r--r--src/gc/gchandletableimpl.h6
-rw-r--r--src/gc/gcinterface.h6
-rw-r--r--src/gc/objecthandle.cpp45
-rw-r--r--src/gc/objecthandle.h225
-rw-r--r--src/gc/sample/GCSample.cpp2
6 files changed, 29 insertions, 272 deletions
diff --git a/src/gc/gchandletable.cpp b/src/gc/gchandletable.cpp
index f8222b193a..accc72d863 100644
--- a/src/gc/gchandletable.cpp
+++ b/src/gc/gchandletable.cpp
@@ -54,4 +54,19 @@ OBJECTHANDLE GCHandleTable::CreateDependentHandle(void* table, Object* primary,
::SetDependentHandleSecondary(handle, ObjectToOBJECTREF(secondary));
return handle;
-} \ No newline at end of file
+}
+
+void GCHandleTable::DestroyHandleOfType(OBJECTHANDLE handle, int type)
+{
+ ::HndDestroyHandle(::HndGetHandleTable(handle), type, handle);
+}
+
+void GCHandleTable::DestroyHandleOfUnknownType(OBJECTHANDLE handle)
+{
+ ::HndDestroyHandleOfUnknownType(::HndGetHandleTable(handle), handle);
+}
+
+void* GCHandleTable::GetExtraInfoFromHandle(OBJECTHANDLE handle)
+{
+ return (void*)::HndGetHandleExtraInfo(handle);
+}
diff --git a/src/gc/gchandletableimpl.h b/src/gc/gchandletableimpl.h
index 787e0c1675..350ae58197 100644
--- a/src/gc/gchandletableimpl.h
+++ b/src/gc/gchandletableimpl.h
@@ -25,6 +25,12 @@ public:
virtual OBJECTHANDLE CreateDependentHandle(void* table, Object* primary, Object* secondary);
virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type);
+
+ virtual void DestroyHandleOfType(OBJECTHANDLE handle, int type);
+
+ virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle);
+
+ virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle);
};
#endif // GCHANDLETABLE_H_
diff --git a/src/gc/gcinterface.h b/src/gc/gcinterface.h
index d0fa87969f..b10e081fa4 100644
--- a/src/gc/gcinterface.h
+++ b/src/gc/gcinterface.h
@@ -420,6 +420,12 @@ public:
virtual OBJECTHANDLE CreateDependentHandle(void* table, Object* primary, Object* secondary) = 0;
virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type) = 0;
+
+ virtual void DestroyHandleOfType(OBJECTHANDLE handle, int type) = 0;
+
+ virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle) = 0;
+
+ virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle) = 0;
};
// IGCHeap is the interface that the VM will use when interacting with the GC.
diff --git a/src/gc/objecthandle.cpp b/src/gc/objecthandle.cpp
index a1000377ba..5df53baad5 100644
--- a/src/gc/objecthandle.cpp
+++ b/src/gc/objecthandle.cpp
@@ -1856,51 +1856,6 @@ bool HandleTableBucket::Contains(OBJECTHANDLE handle)
return FALSE;
}
-void DestroySizedRefHandle(OBJECTHANDLE handle)
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- SO_TOLERANT;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- HHANDLETABLE hTable = HndGetHandleTable(handle);
- HndDestroyHandle(hTable , HNDTYPE_SIZEDREF, handle);
- AppDomain* pDomain = SystemDomain::GetAppDomainAtIndex(HndGetHandleTableADIndex(hTable));
- pDomain->DecNumSizedRefHandles();
-}
-
-#ifdef FEATURE_COMINTEROP
-
-void DestroyWinRTWeakHandle(OBJECTHANDLE handle)
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- CAN_TAKE_LOCK;
- SO_TOLERANT;
- }
- CONTRACTL_END;
-
- // Release the WinRT weak reference if we have one. We're assuming that this will not reenter the
- // runtime, since if we are pointing at a managed object, we should not be using a HNDTYPE_WEAK_WINRT
- // but rather a HNDTYPE_WEAK_SHORT or HNDTYPE_WEAK_LONG.
- IWeakReference* pWinRTWeakReference = reinterpret_cast<IWeakReference*>(HndGetHandleExtraInfo(handle));
- if (pWinRTWeakReference != NULL)
- {
- pWinRTWeakReference->Release();
- }
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_WINRT, handle);
-}
-
-#endif // FEATURE_COMINTEROP
-
#endif // !DACCESS_COMPILE
OBJECTREF GetDependentHandleSecondary(OBJECTHANDLE handle)
diff --git a/src/gc/objecthandle.h b/src/gc/objecthandle.h
index 73d363f4a7..9b2b52511a 100644
--- a/src/gc/objecthandle.h
+++ b/src/gc/objecthandle.h
@@ -73,119 +73,10 @@ struct HandleTableBucket
(flag == VHT_STRONG) || \
(flag == VHT_PINNED))
-#ifndef DACCESS_COMPILE
-/*
- * Convenience macros and prototypes for the various handle types we define
- */
-
-inline void DestroyTypedHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandleOfUnknownType(HndGetHandleTable(handle), handle);
-}
-
-inline void DestroyHandle(OBJECTHANDLE handle)
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- CAN_TAKE_LOCK;
- SO_TOLERANT;
- }
- CONTRACTL_END;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, handle);
-}
-
-inline void DestroyWeakHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_DEFAULT, handle);
-}
-
-inline void DestroyShortWeakHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_SHORT, handle);
-}
-
-inline void DestroyLongWeakHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_LONG, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Holder<OBJECTHANDLE,DoNothing<OBJECTHANDLE>,DestroyLongWeakHandle> LongWeakHandleHolder;
-#endif
-
-inline void DestroyStrongHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_STRONG, handle);
-}
-
-inline void DestroyPinningHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_PINNED, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyPinningHandle, NULL> PinningHandleHolder;
-#endif
-
-inline void DestroyAsyncPinningHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_ASYNCPINNED, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyAsyncPinningHandle, NULL> AsyncPinningHandleHolder;
-#endif
-
-void DestroySizedRefHandle(OBJECTHANDLE handle);
-
-#ifndef FEATURE_REDHAWK
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroySizedRefHandle, NULL> SizeRefHandleHolder;
-#endif
-
-#ifdef FEATURE_COMINTEROP
-
-inline void DestroyRefcountedHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_REFCOUNTED, handle);
-}
-
-void DestroyWinRTWeakHandle(OBJECTHANDLE handle);
-
-#endif // FEATURE_COMINTEROP
-
-#endif // !DACCESS_COMPILE
-
OBJECTREF GetDependentHandleSecondary(OBJECTHANDLE handle);
#ifndef DACCESS_COMPILE
void SetDependentHandleSecondary(OBJECTHANDLE handle, OBJECTREF secondary);
-
-inline void DestroyDependentHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_DEPENDENT, handle);
-}
#endif // !DACCESS_COMPILE
#ifndef DACCESS_COMPILE
@@ -193,130 +84,14 @@ uint32_t GetVariableHandleType(OBJECTHANDLE handle);
void UpdateVariableHandleType(OBJECTHANDLE handle, uint32_t type);
uint32_t CompareExchangeVariableHandleType(OBJECTHANDLE handle, uint32_t oldType, uint32_t newType);
-inline void DestroyVariableHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_VARIABLE, handle);
-}
-
void GCHandleValidatePinnedObject(OBJECTREF obj);
/*
- * Holder for OBJECTHANDLE
- */
-
-#ifndef FEATURE_REDHAWK
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyHandle > OHWrapper;
-
-class OBJECTHANDLEHolder : public OHWrapper
-{
-public:
- FORCEINLINE OBJECTHANDLEHolder(OBJECTHANDLE p = NULL) : OHWrapper(p)
- {
- LIMITED_METHOD_CONTRACT;
- }
- FORCEINLINE void operator=(OBJECTHANDLE p)
- {
- WRAPPER_NO_CONTRACT;
-
- OHWrapper::operator=(p);
- }
-};
-#endif
-
-#ifdef FEATURE_COMINTEROP
-
-typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyRefcountedHandle> RefCountedOHWrapper;
-
-class RCOBJECTHANDLEHolder : public RefCountedOHWrapper
-{
-public:
- FORCEINLINE RCOBJECTHANDLEHolder(OBJECTHANDLE p = NULL) : RefCountedOHWrapper(p)
- {
- LIMITED_METHOD_CONTRACT;
- }
- FORCEINLINE void operator=(OBJECTHANDLE p)
- {
- WRAPPER_NO_CONTRACT;
-
- RefCountedOHWrapper::operator=(p);
- }
-};
-
-#endif // FEATURE_COMINTEROP
-/*
* Convenience prototypes for using the global handles
*/
int GetCurrentThreadHomeHeapNumber();
-inline void DestroyGlobalTypedHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandleOfUnknownType(HndGetHandleTable(handle), handle);
-}
-
-inline void DestroyGlobalHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, handle);
-}
-
-inline void DestroyGlobalWeakHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_DEFAULT, handle);
-}
-
-inline void DestroyGlobalShortWeakHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_SHORT, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Holder<OBJECTHANDLE,DoNothing<OBJECTHANDLE>,DestroyGlobalShortWeakHandle> GlobalShortWeakHandleHolder;
-#endif
-
-inline void DestroyGlobalLongWeakHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_LONG, handle);
-}
-
-inline void DestroyGlobalStrongHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_STRONG, handle);
-}
-
-#ifndef FEATURE_REDHAWK
-typedef Holder<OBJECTHANDLE,DoNothing<OBJECTHANDLE>,DestroyGlobalStrongHandle> GlobalStrongHandleHolder;
-#endif
-
-inline void DestroyGlobalPinningHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_PINNED, handle);
-}
-
-#ifdef FEATURE_COMINTEROP
-inline void DestroyGlobalRefcountedHandle(OBJECTHANDLE handle)
-{
- WRAPPER_NO_CONTRACT;
-
- HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_REFCOUNTED, handle);
-}
-#endif // FEATURE_COMINTEROP
-
inline void ResetOBJECTHANDLE(OBJECTHANDLE handle)
{
WRAPPER_NO_CONTRACT;
diff --git a/src/gc/sample/GCSample.cpp b/src/gc/sample/GCSample.cpp
index ed67e892ff..2914ee1665 100644
--- a/src/gc/sample/GCSample.cpp
+++ b/src/gc/sample/GCSample.cpp
@@ -229,7 +229,7 @@ int __cdecl main(int argc, char* argv[])
return -1;
// Destroy the strong handle so that nothing will be keeping out object alive
- DestroyGlobalHandle(oh);
+ HndDestroyHandle(HndGetHandleTable(oh), HNDTYPE_DEFAULT, oh);
// Explicitly trigger full GC
pGCHeap->GarbageCollect();