-/*
- * sgen-mono.c: SGen features specific to Mono.
+/**
+ * \file
+ * SGen features specific to Mono.
*
* Copyright (C) 2014 Xamarin Inc
*
/**
* mono_gc_wbarrier_object_copy:
*
- * Write barrier to call when obj is the result of a clone or copy of an object.
+ * Write barrier to call when \p obj is the result of a clone or copy of an object.
*/
void
mono_gc_wbarrier_object_copy (MonoObject* obj, MonoObject *src)
sgen_get_remset ()->wbarrier_object_copy (obj, src);
}
+/**
+ * mono_gc_wbarrier_set_arrayref:
+ */
void
mono_gc_wbarrier_set_arrayref (MonoArray *arr, gpointer slot_ptr, MonoObject* value)
{
sgen_get_remset ()->wbarrier_set_field ((GCObject*)arr, slot_ptr, value);
}
+/**
+ * mono_gc_wbarrier_set_field:
+ */
void
mono_gc_wbarrier_set_field (MonoObject *obj, gpointer field_ptr, MonoObject* value)
{
mono_gc_run_finalize (obj, NULL);
}
+/**
+ * mono_gc_invoke_finalizers:
+ */
int
mono_gc_invoke_finalizers (void)
{
return sgen_gc_invoke_finalizers ();
}
+/**
+ * mono_gc_pending_finalizers:
+ */
MonoBoolean
mono_gc_pending_finalizers (void)
{
/**
* mono_gc_finalizers_for_domain:
- * @domain: the unloading appdomain
- * @out_array: output array
- * @out_size: size of output array
- *
- * Enqueue for finalization all objects that belong to the unloading appdomain @domain
- * @suspend is used for early termination of the enqueuing process.
+ * \param domain the unloading appdomain
+ * \param out_array output array
+ * \param out_size size of output array
+ * Enqueue for finalization all objects that belong to the unloading appdomain \p domain.
+ * \p suspend is used for early termination of the enqueuing process.
*/
void
mono_gc_finalize_domain (MonoDomain *domain)
return obj;
}
+/**
+ * mono_gc_alloc_fixed:
+ */
void*
mono_gc_alloc_fixed (size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg)
{
return res;
}
+/**
+ * mono_gc_free_fixed:
+ */
void
mono_gc_free_fixed (void* addr)
{
/**
* mono_gc_walk_heap:
- * @flags: flags for future use
- * @callback: a function pointer called for each object in the heap
- * @data: a user data pointer that is passed to callback
- *
- * This function can be used to iterate over all the live objects in the heap:
- * for each object, @callback is invoked, providing info about the object's
+ * \param flags flags for future use
+ * \param callback a function pointer called for each object in the heap
+ * \param data a user data pointer that is passed to callback
+ * This function can be used to iterate over all the live objects in the heap;
+ * for each object, \p callback is invoked, providing info about the object's
* location in memory, its class, its size and the objects it references.
- * For each referenced object it's offset from the object address is
+ * For each referenced object its offset from the object address is
* reported in the offsets array.
* The object references may be buffered, so the callback may be invoked
* multiple times for the same object: in all but the first call, the size
* argument will be zero.
- * Note that this function can be only called in the #MONO_GC_EVENT_PRE_START_WORLD
+ * Note that this function can be only called in the \c MONO_GC_EVENT_PRE_START_WORLD
* profiler event handler.
- *
- * Returns: a non-zero value if the GC doesn't support heap walking
+ * \returns a non-zero value if the GC doesn't support heap walking
*/
int
mono_gc_walk_heap (int flags, MonoGCReferences callback, void *data)
mono_thread_detach_internal (mono_thread_internal_current ());
}
+/**
+ * mono_gc_register_thread:
+ */
gboolean
mono_gc_register_thread (void *baseptr)
{
return mono_thread_info_attach (baseptr) != NULL;
}
+/**
+ * mono_gc_is_gc_thread:
+ */
gboolean
mono_gc_is_gc_thread (void)
{
return obj;
}
+typedef struct {
+ void **start_nursery;
+ void **end_nursery;
+} PinHandleStackInteriorPtrData;
+
+/* Called when we're scanning the handle stack imprecisely and we encounter a pointer into the
+ middle of an object.
+ */
+static void
+pin_handle_stack_interior_ptrs (void **ptr_slot, void *user_data)
+{
+ PinHandleStackInteriorPtrData *ud = (PinHandleStackInteriorPtrData *)user_data;
+ sgen_conservatively_pin_objects_from (ptr_slot, ptr_slot+1, ud->start_nursery, ud->end_nursery, PIN_TYPE_STACK);
+}
+
+
/*
* Mark from thread stacks and registers.
*/
}
}
}
- if (precise && info->client_info.info.handle_stack) {
- mono_handle_stack_scan ((HandleStack*)info->client_info.info.handle_stack, (GcScanFunc)ctx.ops->copy_or_mark_object, ctx.queue);
+ if (info->client_info.info.handle_stack) {
+ /*
+ Make two passes over the handle stack. On the imprecise pass, pin all
+ objects where the handle points into the interior of the object. On the
+ precise pass, copy or mark all the objects that have handles to the
+ beginning of the object.
+ */
+ if (precise)
+ mono_handle_stack_scan ((HandleStack*)info->client_info.info.handle_stack, (GcScanFunc)ctx.ops->copy_or_mark_object, ctx.queue, precise);
+ else {
+ PinHandleStackInteriorPtrData ud = { .start_nursery = start_nursery,
+ .end_nursery = end_nursery,
+ };
+ mono_handle_stack_scan ((HandleStack*)info->client_info.info.handle_stack, pin_handle_stack_interior_ptrs, &ud, precise);
+ }
}
} FOREACH_THREAD_END
}
/**
* mono_gchandle_is_in_domain:
- * @gchandle: a GCHandle's handle.
- * @domain: An application domain.
- *
- * Returns: TRUE if the object wrapped by the @gchandle belongs to the specific @domain.
+ * \param gchandle a GCHandle's handle.
+ * \param domain An application domain.
+ * \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_free_domain:
- * @unloading: domain that is unloading
+ * \param unloading domain that is unloading
*
* Function used internally to cleanup any GC handle for objects belonging
* to the specified domain during appdomain unload.
static gboolean gc_inited;
+/**
+ * mono_gc_base_init:
+ */
void
mono_gc_base_init (void)
{