static gboolean gc_initialized = FALSE;
static mono_mutex_t mono_gc_lock;
-static void*
-boehm_thread_register (MonoThreadInfo* info, void *baseptr);
-static void
-boehm_thread_unregister (MonoThreadInfo *p);
-static void
-boehm_thread_detach (MonoThreadInfo *p);
static void
register_test_toggleref_callback (void);
void
mono_gc_base_init (void)
{
- MonoThreadInfoCallbacks cb;
- const char *env;
- int dummy;
+ char *env;
if (gc_initialized)
return;
* we used to do this only when running on valgrind,
* but it happens also in other setups.
*/
-#if defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) && !defined(__native_client__)
+#if defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
{
size_t size;
void *sstart;
pthread_attr_getstack (&attr, &sstart, &size);
pthread_attr_destroy (&attr);
/*g_print ("stackbottom pth is: %p\n", (char*)sstart + size);*/
-#ifdef __ia64__
- /*
- * The calculation above doesn't seem to work on ia64, also we need to set
- * GC_register_stackbottom as well, but don't know how.
- */
-#else
/* apparently with some linuxthreads implementations sstart can be NULL,
* fallback to the more imprecise method (bug# 78096).
*/
stack_bottom &= ~4095;
GC_stackbottom = (char*)stack_bottom;
}
-#endif
}
#elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
GC_stackbottom = (char*)pthread_get_stackaddr_np (pthread_self ());
GC_stackbottom = (char*)ss.ss_sp;
}
-#elif defined(__native_client__)
- /* Do nothing, GC_stackbottom is set correctly in libgc */
#else
{
int dummy;
log_finalizers = 1;
}
}
+ g_free (env);
}
}
*/
}
}
+ g_free (env);
g_strfreev (opts);
}
- memset (&cb, 0, sizeof (cb));
- cb.thread_register = boehm_thread_register;
- cb.thread_unregister = boehm_thread_unregister;
- cb.thread_detach = boehm_thread_detach;
- cb.mono_method_is_critical = (gboolean (*)(void *))mono_runtime_is_critical_method;
-
- mono_threads_init (&cb, sizeof (MonoThreadInfo));
+ mono_thread_callbacks_init ();
+ mono_thread_info_init (sizeof (MonoThreadInfo));
mono_os_mutex_init (&mono_gc_lock);
mono_os_mutex_init_recursive (&handle_section);
- mono_thread_info_attach (&dummy);
+ mono_thread_info_attach ();
GC_set_on_collection_event (on_gc_notification);
GC_on_heap_resize = on_gc_heap_resize;
return GC_thread_is_registered ();
}
-gboolean
-mono_gc_register_thread (void *baseptr)
-{
- return mono_thread_info_attach (baseptr) != NULL;
-}
-
-static void*
-boehm_thread_register (MonoThreadInfo* info, void *baseptr)
+gpointer
+mono_gc_thread_attach (MonoThreadInfo* info)
{
struct GC_stack_base sb;
int res;
/* TODO: use GC_get_stack_base instead of baseptr. */
- sb.mem_base = baseptr;
+ sb.mem_base = info->stack_end;
res = GC_register_my_thread (&sb);
if (res == GC_UNIMPLEMENTED)
return NULL; /* Cannot happen with GC v7+. */
return info;
}
-static void
-boehm_thread_unregister (MonoThreadInfo *p)
+void
+mono_gc_thread_detach_with_lock (MonoThreadInfo *p)
{
MonoNativeThreadId tid;
if (p->runtime_thread)
mono_threads_add_joinable_thread ((gpointer)tid);
+
+ mono_handle_stack_free (p->handle_stack);
}
-static void
-boehm_thread_detach (MonoThreadInfo *p)
+gboolean
+mono_gc_thread_in_critical_region (MonoThreadInfo *info)
{
- if (mono_thread_internal_current_is_attached ())
- mono_thread_detach_internal (mono_thread_internal_current ());
+ return FALSE;
}
gboolean
}
#endif
gc_stats.major_gc_time += mono_100ns_ticks () - gc_start_time;
- mono_trace_message (MONO_TRACE_GC, "gc took %d usecs", (mono_100ns_ticks () - gc_start_time) / 10);
+ mono_trace_message (MONO_TRACE_GC, "gc took %" G_GINT64_FORMAT " usecs", (mono_100ns_ticks () - gc_start_time) / 10);
break;
default:
break;
gboolean
mono_gc_is_disabled (void)
{
- if (GC_dont_gc || g_getenv ("GC_DONT_GC"))
+ if (GC_dont_gc || g_hasenv ("GC_DONT_GC"))
return TRUE;
else
return FALSE;
}
void
-mono_gc_wbarrier_value_copy_bitmap (gpointer _dest, gpointer _src, int size, unsigned bitmap)
+mono_gc_wbarrier_range_copy (gpointer _dest, gpointer _src, int size)
{
g_assert_not_reached ();
}
+void*
+mono_gc_get_range_copy_func (void)
+{
+ return &mono_gc_wbarrier_range_copy;
+}
guint8*
mono_gc_get_card_table (int *shift_bits, gpointer *card_mask)