* needed by the other functions.
*/
gpointer (*thread_attach_func) (void);
- /* FIXME: Add a cleanup function too */
+ /*
+ * Function called during thread deatch to free the data allocated by
+ * thread_attach_func.
+ */
+ void (*thread_detach_func) (gpointer user_data);
/*
* Function called from every thread when suspending for GC. It can save
* data needed for marking from thread stacks. user_data is the data returned
} else {
prev->next = p->next;
}
+
+ if (gc_callbacks.thread_detach_func) {
+ gc_callbacks.thread_detach_func (p->runtime_data);
+ p->runtime_data = NULL;
+ }
+
if (p->remset) {
if (freed_thread_remsets) {
for (rset = p->remset; rset->next; rset = rset->next)
* Contains information collected during the conservative stack marking pass,
* used during the precise pass. This helps to avoid doing a stack walk twice, which
* is expensive.
- * FIXME: Optimize memory usage.
*/
typedef struct {
guint8 *bitmap;
return tls;
}
+static void
+thread_detach_func (gpointer user_data)
+{
+ TlsData *tls = user_data;
+
+ g_free (tls);
+}
+
static void
thread_suspend_func (gpointer user_data, void *sigctx)
{
memset (&cb, 0, sizeof (cb));
cb.thread_attach_func = thread_attach_func;
+ cb.thread_detach_func = thread_detach_func;
cb.thread_suspend_func = thread_suspend_func;
/* Comment this out to disable precise stack marking */
cb.thread_mark_func = thread_mark_func;