This would enable in the future to use CoreCLR's GC with mono. This doesn't change the current embedding api, but, in the future, we will end up aligning with coreclr on an embedding api that uses pointer sized gchandles.
Co-authored-by: Vlad Brezae <brezaevlad@gmail.com>
MonoStringHandle root_app_base = MONO_HANDLE_NEW_GET (MonoString, root_setup, application_base);
if (!MONO_HANDLE_IS_NULL (root_app_base)) {
/* N.B. new string is in the new domain */
- uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, root_app_base), TRUE);
+ MonoGCHandle gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, root_app_base), TRUE);
MonoStringHandle s = mono_string_new_utf16_handle (data, mono_string_chars_internal (MONO_HANDLE_RAW (root_app_base)), mono_string_handle_length (root_app_base), error);
mono_gchandle_free_internal (gchandle);
if (!is_ok (error)) {
mono_error_set_out_of_memory (error, "Could not allocate %ud bytes to copy raw assembly data", raw_assembly_len);
return refass;
}
- uint32_t gchandle;
+ MonoGCHandle gchandle;
mono_byte *raw_data = (mono_byte*) MONO_ARRAY_HANDLE_PIN (raw_assembly, gchar, 0, &gchandle);
memcpy (assembly_data, raw_data, raw_assembly_len);
mono_gchandle_free_internal (gchandle); /* unpin */
mono_byte *raw_symbol_data = NULL;
guint32 symbol_len = 0;
- uint32_t symbol_gchandle = 0;
+ MonoGCHandle symbol_gchandle = 0;
if (!MONO_HANDLE_IS_NULL (raw_symbol_store)) {
symbol_len = mono_array_handle_length (raw_symbol_store);
raw_symbol_data = (mono_byte*) MONO_ARRAY_HANDLE_PIN (raw_symbol_store, mono_byte, 0, &symbol_gchandle);
mono_domain_unlock (mono_root_domain);
return mono_string_new_utf16_handle (mono_domain_get (), process_guid, sizeof(process_guid)/2, error);
}
- uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, newguid), TRUE);
+ MonoGCHandle gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, newguid), TRUE);
memcpy (process_guid, mono_string_chars_internal (MONO_HANDLE_RAW (newguid)), sizeof(process_guid));
mono_gchandle_free_internal (gchandle);
process_guid_set = TRUE;
* \returns a handle that can be used to access the object from
* unmanaged code.
*/
-guint32
+MonoGCHandle
mono_gchandle_new_internal (MonoObject *obj, gboolean pinned)
{
- return alloc_handle (&gc_handles [pinned? HANDLE_PINNED: HANDLE_NORMAL], obj, FALSE);
+ return (MonoGCHandle)(size_t)alloc_handle (&gc_handles [pinned? HANDLE_PINNED: HANDLE_NORMAL], obj, FALSE);
}
/**
* \returns a handle that can be used to access the object from
* unmanaged code.
*/
-guint32
+MonoGCHandle
mono_gchandle_new_weakref_internal (MonoObject *obj, gboolean track_resurrection)
{
- return alloc_handle (&gc_handles [track_resurrection? HANDLE_WEAK_TRACK: HANDLE_WEAK], obj, track_resurrection);
+ return MONO_GC_HANDLE_FROM_UINT (alloc_handle (&gc_handles [track_resurrection? HANDLE_WEAK_TRACK: HANDLE_WEAK], obj, track_resurrection));
}
/**
* NULL for a collected object if using a weakref handle.
*/
MonoObject*
-mono_gchandle_get_target_internal (guint32 gchandle)
+mono_gchandle_get_target_internal (MonoGCHandle gch)
{
+ guint32 gchandle = MONO_GC_HANDLE_TO_UINT (gch);
guint slot = MONO_GC_HANDLE_SLOT (gchandle);
guint type = MONO_GC_HANDLE_TYPE (gchandle);
HandleData *handles = &gc_handles [type];
}
void
-mono_gchandle_set_target (guint32 gchandle, MonoObject *obj)
+mono_gchandle_set_target (MonoGCHandle gch, MonoObject *obj)
{
+ guint32 gchandle = MONO_GC_HANDLE_TO_UINT (gch);
guint slot = MONO_GC_HANDLE_SLOT (gchandle);
guint type = MONO_GC_HANDLE_TYPE (gchandle);
HandleData *handles = &gc_handles [type];
* \returns TRUE if the object wrapped by the \p gchandle belongs to the specific \p domain.
*/
gboolean
-mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain)
+mono_gchandle_is_in_domain (MonoGCHandle gch, MonoDomain *domain)
{
+ guint32 gchandle = MONO_GC_HANDLE_TO_UINT (gch);
guint slot = MONO_GC_HANDLE_SLOT (gchandle);
guint type = MONO_GC_HANDLE_TYPE (gchandle);
HandleData *handles = &gc_handles [type];
* object wrapped.
*/
void
-mono_gchandle_free_internal (guint32 gchandle)
+mono_gchandle_free_internal (MonoGCHandle gch)
{
+ guint32 gchandle = MONO_GC_HANDLE_TO_UINT (gch);
if (!gchandle)
return;
guint32 value;
} Uint32Property;
-guint32
+typedef struct {
+ MonoPropertyBagItem head;
+ MonoGCHandle value;
+} GCHandleProperty;
+
+MonoGCHandle
mono_class_get_ref_info_handle (MonoClass *klass)
{
- Uint32Property *prop = (Uint32Property*)mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
- return prop ? prop->value : 0;
+ GCHandleProperty *prop = (GCHandleProperty*)mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
+ return prop ? prop->value : NULL;
}
-guint32
-mono_class_set_ref_info_handle (MonoClass *klass, guint32 value)
+MonoGCHandle
+mono_class_set_ref_info_handle (MonoClass *klass, gpointer value)
{
if (!value) {
- Uint32Property *prop = (Uint32Property*)mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
+ GCHandleProperty *prop = (GCHandleProperty*)mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
if (prop)
- prop->value = 0;
- return 0;
+ prop->value = NULL;
+ return NULL;
}
- Uint32Property *prop = (Uint32Property*)mono_class_alloc (klass, sizeof (Uint32Property));
+ GCHandleProperty *prop = (GCHandleProperty*)mono_class_alloc (klass, sizeof (GCHandleProperty));
prop->head.tag = PROP_REF_INFO_HANDLE;
prop->value = value;
- prop = (Uint32Property*)mono_property_bag_add (m_class_get_infrequent_data (klass), prop);
+ prop = (GCHandleProperty*)mono_property_bag_add (m_class_get_infrequent_data (klass), prop);
return prop->value;
}
mono_class_set_type_load_failure (klass, "Could not create array type '%s[]'", full_name);
g_free (full_name);
} else if (eclass->enumtype && !mono_class_enum_basetype_internal (eclass)) {
- guint32 ref_info_handle = mono_class_get_ref_info_handle (eclass);
+ MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (eclass);
if (!ref_info_handle || eclass->wastypebuilder) {
g_warning ("Only incomplete TypeBuilder objects are allowed to be an enum without base_type");
g_assert (ref_info_handle && !eclass->wastypebuilder);
void
mono_class_set_marshal_info (MonoClass *klass, MonoMarshalType *marshal_info);
-guint32
+MonoGCHandle
mono_class_get_ref_info_handle (MonoClass *klass);
-guint32
-mono_class_set_ref_info_handle (MonoClass *klass, guint32 value);
+MonoGCHandle
+mono_class_set_ref_info_handle (MonoClass *klass, gpointer value);
MonoErrorBoxed*
mono_class_get_exception_data (MonoClass *klass);
if (MONO_HANDLE_IS_NULL (s))
return NULL;
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
mono_bstr const res = mono_ptr_to_bstr (mono_string_handle_pin_chars (s, &gchandle), mono_string_handle_length (s));
mono_gchandle_free_internal (gchandle);
return res;
*/
typedef struct {
guint32 ref_count;
- guint32 gc_handle;
+ MonoGCHandle gc_handle;
GHashTable* vtable_hash;
#ifdef HOST_WIN32
MonoIUnknown *free_marshaler; // actually IMarshal
return;
mono_cominterop_lock ();
- guint32 const gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (rcw_hash, MONO_HANDLE_GETVAL (obj, iunknown)));
+ MonoGCHandle gchandle = (MonoGCHandle)g_hash_table_lookup (rcw_hash, MONO_HANDLE_GETVAL (obj, iunknown));
if (gchandle) {
mono_gchandle_free_internal (gchandle);
g_hash_table_remove (rcw_hash, MONO_HANDLE_GETVAL (obj, iunknown));
static gboolean
cominterop_rcw_finalizer (gpointer key, gpointer value, gpointer user_data)
{
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
- gchandle = GPOINTER_TO_UINT (value);
+ gchandle = (MonoGCHandle)value;
if (gchandle) {
MonoComInteropProxy* proxy = (MonoComInteropProxy*)mono_gchandle_get_target_internal (gchandle);
ves_icall_Mono_Interop_ComInteropProxy_AddProxy (gpointer pUnk, MonoComInteropProxy *volatile* proxy_handle)
{
#ifndef DISABLE_COM
- guint32 const gchandle = mono_gchandle_new_weakref_internal ((MonoObject*)*proxy_handle, FALSE);
+ MonoGCHandle gchandle = mono_gchandle_new_weakref_internal ((MonoObject*)*proxy_handle, FALSE);
mono_cominterop_lock ();
if (!rcw_hash)
rcw_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
- g_hash_table_insert (rcw_hash, pUnk, GUINT_TO_POINTER (gchandle));
+ g_hash_table_insert (rcw_hash, pUnk, gchandle);
mono_cominterop_unlock ();
#else
g_assert_not_reached ();
#ifndef DISABLE_COM
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
mono_cominterop_lock ();
if (rcw_hash)
- gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (rcw_hash, pUnk));
+ gchandle = (MonoGCHandle)g_hash_table_lookup (rcw_hash, pUnk);
mono_cominterop_unlock ();
if (!gchandle)
return;
*
* Returns: the corresponding object for the CCW
*/
-static gchandle_t
+static MonoGCHandle
cominterop_get_ccw_gchandle (MonoCCWInterface* ccw_entry, gboolean verify)
{
/* no CCW's exist yet */
static MonoObjectHandle
cominterop_get_ccw_handle (MonoCCWInterface* ccw_entry, gboolean verify)
{
- gchandle_t const gchandle = cominterop_get_ccw_gchandle (ccw_entry, verify);
+ MonoGCHandle const gchandle = cominterop_get_ccw_gchandle (ccw_entry, verify);
return gchandle ? mono_gchandle_get_target_handle (gchandle) : NULL_HANDLE;
}
static MonoObject*
cominterop_get_ccw_object (MonoCCWInterface* ccw_entry, gboolean verify)
{
- gchandle_t const gchandle = cominterop_get_ccw_gchandle (ccw_entry, verify);
+ MonoGCHandle const gchandle = cominterop_get_ccw_gchandle (ccw_entry, verify);
return gchandle ? mono_gchandle_get_target_internal (gchandle) : NULL;
}
gboolean destroy_ccw = is_null || is_equal;
if (is_null) {
MonoCCWInterface* ccw_entry = (MonoCCWInterface *)g_hash_table_lookup (ccw_iter->vtable_hash, mono_class_get_iunknown_class ());
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
if (!(ccw_entry && (gchandle = cominterop_get_ccw_gchandle (ccw_entry, FALSE)) && mono_gchandle_target_equal (gchandle, object)))
destroy_ccw = FALSE;
}
g_assert (ccw->gc_handle);
gint32 const ref_count = mono_atomic_inc_i32 ((gint32*)&ccw->ref_count);
if (ref_count == 1) {
- guint32 oldhandle = ccw->gc_handle;
+ MonoGCHandle oldhandle = ccw->gc_handle;
g_assert (oldhandle);
/* since we now have a ref count, alloc a strong handle*/
ccw->gc_handle = mono_gchandle_from_handle (mono_gchandle_get_target_handle (oldhandle), FALSE);
gint32 const ref_count = mono_atomic_dec_i32 ((gint32*)&ccw->ref_count);
if (ref_count == 0) {
/* allow gc of object */
- guint32 oldhandle = ccw->gc_handle;
+ MonoGCHandle oldhandle = ccw->gc_handle;
g_assert (oldhandle);
ccw->gc_handle = mono_gchandle_new_weakref_from_handle (mono_gchandle_get_target_handle (oldhandle));
mono_gchandle_free_internal (oldhandle);
if (ret == -1)
return FALSE;
- uint32_t h;
+ MonoGCHandle h;
set_control_chars (MONO_ARRAY_HANDLE_PIN (control_chars_arr, gchar, 0, &h), mono_attr.c_cc);
mono_gchandle_free_internal (h);
/* If initialized from another appdomain... */
continue;
MONO_HANDLE_GET (cattr_data, cattr, data);
unsigned char *saved = (unsigned char *)mono_image_alloc (image, mono_array_handle_length (cattr_data));
- guint32 gchandle = 0;
+ MonoGCHandle gchandle = NULL;
memcpy (saved, MONO_ARRAY_HANDLE_PIN (cattr_data, char, 0, &gchandle), mono_array_handle_length (cattr_data));
mono_gchandle_free_internal (gchandle);
ainfo->attrs [index].ctor = ctor_method;
typedef struct {
gpointer *static_data; /* Used to free the static data without going through the MonoAppContext object itself. */
- uint32_t gc_handle;
+ MonoGCHandle gc_handle;
} ContextStaticData;
struct _MonoAppContext {
domain = mono_domain_get ();
len = mono_array_handle_length (arr);
text = g_string_new_len (NULL, len * 20);
- uint32_t gchandle;
+ MonoGCHandle gchandle;
gpointer *addr = MONO_ARRAY_HANDLE_PIN (arr, gpointer, 0, &gchandle);
MONO_ENTER_GC_SAFE;
messages = backtrace_symbols (addr, len);
uint32_t
mono_gchandle_new (MonoObject *obj, mono_bool pinned)
{
- MONO_EXTERNAL_ONLY_GC_UNSAFE (uint32_t, mono_gchandle_new_internal (obj, pinned));
+ MONO_EXTERNAL_ONLY_GC_UNSAFE (uint32_t, (uint32_t)(size_t)mono_gchandle_new_internal (obj, pinned));
}
/**
uint32_t
mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection)
{
- MONO_EXTERNAL_ONLY_GC_UNSAFE (uint32_t, mono_gchandle_new_weakref_internal (obj, track_resurrection));
+ MONO_EXTERNAL_ONLY_GC_UNSAFE (uint32_t, (uint32_t)(size_t)mono_gchandle_new_weakref_internal (obj, track_resurrection));
}
/**
MonoObject*
mono_gchandle_get_target (uint32_t gchandle)
{
- MONO_EXTERNAL_ONLY_GC_UNSAFE (MonoObject*, mono_gchandle_get_target_internal (gchandle));
+ MONO_EXTERNAL_ONLY_GC_UNSAFE (MonoObject*, mono_gchandle_get_target_internal ((MonoGCHandle)(size_t)gchandle));
}
/**
* the gchandle code is lockfree. SGen calls back into Mono which
* fires a profiler event, so the profiler must be prepared to be
* called from threads that aren't attached to Mono. */
- MONO_EXTERNAL_ONLY_VOID (mono_gchandle_free_internal (gchandle));
+ MONO_EXTERNAL_ONLY_VOID (mono_gchandle_free_internal ((MonoGCHandle)(size_t)gchandle));
}
/* GC write barriers support */
#define MONO_GC_UNREGISTER_ROOT(x) mono_gc_deregister_root ((char*)&(x))
/*
+ * The lowest bit is used to mark pinned handles by netcore's GCHandle class. These macros
+ * are used to convert between the old int32 representation to a netcore compatible pointer
+ * representation.
+ */
+#define MONO_GC_HANDLE_TO_UINT(ptr) ((guint32)((size_t)(ptr) >> 1))
+#define MONO_GC_HANDLE_FROM_UINT(i) ((MonoGCHandle)((size_t)(i) << 1))
+/*
* Return a GC descriptor for an array containing N pointers to memory allocated
* by mono_gc_alloc_fixed ().
*/
gboolean mono_object_is_alive (MonoObject* obj);
gboolean mono_gc_is_finalizer_thread (MonoThread *thread);
-void mono_gchandle_set_target (guint32 gchandle, MonoObject *obj);
+void mono_gchandle_set_target (MonoGCHandle gchandle, MonoObject *obj);
/*Ephemeron functionality. Sgen only*/
gboolean mono_gc_ephemeron_array_add (MonoObject *obj);
void mono_gc_free_fixed (void* addr);
/* make sure the gchandle was allocated for an object in domain */
-gboolean mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain);
+gboolean mono_gchandle_is_in_domain (MonoGCHandle gchandle, MonoDomain *domain);
void mono_gchandle_free_domain (MonoDomain *domain);
typedef void (*FinalizerThreadCallback) (gpointer user_data);
struct _RefQueueEntry {
void *dis_link;
- guint32 gchandle;
+ MonoGCHandle gchandle;
MonoDomain *domain;
void *user_data;
RefQueueEntry *next;
#if ENABLE_NETCORE
-gpointer
+MonoGCHandle
ves_icall_System_GCHandle_InternalAlloc (MonoObjectHandle obj, gint32 type, MonoError *error)
{
- guint32 handle = 0;
+ MonoGCHandle handle = NULL;
switch (type) {
case HANDLE_WEAK:
default:
g_assert_not_reached ();
}
- /* The lowest bit is used to mark pinned handles by netcore's GCHandle class */
- return GUINT_TO_POINTER (handle << 1);
+ return handle;
}
void
-ves_icall_System_GCHandle_InternalFree (gpointer handle, MonoError *error)
+ves_icall_System_GCHandle_InternalFree (MonoGCHandle handle, MonoError *error)
{
- mono_gchandle_free_internal (GPOINTER_TO_UINT (handle) >> 1);
+ mono_gchandle_free_internal (handle);
}
MonoObjectHandle
-ves_icall_System_GCHandle_InternalGet (gpointer handle, MonoError *error)
+ves_icall_System_GCHandle_InternalGet (MonoGCHandle handle, MonoError *error)
{
- return mono_gchandle_get_target_handle (GPOINTER_TO_UINT (handle) >> 1);
+ return mono_gchandle_get_target_handle (handle);
}
void
-ves_icall_System_GCHandle_InternalSet (gpointer handle, MonoObjectHandle obj, MonoError *error)
+ves_icall_System_GCHandle_InternalSet (MonoGCHandle handle, MonoObjectHandle obj, MonoError *error)
{
- mono_gchandle_set_target_handle (GPOINTER_TO_UINT (handle) >> 1, obj);
+ mono_gchandle_set_target_handle (handle, obj);
}
#else
MonoObjectHandle
-ves_icall_System_GCHandle_GetTarget (guint32 handle, MonoError *error)
+ves_icall_System_GCHandle_GetTarget (MonoGCHandle handle, MonoError *error)
{
return mono_gchandle_get_target_handle (handle);
}
/*
* if type == -1, change the target of the handle, otherwise allocate a new handle.
*/
-guint32
-ves_icall_System_GCHandle_GetTargetHandle (MonoObjectHandle obj, guint32 handle, gint32 type, MonoError *error)
+MonoGCHandle
+ves_icall_System_GCHandle_GetTargetHandle (MonoObjectHandle obj, MonoGCHandle handle, gint32 type, MonoError *error)
{
if (type == -1) {
mono_gchandle_set_target_handle (handle, obj);
default:
g_assert_not_reached ();
}
- return 0;
+ return NULL;
}
void
-ves_icall_System_GCHandle_FreeHandle (guint32 handle)
+ves_icall_System_GCHandle_FreeHandle (MonoGCHandle handle)
{
mono_gchandle_free_internal (handle);
}
gpointer
-ves_icall_System_GCHandle_GetAddrOfPinnedObject (guint32 handle)
+ves_icall_System_GCHandle_GetAddrOfPinnedObject (MonoGCHandle handle)
{
// Handles seem to only be in the way here, and the object is pinned.
MonoObject *obj;
+ guint32 gch = MONO_GC_HANDLE_TO_UINT (handle);
- if (MONO_GC_HANDLE_TYPE (handle) != HANDLE_PINNED)
+ if (MONO_GC_HANDLE_TYPE (gch) != HANDLE_PINNED)
return (gpointer)-2;
+
obj = mono_gchandle_get_target_internal (handle);
if (obj) {
MonoClass *klass = mono_object_class (obj);
}
MonoBoolean
-ves_icall_System_GCHandle_CheckCurrentDomain (guint32 gchandle)
+ves_icall_System_GCHandle_CheckCurrentDomain (MonoGCHandle gchandle)
{
return mono_gchandle_is_in_domain (gchandle, mono_domain_get ());
}
RefQueueEntry *entry;
while ((entry = *iter)) {
if (queue->should_be_deleted || !mono_gchandle_get_target_internal (entry->gchandle)) {
- mono_gchandle_free_internal ((guint32)entry->gchandle);
+ mono_gchandle_free_internal (entry->gchandle);
ref_list_remove_element (iter, entry);
queue->callback (entry->user_data);
g_free (entry);
RefQueueEntry *entry;
while ((entry = *iter)) {
if (entry->domain == domain) {
- mono_gchandle_free_internal ((guint32)entry->gchandle);
+ mono_gchandle_free_internal (entry->gchandle);
ref_list_remove_element (iter, entry);
queue->callback (entry->user_data);
g_free (entry);
return MONO_HANDLE_NEW (MonoArray, mono_array_new_full_checked (domain, array_class, lengths, lower_bounds, error));
}
-uint32_t
+MonoGCHandle
mono_gchandle_from_handle (MonoObjectHandle handle, mono_bool pinned)
{
// FIXME This used to check for out of scope handles.
}
MonoObjectHandle
-mono_gchandle_get_target_handle (uint32_t gchandle)
+mono_gchandle_get_target_handle (MonoGCHandle gchandle)
{
return MONO_HANDLE_NEW (MonoObject, mono_gchandle_get_target_internal (gchandle));
}
gpointer
-mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t idx, uint32_t *gchandle)
+mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t idx, MonoGCHandle *gchandle)
{
g_assert (gchandle != NULL);
*gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST(MonoObject,handle), TRUE);
}
gunichar2*
-mono_string_handle_pin_chars (MonoStringHandle handle, uint32_t *gchandle)
+mono_string_handle_pin_chars (MonoStringHandle handle, MonoGCHandle *gchandle)
{
g_assert (gchandle != NULL);
*gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, handle), TRUE);
}
gpointer
-mono_object_handle_pin_unbox (MonoObjectHandle obj, uint32_t *gchandle)
+mono_object_handle_pin_unbox (MonoObjectHandle obj, MonoGCHandle *gchandle)
{
g_assert (!MONO_HANDLE_IS_NULL (obj));
MonoClass *klass = mono_handle_class (obj);
//FIXME inline
gboolean
-mono_gchandle_target_equal (uint32_t gchandle, MonoObjectHandle equal)
+mono_gchandle_target_equal (MonoGCHandle gchandle, MonoObjectHandle equal)
{
// This function serves to reduce coop handle creation.
MONO_HANDLE_SUPPRESS_SCOPE (1);
//FIXME inline
void
-mono_gchandle_target_is_null_or_equal (uint32_t gchandle, MonoObjectHandle equal, gboolean *is_null,
+mono_gchandle_target_is_null_or_equal (MonoGCHandle gchandle, MonoObjectHandle equal, gboolean *is_null,
gboolean *is_equal)
{
// This function serves to reduce coop handle creation.
//FIXME inline
void
-mono_gchandle_set_target_handle (guint32 gchandle, MonoObjectHandle obj)
+mono_gchandle_set_target_handle (MonoGCHandle gchandle, MonoObjectHandle obj)
{
mono_gchandle_set_target (gchandle, MONO_HANDLE_RAW (obj));
}
//FIXME inline
-guint32
+MonoGCHandle
mono_gchandle_new_weakref_from_handle (MonoObjectHandle handle)
{
return mono_gchandle_new_weakref_internal (MONO_HANDLE_SUPPRESS (MONO_HANDLE_RAW (handle)), FALSE);
}
//FIXME inline
-guint32
+MonoGCHandle
mono_gchandle_new_weakref_from_handle_track_resurrection (MonoObjectHandle handle)
{
return mono_gchandle_new_weakref_internal (MONO_HANDLE_SUPPRESS (MONO_HANDLE_RAW (handle)), TRUE);
/* Local handles to global GC handles and back */
-uint32_t
+MonoGCHandle
mono_gchandle_from_handle (MonoObjectHandle handle, mono_bool pinned);
MonoObjectHandle
-mono_gchandle_get_target_handle (uint32_t gchandle);
+mono_gchandle_get_target_handle (MonoGCHandle gchandle);
gboolean
-mono_gchandle_target_equal (uint32_t gchandle, MonoObjectHandle equal);
+mono_gchandle_target_equal (MonoGCHandle gchandle, MonoObjectHandle equal);
void
-mono_gchandle_target_is_null_or_equal (uint32_t gchandle, MonoObjectHandle equal, gboolean *is_null,
+mono_gchandle_target_is_null_or_equal (MonoGCHandle gchandle, MonoObjectHandle equal, gboolean *is_null,
gboolean *is_equal);
void
-mono_gchandle_set_target_handle (guint32 gchandle, MonoObjectHandle obj);
+mono_gchandle_set_target_handle (MonoGCHandle gchandle, MonoObjectHandle obj);
void
mono_array_handle_memcpy_refs (MonoArrayHandle dest, uintptr_t dest_idx, MonoArrayHandle src, uintptr_t src_idx, uintptr_t len);
* size. Call mono_gchandle_free to unpin.
*/
gpointer
-mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t index, uint32_t *gchandle);
+mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t index, MonoGCHandle *gchandle);
#define MONO_ARRAY_HANDLE_PIN(handle,type,index,gchandle_out) ((type*)mono_array_handle_pin_with_size (MONO_HANDLE_CAST(MonoArray,(handle)), sizeof (type), (index), (gchandle_out)))
mono_value_copy_array_handle (MonoArrayHandle dest, int dest_idx, gconstpointer src, int count);
gunichar2 *
-mono_string_handle_pin_chars (MonoStringHandle s, uint32_t *gchandle_out);
+mono_string_handle_pin_chars (MonoStringHandle s, MonoGCHandle *gchandle_out);
gpointer
-mono_object_handle_pin_unbox (MonoObjectHandle boxed_valuetype_obj, uint32_t *gchandle_out);
+mono_object_handle_pin_unbox (MonoObjectHandle boxed_valuetype_obj, MonoGCHandle *gchandle_out);
static inline gpointer
mono_handle_unbox_unsafe (MonoObjectHandle handle)
void
mono_context_set_handle (MonoAppContextHandle new_context);
-guint32
+MonoGCHandle
mono_gchandle_new_weakref_from_handle (MonoObjectHandle handle);
int
mono_handle_hash (MonoObjectHandle object);
-guint32
+MonoGCHandle
mono_gchandle_new_weakref_from_handle_track_resurrection (MonoObjectHandle handle);
#endif /* __MONO_HANDLE_H__ */
ICALL_EXPORT MonoBoolean ves_icall_RuntimeTypeHandle_is_subclass_of (MonoType*, MonoType*);
ICALL_EXPORT MonoBoolean ves_icall_System_Environment_GetIs64BitOperatingSystem (void);
ICALL_EXPORT MonoBoolean ves_icall_System_Environment_get_HasShutdownStarted (void);
-ICALL_EXPORT MonoBoolean ves_icall_System_GCHandle_CheckCurrentDomain (guint32 gchandle);
+ICALL_EXPORT MonoBoolean ves_icall_System_GCHandle_CheckCurrentDomain (MonoGCHandle gchandle);
ICALL_EXPORT MonoBoolean ves_icall_System_IO_DriveInfo_GetDiskFreeSpace (const gunichar2*, gint32, guint64*, guint64*, guint64*, gint32*);
ICALL_EXPORT MonoBoolean ves_icall_System_Reflection_AssemblyName_ParseAssemblyName (const char*, MonoAssemblyName*, MonoBoolean*, MonoBoolean* is_token_defined_arg);
ICALL_EXPORT MonoBoolean ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void);
ICALL_EXPORT gint64 ves_icall_System_Diagnostics_Stopwatch_GetTimestamp (void);
ICALL_EXPORT gint64 ves_icall_System_GC_GetTotalMemory (MonoBoolean forceCollection);
ICALL_EXPORT gint64 ves_icall_System_Threading_Timer_GetTimeMonotonic (void);
-ICALL_EXPORT gpointer ves_icall_System_GCHandle_GetAddrOfPinnedObject (guint32 handle);
+ICALL_EXPORT gpointer ves_icall_System_GCHandle_GetAddrOfPinnedObject (MonoGCHandle handle);
ICALL_EXPORT int ves_icall_Interop_Sys_DoubleToString (double, char*, char*, int);
ICALL_EXPORT int ves_icall_System_Environment_get_Platform (void);
ICALL_EXPORT int ves_icall_System_GC_GetCollectionCount (int);
ICALL_EXPORT void ves_icall_System_Array_SetGenericValue_icall (MonoArray**, guint32, gpointer);
ICALL_EXPORT void ves_icall_System_Buffer_MemcpyInternal (gpointer dest, gconstpointer src, gint32 count);
ICALL_EXPORT void ves_icall_System_Environment_Exit (int);
-ICALL_EXPORT void ves_icall_System_GCHandle_FreeHandle (guint32 handle);
+ICALL_EXPORT void ves_icall_System_GCHandle_FreeHandle (MonoGCHandle handle);
ICALL_EXPORT void ves_icall_System_GC_InternalCollect (int generation);
ICALL_EXPORT void ves_icall_System_GC_RecordPressure (gint64);
ICALL_EXPORT void ves_icall_System_GC_WaitForPendingFinalizers (void);
NOHANDLES(ICALL(GCH_1, "CheckCurrentDomain", ves_icall_System_GCHandle_CheckCurrentDomain))
NOHANDLES(ICALL(GCH_2, "FreeHandle", ves_icall_System_GCHandle_FreeHandle))
NOHANDLES(ICALL(GCH_3, "GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject))
-HANDLES(GCH_4, "GetTarget", ves_icall_System_GCHandle_GetTarget, MonoObject, 1, (guint32))
-HANDLES(GCH_5, "GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle, guint32, 3, (MonoObject, guint32, gint32))
+HANDLES(GCH_4, "GetTarget", ves_icall_System_GCHandle_GetTarget, MonoObject, 1, (gpointer))
+HANDLES(GCH_5, "GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle, gpointer, 3, (MonoObject, gpointer, gint32))
#if !defined(DISABLE_COM) || defined (HOST_WIN32)
ICALL_TYPE(MARSHAL, "System.Runtime.InteropServices.Marshal", MARSHAL_1)
return_if_nok (error);
gboolean isref = FALSE;
- uint32_t value_gchandle = 0;
+ MonoGCHandle value_gchandle = 0;
gchar *v = NULL;
if (!type->byref) {
switch (type->type) {
MonoObjectHandle nullable = mono_object_new_handle (mono_domain_get (), nklass, error);
return_if_nok (error);
- uint32_t nullable_gchandle = 0;
+ MonoGCHandle nullable_gchandle = 0;
guint8 *nval = (guint8*)mono_object_handle_pin_unbox (nullable, &nullable_gchandle);
mono_nullable_init_from_handle (nval, value, nklass);
} else if (MONO_TYPE_IS_REFERENCE (f->type)) {
mono_copy_value (f->type, (guint8*)obj->value + m_field_get_offset (f) - sizeof (MonoObject), MONO_HANDLE_RAW (value_h), FALSE);
} else {
- guint gchandle = 0;
+ MonoGCHandle gchandle = NULL;
g_assert (MONO_HANDLE_RAW (value_h));
mono_copy_value (f->type, (guint8*)obj->value + m_field_get_offset (f) - sizeof (MonoObject), mono_object_handle_pin_unbox (value_h, &gchandle), FALSE);
mono_gchandle_free_internal (gchandle);
if (mono_class_is_ginst (klass)) {
MonoClass *generic_class = mono_class_get_generic_class (klass)->container_class;
- guint32 ref_info_handle = mono_class_get_ref_info_handle (generic_class);
+ MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (generic_class);
if (m_class_was_typebuilder (generic_class) && ref_info_handle) {
MonoObjectHandle tb = mono_gchandle_get_target_handle (ref_info_handle);
// FIXME MONO_ENTER_NO_SAFEPOINTS instead of pin/gchandle.
- uint32_t h;
+ MonoGCHandle h;
gpointer array_base = MONO_ARRAY_HANDLE_PIN (res, guint8, 0, &h);
memcpy (array_base, ptr, len);
mono_gchandle_free_internal (h);
}
static void
-emit_managed_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
+emit_managed_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, MonoGCHandle target_handle)
{
MonoMethodSignature *sig, *csig;
int i, *tmp_locals, orig_domain, attach_cookie;
if (sig->hasthis) {
if (target_handle) {
- mono_mb_emit_icon (mb, (gint32)target_handle);
+ mono_mb_emit_icon8 (mb, (gint64)target_handle);
+ mono_mb_emit_byte (mb, CEE_CONV_I);
mono_mb_emit_icall (mb, mono_gchandle_get_target_internal);
} else {
/* fixme: */
g_assert_not_reached ();
}
} else if (closed) {
- mono_mb_emit_icon (mb, (gint32)target_handle);
+ mono_mb_emit_icon8 (mb, (gint64)target_handle);
+ mono_mb_emit_byte (mb, CEE_CONV_I);
mono_mb_emit_icall (mb, mono_gchandle_get_target_internal);
}
// FIXME pass g_utf16_to_utf8 an allocator to avoid double alloc/copy.
- uint32_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
tmp = g_utf16_to_utf8 (mono_string_handle_pin_chars (s, &gchandle), mono_string_handle_length (s), NULL, &len, &gerror);
mono_gchandle_free_internal (gchandle);
if (gerror) {
register_icall (mono_delegate_begin_invoke, mono_icall_sig_object_object_ptr, FALSE);
register_icall (mono_delegate_end_invoke, mono_icall_sig_object_object_ptr, FALSE);
register_icall (mono_gc_wbarrier_generic_nostore_internal, mono_icall_sig_void_ptr, FALSE);
- register_icall (mono_gchandle_get_target_internal, mono_icall_sig_object_int32, TRUE);
+ register_icall (mono_gchandle_get_target_internal, mono_icall_sig_object_ptr, TRUE);
register_icall (mono_marshal_isinst_with_cache, mono_icall_sig_object_object_ptr_ptr, FALSE);
register_icall (mono_threads_enter_gc_safe_region_unbalanced, mono_icall_sig_ptr_ptr, TRUE);
register_icall (mono_threads_exit_gc_safe_region_unbalanced, mono_icall_sig_void_ptr_ptr, TRUE);
gpointer result = NULL;
MonoMethod *method, *wrapper;
MonoClass *klass;
- uint32_t target_handle = 0;
+ MonoGCHandle target_handle = 0;
if (MONO_HANDLE_IS_NULL (delegate))
goto leave;
static void
delegate_hash_table_remove (MonoDelegate *d)
{
- guint32 gchandle = 0;
+ MonoGCHandle gchandle = NULL;
if (!d->target)
return;
mono_marshal_lock ();
if (delegate_hash_table == NULL)
delegate_hash_table = delegate_hash_table_new ();
- gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, d->delegate_trampoline));
+ gchandle = (MonoGCHandle)g_hash_table_lookup (delegate_hash_table, d->delegate_trampoline);
g_hash_table_remove (delegate_hash_table, d->delegate_trampoline);
mono_marshal_unlock ();
if (gchandle)
if (has_target) {
// If the delegate has an instance method there is 1 to 1 mapping between
// the delegate object and the delegate_trampoline
- guint32 gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, delegate_trampoline));
+ MonoGCHandle gchandle = (MonoGCHandle)g_hash_table_lookup (delegate_hash_table, delegate_trampoline);
if (gchandle) {
// Somehow, some other thread beat us to it ?
g_assert (mono_gchandle_target_equal (gchandle, MONO_HANDLE_CAST (MonoObject, d)));
} else {
gchandle = mono_gchandle_new_weakref_from_handle (MONO_HANDLE_CAST (MonoObject, d));
- g_hash_table_insert (delegate_hash_table, delegate_trampoline, GUINT_TO_POINTER (gchandle));
+ g_hash_table_insert (delegate_hash_table, delegate_trampoline, gchandle);
}
} else {
if (g_hash_table_lookup (delegate_hash_table, delegate_trampoline) == NULL) {
- guint32 gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, d), FALSE);
+ MonoGCHandle gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, d), FALSE);
// This delegate will always be associated with its delegate_trampoline in the table.
// We don't free this delegate object because it is too expensive to keep track of these
// pairs and avoid races with the delegate finalization.
- g_hash_table_insert (delegate_hash_table, delegate_trampoline, GUINT_TO_POINTER (gchandle));
+ g_hash_table_insert (delegate_hash_table, delegate_trampoline, gchandle);
}
}
mono_marshal_unlock ();
MonoDelegateHandle
mono_ftnptr_to_delegate_impl (MonoClass *klass, gpointer ftn, MonoError *error)
{
- guint32 gchandle;
+ MonoGCHandle gchandle;
MonoDelegateHandle d = MONO_HANDLE_NEW (MonoDelegate, NULL);
if (ftn == NULL)
mono_marshal_lock ();
if (delegate_hash_table == NULL)
delegate_hash_table = delegate_hash_table_new ();
- gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, ftn));
+ gchandle = (MonoGCHandle)g_hash_table_lookup (delegate_hash_table, ftn);
mono_marshal_unlock ();
if (gchandle)
MONO_HANDLE_ASSIGN (d, MONO_HANDLE_CAST (MonoDelegate, mono_gchandle_get_target_handle (gchandle)));
}
if (ptr) {
- uint32_t gchandle;
+ MonoGCHandle gchandle;
void **method_data;
MonoMethod *method;
method_data = (void **)((MonoMethodWrapper*)method)->method_data;
/*the target gchandle is the first entry after size and the wrapper itself.*/
- gchandle = GPOINTER_TO_UINT (method_data [2]);
+ gchandle = (MonoGCHandle)method_data [2];
if (gchandle)
mono_gchandle_free_internal (gchandle);
g_error_free (gerror);
return;
}
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
memcpy (MONO_ARRAY_HANDLE_PIN (arr, gunichar2, 0, &gchandle), ut, items_written * sizeof (gunichar2));
mono_gchandle_free_internal (gchandle);
g_free (ut);
GError *gerror = NULL;
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
char *as = g_utf16_to_utf8 (MONO_ARRAY_HANDLE_PIN (arr, gunichar2, 0, &gchandle), mono_array_handle_length (arr), NULL, NULL, &gerror);
mono_gchandle_free_internal (gchandle);
if (gerror) {
return;
}
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
int len = MIN (size, mono_string_handle_length (src));
memcpy (dst, mono_string_handle_pin_chars (src, &gchandle), len * sizeof (gunichar2));
mono_gchandle_free_internal (gchandle);
* THIS_LOC is the memory location where the target of the delegate is stored.
*/
void
-mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
+mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, MonoGCHandle target_handle)
{
get_marshal_cb ()->emit_managed_wrapper (mb, invoke_sig, mspecs, m, method, target_handle);
}
#ifndef ENABLE_ILGEN
static void
-emit_managed_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
+emit_managed_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, MonoGCHandle target_handle)
{
MonoMethodSignature *sig, *csig;
int i;
* If \p target_handle is \c 0, the wrapper info will be a \c WrapperInfo structure.
*/
MonoMethod *
-mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, uint32_t target_handle, MonoError *error)
+mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, MonoGCHandle target_handle, MonoError *error)
{
MonoMethodSignature *sig, *csig, *invoke_sig;
MonoMethodBuilder *mb;
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_NATIVE_TO_MANAGED);
/*the target gchandle must be the first entry after size and the wrapper itself.*/
- mono_mb_add_data (mb, GUINT_TO_POINTER (target_handle));
+ mono_mb_add_data (mb, target_handle);
/* we copy the signature, so that we can modify it */
if (target_handle)
gsize const length = mono_string_handle_length (s);
gunichar2 *res = (gunichar2 *)mono_marshal_alloc ((length + 1) * sizeof (*res), error);
return_val_if_nok (error, NULL);
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
memcpy (res, mono_string_handle_pin_chars (s, &gchandle), length * sizeof (*res));
mono_gchandle_free_internal (gchandle);
res [length] = 0;
static gsize
copy_managed_common (MonoArrayHandle managed, gconstpointer native, gint32 start_index,
- gint32 length, gpointer *managed_addr, guint32 *gchandle, MonoError *error)
+ gint32 length, gpointer *managed_addr, MonoGCHandle *gchandle, MonoError *error)
{
MONO_CHECK_ARG_NULL_HANDLE (managed, 0);
MONO_CHECK_ARG_NULL (native, 0);
{
g_assert_not_netcore ();
- guint32 gchandle = 0;
+ MonoGCHandle gchandle = 0;
gsize const bytes = copy_managed_common (src, dest, start_index, length, (gpointer*)&managed_source_addr, &gchandle, error);
if (bytes)
memmove (dest, managed_source_addr, bytes); // no references should be involved
{
g_assert_not_netcore ();
- guint32 gchandle = 0;
+ MonoGCHandle gchandle = 0;
gsize const bytes = copy_managed_common (dest, src, start_index, length, &managed_dest_addr, &gchandle, error);
if (bytes)
memmove (managed_dest_addr, src, bytes); // no references should be involved
void (*emit_stelemref) (MonoMethodBuilder *mb);
void (*emit_array_address) (MonoMethodBuilder *mb, int rank, int elem_size);
void (*emit_native_wrapper) (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func, gboolean aot, gboolean check_exceptions, gboolean func_param, gboolean skip_gc_trans);
- void (*emit_managed_wrapper) (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle);
+ void (*emit_managed_wrapper) (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, MonoGCHandle target_handle);
void (*emit_runtime_invoke_body) (MonoMethodBuilder *mb, const char **param_names, MonoImage *image, MonoMethod *method, MonoMethodSignature *sig, MonoMethodSignature *callsig, gboolean virtual_, gboolean need_direct_wrapper);
void (*emit_runtime_invoke_dynamic) (MonoMethodBuilder *mb);
void (*emit_delegate_begin_invoke) (MonoMethodBuilder *mb, MonoMethodSignature *sig);
mono_marshal_get_string_ctor_signature (MonoMethod *method);
MonoMethod *
-mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, uint32_t this_loc, MonoError *exernal_error);
+mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, MonoGCHandle this_loc, MonoError *exernal_error);
gpointer
mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type);
mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func, gboolean aot, gboolean check_exceptions, gboolean func_param, gboolean skip_gc_trans);
void
-mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle);
+mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, MonoGCHandle target_handle);
GHashTable*
mono_marshal_get_cache (GHashTable **var, GHashFunc hash_func, GCompareFunc equal_func);
to_recycle++;
} else {
if (!monitor_is_on_freelist ((MonoThreadsSync *)mon->data)) {
- MonoObject *holder = (MonoObject *)mono_gchandle_get_target_internal ((guint32)(gsize)mon->data);
+ MonoObject *holder = (MonoObject *)mono_gchandle_get_target_internal ((MonoGCHandle)mon->data);
if (mon_status_get_owner (mon->status)) {
g_print ("Lock %p in object %p held by thread %d, nest level: %d\n",
mon, holder, mon_status_get_owner (mon->status), mon->nest);
new_ = NULL;
for (marray = monitor_allocated; marray; marray = marray->next) {
for (i = 0; i < marray->num_monitors; ++i) {
- if (mono_gchandle_get_target_internal ((guint32)(gsize)marray->monitors [i].data) == NULL) {
+ if (mono_gchandle_get_target_internal ((MonoGCHandle)marray->monitors [i].data) == NULL) {
new_ = &marray->monitors [i];
if (new_->wait_list) {
/* Orphaned events left by aborted threads */
new_->wait_list = g_slist_remove (new_->wait_list, new_->wait_list->data);
}
}
- mono_gchandle_free_internal ((guint32)(gsize)new_->data);
+ mono_gchandle_free_internal ((MonoGCHandle)new_->data);
new_->data = monitor_freelist;
monitor_freelist = new_;
}
mono_monitor_allocator_lock ();
mon = mon_new (id);
- mon->data = (void *)(size_t)mono_gchandle_new_weakref_internal (obj, TRUE);
+ mon->data = mono_gchandle_new_weakref_internal (obj, TRUE);
mono_monitor_allocator_unlock ();
return mon;
discard_mon (MonoThreadsSync *mon)
{
mono_monitor_allocator_lock ();
- mono_gchandle_free_internal ((guint32)(gsize)mon->data);
+ mono_gchandle_free_internal ((MonoGCHandle)mon->data);
mon_finalize (mon);
mono_monitor_allocator_unlock ();
}
MONO_EXTERNAL_ONLY_VOID (mono_monitor_exit_internal (obj));
}
-guint32
+MonoGCHandle
mono_monitor_get_object_monitor_gchandle (MonoObject *object)
{
LockWord lw;
if (lock_word_is_inflated (lw)) {
MonoThreadsSync *mon = lock_word_get_inflated_lock (lw);
- return (guint32)(gsize)mon->data;
+ return (MonoGCHandle)mon->data;
}
- return 0;
+ return NULL;
}
/*
guint32
mono_monitor_enter_v4_fast (MonoObject *obj, MonoBoolean *lock_taken);
-guint32
+MonoGCHandle
mono_monitor_get_object_monitor_gchandle (MonoObject *object);
void
MonoThreadName name;
guint32 state; /* must be accessed while longlived->synch_cs is locked */
MonoException *abort_exc;
- int abort_state_handle;
+ MonoGCHandle abort_state_handle;
guint64 tid; /* This is accessed as a gsize in the code (so it can hold a 64bit pointer on systems that need it), but needs to reserve 64 bits of space on all machines as it corresponds to a field in managed code */
gsize debugger_thread; // FIXME switch to bool as soon as CI testing with corlib version bump works
gpointer *static_data;
* mono_gchandle_get_target () can be used to get the object referenced by both kinds
* of handle: for a weakref handle, if an object has been collected, it will return NULL.
*/
-uint32_t
+MonoGCHandle
mono_gchandle_new_internal (MonoObject *obj, mono_bool pinned);
-uint32_t
+MonoGCHandle
mono_gchandle_new_weakref_internal (MonoObject *obj, mono_bool track_resurrection);
ICALL_EXTERN_C
MonoObject*
-mono_gchandle_get_target_internal (uint32_t gchandle);
+mono_gchandle_get_target_internal (MonoGCHandle gchandle);
-void mono_gchandle_free_internal (uint32_t gchandle);
+void mono_gchandle_free_internal (MonoGCHandle gchandle);
/* Reference queue support
*
g_assertf (method, "Could not lookup zero argument constructor for class %s", mono_type_get_full_name (klass));
if (m_class_is_valuetype (method->klass)) {
- guint gchandle = 0;
+ MonoGCHandle gchandle = NULL;
gpointer raw = mono_object_handle_pin_unbox (this_obj, &gchandle);
mono_runtime_invoke_checked (method, raw, NULL, error);
mono_gchandle_free_internal (gchandle);
MONO_REQ_GC_UNSAFE_MODE;
if (!MONO_HANDLE_IS_NULL (value)) {
- uint32_t value_gchandle = 0;
+ MonoGCHandle value_gchandle = NULL;
gpointer src = mono_object_handle_pin_unbox (value, &value_gchandle);
mono_nullable_init_unboxed (buf, src, klass);
error_init (error);
/* Pin source array here - if bounds is non-NULL, it's a pointer into the object data */
- uint32_t src_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, array_handle), TRUE);
+ MonoGCHandle src_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, array_handle), TRUE);
MonoArrayBounds *array_bounds = MONO_HANDLE_GETVAL (array_handle, bounds);
MonoArrayHandle o;
goto_if_nok (error, leave);
}
- uint32_t dst_handle;
+ MonoGCHandle dst_handle;
dst_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, o), TRUE);
array_full_copy_unchecked_size (MONO_HANDLE_RAW (array_handle), MONO_HANDLE_RAW (o), klass, size);
mono_gchandle_free_internal (dst_handle);
mono_class_get_ref_info (MonoClass *klass)
{
MONO_REQ_GC_UNSAFE_MODE;
- guint32 ref_info_handle = mono_class_get_ref_info_handle (klass);
+ MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (klass);
if (ref_info_handle == 0)
return MONO_HANDLE_NEW (MonoReflectionTypeBuilder, NULL);
{
/* FIXME callers of mono_class_get_ref_info_raw should use handles */
MONO_REQ_GC_UNSAFE_MODE;
- guint32 ref_info_handle = mono_class_get_ref_info_handle (klass);
+ MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (klass);
if (ref_info_handle == 0)
return NULL;
{
MONO_REQ_GC_UNSAFE_MODE;
- guint32 candidate = mono_gchandle_from_handle (obj, FALSE);
- guint32 handle = mono_class_set_ref_info_handle (klass, candidate);
+ MonoGCHandle candidate = mono_gchandle_from_handle (obj, FALSE);
+ MonoGCHandle handle = mono_class_set_ref_info_handle (klass, candidate);
++class_ref_info_handle_count;
if (handle != candidate)
mono_class_free_ref_info (MonoClass *klass)
{
MONO_REQ_GC_NEUTRAL_MODE;
- guint32 handle = mono_class_get_ref_info_handle (klass);
+ MonoGCHandle handle = mono_class_get_ref_info_handle (klass);
if (handle) {
mono_gchandle_free_internal (handle);
MonoArrayHandle il_arr;
il_arr = mono_array_new_handle (domain, mono_defaults.byte_class, header->code_size, error);
goto_if_nok (error, fail);
- uint32_t il_gchandle;
+ MonoGCHandle il_gchandle;
guint8* il_data;
il_data = MONO_ARRAY_HANDLE_PIN (il_arr, guint8, 0, &il_gchandle);
memcpy (il_data, header->code, header->code_size);
case MONO_TYPE_U8:
case MONO_TYPE_R4:
case MONO_TYPE_R8: {
- uint32_t gchandle = mono_gchandle_from_handle (val, TRUE);
+ MonoGCHandle gchandle = mono_gchandle_from_handle (val, TRUE);
MonoObjectHandle res = MONO_HANDLE_NEW (MonoObject, mono_value_box_checked (domain, klass, ((char*)MONO_HANDLE_RAW (val)) + sizeof(MonoObject), error)); /* FIXME use handles in mono_value_box_checked */
mono_gchandle_free_internal (gchandle);
goto_if_nok (error, leave);
}
case MONO_TYPE_STRING: {
MonoStringHandle str = MONO_HANDLE_CAST (MonoString, val);
- uint32_t gchandle = mono_gchandle_from_handle (val, TRUE);
+ MonoGCHandle gchandle = mono_gchandle_from_handle (val, TRUE);
MonoStringHandle res = mono_string_new_utf16_handle (domain, mono_string_chars_internal (MONO_HANDLE_RAW (str)), mono_string_handle_length (str), error);
mono_gchandle_free_internal (gchandle);
goto_if_nok (error, leave);
remove = need_remove_object_for_domain (obj, domain);
if (remove && obj->synchronisation) {
- guint32 dislink = mono_monitor_get_object_monitor_gchandle (obj);
+ MonoGCHandle dislink = mono_monitor_get_object_monitor_gchandle (obj);
if (dislink)
mono_gchandle_free_internal (dislink);
}
*
* \returns a handle that can be used to access the object from unmanaged code.
*/
-guint32
+MonoGCHandle
mono_gchandle_new_internal (MonoObject *obj, gboolean pinned)
{
- return sgen_gchandle_new (obj, pinned);
+ return MONO_GC_HANDLE_FROM_UINT (sgen_gchandle_new (obj, pinned));
}
/**
* \returns a handle that can be used to access the object from
* unmanaged code.
*/
-guint32
+MonoGCHandle
mono_gchandle_new_weakref_internal (GCObject *obj, gboolean track_resurrection)
{
- return sgen_gchandle_new_weakref (obj, track_resurrection);
+ return MONO_GC_HANDLE_FROM_UINT (sgen_gchandle_new_weakref (obj, track_resurrection));
}
/**
* \returns TRUE if the object wrapped by the \p gchandle belongs to the specific \p domain.
*/
gboolean
-mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain)
+mono_gchandle_is_in_domain (MonoGCHandle gchandle, MonoDomain *domain)
{
- MonoDomain *gchandle_domain = (MonoDomain *)sgen_gchandle_get_metadata (gchandle);
+ MonoDomain *gchandle_domain = (MonoDomain *)sgen_gchandle_get_metadata (MONO_GC_HANDLE_TO_UINT (gchandle));
return domain->domain_id == gchandle_domain->domain_id;
}
* object wrapped.
*/
void
-mono_gchandle_free_internal (guint32 gchandle)
+mono_gchandle_free_internal (MonoGCHandle gchandle)
{
- sgen_gchandle_free (gchandle);
+ sgen_gchandle_free (MONO_GC_HANDLE_TO_UINT (gchandle));
}
/**
* NULL for a collected object if using a weakref handle.
*/
MonoObject*
-mono_gchandle_get_target_internal (guint32 gchandle)
+mono_gchandle_get_target_internal (MonoGCHandle gchandle)
{
- return sgen_gchandle_get_target (gchandle);
+ return sgen_gchandle_get_target (MONO_GC_HANDLE_TO_UINT (gchandle));
}
static gpointer
}
void
-mono_gchandle_set_target (guint32 gchandle, MonoObject *obj)
+mono_gchandle_set_target (MonoGCHandle gchandle, MonoObject *obj)
{
- sgen_gchandle_set_target (gchandle, obj);
+ sgen_gchandle_set_target (MONO_GC_HANDLE_TO_UINT (gchandle), obj);
}
void
MonoArrayHandle result;
result = mono_array_new_handle (mono_domain_get (), mono_defaults.byte_class, buflen, error);
goto_if_nok (error, fail);
- uint32_t gchandle;
+ MonoGCHandle gchandle;
void *base;
base = MONO_ARRAY_HANDLE_PIN (result, char, 0, &gchandle);
memcpy (base, buf.buf, buflen);
MonoArrayHandle result;
result = mono_array_new_handle (mono_domain_get (), mono_defaults.byte_class, buflen, error);
goto_if_nok (error, fail);
- uint32_t gchandle;
+ MonoGCHandle gchandle;
void *base;
base = MONO_ARRAY_HANDLE_PIN (result, char, 0, &gchandle);
memcpy (base, buf.buf, buflen);
mono_metadata_encode_value (1 | (length * 2), b, &b);
idx = mono_image_add_stream_data (&assembly->us, buf, b-buf);
/* pinned */
- uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, str), TRUE);
+ MonoGCHandle gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, str), TRUE);
const char *p = (const char*)mono_string_chars_internal (MONO_HANDLE_RAW (str));
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
{
DynamicMethodReleaseData *data = (DynamicMethodReleaseData *)dynamic_method;
MonoDomain *domain = data->domain;
MonoMethod *method = data->handle;
- guint32 dis_link;
+ MonoGCHandle dis_link;
mono_domain_lock (domain);
- dis_link = (guint32)(size_t)g_hash_table_lookup (domain->method_to_dyn_method, method);
+ dis_link = g_hash_table_lookup (domain->method_to_dyn_method, method);
g_hash_table_remove (domain->method_to_dyn_method, method);
mono_domain_unlock (domain);
g_assert (dis_link);
mono_domain_lock (domain);
if (!domain->method_to_dyn_method)
domain->method_to_dyn_method = g_hash_table_new (NULL, NULL);
- g_hash_table_insert (domain->method_to_dyn_method, handle, (gpointer)(size_t)mono_gchandle_new_weakref_internal ((MonoObject *)mb, TRUE));
+ g_hash_table_insert (domain->method_to_dyn_method, handle, mono_gchandle_new_weakref_internal ((MonoObject *)mb, TRUE));
mono_domain_unlock (domain);
return TRUE;
void
ves_icall_AssemblyBuilder_basic_init (MonoReflectionAssemblyBuilderHandle assemblyb, MonoError *error)
{
- uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, assemblyb), TRUE);
+ MonoGCHandle gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, assemblyb), TRUE);
mono_reflection_dynimage_basic_init (MONO_HANDLE_RAW (assemblyb), error);
mono_gchandle_free_internal (gchandle);
}
MonoThreadInfo *info;
MonoInternalThread *internal;
MonoDomain *domain, *root_domain;
- guint32 gchandle;
+ MonoGCHandle gchandle;
g_assert (thread);
MonoThreadInfo *info;
MonoInternalThread *value;
gboolean removed;
- guint32 gchandle;
+ MonoGCHandle gchandle;
g_assert (mono_thread_internal_is_current (thread));
internal->state = ThreadState_Unstarted;
- int const thread_gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, this_obj_handle), TRUE);
+ MonoGCHandle thread_gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, this_obj_handle), TRUE);
MonoThreadObject *this_obj = MONO_HANDLE_RAW (this_obj_handle);
struct {
MonoArrayHandle handle;
gpointer p;
- guint gchandle;
+ MonoGCHandle gchandle;
}
source = { arr },
dest = { mono_array_new_handle (domain, mono_defaults.byte_class, size, error) };
if (!context_queue)
context_queue = mono_gc_reference_queue_new_internal (free_context);
- gpointer gch = GUINT_TO_POINTER (mono_gchandle_new_weakref_from_handle (MONO_HANDLE_CAST (MonoObject, ctx)));
+ MonoGCHandle gch = mono_gchandle_new_weakref_from_handle (MONO_HANDLE_CAST (MonoObject, ctx));
g_hash_table_insert (contexts, gch, gch);
/*
* handle in the reference queue callback.
*/
ContextStaticData *data = g_new0 (ContextStaticData, 1);
- data->gc_handle = GPOINTER_TO_UINT (gch);
+ data->gc_handle = gch;
MONO_HANDLE_SETVAL (ctx, data, ContextStaticData*, data);
context_adjust_static_data (ctx);
thread_detach (MonoThreadInfo *info)
{
MonoInternalThread *internal;
- guint32 gchandle;
+ MonoGCHandle gchandle;
/* If a delegate is passed to native code and invoked on a thread we dont
* know about, marshal will register it with mono_threads_attach_coop, but
typedef struct {
int nthreads, max_threads;
- guint32 *threads;
+ MonoGCHandle *threads;
} CollectThreadsUserData;
typedef struct {
* THREADS should be an array allocated on the stack.
*/
static int
-collect_threads (guint32 *thread_handles, int max_threads)
+collect_threads (MonoGCHandle *thread_handles, int max_threads)
{
CollectThreadsUserData ud;
{
FILE* output_file = NULL;
ThreadDumpUserData ud;
- guint32 thread_array [128];
+ MonoGCHandle thread_array [128];
int tindex, nthreads;
if (!thread_dump_requested)
ud.max_frames = 256;
for (tindex = 0; tindex < nthreads; ++tindex) {
- guint32 handle = thread_array [tindex];
+ MonoGCHandle handle = thread_array [tindex];
MonoInternalThread *thread = (MonoInternalThread *) mono_gchandle_get_target_internal (handle);
dump_thread (thread, &ud, output_file != NULL ? output_file : stdout);
mono_gchandle_free_internal (handle);
MONO_HANDLE_ASSIGN_RAW (out_threads_handle, NULL);
MONO_HANDLE_ASSIGN_RAW (out_stack_frames_handle, NULL);
- guint32 handle = 0;
+ MonoGCHandle handle = 0;
MonoStackFrameHandle stack_frame_handle = MONO_HANDLE_NEW (MonoStackFrame, NULL);
MonoReflectionMethodHandle reflection_method_handle = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
MonoArrayHandle thread_frames_handle = MONO_HANDLE_NEW (MonoArray, NULL);
ThreadDumpUserData ud;
- guint32 thread_array [128];
+ MonoGCHandle thread_array [128];
MonoDomain *domain = mono_domain_get ();
MonoDebugSourceLocation *location;
int tindex, nthreads;
static void
alloc_context_static_data_helper (gpointer key, gpointer value, gpointer user)
{
- MonoAppContext *ctx = (MonoAppContext *) mono_gchandle_get_target_internal (GPOINTER_TO_INT (key));
+ MonoAppContext *ctx = (MonoAppContext *) mono_gchandle_get_target_internal ((MonoGCHandle)key);
if (!ctx)
return;
static void
free_context_static_data_helper (gpointer key, gpointer value, gpointer user)
{
- MonoAppContext *ctx = (MonoAppContext *) mono_gchandle_get_target_internal (GPOINTER_TO_INT (key));
+ MonoAppContext *ctx = (MonoAppContext *) mono_gchandle_get_target_internal ((MonoGCHandle)key);
if (!ctx)
return;
return 0;
}
- guint32 buffer_handle = 0;
+ MonoGCHandle buffer_handle = NULL;
buffer = MONO_ARRAY_HANDLE_PIN (dest, guchar, dest_offset, &buffer_handle);
result = mono_w32file_read (handle, buffer, count, &n, io_error);
mono_gchandle_free_internal (buffer_handle);
return 0;
}
- guint32 src_handle = 0;
+ MonoGCHandle src_handle = NULL;
buffer = MONO_ARRAY_HANDLE_PIN (src, guchar, src_offset, &src_handle);
result = mono_w32file_write (handle, buffer, count, &n, io_error);
mono_gchandle_free_internal (src_handle);
/* Copy each environ string into 'strings' turning it into utf8 (or the requested encoding) at the same time */
for (gsize i = 0; i < array_length; ++i) {
MONO_HANDLE_ARRAY_GETREF (var, array, i);
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
env_strings [i] = mono_unicode_to_external (mono_string_handle_pin_chars (var, &gchandle));
mono_gchandle_free_internal (gchandle);
}
PROCESS_INFORMATION *process_info)
{
gboolean result = FALSE;
- gchandle_t cmd_gchandle = 0;
+ MonoGCHandle cmd_gchandle = NULL;
gunichar2 *cmd_chars = MONO_HANDLE_IS_NULL (cmd) ? NULL : mono_string_handle_pin_chars (cmd, &cmd_gchandle);
MONO_ENTER_GC_SAFE;
for (gsize i = 0; i < array_length; i++) {
MONO_HANDLE_ARRAY_GETREF (var, array, i);
- gchandle_t gchandle = 0;
+ MonoGCHandle gchandle = NULL;
memcpy (ptr, mono_string_handle_pin_chars (var, &gchandle), mono_string_handle_length (var) * sizeof (gunichar2));
mono_gchandle_free_internal (gchandle);
ptr += mono_string_handle_length (var);
#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
static void
-mono_pin_string (MonoStringHandle in_coophandle, MonoStringHandle *out_coophandle, gunichar2 **chars, gsize *length, gchandle_t *gchandle)
+mono_pin_string (MonoStringHandle in_coophandle, MonoStringHandle *out_coophandle, gunichar2 **chars, gsize *length, MonoGCHandle *gchandle)
{
*out_coophandle = in_coophandle;
if (!MONO_HANDLE_IS_NULL (in_coophandle)) {
}
static void
-mono_unpin_array (gchandle_t *gchandles, gsize count)
+mono_unpin_array (MonoGCHandle *gchandles, gsize count)
{
for (gsize i = 0; i < count; ++i) {
mono_gchandle_free_internal (gchandles [i]);
void
mono_createprocess_coop_cleanup (MonoCreateProcessCoop *coop)
{
- mono_unpin_array ((gchandle_t*)&coop->gchandle, sizeof (coop->gchandle) / sizeof (gchandle_t));
+ mono_unpin_array ((MonoGCHandle*)&coop->gchandle, sizeof (coop->gchandle) / sizeof (MonoGCHandle));
memset (coop, 0, sizeof (*coop));
}
TYPED_HANDLE_DECL (MonoW32ProcessStartInfo);
-typedef uint32_t gchandle_t; // FIXME use this more, make it typesafe.
-
typedef struct _MonoCreateProcessCoop {
gunichar2 *filename;
gunichar2 *arguments;
MonoStringHandle domain;
} coophandle;
struct {
- gchandle_t filename;
- gchandle_t arguments;
- gchandle_t working_directory;
- gchandle_t verb;
- gchandle_t username;
- gchandle_t domain;
+ MonoGCHandle filename;
+ MonoGCHandle arguments;
+ MonoGCHandle working_directory;
+ MonoGCHandle verb;
+ MonoGCHandle username;
+ MonoGCHandle domain;
} gchandle;
struct {
gsize filename;
len = MONO_HANDLE_GET_FIELD_VAL (saddr_obj, int, domain->sockaddr_data_length_field);
g_assert (len >= 2);
- uint32_t gchandle;
+ MonoGCHandle gchandle;
guint8 *buf = MONO_ARRAY_HANDLE_PIN (data, guint8, 0, &gchandle);
family = convert_family ((MonoAddressFamily)(buf[0] + (buf[1] << 8)));
if (family == AF_INET) {
valsize = mono_array_handle_length (byte_val);
- uint32_t gchandle;
+ MonoGCHandle gchandle;
guchar *buf = MONO_ARRAY_HANDLE_PIN (byte_val, guchar, 0, &gchandle);
ret = mono_w32socket_getsockopt (sock, system_level, system_name, buf, &valsize);
}
} else if (!MONO_HANDLE_IS_NULL (byte_val)) {
int valsize = mono_array_handle_length (byte_val);
- uint32_t gchandle;
+ MonoGCHandle gchandle;
guchar *buf = MONO_ARRAY_HANDLE_PIN (byte_val, guchar, 0, &gchandle);
switch(name) {
#endif
gchar *i_buffer, *o_buffer;
gint i_len, o_len;
- uint32_t i_gchandle = 0;
- uint32_t o_gchandle = 0;
+ MonoGCHandle i_gchandle = 0;
+ MonoGCHandle o_gchandle = 0;
gint ret;
error_init (error);
HANDLE file;
gboolean ret;
TRANSMIT_FILE_BUFFERS buffers;
- uint32_t pre_buffer_gchandle = 0;
- uint32_t post_buffer_gchandle = 0;
+ MonoGCHandle pre_buffer_gchandle = 0;
+ MonoGCHandle post_buffer_gchandle = 0;
error_init (error);
*werror = 0;
/* FIXME: replace file by a proper fd that we can call open and close on, as they are interruptible */
- uint32_t filename_gchandle;
+ MonoGCHandle filename_gchandle;
gunichar2 *filename_chars = mono_string_handle_pin_chars (filename, &filename_gchandle);
file = mono_w32file_create (filename_chars, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, 0);
mono_gchandle_free_internal (filename_gchandle);
* A weakref gc handle pointing to the object. The gc handle is used to
* detect if the object was garbage collected.
*/
- guint32 handle;
+ MonoGCHandle handle;
} ObjRef;
/* Clause that we are resuming to */
MonoJitExceptionInfo *handler_ei;
/* Exception that is being thrown. Set with rest of resume state */
- guint32 exc_gchandle;
+ MonoGCHandle exc_gchandle;
/* Stack of frame data */
FrameStack data_stack;
} ThreadContext;
MonoMList *list = (MonoMList*)mono_ex->dynamic_methods;
for (l = *dynamic_methods; l; l = l->next) {
- guint32 dis_link;
+ MonoGCHandle dis_link;
MonoDomain *domain = mono_domain_get ();
if (domain->method_to_dyn_method) {
mono_domain_lock (domain);
- dis_link = (guint32)(size_t)g_hash_table_lookup (domain->method_to_dyn_method, l->data);
+ dis_link = (MonoGCHandle)g_hash_table_lookup (domain->method_to_dyn_method, l->data);
mono_domain_unlock (domain);
if (dis_link) {
MonoObject *o = mono_gchandle_get_target_internal (dis_link);
}
if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED && ftnptr_eh_callback) {
- guint32 handle = mono_gchandle_new_internal (obj, FALSE);
+ MonoGCHandle handle = mono_gchandle_new_internal (obj, FALSE);
MONO_STACKDATA (stackptr);
mono_threads_enter_gc_safe_region_unbalanced_internal (&stackptr);
/*
* The current exception in flight
*/
- guint32 thrown_exc;
+ MonoGCHandle thrown_exc;
/*
* If the current exception is not a subclass of Exception,
* the original exception.
*/
- guint32 thrown_non_exc;
+ MonoGCHandle thrown_non_exc;
/*
* The calling assembly in llvmonly mode.
#endif
} MonoLMFExt;
-typedef void (*MonoFtnPtrEHCallback) (guint32 gchandle);
+typedef void (*MonoFtnPtrEHCallback) (MonoGCHandle gchandle);
typedef struct MonoDebugOptions {
gboolean handle_sigint;
#define __MONO_ERROR_INTERNALS_H__
#include <mono/metadata/object-forward.h>
+#include <mono/utils/mono-forward.h>
#include "mono/utils/mono-compiler.h"
/*Keep in sync with MonoError*/
/* Valid if error_code == MONO_ERROR_EXCEPTION_INSTANCE.
* Generic error specified by a managed instance.
*/
- uint32_t instance_handle;
+ MonoGCHandle instance_handle;
} exn;
const char *full_message;
const char *full_message_with_fields;
typedef struct _MonoDomain MonoDomain;
typedef struct _MonoJitInfo MonoJitInfo;
+typedef void * MonoGCHandle;
+
#endif
info->stack_end = staddr + stsize;
info->stackdata = g_byte_array_new ();
- info->internal_thread_gchandle = G_MAXUINT32;
+ info->internal_thread_gchandle = NULL;
info->profiler_signal_ack = 1;
}
gboolean
-mono_thread_info_try_get_internal_thread_gchandle (MonoThreadInfo *info, guint32 *gchandle)
+mono_thread_info_try_get_internal_thread_gchandle (MonoThreadInfo *info, MonoGCHandle *gchandle)
{
g_assertf (info, ""); // f includes __func__
g_assert (mono_thread_info_is_current (info));
- if (info->internal_thread_gchandle == G_MAXUINT32)
+ if (info->internal_thread_gchandle == NULL)
return FALSE;
*gchandle = info->internal_thread_gchandle;
}
void
-mono_thread_info_set_internal_thread_gchandle (MonoThreadInfo *info, guint32 gchandle)
+mono_thread_info_set_internal_thread_gchandle (MonoThreadInfo *info, MonoGCHandle gchandle)
{
g_assertf (info, ""); // f includes __func__
g_assert (mono_thread_info_is_current (info));
- g_assert (gchandle != G_MAXUINT32);
info->internal_thread_gchandle = gchandle;
}
{
g_assertf (info, ""); // f includes __func__
g_assert (mono_thread_info_is_current (info));
- info->internal_thread_gchandle = G_MAXUINT32;
+ info->internal_thread_gchandle = NULL;
}
/*
gpointer stack_mark;
/* GCHandle to MonoInternalThread */
- guint32 internal_thread_gchandle;
+ MonoGCHandle internal_thread_gchandle;
/*
* Used by the sampling code in mini-posix.c to ensure that a thread has
mono_thread_info_detach (void);
gboolean
-mono_thread_info_try_get_internal_thread_gchandle (THREAD_INFO_TYPE *info, guint32 *gchandle);
+mono_thread_info_try_get_internal_thread_gchandle (THREAD_INFO_TYPE *info, MonoGCHandle *gchandle);
void
-mono_thread_info_set_internal_thread_gchandle (THREAD_INFO_TYPE *info, guint32 gchandle);
+mono_thread_info_set_internal_thread_gchandle (THREAD_INFO_TYPE *info, MonoGCHandle gchandle);
void
mono_thread_info_unset_internal_thread_gchandle (THREAD_INFO_TYPE *info);