gpointer stack_start = &stack_start;
SgenThreadInfo *info = mono_thread_info_current ();
- if (ptr >= stack_start && ptr < (gpointer)info->client_info.stack_end)
+ if (ptr >= stack_start && ptr < (gpointer)info->client_info.info.stack_end)
return TRUE;
return FALSE;
}
}
void
-sgen_client_thread_register (SgenThreadInfo* info, void *stack_bottom_fallback)
+sgen_client_thread_attach (SgenThreadInfo* info)
{
- size_t stsize = 0;
- guint8 *staddr = NULL;
-
mono_tls_set_sgen_thread_info (info);
info->client_info.skip = 0;
info->client_info.signal = 0;
#endif
- mono_thread_info_get_stack_bounds (&staddr, &stsize);
- if (staddr) {
- info->client_info.stack_start_limit = staddr;
- info->client_info.stack_end = staddr + stsize;
- } else {
- gsize stack_bottom = (gsize)stack_bottom_fallback;
- stack_bottom += 4095;
- stack_bottom &= ~4095;
- info->client_info.stack_end = (char*)stack_bottom;
- }
-
memset (&info->client_info.ctx, 0, sizeof (MonoContext));
if (mono_gc_get_gc_callbacks ()->thread_attach_func)
binary_protocol_thread_register ((gpointer)mono_thread_info_get_tid (info));
- SGEN_LOG (3, "registered thread %p (%p) stack end %p", info, (gpointer)mono_thread_info_get_tid (info), info->client_info.stack_end);
+ SGEN_LOG (3, "registered thread %p (%p) stack end %p", info, (gpointer)mono_thread_info_get_tid (info), info->client_info.info.stack_end);
info->client_info.info.handle_stack = mono_handle_stack_alloc ();
}
void
-sgen_client_thread_unregister (SgenThreadInfo *p)
+sgen_client_thread_detach_with_lock (SgenThreadInfo *p)
{
MonoNativeThreadId tid;
return info->client_info.in_critical_region;
}
-static void
-sgen_thread_attach (SgenThreadInfo *info)
-{
- if (mono_gc_get_gc_callbacks ()->thread_attach_func && !info->client_info.runtime_data)
- info->client_info.runtime_data = mono_gc_get_gc_callbacks ()->thread_attach_func ();
-}
-
static void
sgen_thread_detach (SgenThreadInfo *p)
{
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:
*/
void *aligned_stack_start;
if (info->client_info.skip) {
- SGEN_LOG (3, "Skipping dead thread %p, range: %p-%p, size: %zd", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start);
+ SGEN_LOG (3, "Skipping dead thread %p, range: %p-%p, size: %zd", info, info->client_info.stack_start, info->client_info.info.stack_end, (char*)info->client_info.info.stack_end - (char*)info->client_info.stack_start);
skip_reason = 1;
} else if (info->client_info.gc_disabled) {
- SGEN_LOG (3, "GC disabled for thread %p, range: %p-%p, size: %zd", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start);
+ SGEN_LOG (3, "GC disabled for thread %p, range: %p-%p, size: %zd", info, info->client_info.stack_start, info->client_info.info.stack_end, (char*)info->client_info.info.stack_end - (char*)info->client_info.stack_start);
skip_reason = 2;
} else if (!mono_thread_info_is_live (info)) {
- SGEN_LOG (3, "Skipping non-running thread %p, range: %p-%p, size: %zd (state %x)", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start, info->client_info.info.thread_state);
+ SGEN_LOG (3, "Skipping non-running thread %p, range: %p-%p, size: %zd (state %x)", info, info->client_info.stack_start, info->client_info.info.stack_end, (char*)info->client_info.info.stack_end - (char*)info->client_info.stack_start, info->client_info.info.thread_state);
skip_reason = 3;
} else if (!info->client_info.stack_start) {
SGEN_LOG (3, "Skipping starting or detaching thread %p", info);
skip_reason = 4;
}
- binary_protocol_scan_stack ((gpointer)mono_thread_info_get_tid (info), info->client_info.stack_start, info->client_info.stack_end, skip_reason);
+ binary_protocol_scan_stack ((gpointer)mono_thread_info_get_tid (info), info->client_info.stack_start, info->client_info.info.stack_end, skip_reason);
if (skip_reason) {
if (precise) {
}
g_assert (info->client_info.stack_start);
- g_assert (info->client_info.stack_end);
+ g_assert (info->client_info.info.stack_end);
aligned_stack_start = (void*)(mword) ALIGN_TO ((mword)info->client_info.stack_start, SIZEOF_VOID_P);
#ifdef HOST_WIN32
#endif
g_assert (info->client_info.suspend_done);
- SGEN_LOG (3, "Scanning thread %p, range: %p-%p, size: %zd, pinned=%zd", info, info->client_info.stack_start, info->client_info.stack_end, (char*)info->client_info.stack_end - (char*)info->client_info.stack_start, sgen_get_pinned_count ());
+ SGEN_LOG (3, "Scanning thread %p, range: %p-%p, size: %zd, pinned=%zd", info, info->client_info.stack_start, info->client_info.info.stack_end, (char*)info->client_info.info.stack_end - (char*)info->client_info.stack_start, sgen_get_pinned_count ());
if (mono_gc_get_gc_callbacks ()->thread_mark_func && !conservative_stack_mark) {
- mono_gc_get_gc_callbacks ()->thread_mark_func (info->client_info.runtime_data, (guint8 *)aligned_stack_start, (guint8 *)info->client_info.stack_end, precise, &ctx);
+ mono_gc_get_gc_callbacks ()->thread_mark_func (info->client_info.runtime_data, (guint8 *)aligned_stack_start, (guint8 *)info->client_info.info.stack_end, precise, &ctx);
} else if (!precise) {
if (!conservative_stack_mark) {
fprintf (stderr, "Precise stack mark not supported - disabling.\n");
conservative_stack_mark = TRUE;
}
//FIXME we should eventually use the new stack_mark from coop
- sgen_conservatively_pin_objects_from ((void **)aligned_stack_start, (void **)info->client_info.stack_end, start_nursery, end_nursery, PIN_TYPE_STACK);
+ sgen_conservatively_pin_objects_from ((void **)aligned_stack_start, (void **)info->client_info.info.stack_end, start_nursery, end_nursery, PIN_TYPE_STACK);
}
if (!precise) {
{
// This is used on Coop GC for platforms where we cannot get the data for individual registers.
// We force a spill of all registers into the stack and pass a chunk of data into sgen.
- //FIXME under coop, for now, what we need to ensure is that we scan any extra memory from info->client_info.stack_end to stack_mark
+ //FIXME under coop, for now, what we need to ensure is that we scan any extra memory from info->client_info.info.stack_end to stack_mark
MonoThreadUnwindState *state = &info->client_info.info.thread_saved_state [SELF_SUSPEND_STATE_INDEX];
if (state && state->gc_stackdata) {
sgen_conservatively_pin_objects_from ((void **)state->gc_stackdata, (void**)((char*)state->gc_stackdata + state->gc_stackdata_size),
LOCK_GC;
info = mono_thread_info_current ();
if (info) {
- SGEN_ASSERT (0, stack_end < info->client_info.stack_end, "Can only lower stack end");
- info->client_info.stack_end = stack_end;
+ SGEN_ASSERT (0, stack_end < info->client_info.info.stack_end, "Can only lower stack end");
+ info->client_info.info.stack_end = stack_end;
}
UNLOCK_GC;
}
void
sgen_client_init (void)
{
- int dummy;
MonoThreadInfoCallbacks cb;
- cb.thread_register = sgen_thread_register;
- cb.thread_detach = sgen_thread_detach;
- cb.thread_unregister = sgen_thread_unregister;
cb.thread_attach = sgen_thread_attach;
+ cb.thread_detach = sgen_thread_detach;
+ cb.thread_detach_with_lock = sgen_thread_detach_with_lock;
cb.mono_thread_in_critical_region = thread_in_critical_region;
cb.ip_in_critical_region = ip_in_critical_region;
mono_tls_init_gc_keys ();
- mono_gc_register_thread (&dummy);
+ mono_thread_info_attach ();
}
gboolean