if (g_pConfig->AppDomainLeaks() && str->SetAppDomainNoThrow())
{
#endif
- StoreObjectInHandle(m_StressObjs[i], ObjectToOBJECTREF(str));
+ HndAssignHandle(m_StressObjs[i], ObjectToOBJECTREF(str));
#if CHECK_APP_DOMAIN_LEAKS
}
#endif
{
// Let the string itself become garbage.
// will be realloced next time around
- StoreObjectInHandle(m_StressObjs[m_CurStressObj], 0);
+ HndAssignHandle(m_StressObjs[m_CurStressObj], 0);
}
}
}
{
return (void*)::HndGetHandleExtraInfo(handle);
}
+
+void GCHandleManager::StoreObjectInHandle(OBJECTHANDLE handle, Object* object)
+{
+ ::HndAssignHandle(handle, ObjectToOBJECTREF(object));
+}
+
+bool GCHandleManager::StoreObjectInHandleIfNull(OBJECTHANDLE handle, Object* object)
+{
+ return !!::HndFirstAssignHandle(handle, ObjectToOBJECTREF(object));
+}
+
+Object* GCHandleManager::CompareAndSwapObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject)
+{
+ return (Object*)::HndInterlockedCompareExchangeHandle(handle, ObjectToOBJECTREF(object), ObjectToOBJECTREF(comparandObject));
+}
virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle);
virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle);
+
+ virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object);
+
+ virtual bool StoreObjectInHandleIfNull(OBJECTHANDLE handle, Object* object);
+
+ virtual Object* CompareAndSwapObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject);
};
#endif // GCHANDLETABLE_H_
virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle) = 0;
virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle) = 0;
+
+ virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object) = 0;
+
+ virtual bool StoreObjectInHandleIfNull(OBJECTHANDLE handle, Object* object) = 0;
+
+ virtual Object* CompareAndSwapObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject) = 0;
};
// IGCHeap is the interface that the VM will use when interacting with the GC.
#include <weakreference.h>
#endif // FEATURE_COMINTEROP
-/*
- * Convenience macros for accessing handles. StoreFirstObjectInHandle is like
- * StoreObjectInHandle, except it only succeeds if transitioning from NULL to
- * non-NULL. In other words, if this handle is being initialized for the first
- * time.
- */
-#define StoreObjectInHandle(handle, object) HndAssignHandle(handle, object)
-#define InterlockedCompareExchangeObjectInHandle(handle, object, oldObj) HndInterlockedCompareExchangeHandle(handle, object, oldObj)
-#define StoreFirstObjectInHandle(handle, object) HndFirstAssignHandle(handle, object)
-
typedef DPTR(struct HandleTableMap) PTR_HandleTableMap;
typedef DPTR(struct HandleTableBucket) PTR_HandleTableBucket;
typedef DPTR(PTR_HandleTableBucket) PTR_PTR_HandleTableBucket;
{
WRAPPER_NO_CONTRACT;
- StoreObjectInHandle(handle, NULL);
+ HndAssignHandle(handle, NULL);
}
#ifndef FEATURE_REDHAWK
obj = (APPDOMAINREF) AllocateObject(pMT);
obj->SetDomain(this);
- if(StoreFirstObjectInHandle(m_ExposedObject, (OBJECTREF) obj) == FALSE) {
+ if (!StoreFirstObjectInHandle(m_ExposedObject, (OBJECTREF) obj))
+ {
obj = (APPDOMAINREF) GetRawExposedObject();
_ASSERTE(obj);
}
return store->CreateHandleWithExtraInfo(OBJECTREFToObject(object), HNDTYPE_VARIABLE, (void*)((uintptr_t)type));
}
+// Handle object manipulation convenience functions
+
+inline void StoreObjectInHandle(OBJECTHANDLE handle, OBJECTREF object)
+{
+ GCHandleUtilities::GetGCHandleManager()->StoreObjectInHandle(handle, OBJECTREFToObject(object));
+}
+
+inline bool StoreFirstObjectInHandle(OBJECTHANDLE handle, OBJECTREF object)
+{
+ return GCHandleUtilities::GetGCHandleManager()->StoreObjectInHandleIfNull(handle, OBJECTREFToObject(object));
+}
+
+inline void* InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE handle, OBJECTREF object, OBJECTREF comparandObject)
+{
+ return GCHandleUtilities::GetGCHandleManager()->CompareAndSwapObjectInHandle(handle, OBJECTREFToObject(object), OBJECTREFToObject(comparandObject));
+}
+
// Handle destruction convenience functions
inline void DestroyHandle(OBJECTHANDLE handle)