Skip to content

Commit

Permalink
Boehm doesn't need the pinning root for threads.
Browse files Browse the repository at this point in the history
	* threads.c: Boehm doesn't need the pinning for each thread as it doesn't
	move objects and those objects are reachable through the thread hashtable.

	This fixes a crash on mobile that has a very small number of root slots.
  • Loading branch information
kumpera committed Feb 15, 2013
1 parent d811c08 commit 0a2b281
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions mono/metadata/threads.c
Expand Up @@ -410,7 +410,11 @@ static void thread_cleanup (MonoInternalThread *thread)
if (mono_thread_cleanup_fn)
mono_thread_cleanup_fn (thread);

MONO_GC_UNREGISTER_ROOT (thread->thread_pinning_ref);
if (mono_gc_is_moving ()) {
MONO_GC_UNREGISTER_ROOT (thread->thread_pinning_ref);
thread->thread_pinning_ref = NULL;
}

}

static gpointer
Expand Down Expand Up @@ -763,9 +767,11 @@ mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, gb
internal->handle=thread_handle;
internal->tid=tid;
internal->apartment_state=ThreadApartmentState_Unknown;
internal->thread_pinning_ref = internal;
internal->managed_id = get_next_managed_thread_id ();
MONO_GC_REGISTER_ROOT_PINNING (internal->thread_pinning_ref);
if (mono_gc_is_moving ()) {
internal->thread_pinning_ref = internal;
MONO_GC_REGISTER_ROOT_PINNING (internal->thread_pinning_ref);
}

internal->synch_cs = g_new0 (CRITICAL_SECTION, 1);
InitializeCriticalSection (internal->synch_cs);
Expand Down Expand Up @@ -894,9 +900,11 @@ mono_thread_attach (MonoDomain *domain)
thread->android_tid = (gpointer) gettid ();
#endif
thread->apartment_state=ThreadApartmentState_Unknown;
thread->thread_pinning_ref = thread;
thread->managed_id = get_next_managed_thread_id ();
MONO_GC_REGISTER_ROOT_PINNING (thread->thread_pinning_ref);
if (mono_gc_is_moving ()) {
thread->thread_pinning_ref = thread;
MONO_GC_REGISTER_ROOT_PINNING (thread->thread_pinning_ref);
}

thread->stack_ptr = &tid;

Expand Down Expand Up @@ -1063,8 +1071,10 @@ HANDLE ves_icall_System_Threading_Thread_Thread_internal(MonoThread *this,

internal->handle=thread;
internal->tid=tid;
internal->thread_pinning_ref = internal;
MONO_GC_REGISTER_ROOT_PINNING (internal->thread_pinning_ref);
if (mono_gc_is_moving ()) {
internal->thread_pinning_ref = internal;
MONO_GC_REGISTER_ROOT_PINNING (internal->thread_pinning_ref);
}


/* Don't call handle_store() here, delay it to Start.
Expand Down

0 comments on commit 0a2b281

Please sign in to comment.